added the ante hanlder pattern

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel 2023-10-05 16:19:08 +02:00
parent b81cdb6dc9
commit fa1b16ba58
No known key found for this signature in database
2 changed files with 30 additions and 0 deletions

View File

@ -50,6 +50,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewValidateMemoDecorator(options.AccountKeeper),
NewCheckMachineDecorator(options.MachineKeeper),
NewCheckMintAddressDecorator(),
NewCheckReissuanceDecorator(),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators

View File

@ -0,0 +1,29 @@
package ante
import (
sdk "github.com/cosmos/cosmos-sdk/types"
daotypes "github.com/planetmint/planetmint-go/x/dao/types"
)
type CheckReissuanceDecorator struct {
MintAddress string
}
func NewCheckReissuanceDecorator() CheckReissuanceDecorator {
return CheckReissuanceDecorator{}
}
func (cmad CheckReissuanceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
for _, msg := range tx.GetMsgs() {
if sdk.MsgTypeURL(msg) == "/planetmintgo.dao.NewMsgReissueRDDLProposal" {
_, ok := msg.(*daotypes.MsgReissueRDDLProposal)
//reissueMsg, ok := msg.(*daotypes.NewMsgReissueRDDLProposal)
if ok {
// TODO: verify if the messages related PoP (BlockHeight) reflects
// what is actually traded within the raw transaction
}
}
}
return next(ctx, tx, simulate)
}