Skip to content

Commit

Permalink
feat(app)!: update app for v0.50.x sdk changes
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Jan 17, 2024
1 parent 91ae4ce commit 8a39efc
Show file tree
Hide file tree
Showing 4 changed files with 497 additions and 382 deletions.
39 changes: 21 additions & 18 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
package app

import (
"errors"

corestoretypes "cosmossdk.io/core/store"
circuitante "cosmossdk.io/x/circuit/ante"
circuitkeeper "cosmossdk.io/x/circuit/keeper"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"

errorsmod "cosmossdk.io/errors"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"

ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
"github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
"github.com/cosmos/ibc-go/v8/modules/core/keeper"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
// channel keeper.
type HandlerOptions struct {
ante.HandlerOptions

IBCKeeper *keeper.Keeper
WasmConfig *wasmTypes.WasmConfig
TXCounterStoreKey storetypes.StoreKey
IBCKeeper *keeper.Keeper
WasmConfig *wasmTypes.WasmConfig
WasmKeeper *wasmkeeper.Keeper
TXCounterStoreService corestoretypes.KVStoreService
CircuitKeeper *circuitkeeper.Keeper
}

func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
return nil, errors.New("account keeper is required for AnteHandler")
}
if options.BankKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")
return nil, errors.New("bank keeper is required for AnteHandler")
}
if options.SignModeHandler == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
return nil, errors.New("sign mode handler is required for ante builder")
}
if options.WasmConfig == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "wasm config is required for ante builder")
return nil, errors.New("wasm config is required for ante builder")
}
if options.TXCounterStoreKey == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "tx counter key is required for ante builder")
if options.TXCounterStoreService == nil {
return nil, errors.New("wasm store service is required for ante builder")
}

sigGasConsumer := options.SigGasConsumer
Expand All @@ -50,7 +51,9 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), // after setup context to enforce limits early
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreKey),
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreService),
wasmkeeper.NewGasRegisterDecorator(options.WasmKeeper.GetGasRegister()),
circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
Expand Down
Loading

0 comments on commit 8a39efc

Please sign in to comment.