Skip to content

Commit

Permalink
Merge pull request #1095 from o1-labs/fix-signature-contract
Browse files Browse the repository at this point in the history
Add check to assert proofs are attached if required
  • Loading branch information
Trivo25 authored Aug 30, 2023
2 parents 0b4fa9e + 101ae64 commit 8cb0cf8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lib/mina.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,20 @@ 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();\`?`
);
}

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

await verifyAccountUpdate(
account,
update,
Expand Down

0 comments on commit 8cb0cf8

Please sign in to comment.