-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Conversation
henryyuanheng-wang
commented
Jun 6, 2022
- 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 Report
@@ 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
Continue to review full report at Codecov.
|
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
docs/source/guides/plutus.rst
Outdated
`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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.