Skip to content

Commit

Permalink
fix dex gas antedeps
Browse files Browse the repository at this point in the history
fix switch case
  • Loading branch information
udpatil committed May 21, 2023
1 parent 3d6cd9c commit 02628d3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func NewAnteHandlerAndDepGenerator(options HandlerOptions) (sdk.AnteHandler, sdk
sdk.CustomDepWrappedAnteDecorator(ante.NewIncrementSequenceDecorator(options.AccountKeeper), depdecorators.SignerDepDecorator{ReadOnly: false}),
sdk.DefaultWrappedAnteDecorator(ibcante.NewAnteDecorator(options.IBCKeeper)),
sdk.DefaultWrappedAnteDecorator(dex.NewTickSizeMultipleDecorator(*options.DexKeeper)),
sdk.DefaultWrappedAnteDecorator(dex.NewCheckDexGasDecorator(*options.DexKeeper, options.CheckTxMemState)),
dex.NewCheckDexGasDecorator(*options.DexKeeper, options.CheckTxMemState),
antedecorators.NewACLWasmDependencyDecorator(*options.AccessControlKeeper, *options.WasmKeeper),
}

Expand Down
22 changes: 22 additions & 0 deletions x/dex/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkacltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
dexcache "github.com/sei-protocol/sei-chain/x/dex/cache"
"github.com/sei-protocol/sei-chain/x/dex/keeper"
Expand Down Expand Up @@ -157,3 +158,24 @@ func (d CheckDexGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo
}
return ctx, sdkerrors.ErrInsufficientFee
}

func (d CheckDexGasDecorator) AnteDeps(txDeps []sdkacltypes.AccessOperation, tx sdk.Tx, next sdk.AnteDepGenerator) (newTxDeps []sdkacltypes.AccessOperation, err error) {
deps := []sdkacltypes.AccessOperation{}
for _, msg := range tx.GetMsgs() {
// Error checking will be handled in AnteHandler
switch msg.(type) {
case *types.MsgPlaceOrders, *types.MsgCancelOrders:
deps = append(deps, []sdkacltypes.AccessOperation{
// read the dex contract info
{
ResourceType: sdkacltypes.ResourceType_KV_DEX_CONTRACT,
AccessType: sdkacltypes.AccessType_READ,
IdentifierTemplate: "*",
},
}...)
default:
continue
}
}
return next(append(txDeps, deps...), tx)
}

0 comments on commit 02628d3

Please sign in to comment.