Skip to content

Commit

Permalink
feat(denommetadata): wire the denommetadata ibc middleware (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
zale144 authored Jul 4, 2024
1 parent fc01049 commit faa3771
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
49 changes: 44 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ import (
"github.com/evmos/evmos/v12/x/ibc/transfer"
transferkeeper "github.com/evmos/evmos/v12/x/ibc/transfer/keeper"

"github.com/dymensionxyz/dymension-rdk/x/denommetadata"
denommetadatamoduletypes "github.com/dymensionxyz/dymension-rdk/x/denommetadata/types"
"github.com/dymensionxyz/dymension-rdk/x/hub"
hubkeeper "github.com/dymensionxyz/dymension-rdk/x/hub/keeper"
hubtypes "github.com/dymensionxyz/dymension-rdk/x/hub/types"

// Upgrade handlers
v2_2_0_upgrade "github.com/dymensionxyz/rollapp-evm/app/upgrades/v2.2.0"

Expand All @@ -157,7 +163,7 @@ var (
minttypes.StoreKey, distrtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey,
ibchost.StoreKey, upgradetypes.StoreKey,
epochstypes.StoreKey, hubgentypes.StoreKey,
epochstypes.StoreKey, hubtypes.StoreKey, hubgentypes.StoreKey,
ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
// ethermint keys
evmtypes.StoreKey, feemarkettypes.StoreKey,
Expand Down Expand Up @@ -210,6 +216,7 @@ var (
ibc.AppModuleBasic{},
vesting.AppModuleBasic{},
hubgenesis.AppModuleBasic{},
hub.AppModuleBasic{},
// Ethermint modules
evm.AppModuleBasic{},
feemarket.AppModuleBasic{},
Expand Down Expand Up @@ -291,6 +298,7 @@ type App struct {
EpochsKeeper epochskeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper govkeeper.Keeper
HubKeeper hubkeeper.Keeper
HubGenesisKeeper hubgenkeeper.Keeper
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
Expand Down Expand Up @@ -541,13 +549,30 @@ func NewRollapp(
app.AccountKeeper,
)

genesisTransfersBlocker := hubgenkeeper.NewICS4Wrapper(app.ClaimsKeeper, app.HubGenesisKeeper) // ICS4 Wrapper: claims IBC middleware
app.HubKeeper = hubkeeper.NewKeeper(
appCodec,
keys[hubtypes.StoreKey],
)

denomMetadataMiddleware := denommetadata.NewICS4Wrapper(
app.ClaimsKeeper,
app.HubKeeper,
app.BankKeeper,
app.HubGenesisKeeper.GetState,
)

genesisTransfersBlocker := hubgenkeeper.NewICS4Wrapper(denomMetadataMiddleware, app.HubGenesisKeeper) // ICS4 Wrapper: claims IBC middleware

app.TransferKeeper = transferkeeper.NewKeeper(
appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName),
appCodec,
keys[ibctransfertypes.StoreKey],
app.GetSubspace(ibctransfertypes.ModuleName),
genesisTransfersBlocker,
app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
app.AccountKeeper, app.BankKeeper, scopedTransferKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
app.BankKeeper,
scopedTransferKeeper,
app.Erc20Keeper, // Add ERC20 Keeper for ERC20 transfers
)

Expand All @@ -563,6 +588,16 @@ func NewRollapp(

transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = claims.NewIBCMiddleware(*app.ClaimsKeeper, transferStack)
transferStack = denommetadata.NewIBCModule(
transferStack,
app.BankKeeper,
app.TransferKeeper,
app.HubKeeper,
denommetadatamoduletypes.NewMultiDenommetadataHooks(
erc20keeper.NewERC20ContractRegistrationHook(app.Erc20Keeper),
),
)

transferStack = erc20.NewIBCMiddleware(app.Erc20Keeper, transferStack)
transferStack = hubgenkeeper.NewIBCModule(
transferStack,
Expand Down Expand Up @@ -602,6 +637,7 @@ func NewRollapp(
ibc.NewAppModule(app.IBCKeeper),
upgrade.NewAppModule(app.UpgradeKeeper),
hubgenesis.NewAppModule(appCodec, app.HubGenesisKeeper),
hub.NewAppModule(appCodec, app.HubKeeper),

// Ethermint app modules
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, app.GetSubspace(evmtypes.ModuleName)),
Expand Down Expand Up @@ -642,6 +678,7 @@ func NewRollapp(
epochstypes.ModuleName,
paramstypes.ModuleName,
hubgentypes.ModuleName,
hubtypes.ModuleName,
}
app.mm.SetOrderBeginBlockers(beginBlockersList...)

Expand All @@ -668,6 +705,7 @@ func NewRollapp(
ibchost.ModuleName,
ibctransfertypes.ModuleName,
hubgentypes.ModuleName,
hubtypes.ModuleName,
}
app.mm.SetOrderEndBlockers(endBlockersList...)

Expand Down Expand Up @@ -701,6 +739,7 @@ func NewRollapp(
ibctransfertypes.ModuleName,
feegrant.ModuleName,
hubgentypes.ModuleName,
hubtypes.ModuleName,
}
app.mm.SetOrderInitGenesis(initGenesisList...)

Expand Down
7 changes: 6 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/bcdevtools/evm-block-explorer-rpc-cosmos v1.1.4
github.com/cosmos/cosmos-sdk v0.46.16
github.com/cosmos/ibc-go/v6 v6.2.1
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20240625103643-74f21279f16d
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20240625180315-c98e3e67c156
github.com/dymensionxyz/dymint v1.1.3
github.com/ethereum/go-ethereum v1.12.0
github.com/evmos/evmos/v12 v12.1.6
Expand All @@ -35,6 +35,8 @@ require (
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
github.com/CosmWasm/wasmd v0.33.0 // indirect
github.com/CosmWasm/wasmvm v1.2.3 // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
Expand Down Expand Up @@ -99,6 +101,7 @@ require (
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dlclark/regexp2 v1.7.0 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7 // indirect
github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac // indirect
Expand Down Expand Up @@ -137,6 +140,7 @@ require (
github.com/google/btree v1.1.2 // indirect
github.com/google/flatbuffers v2.0.8+incompatible // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5 // indirect
Expand Down Expand Up @@ -232,6 +236,7 @@ require (
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onsi/ginkgo/v2 v2.15.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ github.com/cosmos/iavl v0.19.6 h1:XY78yEeNPrEYyNCKlqr9chrwoeSDJ0bV2VjocTk//OU=
github.com/cosmos/iavl v0.19.6/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw=
github.com/cosmos/ibc-go/v6 v6.2.1 h1:NiaDXTRhKwf3n9kELD4VRIe5zby1yk1jBvaz9tXTQ6k=
github.com/cosmos/ibc-go/v6 v6.2.1/go.mod h1:XLsARy4Y7+GtAqzMcxNdlQf6lx+ti1e8KcMGv5NIK7A=
github.com/cosmos/interchain-accounts v0.4.3 h1:WedxEa/Hj/2GY7AF6CafkEPJ/Z9rhl3rT1mRwNHsdts=
github.com/cosmos/interchain-accounts v0.4.3/go.mod h1:qibHB6y/R2YsuuZdamI2BcIUBPMyhyELDWAr8Nk8x4g=
github.com/cosmos/ledger-cosmos-go v0.12.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw=
github.com/cosmos/ledger-cosmos-go v0.12.4/go.mod h1:fjfVWRf++Xkygt9wzCsjEBdjcf7wiiY35fv3ctT+k4M=
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
Expand Down Expand Up @@ -559,8 +561,8 @@ github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQx
github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
github.com/dymensionxyz/cosmosclient v0.4.2-beta h1:sokBefcN1tIOlUKmB8Q2E9XMJ93LueqtFThiM/kA4DI=
github.com/dymensionxyz/cosmosclient v0.4.2-beta/go.mod h1:GQQu3ITEjWfi5ULR2B6X2i2YZNennY1yzcT5qdL4MGI=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20240625103643-74f21279f16d h1:CNB9T88z3GF9ovsLR8A+AdHf211IHLvZwM7I8dmx6dg=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20240625103643-74f21279f16d/go.mod h1:5Sy8rIg1FUEltWHi2d0Py+AiTlK3CNjCtJx1l5BW/Gw=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20240625180315-c98e3e67c156 h1:GuMpR4LGwHVdBTZZ6+wMtJeq1EU06/JlD+B9QlRevqA=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20240625180315-c98e3e67c156/go.mod h1:M7YD1jsbAUYlnpfE0cj0MP0esKI3J6NsrVFAit+Rx+8=
github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56 h1:cmpJYdRviuUfmlJdHrcAND8Jd6JIY4rp63bWAQzPr54=
github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56/go.mod h1:3Pfrr8j/BR9ztNKztGfC5PqDiO6CcrzMLCJtFtPEVW4=
github.com/dymensionxyz/dymint v1.1.3 h1:GgYHy5LbTba0Ys34W4BTsqsQnRXoHvgPxly/7GnI7NA=
Expand Down

0 comments on commit faa3771

Please sign in to comment.