Skip to content

Commit

Permalink
fix(genesis transfers): wires the middleware correctly (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt authored Jul 2, 2024
1 parent f0e0909 commit 941ac19
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,13 @@ var (
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account
erc20types.ModuleName: {authtypes.Minter, authtypes.Burner},
claimstypes.ModuleName: nil,
hubgentypes.ModuleName: {authtypes.Burner},
hubgentypes.ModuleName: {authtypes.Minter},
}

// module accounts that are allowed to receive tokens
allowedReceivingModAcc = map[string]bool{
distrtypes.ModuleName: true,
distrtypes.ModuleName: true,
hubgentypes.ModuleName: true,
}
)

Expand Down Expand Up @@ -533,21 +534,23 @@ func NewRollapp(
),
)

app.TransferKeeper = transferkeeper.NewKeeper(
appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName),
app.ClaimsKeeper, // ICS4 Wrapper: claims IBC middleware
app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
app.AccountKeeper, app.BankKeeper, scopedTransferKeeper,
app.Erc20Keeper, // Add ERC20 Keeper for ERC20 transfers
)

app.HubGenesisKeeper = hubgenkeeper.NewKeeper(
appCodec,
keys[hubgentypes.StoreKey],
app.GetSubspace(hubgentypes.ModuleName),
app.AccountKeeper,
)

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

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

// NOTE: app.Erc20Keeper is already initialized elsewhere
// Set the ICS4 wrappers for custom module middlewares
app.ClaimsKeeper.SetICS4Wrapper(app.IBCKeeper.ChannelKeeper)
Expand All @@ -561,6 +564,12 @@ func NewRollapp(
transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = claims.NewIBCMiddleware(*app.ClaimsKeeper, transferStack)
transferStack = erc20.NewIBCMiddleware(app.Erc20Keeper, transferStack)
transferStack = hubgenkeeper.NewIBCModule(
transferStack,
app.TransferKeeper,
app.HubGenesisKeeper,
app.BankKeeper,
)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
Expand Down

0 comments on commit 941ac19

Please sign in to comment.