Skip to content

Commit

Permalink
wasm: update to non-panicking core API
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed May 2, 2024
1 parent 62635fa commit 871ae3c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion wasm/vp_implicit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ fn validate_tx(
ctx.read_pre(key).into_vp_error()?.unwrap_or_default();
let post: token::Amount =
ctx.read_post(key).into_vp_error()?.unwrap_or_default();
let change = post.change() - pre.change();
let change =
post.change().checked_sub(pre.change()).unwrap();
gadget.verify_signatures_when(
// NB: debit has to signed, credit doesn't
|| change.is_negative(),
Expand Down
3 changes: 2 additions & 1 deletion wasm/vp_user/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ fn validate_tx(
ctx.read_pre(key).into_vp_error()?.unwrap_or_default();
let post: token::Amount =
ctx.read_post(key).into_vp_error()?.unwrap_or_default();
let change = post.change() - pre.change();
let change =
post.change().checked_sub(pre.change()).unwrap();
gadget.verify_signatures_when(
// NB: debit has to signed, credit doesn't
|| change.is_negative(),
Expand Down
6 changes: 6 additions & 0 deletions wasm_for_tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 871ae3c

Please sign in to comment.