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

NFT transfer over IBC #2407

Merged
merged 28 commits into from
Apr 12, 2024
Merged

NFT transfer over IBC #2407

merged 28 commits into from
Apr 12, 2024

Conversation

yito88
Copy link
Member

@yito88 yito88 commented Jan 16, 2024

Describe your changes

Need to wait for ibc-rs upstream for ICS-721 implementation

  • Updated ibc-rs to v0.50.0 including ICS-721 impl.
  • Integrated ibc-rs' NFT transfer module/context
  • Add Namada's MsgTransfer and MsgNftTransfer
    • Each message has ibc-rs' MsgTransfer/MsgNftTransfer and Option<IbcShieldedTransfer>
  • Fixed to retrieve the minted token info. and the memo(MASP transaction) from the IBC message instead of ABCI events
  • Replaced DenominatedAmount with Amount in IBC handling (Also fixed tx_prelude::token::transfer)

Indicate on which release or other PRs this topic is based on

v0.31.9

Checklist before merging to draft

  • I have added a changelog
  • Git history is in acceptable state

@yito88 yito88 requested review from sug0 and grarco January 26, 2024 08:56
@yito88 yito88 marked this pull request as ready for review January 26, 2024 08:56
@Fraccaman Fraccaman mentioned this pull request Jan 29, 2024
Copy link
Contributor

@sug0 sug0 left a comment

Choose a reason for hiding this comment

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

just one comment to consider, the rest are nits

/// Returns the trace path and the token string if the trace is an NFT one
pub fn is_nft_trace(
trace: impl AsRef<str>,
) -> Option<(NftTracePath, String, String)> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
) -> Option<(NftTracePath, String, String)> {
) -> Option<(NftTracePath, BaseClass, TokenId)> {

I would add some kind of domain specific type here, but given we're pressed for time feel free to ignore this comment.

crates/ibc/src/context/nft_transfer.rs Outdated Show resolved Hide resolved
@@ -51,20 +53,18 @@ where
// Convert IBC amount to Namada amount for the token
let denom = read_denom(&*self.inner.borrow(), &token)
.map_err(ContextError::from)?
.unwrap_or(token::Denomination(0));
.unwrap_or(Denomination(0));
Copy link
Contributor

Choose a reason for hiding this comment

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

honestly, I think we should always assume a denomination of 0 during protocol execution. denomination should be a concern of clients. for the protocol, amounts should already be handed in correctly denominated.

this will likely always return 0 anyway, unless we specifically store the denomination of an ibc token

for the purposes of this review, I'd leave things as is, especially because we have very little time, but I would consult this code later and change things accordingly.

@@ -735,15 +737,11 @@ impl<U: ShieldedUtils + MaybeSend + MaybeSync> ShieldedContext<U> {
.block
.data;

for (idx, tx_event) in txs_results {
for idx in txs_results {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good to me, unfortunately we modified this file in the last release to require tx events for other things but ibc (basically to use the changed keys instead of Transfer) so we'll probably need to revert some of your changes here when merging

grarco
grarco previously approved these changes Jan 30, 2024
Copy link
Contributor

@grarco grarco left a comment

Choose a reason for hiding this comment

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

Minor comments but looks good to me, thanks!

Copy link

codecov bot commented Feb 22, 2024

Codecov Report

Attention: Patch coverage is 56.99164% with 772 lines in your changes are missing coverage. Please review.

Project coverage is 54.00%. Comparing base (cc3edde) to head (86853c4).

Files Patch % Lines
crates/ibc/src/context/nft_transfer_mod.rs 7.67% 361 Missing ⚠️
crates/ibc/src/context/nft_transfer.rs 61.68% 82 Missing ⚠️
crates/ibc/src/lib.rs 54.94% 82 Missing ⚠️
crates/sdk/src/tx.rs 0.00% 65 Missing ⚠️
crates/sdk/src/masp.rs 0.00% 58 Missing ⚠️
crates/core/src/ibc.rs 82.16% 28 Missing ⚠️
crates/ibc/src/actions.rs 0.00% 18 Missing ⚠️
crates/apps/src/lib/client/rpc.rs 0.00% 16 Missing ⚠️
crates/vp_env/src/lib.rs 0.00% 12 Missing ⚠️
crates/apps/src/lib/bench_utils.rs 0.00% 9 Missing ⚠️
... and 8 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2407      +/-   ##
==========================================
+ Coverage   53.88%   54.00%   +0.12%     
==========================================
  Files         308      310       +2     
  Lines      100154   101492    +1338     
==========================================
+ Hits        53967    54814     +847     
- Misses      46187    46678     +491     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

tzemanovic added a commit that referenced this pull request Mar 18, 2024
* origin/yuji/ibc-nft:
  for clippy
  remove stale comments
  not handle masp when receiving fails
  refactoring
  add changelog
  fmt
  fix to get memo for NFT transfer
  fix benches
  fix test
  fix tests
  update ibc-rs
  update ibc-rs
  not delete NFT metadata
  nft transfer
  option data
  back to upstream branch
  update ibc-rs and add some tests
  add nft send test
  add nft transfer
  WIP: impl context
  for new ibc-rs
tzemanovic added a commit that referenced this pull request Mar 19, 2024
* origin/yuji/ibc-nft:
  for clippy
  remove stale comments
  not handle masp when receiving fails
  refactoring
  add changelog
  fmt
  fix to get memo for NFT transfer
  fix benches
  fix test
  fix tests
  update ibc-rs
  update ibc-rs
  not delete NFT metadata
  nft transfer
  option data
  back to upstream branch
  update ibc-rs and add some tests
  add nft send test
  add nft transfer
  WIP: impl context
  for new ibc-rs
tzemanovic added a commit that referenced this pull request Apr 10, 2024
* origin/yuji/ibc-nft:
  for clippy
  remove stale comments
  not handle masp when receiving fails
  refactoring
  add changelog
  fmt
  fix to get memo for NFT transfer
  fix benches
  fix test
  fix tests
  update ibc-rs
  update ibc-rs
  not delete NFT metadata
  nft transfer
  option data
  back to upstream branch
  update ibc-rs and add some tests
  add nft send test
  add nft transfer
  WIP: impl context
  for new ibc-rs
@tzemanovic tzemanovic merged commit 23794f8 into main Apr 12, 2024
18 of 19 checks passed
@tzemanovic tzemanovic deleted the yuji/ibc-nft branch April 12, 2024 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants