@@ -128,9 +128,7 @@ contract Token {
128
128
129
129
// docs:start:set_admin
130
130
#[aztec(public)]
131
- fn set_admin (
132
- new_admin : AztecAddress ,
133
- ) {
131
+ fn set_admin (new_admin : AztecAddress ) {
134
132
assert (storage .admin .read ().eq (AztecAddress ::new (context .msg_sender ())), "caller is not admin" );
135
133
// docs:start:write_admin
136
134
storage .admin .write (new_admin );
@@ -140,10 +138,7 @@ contract Token {
140
138
141
139
// docs:start:set_minter
142
140
#[aztec(public)]
143
- fn set_minter (
144
- minter : AztecAddress ,
145
- approve : bool ,
146
- ) {
141
+ fn set_minter (minter : AztecAddress , approve : bool ) {
147
142
// docs:start:read_admin
148
143
assert (storage .admin .read ().eq (AztecAddress ::new (context .msg_sender ())), "caller is not admin" );
149
144
// docs:end:read_admin
@@ -155,10 +150,7 @@ contract Token {
155
150
156
151
// docs:start:mint_public
157
152
#[aztec(public)]
158
- fn mint_public (
159
- to : AztecAddress ,
160
- amount : Field ,
161
- ) -> Field {
153
+ fn mint_public (to : AztecAddress , amount : Field ) -> Field {
162
154
// docs:start:read_minter
163
155
assert (storage .minters .at (context .msg_sender ()).read (), "caller is not minter" );
164
156
// docs:end:read_minter
@@ -174,10 +166,7 @@ contract Token {
174
166
175
167
// docs:start:mint_private
176
168
#[aztec(public)]
177
- fn mint_private (
178
- amount : Field ,
179
- secret_hash : Field ,
180
- ) -> Field {
169
+ fn mint_private (amount : Field , secret_hash : Field ) -> Field {
181
170
assert (storage .minters .at (context .msg_sender ()).read (), "caller is not minter" );
182
171
let pending_shields = storage .pending_shields ;
183
172
let mut note = TransparentNote ::new (amount , secret_hash );
@@ -193,12 +182,7 @@ contract Token {
193
182
194
183
// docs:start:shield
195
184
#[aztec(public)]
196
- fn shield (
197
- from : AztecAddress ,
198
- amount : Field ,
199
- secret_hash : Field ,
200
- nonce : Field ,
201
- ) -> Field {
185
+ fn shield (from : AztecAddress , amount : Field , secret_hash : Field , nonce : Field ) -> Field {
202
186
if (from .address != context .msg_sender ()) {
203
187
// The redeem is only spendable once, so we need to ensure that you cannot insert multiple shields from the same message.
204
188
assert_current_call_valid_authwit_public (&mut context , from );
@@ -220,12 +204,7 @@ contract Token {
220
204
221
205
// docs:start:transfer_public
222
206
#[aztec(public)]
223
- fn transfer_public (
224
- from : AztecAddress ,
225
- to : AztecAddress ,
226
- amount : Field ,
227
- nonce : Field ,
228
- ) -> Field {
207
+ fn transfer_public (from : AztecAddress , to : AztecAddress , amount : Field , nonce : Field ) -> Field {
229
208
if (from .address != context .msg_sender ()) {
230
209
assert_current_call_valid_authwit_public (&mut context , from );
231
210
} else {
@@ -245,11 +224,7 @@ contract Token {
245
224
246
225
// docs:start:burn_public
247
226
#[aztec(public)]
248
- fn burn_public (
249
- from : AztecAddress ,
250
- amount : Field ,
251
- nonce : Field ,
252
- ) -> Field {
227
+ fn burn_public (from : AztecAddress , amount : Field , nonce : Field ) -> Field {
253
228
if (from .address != context .msg_sender ()) {
254
229
assert_current_call_valid_authwit_public (&mut context , from );
255
230
} else {
@@ -269,11 +244,7 @@ contract Token {
269
244
270
245
// docs:start:redeem_shield
271
246
#[aztec(private)]
272
- fn redeem_shield (
273
- to : AztecAddress ,
274
- amount : Field ,
275
- secret : Field ,
276
- ) -> Field {
247
+ fn redeem_shield (to : AztecAddress , amount : Field , secret : Field ) -> Field {
277
248
let pending_shields = storage .pending_shields ;
278
249
let secret_hash = compute_secret_hash (secret );
279
250
let options = NoteGetterOptions ::new ().select (0 , amount ).select (1 , secret_hash ).set_limit (1 );
@@ -289,12 +260,7 @@ contract Token {
289
260
290
261
// docs:start:unshield
291
262
#[aztec(private)]
292
- fn unshield (
293
- from : AztecAddress ,
294
- to : AztecAddress ,
295
- amount : Field ,
296
- nonce : Field ,
297
- ) -> Field {
263
+ fn unshield (from : AztecAddress , to : AztecAddress , amount : Field , nonce : Field ) -> Field {
298
264
if (from .address != context .msg_sender ()) {
299
265
assert_current_call_valid_authwit (&mut context , from );
300
266
} else {
@@ -312,12 +278,7 @@ contract Token {
312
278
313
279
// docs:start:transfer
314
280
#[aztec(private)]
315
- fn transfer (
316
- from : AztecAddress ,
317
- to : AztecAddress ,
318
- amount : Field ,
319
- nonce : Field ,
320
- ) -> Field {
281
+ fn transfer (from : AztecAddress , to : AztecAddress , amount : Field , nonce : Field ) -> Field {
321
282
if (from .address != context .msg_sender ()) {
322
283
assert_current_call_valid_authwit (&mut context , from );
323
284
} else {
@@ -334,11 +295,7 @@ contract Token {
334
295
335
296
// docs:start:burn
336
297
#[aztec(private)]
337
- fn burn (
338
- from : AztecAddress ,
339
- amount : Field ,
340
- nonce : Field ,
341
- ) -> Field {
298
+ fn burn (from : AztecAddress , amount : Field , nonce : Field ) -> Field {
342
299
if (from .address != context .msg_sender ()) {
343
300
assert_current_call_valid_authwit (&mut context , from );
344
301
} else {
@@ -356,9 +313,7 @@ contract Token {
356
313
357
314
// docs:start:initialize
358
315
#[aztec(public)]
359
- internal fn _initialize (
360
- new_admin : AztecAddress ,
361
- ) {
316
+ internal fn _initialize (new_admin : AztecAddress ) {
362
317
storage .admin .write (new_admin );
363
318
storage .minters .at (new_admin .address ).write (true );
364
319
}
@@ -368,20 +323,15 @@ contract Token {
368
323
369
324
// docs:start:increase_public_balance
370
325
#[aztec(public)]
371
- internal fn _increase_public_balance (
372
- to : AztecAddress ,
373
- amount : Field ,
374
- ) {
326
+ internal fn _increase_public_balance (to : AztecAddress , amount : Field ) {
375
327
let new_balance = storage .public_balances .at (to .address ).read ().add (SafeU120 ::new (amount ));
376
328
storage .public_balances .at (to .address ).write (new_balance );
377
329
}
378
330
// docs:end:increase_public_balance
379
331
380
332
// docs:start:reduce_total_supply
381
333
#[aztec(public)]
382
- internal fn _reduce_total_supply (
383
- amount : Field ,
384
- ) {
334
+ internal fn _reduce_total_supply (amount : Field ) {
385
335
// Only to be called from burn.
386
336
let new_supply = storage .total_supply .read ().sub (SafeU120 ::new (amount ));
387
337
storage .total_supply .write (new_supply );
@@ -391,37 +341,31 @@ contract Token {
391
341
/// Unconstrained ///
392
342
393
343
// docs:start:admin
394
- unconstrained fn admin () -> Field {
344
+ unconstrained fn admin () -> pub Field {
395
345
storage .admin .read ().address
396
346
}
397
347
// docs:end:admin
398
348
399
349
// docs:start:is_minter
400
- unconstrained fn is_minter (
401
- minter : AztecAddress ,
402
- ) -> bool {
350
+ unconstrained fn is_minter (minter : AztecAddress ) -> pub bool {
403
351
storage .minters .at (minter .address ).read ()
404
352
}
405
353
// docs:end:is_minter
406
354
407
355
// docs:start:total_supply
408
- unconstrained fn total_supply () -> u120 {
356
+ unconstrained fn total_supply () -> pub u120 {
409
357
storage .total_supply .read ().value
410
358
}
411
359
// docs:end:total_supply
412
360
413
361
// docs:start:balance_of_private
414
- unconstrained fn balance_of_private (
415
- owner : AztecAddress ,
416
- ) -> u120 {
362
+ unconstrained fn balance_of_private (owner : AztecAddress ) -> pub u120 {
417
363
storage .balances .at (owner ).balance_of ().value
418
364
}
419
365
// docs:end:balance_of_private
420
366
421
367
// docs:start:balance_of_public
422
- unconstrained fn balance_of_public (
423
- owner : AztecAddress ,
424
- ) -> u120 {
368
+ unconstrained fn balance_of_public (owner : AztecAddress ) -> pub u120 {
425
369
storage .public_balances .at (owner .address ).read ().value
426
370
}
427
371
// docs:end:balance_of_public
@@ -433,7 +377,12 @@ contract Token {
433
377
// Computes note hash and nullifier.
434
378
// Note 1: Needs to be defined by every contract producing logs.
435
379
// Note 2: Having it in all the contracts gives us the ability to compute the note hash and nullifier differently for different kind of notes.
436
- unconstrained fn compute_note_hash_and_nullifier (contract_address : Field , nonce : Field , storage_slot : Field , serialized_note : [Field ; TOKEN_NOTE_LEN ]) -> [Field ; 4 ] {
380
+ unconstrained fn compute_note_hash_and_nullifier (
381
+ contract_address : Field ,
382
+ nonce : Field ,
383
+ storage_slot : Field ,
384
+ serialized_note : [Field ; TOKEN_NOTE_LEN ]
385
+ ) -> pub [Field ; 4 ] {
437
386
let note_header = NoteHeader ::new (contract_address , nonce , storage_slot );
438
387
if (storage_slot == 5 ) {
439
388
note_utils:: compute_note_hash_and_nullifier (TransparentNoteMethods , note_header , serialized_note )
0 commit comments