-
Notifications
You must be signed in to change notification settings - Fork 751
refactor: remove SendTransfer, require IBC transfers to be initiated with MsgTransfer #2446
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
Changes from all commits
4db8313
d2da1c9
e87087b
7549663
05098fb
c7bb641
1f03958
a11a447
a3d80c7
1b41b9b
9351467
dabfc5c
9c4d411
a878376
cca0b61
9e03e65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ import ( | |
| coretypes "github.com/cosmos/ibc-go/v6/modules/core/types" | ||
| ) | ||
|
|
||
| // SendTransfer handles transfer sending logic. There are 2 possible cases: | ||
| // sendTransfer handles transfer sending logic. There are 2 possible cases: | ||
| // | ||
| // 1. Sender chain is acting as the source zone. The coins are transferred | ||
| // to an escrow address (i.e locked) on the sender chain and then transferred | ||
|
|
@@ -48,34 +48,6 @@ import ( | |
| // 4. A -> C : sender chain is sink zone. Denom upon receiving: 'C/B/denom' | ||
| // 5. C -> B : sender chain is sink zone. Denom upon receiving: 'B/denom' | ||
| // 6. B -> A : sender chain is sink zone. Denom upon receiving: 'denom' | ||
| // | ||
| // Note: An IBC Transfer must be initiated using a MsgTransfer via the Transfer rpc handler | ||
| func (k Keeper) SendTransfer( | ||
| ctx sdk.Context, | ||
| sourcePort, | ||
| sourceChannel string, | ||
| token sdk.Coin, | ||
| sender sdk.AccAddress, | ||
| receiver string, | ||
| timeoutHeight clienttypes.Height, | ||
| timeoutTimestamp uint64, | ||
| metadata []byte, | ||
| ) error { | ||
| _, err := k.sendTransfer( | ||
| ctx, | ||
| sourcePort, | ||
| sourceChannel, | ||
| token, | ||
| sender, | ||
| receiver, | ||
| timeoutHeight, | ||
| timeoutTimestamp, | ||
| metadata, | ||
| ) | ||
| return err | ||
| } | ||
|
|
||
| // sendTransfer handles transfer sending logic. | ||
| func (k Keeper) sendTransfer( | ||
| ctx sdk.Context, | ||
| sourcePort, | ||
|
|
@@ -87,14 +59,6 @@ func (k Keeper) sendTransfer( | |
| timeoutTimestamp uint64, | ||
| metadata []byte, | ||
| ) (uint64, error) { | ||
| if !k.GetSendEnabled(ctx) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason to move these checks to the message server?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the message server was added after send enabled, which is why it ended up within "SendTransfer" The reasoning for why I moved it is because I view it as auxiliary to the transfer logic. It isn't in the IBC specification for ICS20 I visualize the code like this: I think this should be true for most of our handlers:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general I think we should avoid overloading functions. Basic enablement checks make sense to go directly in the entrypoint (msg_server.go), while functions nested deeper in the handler can focus on ICS logic entirely
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree++ Definitely a good way to reason about things! |
||
| return 0, types.ErrSendDisabled | ||
| } | ||
|
|
||
| if k.bankKeeper.BlockedAddr(sender) { | ||
| return 0, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to send funds", sender) | ||
| } | ||
|
|
||
| channel, found := k.channelKeeper.GetChannel(ctx, sourcePort, sourceChannel) | ||
| if !found { | ||
| return 0, sdkerrors.Wrapf(channeltypes.ErrChannelNotFound, "port ID (%s) channel ID (%s)", sourcePort, sourceChannel) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like using suite.Run because it adds the test case name to the output if it fails