Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5ec9dac

Browse files
committedMar 19, 2025
feat: circumvent the problem caused by #34
I inline the logic of `_validate_from_public` directly into each function that uses it, allowing the previously skipped tests to be re-enabled.
1 parent 3dfb4a0 commit 5ec9dac

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed
 

‎src/token_contract/src/main.nr

+21-3
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,13 @@ pub contract Token {
205205

206206
#[public]
207207
fn transfer_public_to_public(from: AztecAddress, to: AztecAddress, amount: U128, nonce: Field) {
208-
_validate_from_public(&mut context, from, nonce);
208+
// _validate_from_public(from, nonce);
209+
// TODO(#34): we cannot call `assert_current_call_valid_authwit_public` from library methods
210+
if (!from.eq(context.msg_sender())) {
211+
assert_current_call_valid_authwit_public(&mut context, from);
212+
} else {
213+
assert(nonce == 0, "invalid nonce");
214+
}
209215
_decrease_public_balance(storage.public_balances, from, amount);
210216
_increase_public_balance(storage.public_balances, to, amount);
211217
}
@@ -220,7 +226,13 @@ pub contract Token {
220226
hiding_point_slot: Field,
221227
nonce: Field,
222228
) {
223-
_validate_from_public(&mut context, from, nonce);
229+
// _validate_from_public(from, nonce);
230+
// TODO(#34): we cannot call `assert_current_call_valid_authwit_public` from library methods
231+
if (!from.eq(context.msg_sender())) {
232+
assert_current_call_valid_authwit_public(&mut context, from);
233+
} else {
234+
assert(nonce == 0, "invalid nonce");
235+
}
224236
_finalize_transfer_public_to_private(
225237
&mut context,
226238
storage.public_balances,
@@ -356,7 +368,13 @@ pub contract Token {
356368

357369
#[public]
358370
fn burn_public(from: AztecAddress, amount: U128, nonce: Field) {
359-
_validate_from_public(&mut context, from, nonce);
371+
// _validate_from_public(from, nonce);
372+
// TODO(#34): we cannot call `assert_current_call_valid_authwit_public` from library methods
373+
if (!from.eq(context.msg_sender())) {
374+
assert_current_call_valid_authwit_public(&mut context, from);
375+
} else {
376+
assert(nonce == 0, "invalid nonce");
377+
}
360378
_decrease_public_balance(storage.public_balances, from, amount);
361379
_decrease_total_supply(storage.total_supply, amount);
362380
}

0 commit comments

Comments
 (0)
Please sign in to comment.