Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add channel 0 check for tokenless #642

Merged
merged 1 commit into from
Dec 16, 2024
Merged
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
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
Loading