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

fix: calculate trace hash from both class ID and token ID #1032

Merged

Conversation

yito88
Copy link
Contributor

@yito88 yito88 commented Jan 8, 2024

Description

Fix for feat/ics721-impl

The class ID and the token ID specify the NFT.
The trace hash should be calculated from both IDs, and we need to submit a trace event per each token.


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

codecov bot commented Jan 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (feat/ics721-impl@8fa64dd). Click here to learn what that means.

❗ Current head 90322e0 differs from pull request most recent head 87ce97a. Consider uploading reports for the commit 87ce97a to get more accurate results

Additional details and impacted files
@@                 Coverage Diff                 @@
##             feat/ics721-impl    #1032   +/-   ##
===================================================
  Coverage                    ?   67.92%           
===================================================
  Files                       ?      196           
  Lines                       ?    20159           
  Branches                    ?        0           
===================================================
  Hits                        ?    13693           
  Misses                      ?     6466           
  Partials                    ?        0           

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

@Farhad-Shabani Farhad-Shabani changed the title Fix token trace fix: calculate trace hash from both class ID and token ID Jan 8, 2024
Copy link
Member

@Farhad-Shabani Farhad-Shabani left a comment

Choose a reason for hiding this comment

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

Does this PR mean that the same event within the bianjieai/nft-transfer repo should get fixed as well?

@Farhad-Shabani
Copy link
Member

Just a nit. To pass the CI we need to place context, handler, and module modules under the #[cfg(feature = "serde")] flag

@yito88
Copy link
Contributor Author

yito88 commented Jan 8, 2024

Does this PR mean that the same event within the bianjieai/nft-transfer repo should get fixed as well?

I think so. In bianjieai/nft-transfer, the prefixed class is handled like the prefixed denom in ICS-20. However, specifying the actual token is required with not only the class but also the token ID. In Cosmos, a non-NFT token received over IBC is shown as ibc/{hash}. I believe it's natural to express both non-NFT and NFT as ibc/{hash}.

@Farhad-Shabani
Copy link
Member

Does this PR mean that the same event within the bianjieai/nft-transfer repo should get fixed as well?

I think so. In bianjieai/nft-transfer, the prefixed class is handled like the prefixed denom in ICS-20. However, specifying the actual token is required with not only the class but also the token ID. In Cosmos, a non-NFT token received over IBC is shown as ibc/{hash}. I believe it's natural to express both non-NFT and NFT as ibc/{hash}.

Makes sense. Thank you!

@Farhad-Shabani Farhad-Shabani merged commit db43598 into cosmos:feat/ics721-impl Jan 8, 2024
12 checks passed
@yito88 yito88 deleted the yuji/fix-token-trace branch January 11, 2024 23:22
Farhad-Shabani added a commit that referenced this pull request Jan 24, 2024
* feat: establish ICS-721 boilerplate, ready for new additions (#1012)

* chore: establish ics721 boilerplate, ready for new additions

* nit

* Implement ICS-721 NFT transfer (#1020)

* WIP: add types and contexts

* WIP: add events

* WIP: implement modules

* add send_transfer

* add recv and refund handlers

* add tests

* fix send and recv

* fix context and add tests

* fix fmt

* fix for CI

* fix messages and serde

* fix comments

* Add (de)serialization tests for `DataValue`, `TokenUri`, and `ClassUri` types (#1027)

* WIP: add types and contexts

* WIP: add events

* WIP: implement modules

* add send_transfer

* add recv and refund handlers

* add tests

* fix send and recv

* fix context and add tests

* fix fmt

* fix for CI

* fix messages and serde

* fix comments

* Stub out DataValue Borsh unit test

* Add basic borsh (de)ser roundtrip tests

* Add basic serde roundtrip tests for DataValue

* Add json (de)serialization tests

* Add roundtrip tests for TokenUri

* Add roundtrip tests for ClassUri

* Remove ignore statement on a test

* Resolve clippy warning

* Change packet data dummy json strings to use camel case

* Configure nft-transfer app under std feature flag

* Move cfg statement

* Add nft-transfer feature

* Add nft-transfer feature

* Remove nft-transfer feature from default features

* Remove `optional = true` from `http` dependency

---------

Co-authored-by: yito88 <[email protected]>

* fix: calculate trace hash from both class ID and token ID (#1032)

* trace hash with class ID and token ID

* add serde flag

* Fix ClassData and TokenData encoding in NonFungiblePacketData (#1038)

* fix encoding for ClassData and TokenData

* fix Cargo.toml

* Support ClassData and TokenData not according to ICS-721 spec (#1039)

* skip validation, make some data optional

* check the length of token_uri and token_data

* fix to set TokenData and TokenUri at once

* imp: add validate_basic method for PacketData

* imp: allow any format for Data + define parse_as_ics721_data method

* fmt and clippy

* custom serde packet data with option

* add a test

* restore conversions

---------

Co-authored-by: Farhad Shabani <[email protected]>

* chore: add unclog

* nit: fix docstrings

---------

Co-authored-by: Yuji Ito <[email protected]>
Co-authored-by: Sean Chen <[email protected]>
Co-authored-by: yito88 <[email protected]>
Farhad-Shabani added a commit that referenced this pull request Sep 9, 2024
* feat: establish ICS-721 boilerplate, ready for new additions (#1012)

* chore: establish ics721 boilerplate, ready for new additions

* nit

* Implement ICS-721 NFT transfer (#1020)

* WIP: add types and contexts

* WIP: add events

* WIP: implement modules

* add send_transfer

* add recv and refund handlers

* add tests

* fix send and recv

* fix context and add tests

* fix fmt

* fix for CI

* fix messages and serde

* fix comments

* Add (de)serialization tests for `DataValue`, `TokenUri`, and `ClassUri` types (#1027)

* WIP: add types and contexts

* WIP: add events

* WIP: implement modules

* add send_transfer

* add recv and refund handlers

* add tests

* fix send and recv

* fix context and add tests

* fix fmt

* fix for CI

* fix messages and serde

* fix comments

* Stub out DataValue Borsh unit test

* Add basic borsh (de)ser roundtrip tests

* Add basic serde roundtrip tests for DataValue

* Add json (de)serialization tests

* Add roundtrip tests for TokenUri

* Add roundtrip tests for ClassUri

* Remove ignore statement on a test

* Resolve clippy warning

* Change packet data dummy json strings to use camel case

* Configure nft-transfer app under std feature flag

* Move cfg statement

* Add nft-transfer feature

* Add nft-transfer feature

* Remove nft-transfer feature from default features

* Remove `optional = true` from `http` dependency

---------

Co-authored-by: yito88 <[email protected]>

* fix: calculate trace hash from both class ID and token ID (#1032)

* trace hash with class ID and token ID

* add serde flag

* Fix ClassData and TokenData encoding in NonFungiblePacketData (#1038)

* fix encoding for ClassData and TokenData

* fix Cargo.toml

* Support ClassData and TokenData not according to ICS-721 spec (#1039)

* skip validation, make some data optional

* check the length of token_uri and token_data

* fix to set TokenData and TokenUri at once

* imp: add validate_basic method for PacketData

* imp: allow any format for Data + define parse_as_ics721_data method

* fmt and clippy

* custom serde packet data with option

* add a test

* restore conversions

---------

Co-authored-by: Farhad Shabani <[email protected]>

* chore: add unclog

* nit: fix docstrings

---------

Co-authored-by: Yuji Ito <[email protected]>
Co-authored-by: Sean Chen <[email protected]>
Co-authored-by: yito88 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants