Skip to content

Commit

Permalink
feat: add channel 0 check for tokenless (#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt authored Dec 16, 2024
1 parent bcb6034 commit 77cdd63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions x/hub-genesis/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ func (k Keeper) GetGenesisInfo(ctx sdk.Context) types.GenesisInfo {
k.cdc.MustUnmarshal(bz, &gInfo)
return gInfo
}

func (k Keeper) Tokenless(ctx sdk.Context) bool {
return k.GetGenesisInfo(ctx).BaseDenom() == ""
}
5 changes: 5 additions & 0 deletions x/hub-genesis/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ func (m msgServer) SendTransfer(goCtx context.Context, msg *types.MsgSendTransfe
return &types.MsgSendTransferResponse{}, nil
}

const expectedChan = "channel-0" // tokenless only

func (k Keeper) SendGenesisTransfer(ctx sdk.Context, channelID string) error {
if k.Tokenless(ctx) && channelID != expectedChan {
return gerrc.ErrInvalidArgument.Wrapf("tokenless chain: wrong channel id, expect: %s", expectedChan)
}
state := k.GetState(ctx)
if state.InFlight {
return gerrc.ErrFailedPrecondition.Wrap("sent transfer is already in flight")
Expand Down

0 comments on commit 77cdd63

Please sign in to comment.