planetmint-go/x/dao/keeper/msg_server_reissue_rddl_result.go
Jürgen Eckel 5adaab3b14
fixed linter issues
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-10-10 01:54:09 +02:00

33 lines
1.2 KiB
Go

package keeper
import (
"context"
"strconv"
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/planetmint/planetmint-go/x/dao/types"
)
func (k msgServer) ReissueRDDLResult(goCtx context.Context, msg *types.MsgReissueRDDLResult) (*types.MsgReissueRDDLResultResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
reissuance, found := k.LookupReissuance(ctx, msg.GetBlockHeight())
if !found {
return nil, errorsmod.Wrapf(types.ErrReissuanceNotFound, " for provided block height %s", strconv.FormatUint(msg.GetBlockHeight(), 10))
}
if reissuance.GetBlockHeight() != msg.GetBlockHeight() {
return nil, errorsmod.Wrapf(types.ErrWrongBlockHeight, " for provided block height %s", strconv.FormatUint(msg.GetBlockHeight(), 10))
}
if reissuance.GetProposer() != msg.GetProposer() {
return nil, errorsmod.Wrapf(types.ErrInvalidProposer, " for provided block height %s", strconv.FormatUint(msg.GetBlockHeight(), 10))
}
if reissuance.GetTxId() != "" {
return nil, errorsmod.Wrapf(types.ErrTXAlreadySet, " for provided block height %s", strconv.FormatUint(msg.GetBlockHeight(), 10))
}
reissuance.TxId = msg.GetTxId()
k.StoreReissuance(ctx, reissuance)
return &types.MsgReissueRDDLResultResponse{}, nil
}