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 check to assert proofs are attached if required #1095

Merged
merged 2 commits into from
Aug 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/lib/mina.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,21 @@ function LocalBlockchain({
Ml.fromPublicKey(update.body.publicKey),
Ml.constFromField(update.body.tokenId)
);

let authIsProof = !!update.authorization.proof;
let kindIsProof = update.body.authorizationKind.isProved.toBoolean();
// checks and edge case where a proof is expected, but the developer forgot to invoke await tx.prove()
// this resulted in an assertion OCaml error, which didn't contain any useful information
if (kindIsProof && !authIsProof) {
throw Error(
`The actual authorization does not match the expected authorization kind.
Did you forget to invoke \`await tx.prove();\`?`
Copy link
Member

@mitschabaude mitschabaude Aug 29, 2023

Choose a reason for hiding this comment

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

could you remove the white space at the start of this line? So that it doesn't show up in the error?

);
}

if (accountJson) {
let account = Account.fromJSON(accountJson);

await verifyAccountUpdate(
account,
update,
Expand Down
Loading