Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"

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

corestoretypes "cosmossdk.io/core/store"
circuitante "cosmossdk.io/x/circuit/ante"
Expand All @@ -23,7 +23,7 @@ type HandlerOptions struct {
ante.HandlerOptions

IBCKeeper *keeper.Keeper
WasmConfig *wasmTypes.WasmConfig
WasmConfig *wasmTypes.NodeConfig
WasmKeeper *wasmkeeper.Keeper
TXCounterStoreService corestoretypes.KVStoreService
CircuitKeeper *circuitkeeper.Keeper
Expand Down
120 changes: 55 additions & 65 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"sort"
"time"

wasmd "github.com/CosmWasm/wasmd/app"
"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
transferv2 "github.com/cosmos/ibc-go/v10/modules/apps/transfer/v2"
"github.com/spf13/cast"
"github.com/strangelove-ventures/tokenfactory/x/tokenfactory"
"github.com/strangelove-ventures/tokenfactory/x/tokenfactory/bindings"
Expand All @@ -29,25 +29,23 @@ import (
"github.com/cosmos/ibc-go/modules/capability"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
ica "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts"
icacontroller "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller"
icacontrollerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
icahost "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types"
ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee"
ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
transfer "github.com/cosmos/ibc-go/v8/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v8/modules/core"
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
ica "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts"
icacontroller "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/controller"
icacontrollerkeeper "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/controller/types"
icahost "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/types"
transfer "github.com/cosmos/ibc-go/v10/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v10/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v10/modules/core"
porttypes "github.com/cosmos/ibc-go/v10/modules/core/05-port/types"
ibcapi "github.com/cosmos/ibc-go/v10/modules/core/api"
ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v10/modules/core/keeper"
ibctm "github.com/cosmos/ibc-go/v10/modules/light-clients/07-tendermint"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
Expand Down Expand Up @@ -196,7 +194,6 @@ var maccPerms = map[string][]string{
nft.ModuleName: nil,
// non sdk modules
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibcfeetypes.ModuleName: nil,
icatypes.ModuleName: nil,
wasmtypes.ModuleName: {authtypes.Burner},
tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
Expand Down Expand Up @@ -241,7 +238,6 @@ type TokenFactoryApp struct {
CircuitKeeper circuitkeeper.Keeper

IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCFeeKeeper ibcfeekeeper.Keeper
ICAControllerKeeper icacontrollerkeeper.Keeper
ICAHostKeeper icahostkeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
Expand Down Expand Up @@ -311,7 +307,7 @@ func NewApp(
evidencetypes.StoreKey, circuittypes.StoreKey,
authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey,
// non sdk store keys
capabilitytypes.StoreKey, ibcexported.StoreKey, ibctransfertypes.StoreKey, ibcfeetypes.StoreKey,
capabilitytypes.StoreKey, ibcexported.StoreKey, ibctransfertypes.StoreKey,
wasmtypes.StoreKey, icahosttypes.StoreKey,
icacontrollertypes.StoreKey, tokenfactorytypes.StoreKey,
)
Expand Down Expand Up @@ -487,11 +483,11 @@ func NewApp(

app.IBCKeeper = ibckeeper.NewKeeper(
appCodec,
keys[ibcexported.StoreKey],
runtime.NewKVStoreService(keys[ibcexported.StoreKey]),
app.GetSubspace(ibcexported.ModuleName),
app.StakingKeeper,
//app.StakingKeeper,
app.UpgradeKeeper,
scopedIBCKeeper,
//scopedIBCKeeper,
govModAddress,
)

Expand Down Expand Up @@ -523,7 +519,7 @@ func NewApp(

app.GovKeeper = *govKeeper.SetHooks(
govtypes.NewMultiGovHooks(
// register the governance hooks
// register the governance hooks
),
)

Expand Down Expand Up @@ -560,54 +556,43 @@ func NewApp(
)
wasmOpts = append(wasmOpts, bindings.RegisterCustomPlugins(app.BankKeeper, &app.TokenFactoryKeeper)...)

// IBC Fee Module keeper
app.IBCFeeKeeper = ibcfeekeeper.NewKeeper(
appCodec, keys[ibcfeetypes.StoreKey],
app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper,
)

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec,
keys[ibctransfertypes.StoreKey],
runtime.NewKVStoreService(keys[ibctransfertypes.StoreKey]),
app.GetSubspace(ibctransfertypes.ModuleName),
app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
app.IBCKeeper.ChannelKeeper,
app.MsgServiceRouter(),
app.AccountKeeper,
app.BankKeeper,
scopedTransferKeeper,
govModAddress,
)

app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec,
keys[icahosttypes.StoreKey],
runtime.NewKVStoreService(keys[icahosttypes.StoreKey]),
app.GetSubspace(icahosttypes.SubModuleName),
app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
app.IBCKeeper.ChannelKeeper,
app.AccountKeeper,
scopedICAHostKeeper,
app.MsgServiceRouter(),
app.GRPCQueryRouter(),
govModAddress,
)

app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper(
appCodec,
keys[icacontrollertypes.StoreKey],
runtime.NewKVStoreService(keys[icacontrollertypes.StoreKey]),
app.GetSubspace(icacontrollertypes.SubModuleName),
app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
scopedICAControllerKeeper,
app.IBCKeeper.ChannelKeeper,
app.MsgServiceRouter(),
govModAddress,
)

wasmDir := filepath.Join(homePath, "wasm")
wasmConfig, err := wasm.ReadWasmConfig(appOpts)
wasmConfig, err := wasm.ReadNodeConfig(appOpts)
if err != nil {
panic(fmt.Sprintf("error while reading wasm config: %s", err))
}
Expand All @@ -624,16 +609,16 @@ func NewApp(
app.BankKeeper,
app.StakingKeeper,
distrkeeper.NewQuerier(app.DistrKeeper),
app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
scopedWasmKeeper,
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.ChannelKeeperV2,
app.TransferKeeper,
app.MsgServiceRouter(),
app.GRPCQueryRouter(),
path.Join(wasmDir, StringWithCharset(12, charset)), // for testing
wasmConfig,
append(wasmd.AllCapabilities(), "token_factory"),
wasmtypes.VMConfig{},
append(wasmkeeper.BuiltInCapabilities(), "token_factory"),
govModAddress,
wasmOpts...,
)
Expand All @@ -644,28 +629,23 @@ func NewApp(
// Create Transfer Stack
var transferStack porttypes.IBCModule
transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper)

// Create Interchain Accounts Stack
// SendPacket, since it is originating from the application to core IBC:
// icaAuthModuleKeeper.SendTx -> icaController.SendPacket -> fee.SendPacket -> channel.SendPacket
var icaControllerStack porttypes.IBCModule
// integration point for custom authentication modules
// see https://medium.com/the-interchain-foundation/ibc-go-v6-changes-to-interchain-accounts-and-how-it-impacts-your-chain-806c185300d7
var noAuthzModule porttypes.IBCModule
icaControllerStack = icacontroller.NewIBCMiddleware(noAuthzModule, app.ICAControllerKeeper)
icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper)
icaControllerStack = icacontroller.NewIBCMiddleware(app.ICAControllerKeeper)

// RecvPacket, message that originates from core IBC and goes down to app, the flow is:
// channel.RecvPacket -> fee.OnRecvPacket -> icaHost.OnRecvPacket
var icaHostStack porttypes.IBCModule
icaHostStack = icahost.NewIBCModule(app.ICAHostKeeper)
icaHostStack = ibcfee.NewIBCMiddleware(icaHostStack, app.IBCFeeKeeper)

// Create fee enabled wasm ibc Stack
var wasmStack porttypes.IBCModule
wasmStack = wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper)
wasmStack = ibcfee.NewIBCMiddleware(wasmStack, app.IBCFeeKeeper)
wasmStack = wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.TransferKeeper, app.IBCKeeper.ChannelKeeper)

// Create static IBC router, add app routes, then set and seal it
ibcRouter := porttypes.NewRouter().
Expand All @@ -675,6 +655,19 @@ func NewApp(
AddRoute(icahosttypes.SubModuleName, icaHostStack)
app.IBCKeeper.SetRouter(ibcRouter)

ibcRouterV2 := ibcapi.NewRouter()
ibcRouterV2 = ibcRouterV2.
AddRoute(ibctransfertypes.PortID, transferv2.NewIBCModule(app.TransferKeeper)).
AddPrefixRoute(wasmkeeper.PortIDPrefixV2, wasmkeeper.NewIBC2Handler(app.WasmKeeper))

app.IBCKeeper.SetRouterV2(ibcRouterV2)

clientKeeper := app.IBCKeeper.ClientKeeper
storeProvider := app.IBCKeeper.ClientKeeper.GetStoreProvider()

tmLightClientModule := ibctm.NewLightClientModule(appCodec, storeProvider)
clientKeeper.AddRoute(ibctm.ModuleName, &tmLightClientModule)

// **** Module Options ****/

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
Expand Down Expand Up @@ -712,9 +705,8 @@ func NewApp(
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)),
ibc.NewAppModule(app.IBCKeeper),
transfer.NewAppModule(app.TransferKeeper),
ibcfee.NewAppModule(app.IBCFeeKeeper),
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
ibctm.NewAppModule(),
ibctm.NewAppModule(tmLightClientModule),
tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(tokenfactorytypes.ModuleName)),
// sdk
crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them
Expand All @@ -741,6 +733,7 @@ func NewApp(
// NOTE: upgrade module is required to be prioritized
app.ModuleManager.SetOrderPreBlockers(
upgradetypes.ModuleName,
authtypes.ModuleName,
)
// During begin block slashing happens after distr.BeginBlocker so that
// there is nothing left over in the validator fee pool, so as to keep the
Expand All @@ -760,7 +753,6 @@ func NewApp(
ibctransfertypes.ModuleName,
ibcexported.ModuleName,
icatypes.ModuleName,
ibcfeetypes.ModuleName,
wasmtypes.ModuleName,
tokenfactorytypes.ModuleName,
)
Expand All @@ -777,7 +769,6 @@ func NewApp(
ibctransfertypes.ModuleName,
ibcexported.ModuleName,
icatypes.ModuleName,
ibcfeetypes.ModuleName,
wasmtypes.ModuleName,
tokenfactorytypes.ModuleName,
)
Expand All @@ -802,7 +793,6 @@ func NewApp(
ibctransfertypes.ModuleName,
ibcexported.ModuleName,
icatypes.ModuleName,
ibcfeetypes.ModuleName,
// wasm after ibc transfer
wasmtypes.ModuleName,
tokenfactorytypes.ModuleName,
Expand Down Expand Up @@ -925,7 +915,7 @@ func NewApp(
return app
}

func (app *TokenFactoryApp) setAnteHandler(txConfig client.TxConfig, wasmConfig wasmtypes.WasmConfig, txCounterStoreKey *storetypes.KVStoreKey) {
func (app *TokenFactoryApp) setAnteHandler(txConfig client.TxConfig, wasmConfig wasmtypes.NodeConfig, txCounterStoreKey *storetypes.KVStoreKey) {
anteHandler, err := NewAnteHandler(
HandlerOptions{
HandlerOptions: ante.HandlerOptions{
Expand Down
10 changes: 5 additions & 5 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import (
tmtypes "github.com/cometbft/cometbft/types"

dbm "github.com/cosmos/cosmos-db"
icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:all
connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
icatypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/host/types"
transfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" //nolint:all
connectiontypes "github.com/cosmos/ibc-go/v10/modules/core/03-connection/types"

"cosmossdk.io/log"
sdkmath "cosmossdk.io/math"
Expand Down
4 changes: 1 addition & 3 deletions cmd/tokend/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/cosmos/cosmos-sdk/server"
"github.com/spf13/cobra"
"github.com/strangelove-ventures/tokenfactory/app"
"github.com/strangelove-ventures/tokenfactory/app/params"
Expand All @@ -16,8 +17,6 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/server"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
Expand Down Expand Up @@ -111,7 +110,6 @@ func NewRootCmd() *cobra.Command {
// add keyring to autocli opts
autoCliOpts := tempApp.AutoCliOpts()
initClientCtx, _ = config.ReadFromClientConfig(initClientCtx)
autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring)
autoCliOpts.ClientCtx = initClientCtx

if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil {
Expand Down
Loading