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

Don't require ICS20 module to implement Channel{Reader,Keeper} #244

Merged
merged 13 commits into from
Nov 18, 2022

Conversation

hu55a1n1
Copy link
Contributor

@hu55a1n1 hu55a1n1 commented Nov 16, 2022

Closes: #182 (potential solution)

With these changes, we no longer require an ICS20 module (i.e. the type implementing Ics20Context) to implement the complete ChannelReader and ChannelKeeper traits. We only require them to implement the Ics20ChannelKeeper and the SendPacketReader traits ->

pub trait Ics20Keeper:
Ics20ChannelKeeper + BankKeeper<AccountId = <Self as Ics20Keeper>::AccountId>

Moreover, we also provide blanket impls for both these traits (i.e. Ics20ChannelKeeper and SendPacketReader) if the type implements ChannelReader and ChannelKeeper respectively.


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests.
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).
  • Tagged one reviewer who will be the one responsible for shepherding this PR.

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

Copy link
Contributor

@plafer plafer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few things but generally looks great!

crates/ibc/src/applications/transfer/context.rs Outdated Show resolved Hide resolved
crates/ibc/src/applications/transfer/context.rs Outdated Show resolved Hide resolved
crates/ibc/src/core/ics04_channel/context.rs Outdated Show resolved Hide resolved
crates/ibc/src/core/ics04_channel/handler/send_packet.rs Outdated Show resolved Hide resolved
ChannelKeeper + BankKeeper<AccountId = <Self as Ics20Keeper>::AccountId>
{
type AccountId;
pub trait Ics20Keeper: BankKeeper {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In light of #247, can we rename this to TokenTransferKeeper?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

pub trait Ics20Reader: ChannelReader {
pub trait Ics20Reader: SendPacketReader {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this to TokenTransferReader?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hu55a1n1 hu55a1n1 merged commit 076dc31 into main Nov 18, 2022
@hu55a1n1 hu55a1n1 deleted the hu55a1n1/182-ics20-channel-reader-keeper branch November 18, 2022 19:37
Farhad-Shabani pushed a commit that referenced this pull request Sep 9, 2024
* Add SendPacketReader trait with blanket impl for all types implementing ChannelReader

* Have SendPacket handler depend on SendPacketReader and return SendPacketResult

* Define Ics20ChannelKeeper and depend on that instead of Channel{Reader,Keeper}

* Update tests

* Add blanket impl for Ics20ChannelKeeper

* Add changelog entry

* Use where clause for trait bounds

* Avoid trait object param in send_packet handler

* Apply suggestion to merge Ics20ChannelKeeper into Ics20Keeper

* Rename Ics20Keeper -> TokenTransferKeeper

* Rename Ics20Reader -> TokenTransferReader
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should Ics20Context implement Module?
2 participants