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

Add support for asset fingerprint (CIP14) #294

Merged
merged 12 commits into from
Jan 10, 2024

Conversation

theeldermillenial
Copy link
Contributor

This PR adds support for CIP14. I looked into a few different ways to integrate it into multi-assets, and I think there is a way to do it (as suggested in #289) but I figured I would open a PR for the minimal implementation first and see if anyone else thinks its a useful/necessary thing to add.

This also includes unit tests against all examples in the CIP.

For reference:
https://developers.cardano.org/docs/governance/cardano-improvement-proposals/cip-0014/

closes #289

@codecov-commenter
Copy link

codecov-commenter commented Jan 10, 2024

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (d1ec439) 84.63% compared to head (8f80fbc) 84.50%.
Report is 1 commits behind head on main.

Files Patch % Lines
pycardano/cip/cip14.py 64.70% 4 Missing and 2 partials ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #294      +/-   ##
==========================================
- Coverage   84.63%   84.50%   -0.13%     
==========================================
  Files          26       27       +1     
  Lines        3071     3092      +21     
  Branches      752      758       +6     
==========================================
+ Hits         2599     2613      +14     
- Misses        353      358       +5     
- Partials      119      121       +2     

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

from pycardano.crypto.bech32 import encode


def encode_asset(policy_id: Union[bytes, str], asset_name: Union[bytes, str]) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use the ScriptHash and AssetName classes of pycardano here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

... because... Hahaha

I actually had considered that. I decided to just go with raw types. I can switch that over.

Ill add in as an additional input type?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I think adding it to the Union would be great :)

@theeldermillenial
Copy link
Contributor Author

Ah, I missed the import and docs. I'll remember that next time. Thanks for the cleanup.

Copy link
Contributor

@nielstron nielstron left a comment

Choose a reason for hiding this comment

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

Thanks, looks good to me!

@theeldermillenial
Copy link
Contributor Author

Send it!

@nielstron nielstron merged commit 3d27786 into Python-Cardano:main Jan 10, 2024
11 checks passed
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.

Support for CIP14
3 participants