-
Notifications
You must be signed in to change notification settings - Fork 122
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
Async circuit, pt. 3 - contract methods #1477
Conversation
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 deleted this entire folder, it was a left-over from CI tests in the Mina repo that don't exist anymore
src/lib/caller.unit-test.ts
Outdated
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.
deleted this test, don't think it was still useful
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 example was too similar to reducer-composite.ts
, I'm trying to purge examples that don't really add anything, as they are a burden to maintain
src/lib/mina/transaction.ts
Outdated
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.
an actual change here. I think the try-catch was unused because it didn't await the promise, so removed 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.
most of the actual changes in this file!
function method<K extends string, T extends SmartContract>( | ||
target: T & { | ||
[k in K]: (...args: any) => Promise<void>; | ||
}, |
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.
the decorator type now enforces a particular function signature of the method that is decorated:
(...args: any) => Promise<void>
'design:returntype', | ||
target, | ||
methodName | ||
); |
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.
we no longer infer the method return type, instead there is @method.returns(...)
result = await assertPromise( | ||
method.apply(this, clonedArgs), | ||
noPromiseError | ||
); |
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.
throughout the wrapped method, we are now awaiting the method result and also throwing a helpful runtime error if it's not returning a promise
* }); | ||
* tx.sign([senderKey, zkAppKey]); | ||
* ``` | ||
*/ | ||
deploy({ | ||
async deploy({ |
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.
deploy()
needs to be async because it calls init()
, which can be a method so might be async
src/lib/proof-system.ts
Outdated
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.
ZKProgram was already supporting async methods at runtime, but not at the type level. This here is the change that forces the method type to be async.
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.
Awesome! We should definitely make sure all the tutorial are up to date as soon as we release this. Happy to help
Closes #735
Most breaking change ever -- requires all smart contract and zkprogram methods to be async.
This PR is stacked behind #1450 and #1468 where most of the internal changes were already made
Here, there aren't much changes apart from
@method
andZKProgram
; introducing@method.returns(..)
for methods with a return valueTODO: