pycardano icon indicating copy to clipboard operation
pycardano copied to clipboard

WIP: CIP67 and CIP68 Support

Open theeldermillenial opened this issue 2 years ago • 6 comments

This PR is a first pass implementation at handling classes for CIP67 and CIP68. These classes will streamline handling and parsing tokens utilizing these standards. This approach attempts to extend AssetName by providing additional validation to ensure CIP68 compliance for token names, as well as associated cbor classes for parsing associated metadata.

Feedback on implementation details and additional functionality is welcomed.

Todo:

  • [ ] Unit Tests
  • [ ] More rigorous validation of CIP68 fields (e.g. the uri fields)
  • [ ] Documentation

theeldermillenial avatar Jan 11 '24 22:01 theeldermillenial

Codecov Report

:x: Patch coverage is 0% with 102 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 65.42%. Comparing base (30712f4) to head (6abe56b).

Files with missing lines Patch % Lines
pycardano/cip/cip68.py 0.00% 82 Missing :warning:
pycardano/cip/cip67.py 0.00% 20 Missing :warning:

:exclamation: There is a different number of reports uploaded between BASE (30712f4) and HEAD (6abe56b). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (30712f4) HEAD (6abe56b)
3 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #297       +/-   ##
===========================================
- Coverage   89.94%   65.42%   -24.53%     
===========================================
  Files          33       35        +2     
  Lines        4855     4957      +102     
  Branches      733      748       +15     
===========================================
- Hits         4367     3243     -1124     
- Misses        315     1516     +1201     
- Partials      173      198       +25     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar Jan 12 '24 00:01 codecov-commenter

This is great. I was actually thinking that PlutusData in pycardano could try to support TypedDict as type annotation for field.

Also I found that deserialization of CIP68 compliant datums fails - have not checked lately if this has been fixed but likely requires a similar fix as #293

nielstron avatar Jan 12 '24 10:01 nielstron

This is great. I was actually thinking that PlutusData in pycardano could try to support TypedDict as type annotation for field.

So we just need some kind of extension of this? https://github.com/Python-Cardano/pycardano/blob/3d27786999eb7ee1b979bf8dafa7b487bfdbabff/pycardano/serialization.py#L806

Also I found that deserialization of CIP68 compliant datums fails - have not checked lately if this has been fixed but likely requires a similar fix as #293

Have any examples? I just did a query of all cip68 reference tokens and found that 99.99% of them are nfts. I'm trying to figure out a good set of test cases for it. I could use the example in the CIP68 docs, but those are extremely sparse. Ideally I could get a range of different examples.

theeldermillenial avatar Jan 12 '24 12:01 theeldermillenial

I would rather extend the support of type annotations for fields of PlutusData here: https://github.com/Python-Cardano/pycardano/blob/3d27786999eb7ee1b979bf8dafa7b487bfdbabff/pycardano/plutus.py#L681

Also for the CIP68 datum I meant the deserialization happening when submitting a transaction with a CIP68 Datum attached - you can try this yourself easily. But don't have any examples at hand right now except for https://preprod.cardanoscan.io/transaction/36f79154eff88d73c21caaf9c5e1bedfc1ff641e39f7f80381dbdba0c104bc50

nielstron avatar Jan 12 '24 13:01 nielstron

I'll be working on finishing this off.

Todo:

  • Resolve merge conflicts
  • Unit tests
  • Example of CIP68 token mints

Cat-Treat avatar Apr 10 '25 00:04 Cat-Treat

@cffls We are close to having something ready. Just need to get builds passing.

theeldermillenial avatar Aug 04 '25 19:08 theeldermillenial