added MsgReissueRDDLResult handling

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel 2023-10-05 17:31:41 +02:00
parent 87641aefe8
commit 8f76199214
No known key found for this signature in database
2 changed files with 20 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package keeper
import (
"context"
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/planetmint/planetmint-go/x/dao/types"
)
@ -10,8 +11,21 @@ import (
func (k msgServer) ReissueRDDLResult(goCtx context.Context, msg *types.MsgReissueRDDLResult) (*types.MsgReissueRDDLResultResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
// TODO: Handling the message
_ = ctx
reissuance, found := k.GetReissuance(ctx, msg.GetBlockHeight())
if found != true {
return nil, errorsmod.Wrapf(types.ErrReissuanceNotFound, " for provided block height %u", msg.GetBlockHeight())
}
if reissuance.GetBlockHeight() != msg.GetBlockHeight() {
return nil, errorsmod.Wrapf(types.ErrWrongBlockHeight, " for provided block height %u", msg.GetBlockHeight())
}
if reissuance.GetProposer() != msg.GetProposer() {
return nil, errorsmod.Wrapf(types.ErrInvalidProposer, " for provided block height %u", msg.GetBlockHeight())
}
if reissuance.GetTxId() != "" {
return nil, errorsmod.Wrapf(types.ErrTXAlreadySet, " for provided block height %u", msg.GetBlockHeight())
}
reissuance.TxId = msg.GetTxId()
k.StoreReissuance(ctx, reissuance)
return &types.MsgReissueRDDLResultResponse{}, nil
}

View File

@ -13,4 +13,8 @@ var (
ErrTransferFailed = errorsmod.Register(ModuleName, 4, "transfer failed")
ErrInvalidAddress = errorsmod.Register(ModuleName, 5, "invalid address")
ErrAlreadyMinted = errorsmod.Register(ModuleName, 6, "already minted")
ErrWrongBlockHeight = errorsmod.Register(ModuleName, 7, "wrong block height")
ErrReissuanceNotFound = errorsmod.Register(ModuleName, 8, "reissuance not found")
ErrInvalidProposer = errorsmod.Register(ModuleName, 9, "invalid proposer")
ErrTXAlreadySet = errorsmod.Register(ModuleName, 10, "tx already set")
)