Skip to content

Add usage guides for Plutus #46

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

Merged
merged 3 commits into from
Jun 15, 2022
Merged

Conversation

henryyuanheng-wang
Copy link
Contributor

  • Add usage guides for Plutus - explained concepts such as script address, datum, redeemer, script context, etc. Demonstrated the use through FortyTwo example.
  • Minor fix to the hyperlink in Transaction.rst
  • removed the "rm -r docs/build" commands before running Sphinx in Makefile

@codecov-commenter
Copy link

codecov-commenter commented Jun 6, 2022

Codecov Report

Merging #46 (605400f) into main (22ab109) will increase coverage by 0.00%.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main      #46   +/-   ##
=======================================
  Coverage   85.60%   85.60%           
=======================================
  Files          21       21           
  Lines        2084     2091    +7     
  Branches      451      455    +4     
=======================================
+ Hits         1784     1790    +6     
  Misses        221      221           
- Partials       79       80    +1     
Impacted Files Coverage Δ
pycardano/txbuilder.py 92.97% <0.00%> (-0.13%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 22ab109...605400f. Read the comment docs.

Copy link
Collaborator

@cffls cffls left a comment

Choose a reason for hiding this comment

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

Thanks Henry, this looks awesome! One small suggestion, we can probably create a dedicated section for datum/redeemer serialization.

@@ -66,7 +66,6 @@ format: ## runs code style and formatter

docs: ## build the documentation
poetry export --dev --without-hashes > docs/requirements.txt
rm -r docs/build
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why remove this? IIRC, this was to clean up docs folder before rebuilding it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think if building doc for the first time, the remove step will complain. We can add a -f flag to remove folder if exists like this rm -r -f docs/build. What do you think?

Comment on lines 74 to 87
`PlutusData` helper class that can serialize itself into a CBOR format, which could be intepreted as a data structure in Plutus scripts. Wrapping datum in PlutusData class will reduce the complexity of serialization and deserialization tremendously. It supports data type of int, bytes, List and hashmap. For our example, we leave it empty. But to construct any arbitrary datum, we can do the following::

>>> # Create sample datum
>>> @dataclass
... class Test(PlutusData):
... CONSTR_ID = 1
... a: int
... b: bytes

>>> test = Test(123, b"321")
>>> test.to_cbor()
'd87a9f187b43333231ff'
>>> assert test == Test.from_cbor("d87a9f187b43333231ff")
True
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel it might be a good idea to move this to a different section. Having it in the middle of forty-two example could be a distraction to readers. We can also add more datum serialization examples in the new section. There are already many examples in the unit test file 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.

Yep that's a great suggestion! Made the modification to the file.

Copy link
Collaborator

@cffls cffls left a comment

Choose a reason for hiding this comment

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

LGTM. I will rebase your changes and resolve the conflicts before merging.

@cffls cffls merged commit 30afedd into Python-Cardano:main Jun 15, 2022
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.

3 participants