@buenos_andres/contracts 0.0.1-test.1 → 0.0.1-test.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +1 -0
  2. package/package.json +4 -17
  3. package/{dist/utils → utils}/Utils.compact +1 -0
  4. package/utils/witnesses/UtilsWitnesses.js +4 -0
  5. package/utils/witnesses/UtilsWitnesses.js.map +1 -0
  6. package/dist/access/AccessControl.compact +0 -321
  7. package/dist/access/Ownable.compact +0 -212
  8. package/dist/access/witnesses/AccessControlWitnesses.d.ts +0 -2
  9. package/dist/access/witnesses/AccessControlWitnesses.js +0 -1
  10. package/dist/access/witnesses/AccessControlWitnesses.ts +0 -3
  11. package/dist/access/witnesses/OwnableWitnesses.d.ts +0 -2
  12. package/dist/access/witnesses/OwnableWitnesses.js +0 -1
  13. package/dist/access/witnesses/OwnableWitnesses.ts +0 -3
  14. package/dist/security/Initializable.compact +0 -59
  15. package/dist/security/Pausable.compact +0 -88
  16. package/dist/security/witnesses/InitializableWitnesses.d.ts +0 -2
  17. package/dist/security/witnesses/InitializableWitnesses.js +0 -1
  18. package/dist/security/witnesses/InitializableWitnesses.ts +0 -3
  19. package/dist/security/witnesses/PausableWitnesses.d.ts +0 -2
  20. package/dist/security/witnesses/PausableWitnesses.js +0 -1
  21. package/dist/security/witnesses/PausableWitnesses.ts +0 -3
  22. package/dist/token/FungibleToken.compact +0 -606
  23. package/dist/token/MultiToken.compact +0 -545
  24. package/dist/token/NonFungibleToken.compact +0 -805
  25. package/dist/token/witnesses/FungibleTokenWitnesses.d.ts +0 -2
  26. package/dist/token/witnesses/FungibleTokenWitnesses.js +0 -1
  27. package/dist/token/witnesses/FungibleTokenWitnesses.ts +0 -3
  28. package/dist/token/witnesses/MultiTokenWitnesses.d.ts +0 -2
  29. package/dist/token/witnesses/MultiTokenWitnesses.js +0 -1
  30. package/dist/token/witnesses/MultiTokenWitnesses.ts +0 -3
  31. package/dist/token/witnesses/NonFungibleTokenWitnesses.d.ts +0 -2
  32. package/dist/token/witnesses/NonFungibleTokenWitnesses.js +0 -1
  33. package/dist/token/witnesses/NonFungibleTokenWitnesses.ts +0 -3
  34. package/dist/utils/witnesses/UtilsWitnesses.js +0 -1
  35. package/dist/utils/witnesses/UtilsWitnesses.ts +0 -3
  36. /package/{dist/utils → utils}/witnesses/UtilsWitnesses.d.ts +0 -0
@@ -1,545 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
-
3
- pragma language_version >= 0.16.0;
4
-
5
- /**
6
- * @module MultiToken
7
- * @description An unshielded MultiToken library. This library is inspired by
8
- * ERC1155. Many aspects of the EIP-1155 spec cannot be implemented in Compact;
9
- * therefore, the MultiToken module should be treated as an approximation of
10
- * the ERC1155 standard and not necessarily a compliant implementation.
11
- *
12
- * @notice One notable difference regarding this implementation and the EIP1155 spec
13
- * consists of the token size. Uint<128> is used as the token size because Uint<256>
14
- * cannot be supported. This is true for both token IDs and for amounts.
15
- * This is due to encoding limits on the midnight circuit backend:
16
- * https://github.com/midnightntwrk/compactc/issues/929
17
- *
18
- * @notice Some features defined in th EIP1155 spec are NOT included.
19
- * Such features include:
20
- *
21
- * 1. Batch mint, burn, transfer - Without support for dynamic arrays,
22
- * batching transfers is difficult to do without a hacky solution.
23
- * For instance, we could change the `to` and `from` parameters to be
24
- * vectors. This would change the signature and would be both difficult
25
- * to use and easy to misuse.
26
- *
27
- * 2. Querying batched balances - This can be somewhat supported.
28
- * The issue, without dynamic arrays, is that the module circuit must use
29
- * Vector<n> for accounts and ids; therefore, the implementing contract must
30
- * explicitly define the number of balances to query in the circuit i.e.
31
- *
32
- * balanceOfBatch_10(
33
- * accounts: Vector<10, Either<ZswapCoinPublicKey, ContractAddress>>,
34
- * ids: Vector<10, Uint<128>>
35
- * ): Vector<10, Uint<128>>
36
- *
37
- * Since this module does not offer mint or transfer batching,
38
- * balance batching is also not included at this time.
39
- *
40
- * 3. Introspection - Compact currently cannot support contract-to-contract
41
- * queries for introspection. ERC165 (or an equivalent thereof) is NOT
42
- * included in the contract.
43
- *
44
- * 4. Safe transfers - The lack of an introspection mechanism means
45
- * safe transfers of any kind can not be supported.
46
- * BE AWARE: Tokens sent to a contract address MAY be lost forever.
47
- *
48
- * Due to the vast incompatibilities with the EIP1155 spec, it is our
49
- * opinion that this implementation should not be called ERC1155 at this time
50
- * as this would be both very confusing and misleading. This may change as more
51
- * features become available. The list of missing features is as follows:
52
- *
53
- * - Full uint256 support.
54
- * - Events.
55
- * - Dynamic arrays.
56
- * - Introspection.
57
- * - Contract-to-contract calls for acceptance callback.
58
- *
59
- * @notice Further discussion and consideration required:
60
- *
61
- * - Consider changing the underscore in the internal methods to `unsafe` or
62
- * adopting dot notation for prefixing imports.
63
- * - Revise logic once contract-to-contract interactions are available on midnight.
64
- */
65
- module MultiToken {
66
- import CompactStandardLibrary;
67
- import "../security/Initializable" prefix Initializable_;
68
- import "../utils/Utils" prefix Utils_;
69
-
70
- /**
71
- * @description Mapping from token ID to account balances.
72
- * @type {Uint<128>} id - The token identifier.
73
- * @type {Either<ZswapCoinPublicKey, ContractAddress>} account - The account address.
74
- * @type {Uint<128>} balance - The balance of the account for the token.
75
- * @type {Map<id, Map<account, balance>>}
76
- * @type {Map<Uint<128>, Map<Either<ZswapCoinPublicKey, ContractAddress>, Uint<128>>>} _balances
77
- */
78
- export ledger _balances: Map<Uint<128>, Map<Either<ZswapCoinPublicKey, ContractAddress>, Uint<128>>>;
79
-
80
- /**
81
- * @description Mapping from account to operator approvals.
82
- * @type {Either<ZswapCoinPublicKey, ContractAddress>} account - The account address.
83
- * @type {Either<ZswapCoinPublicKey, ContractAddress>} operator - The operator address.
84
- * @type {Boolean} approved - The approval status of the operator for the account.
85
- * @type {Map<account, Map<operator, approved>>}
86
- * @type {Map<Either<ZswapCoinPublicKey, ContractAddress>, Map<Either<ZswapCoinPublicKey, ContractAddress>, Boolean>>}
87
- */
88
- export ledger _operatorApprovals: Map<Either<ZswapCoinPublicKey, ContractAddress>, Map<Either<ZswapCoinPublicKey, ContractAddress>, Boolean>>;
89
-
90
- /**
91
- * @description Base URI for computing token URIs.
92
- * Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
93
- * @type {Opaque<"string">} _uri - The base URI for all token URIs.
94
- */
95
- export ledger _uri: Opaque<"string">;
96
-
97
- /**
98
- * @description Initializes the contract by setting the base URI for all tokens.
99
- *
100
- * @circuitInfo k=10, rows=45
101
- *
102
- * Requirements:
103
- *
104
- * - Must be called in the contract's constructor.
105
- *
106
- * @param {Opaque<"string">} uri_ - The base URI for all token URIs.
107
- * @return {[]} - Empty tuple.
108
- */
109
- export circuit initialize(uri_: Opaque<"string">): [] {
110
- Initializable_initialize();
111
- _setURI(uri_);
112
- }
113
-
114
- /**
115
- * @description This implementation returns the same URI for *all* token types. It relies
116
- * on the token type ID substitution mechanism defined in the EIP:
117
- * https://eips.ethereum.org/EIPS/eip-1155#metadata.
118
- * Clients calling this function must replace the `\{id\}` substring with the
119
- * actual token type ID.
120
- *
121
- * @circuitInfo k=10, rows=90
122
- *
123
- * Requirements:
124
- *
125
- * - Contract is initialized.
126
- *
127
- * @param {Uint<128>} id - The token identifier to query.
128
- * return {Opaque<"string">} - The base URI for all tokens.
129
- */
130
- export circuit uri(id: Uint<128>): Opaque<"string"> {
131
- Initializable_assertInitialized();
132
-
133
- return _uri;
134
- }
135
-
136
- /**
137
- * @description Returns the amount of `id` tokens owned by `account`.
138
- *
139
- * @circuitInfo k=10, rows=439
140
- *
141
- * Requirements:
142
- *
143
- * - Contract is initialized.
144
- *
145
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} account - The account balance to query.
146
- * @param {Uint<128>} id - The token identifier to query.
147
- * return {Uint<128>} - The quantity of `id` tokens that `account` owns.
148
- */
149
- export circuit balanceOf(account: Either<ZswapCoinPublicKey, ContractAddress>, id: Uint<128>): Uint<128> {
150
- Initializable_assertInitialized();
151
-
152
- if (!_balances.member(disclose(id)) || !_balances.lookup(id).member(disclose(account))) {
153
- return 0;
154
- }
155
- return _balances.lookup(id).lookup(disclose(account));
156
- }
157
-
158
- /**
159
- * @description Enables or disables approval for `operator` to manage all of the caller's assets.
160
- *
161
- * @circuitInfo k=10, rows=404
162
- *
163
- * Requirements:
164
- *
165
- * - Contract is initialized.
166
- * - `operator` is not the zero address.
167
- *
168
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} operator - The ZswapCoinPublicKey or ContractAddress
169
- * whose approval is set for the caller's assets.
170
- * @param {Boolean} approved - The boolean value determining if the operator may or may not handle the
171
- * caller's assets.
172
- * @return {[]} - Empty tuple.
173
- */
174
- export circuit setApprovalForAll(operator: Either<ZswapCoinPublicKey, ContractAddress>, approved: Boolean): [] {
175
- Initializable_assertInitialized();
176
-
177
- // TODO: Contract-to-contract calls not yet supported.
178
- const caller = left<ZswapCoinPublicKey, ContractAddress>(ownPublicKey());
179
- _setApprovalForAll(caller, operator, approved);
180
- }
181
-
182
- /**
183
- * @description Queries if `operator` is an authorized operator for `owner`.
184
- *
185
- * @circuitInfo k=10, rows=619
186
- *
187
- * Requirements:
188
- *
189
- * - Contract is initialized.
190
- *
191
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} account - The queried possessor of assets.
192
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} operator - The queried handler of `account`'s assets.
193
- * @return {Boolean} - Whether or not `operator` has permission to handle `account`'s assets.
194
- */
195
- export circuit isApprovedForAll(
196
- account: Either<ZswapCoinPublicKey, ContractAddress>,
197
- operator: Either<ZswapCoinPublicKey, ContractAddress>
198
- ): Boolean {
199
- Initializable_assertInitialized();
200
-
201
- if (!_operatorApprovals.member(disclose(account)) || !_operatorApprovals.lookup(account).member(disclose(operator))) {
202
- return false;
203
- }
204
-
205
- return _operatorApprovals.lookup(account).lookup(disclose(operator));
206
- }
207
-
208
- /**
209
- * @description Transfers ownership of `value` amount of `id` tokens from `from` to `to`.
210
- * The caller must be `from` or approved to transfer on their behalf.
211
- *
212
- * @circuitInfo k=11, rows=1882
213
- *
214
- * @notice Transfers to contract addresses are currently disallowed until contract-to-contract
215
- * interactions are supported in Compact. This restriction prevents assets from
216
- * being inadvertently locked in contracts that cannot currently handle token receipt.
217
- *
218
- * @extensibility External circuit. Can be used directly by consumers of this module.
219
- * See **Extensibility** documentation for usage patterns.
220
- *
221
- * Requirements:
222
- *
223
- * - Contract is initialized.
224
- * - `to` is not a ContractAddress.
225
- * - `to` is not the zero address.
226
- * - `from` is not the zero address.
227
- * - Caller must be `from` or approved via `setApprovalForAll`.
228
- * - `from` must have an `id` balance of at least `value`.
229
- *
230
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} from - The owner from which the transfer originates.
231
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} to - The recipient of the transferred assets.
232
- * @param {Uint<128>} id - The unique identifier of the asset type.
233
- * @param {Uint<128>} value - The quantity of `id` tokens to transfer.
234
- * @return {[]} - Empty tuple.
235
- */
236
- export circuit transferFrom(
237
- from: Either<ZswapCoinPublicKey, ContractAddress>,
238
- to: Either<ZswapCoinPublicKey, ContractAddress>,
239
- id: Uint<128>,
240
- value: Uint<128>
241
- ): [] {
242
- assert(!Utils_isContractAddress(to), "MultiToken: unsafe transfer");
243
- _unsafeTransferFrom(from, to, id, value);
244
- }
245
-
246
- /**
247
- * @description Transfers ownership of `value` amount of `id` tokens from `from` to `to`.
248
- * Does not impose restrictions on the caller, making it suitable for composition
249
- * in higher-level contract logic.
250
- *
251
- * @circuitInfo k=11, rows=1487
252
- *
253
- * @notice Transfers to contract addresses are currently disallowed until contract-to-contract
254
- * interactions are supported in Compact. This restriction prevents assets from
255
- * being inadvertently locked in contracts that cannot currently handle token receipt.
256
- *
257
- * Requirements:
258
- *
259
- * - Contract is initialized.
260
- * - `to` is not a ContractAddress.
261
- * - `to` is not the zero address.
262
- * - `from` is not the zero address.
263
- * - `from` must have an `id` balance of at least `value`.
264
- *
265
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} from - The owner from which the transfer originates.
266
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} to - The recipient of the transferred assets.
267
- * @param {Uint<128>} id - The unique identifier of the asset type.
268
- * @param {Uint<128>} value - The quantity of `id` tokens to transfer.
269
- * @return {[]} - Empty tuple.
270
- */
271
- export circuit _transfer(
272
- from: Either<ZswapCoinPublicKey, ContractAddress>,
273
- to: Either<ZswapCoinPublicKey, ContractAddress>,
274
- id: Uint<128>,
275
- value: Uint<128>
276
- ): [] {
277
- assert(!Utils_isContractAddress(to), "MultiToken: unsafe transfer");
278
- _unsafeTransfer(from, to, id, value);
279
- }
280
-
281
- /**
282
- * @description Transfers a value amount of tokens of type id from from to to.
283
- * This circuit will mint (or burn) if `from` (or `to`) is the zero address.
284
- *
285
- * @circuitInfo k=11, rows=1482
286
- *
287
- * Requirements:
288
- *
289
- * - Contract is initialized.
290
- * - If `from` is not zero, the balance of `id` of `from` must be >= `value`.
291
- *
292
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} from - The origin of the transfer.
293
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} to - The destination of the transfer.
294
- * @param {Uint<128>} id - The unique identifier of the asset type.
295
- * @param {Uint<128>} value - The quantity of `id` tokens to transfer.
296
- * @return {[]} - Empty tuple.
297
- */
298
- circuit _update(
299
- from: Either<ZswapCoinPublicKey, ContractAddress>,
300
- to: Either<ZswapCoinPublicKey, ContractAddress>,
301
- id: Uint<128>,
302
- value: Uint<128>
303
- ): [] {
304
- Initializable_assertInitialized();
305
-
306
- if (!Utils_isKeyOrAddressZero(disclose(from))) {
307
- const fromBalance = balanceOf(from, id);
308
- assert(fromBalance >= value, "MultiToken: insufficient balance");
309
- // overflow not possible
310
- const newBalance = fromBalance - value;
311
- _balances.lookup(id).insert(disclose(from), disclose(newBalance));
312
- }
313
-
314
- if (!Utils_isKeyOrAddressZero(disclose(to))) {
315
- // id not initialized
316
- if (!_balances.member(disclose(id))) {
317
- _balances.insert(disclose(id), default<Map<Either<ZswapCoinPublicKey, ContractAddress>, Uint<128>>>);
318
- _balances.lookup(id).insert(disclose(to), disclose(value as Uint<128>));
319
- } else {
320
- const toBalance = balanceOf(to, id);
321
- // TODO: Replace with Max_Uint128()
322
- const MAX_UINT128 = 340282366920938463463374607431768211455;
323
- assert(MAX_UINT128 - toBalance >= value, "MultiToken: arithmetic overflow");
324
- _balances.lookup(id).insert(disclose(to), disclose(toBalance + value as Uint<128>));
325
- }
326
- }
327
- }
328
-
329
- /**
330
- * @description Unsafe variant of `transferFrom` which allows transfers to contract addresses.
331
- * The caller must be `from` or approved to transfer on their behalf.
332
- *
333
- * @circuitInfo k=11, rows=1881
334
- *
335
- * @warning Transfers to contract addresses are considered unsafe because contract-to-contract
336
- * calls are not currently supported. Tokens sent to a contract address may become irretrievable.
337
- * Once contract-to-contract calls are supported, this circuit may be deprecated.
338
- *
339
- * Requirements:
340
- *
341
- * - Contract is initialized.
342
- * - `to` is not the zero address.
343
- * - `from` is not the zero address.
344
- * - Caller must be `from` or approved via `setApprovalForAll`.
345
- * - `from` must have an `id` balance of at least `value`.
346
- *
347
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} from - The owner from which the transfer originates.
348
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} to - The recipient of the transferred assets.
349
- * @param {Uint<128>} id - The unique identifier of the asset type.
350
- * @param {Uint<128>} value - The quantity of `id` tokens to transfer.
351
- * @return {[]} - Empty tuple.
352
- */
353
- export circuit _unsafeTransferFrom(
354
- from: Either<ZswapCoinPublicKey, ContractAddress>,
355
- to: Either<ZswapCoinPublicKey, ContractAddress>,
356
- id: Uint<128>,
357
- value: Uint<128>
358
- ): [] {
359
- Initializable_assertInitialized();
360
-
361
- // TODO: Contract-to-contract calls not yet supported.
362
- // Once available, handle ContractAddress recipients here.
363
- const caller = left<ZswapCoinPublicKey, ContractAddress>(ownPublicKey());
364
- if (disclose(from) != caller) {
365
- assert(isApprovedForAll(from, caller), "MultiToken: unauthorized operator");
366
- }
367
-
368
- _unsafeTransfer(from, to, id, value);
369
- }
370
-
371
- /**
372
- * @description Unsafe variant of `_transfer` which allows transfers to contract addresses.
373
- * Does not impose restrictions on the caller, making it suitable as a low-level
374
- * building block for advanced contract logic.
375
- *
376
- * @circuitInfo k=11, rows=1486
377
- *
378
- * @warning Transfers to contract addresses are considered unsafe because contract-to-contract
379
- * calls are not currently supported. Tokens sent to a contract address may become irretrievable.
380
- * Once contract-to-contract calls are supported, this circuit may be deprecated.
381
- *
382
- * Requirements:
383
- *
384
- * - Contract is initialized.
385
- * - `from` is not the zero address.
386
- * - `to` is not the zero address.
387
- * - `from` must have an `id` balance of at least `value`.
388
- *
389
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} from - The owner from which the transfer originates.
390
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} to - The recipient of the transferred assets.
391
- * @param {Uint<128>} id - The unique identifier of the asset type.
392
- * @param {Uint<128>} value - The quantity of `id` tokens to transfer.
393
- * @return {[]} - Empty tuple.
394
- */
395
- export circuit _unsafeTransfer(
396
- from: Either<ZswapCoinPublicKey, ContractAddress>,
397
- to: Either<ZswapCoinPublicKey, ContractAddress>,
398
- id: Uint<128>,
399
- value: Uint<128>
400
- ): [] {
401
- Initializable_assertInitialized();
402
-
403
- assert(!Utils_isKeyOrAddressZero(from), "MultiToken: invalid sender");
404
- assert(!Utils_isKeyOrAddressZero(to), "MultiToken: invalid receiver");
405
- _update(from, to, id, value);
406
- }
407
-
408
- /**
409
- * @description Sets a new URI for all token types, by relying on the token type ID
410
- * substitution mechanism defined in the MultiToken standard.
411
- * See https://eips.ethereum.org/EIPS/eip-1155#metadata.
412
- *
413
- * @circuitInfo k=10, rows=39
414
- *
415
- * @notice By this mechanism, any occurrence of the `\{id\}` substring in either the
416
- * URI or any of the values in the JSON file at said URI will be replaced by
417
- * clients with the token type ID.
418
- *
419
- * For example, the `https://token-cdn-domain/\{id\}.json` URI would be
420
- * interpreted by clients as
421
- * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
422
- * for token type ID 0x4cce0.
423
- *
424
- * Requirements:
425
- *
426
- * - Contract is initialized.
427
- *
428
- * @param {Opaque<"string">} newURI - The new base URI for all tokens.
429
- * @return {[]} - Empty tuple.
430
- */
431
- export circuit _setURI(newURI: Opaque<"string">): [] {
432
- Initializable_assertInitialized();
433
-
434
- _uri = disclose(newURI);
435
- }
436
-
437
- /**
438
- * @description Creates a `value` amount of tokens of type `token_id`, and assigns them to `to`.
439
- *
440
- * @circuitInfo k=10, rows=912
441
- *
442
- * @notice Transfers to contract addresses are currently disallowed until contract-to-contract
443
- * interactions are supported in Compact. This restriction prevents assets from
444
- * being inadvertently locked in contracts that cannot currently handle token receipt.
445
- *
446
- * Requirements:
447
- *
448
- * - Contract is initialized.
449
- * - `to` is not the zero address.
450
- * - `to` is not a ContractAddress.
451
- *
452
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} to - The recipient of the minted tokens.
453
- * @param {Uint<128>} id - The unique identifier for the token type.
454
- * @param {Uint<128>} value - The quantity of `id` tokens that are minted to `to`.
455
- * @return {[]} - Empty tuple.
456
- */
457
- export circuit _mint(to: Either<ZswapCoinPublicKey, ContractAddress>, id: Uint<128>, value: Uint<128>): [] {
458
- assert(!Utils_isContractAddress(to), "MultiToken: unsafe transfer");
459
- _unsafeMint(to, id, value);
460
- }
461
-
462
- /**
463
- * @description Unsafe variant of `_mint` which allows transfers to contract addresses.
464
- *
465
- * @circuitInfo k=10, rows=911
466
- *
467
- * @warning Transfers to contract addresses are considered unsafe because contract-to-contract
468
- * calls are not currently supported. Tokens sent to a contract address may become irretrievable.
469
- * Once contract-to-contract calls are supported, this circuit may be deprecated.
470
- *
471
- * Requirements:
472
- *
473
- * - Contract is initialized.
474
- * - `to` is not the zero address.
475
- *
476
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} to - The recipient of the minted tokens.
477
- * @param {Uint<128>} id - The unique identifier for the token type.
478
- * @param {Uint<128>} value - The quantity of `id` tokens that are minted to `to`.
479
- * @return {[]} - Empty tuple.
480
- */
481
- export circuit _unsafeMint(to: Either<ZswapCoinPublicKey, ContractAddress>, id: Uint<128>, value: Uint<128>): [] {
482
- Initializable_assertInitialized();
483
-
484
- assert(!Utils_isKeyOrAddressZero(to), "MultiToken: invalid receiver");
485
- _update(burnAddress(), to, id, value);
486
- }
487
-
488
- /**
489
- * @description Destroys a `value` amount of tokens of type `token_id` from `from`.
490
- *
491
- * @circuitInfo k=10, rows=688
492
- *
493
- * Requirements:
494
- *
495
- * - Contract is initialized.
496
- * - `from` is not the zero address.
497
- * - `from` must have an `id` balance of at least `value`.
498
- *
499
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} from - The owner whose tokens will be destroyed.
500
- * @param {Uint<128>} id - The unique identifier of the token type.
501
- * @param {Uint<128>} value - The quantity of `id` tokens that will be destroyed from `from`.
502
- * @return {[]} - Empty tuple.
503
- */
504
- export circuit _burn(from: Either<ZswapCoinPublicKey, ContractAddress>, id: Uint<128>, value: Uint<128>): [] {
505
- Initializable_assertInitialized();
506
-
507
- assert(!Utils_isKeyOrAddressZero(from), "MultiToken: invalid sender");
508
- _update(from, burnAddress(), id, value);
509
- }
510
-
511
- /**
512
- * @description Enables or disables approval for `operator` to manage all of the caller's assets.
513
- *
514
- * @circuitInfo k=10, rows=518
515
- *
516
- * @notice This circuit does not check for access permissions but can be useful as a building block
517
- * for more complex contract logic.
518
- *
519
- * Requirements:
520
- *
521
- * - Contract is initialized.
522
- * - `operator` is not the zero address.
523
- *
524
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} owner - The ZswapCoinPublicKey or ContractAddress of the target owner.
525
- * @param {Either<ZswapCoinPublicKey, ContractAddress>} operator - The ZswapCoinPublicKey or ContractAddress whose approval is set for the
526
- * `owner`'s assets.
527
- * @param {Boolean} approved - The boolean value determining if the operator may or may not handle the
528
- * `owner`'s assets.
529
- * @return {[]} - Empty tuple.
530
- */
531
- export circuit _setApprovalForAll(
532
- owner: Either<ZswapCoinPublicKey, ContractAddress>,
533
- operator: Either<ZswapCoinPublicKey, ContractAddress>,
534
- approved: Boolean
535
- ): [] {
536
- Initializable_assertInitialized();
537
-
538
- assert(!Utils_isKeyOrAddressZero(operator), "MultiToken: invalid operator");
539
- if (!_operatorApprovals.member(disclose(owner))) {
540
- _operatorApprovals.insert(disclose(owner), default<Map<Either<ZswapCoinPublicKey, ContractAddress>, Boolean>>);
541
- }
542
-
543
- _operatorApprovals.lookup(owner).insert(disclose(operator), disclose(approved));
544
- }
545
- }