-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat!: add predicates abigen #726
Conversation
Interface looks good IMO |
I'm assuming you need a new release of |
Yes. Currently the CI is using your branch. |
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 did a first pass focusing on the docs and interfaces. I thought I should publish the review without fully finishing it so you can work through the suggestions while I do another deeper pass!
By the way, it's looking beautiful!
Co-authored-by: Rodrigo Araújo <rod.dearaujo@gmail.com>
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.
This is so good!
Consider this an approval, but since we have to wait for forc
to be released so we can pin a released version, this is just a comment to prevent an accidental merge.
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.
Excellent work. Especially with the bindings and the predicate data offset.
Co-authored-by: Rodrigo Araújo <rod.dearaujo@gmail.com>
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.
Awsome! 🏅
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 -- wonderful work. These tests are 10/10.
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.
Breaking changes: - Predicate instantiation - Sending funds to and receiving funds from predicates
This PR is is based on @mohammadfawaz sway branch which supports main function arguments for predicates.
We do not have to use the
input_predicate_data(0)
data anymore instead we pass the data directly into the main function. This is an example how a new predicate looks like:Previously, we could not use
TestStruct
orAnotherTestStruct
directly in our test because it was not generated.With the new abigen we generate all the types and we also generate an encoding function
encode_data
which has the same inputs as the predicate's main function...This is how the new abigen is used:
Send funds to a predicate:
Spend funds from a predicate. First encode the data and then spend to a wallet:
What was done:
Abigen
to handle predicates and add the predicate abigen macroAbigenType
enum to specify if it is acontract
,script
orpredicate
spend_predicate
function to calculate the appropriate data offset for dynamic datafuels_core::offsets
as it was used infuels-signers
andfuels-contract
Breaking changes:
thanks @mohammadfawaz for the help from the compiler side!