mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-06-07 06:36:42 +00:00
Merge branch 'main' into 124-propose-a-liquid-issuance-to-the-network-unsigned-transaction
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
commit
46ec3df289
@ -20,6 +20,7 @@ type HandlerOptions struct {
|
|||||||
SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params) error
|
SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.Params) error
|
||||||
TxFeeChecker TxFeeChecker
|
TxFeeChecker TxFeeChecker
|
||||||
MachineKeeper MachineKeeper
|
MachineKeeper MachineKeeper
|
||||||
|
DaoKeeper DaoKeeper
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAnteHandler returns an AnteHandler that checks and increments sequence
|
// NewAnteHandler returns an AnteHandler that checks and increments sequence
|
||||||
@ -41,6 +42,9 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
|
|||||||
if options.MachineKeeper == nil {
|
if options.MachineKeeper == nil {
|
||||||
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "machine keeper is required for ante builder")
|
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "machine keeper is required for ante builder")
|
||||||
}
|
}
|
||||||
|
if options.DaoKeeper == nil {
|
||||||
|
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "dao keeper is required for ante builder")
|
||||||
|
}
|
||||||
|
|
||||||
anteDecorators := []sdk.AnteDecorator{
|
anteDecorators := []sdk.AnteDecorator{
|
||||||
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
|
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
|
||||||
@ -49,7 +53,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
|
|||||||
ante.NewTxTimeoutHeightDecorator(),
|
ante.NewTxTimeoutHeightDecorator(),
|
||||||
ante.NewValidateMemoDecorator(options.AccountKeeper),
|
ante.NewValidateMemoDecorator(options.AccountKeeper),
|
||||||
NewCheckMachineDecorator(options.MachineKeeper),
|
NewCheckMachineDecorator(options.MachineKeeper),
|
||||||
NewCheckMintAddressDecorator(),
|
NewCheckMintAddressDecorator(options.DaoKeeper),
|
||||||
NewCheckReissuanceDecorator(),
|
NewCheckReissuanceDecorator(),
|
||||||
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
|
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
|
||||||
NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
|
NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
|
||||||
|
@ -8,11 +8,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type CheckMintAddressDecorator struct {
|
type CheckMintAddressDecorator struct {
|
||||||
MintAddress string
|
dk DaoKeeper
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCheckMintAddressDecorator() CheckMintAddressDecorator {
|
func NewCheckMintAddressDecorator(dk DaoKeeper) CheckMintAddressDecorator {
|
||||||
return CheckMintAddressDecorator{}
|
return CheckMintAddressDecorator{
|
||||||
|
dk: dk,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cmad CheckMintAddressDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
|
func (cmad CheckMintAddressDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
|
||||||
@ -22,7 +24,11 @@ func (cmad CheckMintAddressDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim
|
|||||||
if ok {
|
if ok {
|
||||||
cfg := config.GetConfig()
|
cfg := config.GetConfig()
|
||||||
if mintMsg.Creator != cfg.MintAddress {
|
if mintMsg.Creator != cfg.MintAddress {
|
||||||
return ctx, errorsmod.Wrapf(daotypes.ErrInvalidMintAddress, "expected: %s; got: %s", cmad.MintAddress, mintMsg.Creator)
|
return ctx, errorsmod.Wrapf(daotypes.ErrInvalidMintAddress, "expected: %s; got: %s", cfg.MintAddress, mintMsg.Creator)
|
||||||
|
}
|
||||||
|
_, found := cmad.dk.GetMintRequestByHash(ctx, mintMsg.GetMintRequest().GetLiquidTxHash())
|
||||||
|
if found {
|
||||||
|
return ctx, errorsmod.Wrapf(daotypes.ErrAlreadyMinted, "liquid tx hash %s has already been minted", mintMsg.GetMintRequest().GetLiquidTxHash())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
|
daotypes "github.com/planetmint/planetmint-go/x/dao/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MachineKeeper interface {
|
type MachineKeeper interface {
|
||||||
@ -32,3 +33,7 @@ type BankKeeper interface {
|
|||||||
SendCoins(ctx sdk.Context, from, to sdk.AccAddress, amt sdk.Coins) error
|
SendCoins(ctx sdk.Context, from, to sdk.AccAddress, amt sdk.Coins) error
|
||||||
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
|
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DaoKeeper interface {
|
||||||
|
GetMintRequestByHash(ctx sdk.Context, hash string) (val daotypes.MintRequest, found bool)
|
||||||
|
}
|
||||||
|
@ -775,6 +775,7 @@ func New(
|
|||||||
FeegrantKeeper: app.FeeGrantKeeper,
|
FeegrantKeeper: app.FeeGrantKeeper,
|
||||||
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
|
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
|
||||||
MachineKeeper: app.MachineKeeper,
|
MachineKeeper: app.MachineKeeper,
|
||||||
|
DaoKeeper: app.DaoKeeper,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user