Skip to content

Commit

Permalink
fix(denommetadata): correct base denom format (#1220)
Browse files Browse the repository at this point in the history
  • Loading branch information
zale144 authored Sep 12, 2024
1 parent 4782bc4 commit 6de2c58
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions x/denommetadata/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,20 @@ func (m *ICS4Wrapper) SendPacket(
// At the first match, we assume that the rollapp already contains the metadata.
// It would be technically possible to have a race condition where the denom metadata is added to the rollapp
// from another packet before this packet is acknowledged.
if Contains(rollapp.RegisteredDenoms, packet.Denom) {
// The value of `packet.Denom` here can be one of two things:
// 1. Base denom (e.g. "adym") for the native token of the hub, and
// 2. IBC trace (e.g. "transfer/channel-1/arax") for a third party token.
// We need to handle both cases:
// 1. We use the value of `packet.Denom` as the baseDenom
// 2. We parse the IBC denom trace into IBC denom hash and prepend it with "ibc/" to get the baseDenom
baseDenom := transfertypes.ParseDenomTrace(packet.Denom).IBCDenom()

if Contains(rollapp.RegisteredDenoms, baseDenom) {
return m.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data)
}

// get the denom metadata from the bank keeper, if it doesn't exist, move on to the next middleware in the chain
denomMetadata, ok := m.bankKeeper.GetDenomMetaData(ctx, packet.Denom)
denomMetadata, ok := m.bankKeeper.GetDenomMetaData(ctx, baseDenom)
if !ok {
return m.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data)
}
Expand Down

0 comments on commit 6de2c58

Please sign in to comment.