@openzeppelin/compact-contracts 0.3.0-rc.1 → 0.4.0-alpha.2

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 (46) hide show
  1. package/README.md +14 -4
  2. package/access/AccessControl.compact +14 -14
  3. package/access/Ownable.compact +16 -10
  4. package/access/ShieldedAccessControl.compact +26 -2
  5. package/access/ZOwnablePK.compact +9 -9
  6. package/crypto/EcdhMask.compact +5 -5
  7. package/crypto/Ecdsa.compact +111 -0
  8. package/crypto/Eip712.compact +168 -0
  9. package/crypto/ElGamal.compact +33 -107
  10. package/multisig/EcdsaSignerManager.compact +246 -0
  11. package/multisig/ForwarderPrivate.compact +12 -6
  12. package/multisig/ForwarderShielded.compact +3 -3
  13. package/multisig/ForwarderUnshielded.compact +3 -3
  14. package/multisig/ProposalManager.compact +195 -23
  15. package/multisig/ShieldedTreasury.compact +29 -2
  16. package/multisig/ShieldedTreasuryStateless.compact +2 -2
  17. package/multisig/Signer.compact +28 -80
  18. package/multisig/UnshieldedTreasury.compact +10 -2
  19. package/multisig/{presets/forwarder/ForwarderPrivate.compact → examples/ForwarderPrivateExample.compact} +4 -4
  20. package/multisig/{presets/forwarder/ForwarderShielded.compact → examples/ForwarderShieldedExample.compact} +4 -4
  21. package/multisig/{presets/forwarder/ForwarderUnshielded.compact → examples/ForwarderUnshieldedExample.compact} +4 -4
  22. package/multisig/examples/NativeShieldedTokenIssuerExample.compact +143 -0
  23. package/multisig/examples/ShieldedMultiSigV2Example.compact +77 -0
  24. package/multisig/presets/NativeShieldedTokenIssuer.compact +542 -0
  25. package/multisig/presets/ShieldedMultiSigV2.compact +267 -259
  26. package/package.json +31 -25
  27. package/security/Allowlist.compact +6 -6
  28. package/security/Blocklist.compact +6 -6
  29. package/security/Initializable.compact +9 -5
  30. package/security/Pausable.compact +11 -7
  31. package/token/ConfidentialFungibleToken.compact +143 -270
  32. package/token/FungibleToken.compact +36 -22
  33. package/token/MultiToken.compact +16 -16
  34. package/token/NativeShieldedToken.compact +17 -66
  35. package/token/NativeShieldedTokenCore.compact +26 -48
  36. package/token/NativeShieldedTokenFamily.compact +17 -67
  37. package/token/NonFungibleToken.compact +40 -79
  38. package/token/extensions/ConfidentialFungibleTokenPublicSupply.compact +12 -7
  39. package/token/extensions/NativeShieldedTokenDerivedNonce.compact +3 -3
  40. package/token/extensions/NativeShieldedTokenFamilyPublicSupply.compact +8 -8
  41. package/token/extensions/NativeShieldedTokenPublicSupply.compact +8 -8
  42. package/token/extensions/NativeShieldedTokenPublicSupplyCore.compact +6 -6
  43. package/utils/EvmAbi.compact +134 -0
  44. package/utils/Utils.compact +2 -12
  45. package/multisig/presets/ShieldedMultiSig.compact +0 -227
  46. package/multisig/presets/ShieldedMultiSigV3.compact +0 -368
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-rc.1 (token/NonFungibleToken.compact)
2
+ // OpenZeppelin Compact Contracts v0.4.0-alpha.2 (token/NonFungibleToken.compact)
3
3
 
4
- pragma language_version >= 0.23.0;
4
+ pragma language_version >= 0.26.0;
5
5
 
6
6
  /**
7
7
  * @module NonFungibleToken
@@ -58,7 +58,7 @@ pragma language_version >= 0.23.0;
58
58
  * or in ledger writes. Canonicalization zeroes out the inactive branch of the Either,
59
59
  * ensuring that two values with the same active branch always resolve to the same map key
60
60
  * regardless of what data the inactive branch carries. Write paths are canonicalized in
61
- * `_update` (for `_owners` and `_balances`), `_unsafeApprove` (for `_tokenApprovals`), and
61
+ * `_update` (for `_owners` and `_balances`), `_approve` (for `_tokenApprovals`), and
62
62
  * `_setApprovalForAll` (for `_operatorApprovals`). Read paths are canonicalized in
63
63
  * `balanceOf`, `isApprovedForAll`, and `_isAuthorized`.
64
64
  *
@@ -85,8 +85,13 @@ module NonFungibleToken {
85
85
  import CompactStandardLibrary;
86
86
  import "../utils/Utils" prefix Utils_;
87
87
 
88
- /// Public state
88
+ /**
89
+ * @description The token's human-readable name, set once at construction.
90
+ */
89
91
  export sealed ledger _name: Opaque<"string">;
92
+ /**
93
+ * @description The token's ticker symbol, set once at construction.
94
+ */
90
95
  export sealed ledger _symbol: Opaque<"string">;
91
96
 
92
97
  /**
@@ -160,7 +165,7 @@ module NonFungibleToken {
160
165
  * This MUST be called in the implementing contract's constructor.
161
166
  * Failure to do so can lead to an irreparable contract.
162
167
  *
163
- * @circuitInfo k=6, rows=52
168
+ * @constraints k=6, rows=52
164
169
  *
165
170
  * Requirements:
166
171
  *
@@ -206,7 +211,7 @@ module NonFungibleToken {
206
211
  /**
207
212
  * @description Returns the number of tokens in `owner`'s account.
208
213
  *
209
- * @circuitInfo k=10, rows=673
214
+ * @constraints k=10, rows=671
210
215
  *
211
216
  * Requirements:
212
217
  *
@@ -229,7 +234,7 @@ module NonFungibleToken {
229
234
  /**
230
235
  * @description Returns the owner of the `tokenId` token.
231
236
  *
232
- * @circuitInfo k=9, rows=333
237
+ * @constraints k=9, rows=331
233
238
  *
234
239
  * Requirements:
235
240
  *
@@ -247,7 +252,7 @@ module NonFungibleToken {
247
252
  /**
248
253
  * @description Returns the token name.
249
254
  *
250
- * @circuitInfo k=6, rows=28
255
+ * @constraints k=6, rows=26
251
256
  *
252
257
  * Requirements:
253
258
  *
@@ -263,7 +268,7 @@ module NonFungibleToken {
263
268
  /**
264
269
  * @description Returns the symbol of the token.
265
270
  *
266
- * @circuitInfo k=6, rows=28
271
+ * @constraints k=6, rows=26
267
272
  *
268
273
  * Requirements:
269
274
  *
@@ -280,7 +285,7 @@ module NonFungibleToken {
280
285
  * @description Returns the token URI for the given `tokenId`. Returns the empty
281
286
  * string if a tokenURI does not exist.
282
287
  *
283
- * @circuitInfo k=9, rows=326
288
+ * @constraints k=9, rows=324
284
289
  *
285
290
  * Requirements:
286
291
  *
@@ -309,7 +314,7 @@ module NonFungibleToken {
309
314
  /**
310
315
  * @description Sets the URI as `tokenURI` for the given `tokenId`.
311
316
  *
312
- * @circuitInfo k=9, rows=289
317
+ * @constraints k=9, rows=287
313
318
  *
314
319
  * Requirements:
315
320
  *
@@ -338,7 +343,7 @@ module NonFungibleToken {
338
343
  * In the case of an external (non-contract) caller, the caller's identity is derived from the `wit_NonFungibleTokenSK`
339
344
  * witness as `persistentHash(secretKey)`.
340
345
  *
341
- * @circuitInfo k=13, rows=3415
346
+ * @constraints k=13, rows=3491
342
347
  *
343
348
  * Requirements:
344
349
  *
@@ -359,7 +364,7 @@ module NonFungibleToken {
359
364
  /**
360
365
  * @description Returns the account approved for `tokenId` token.
361
366
  *
362
- * @circuitInfo k=9, rows=422
367
+ * @constraints k=9, rows=420
363
368
  *
364
369
  * Requirements:
365
370
  *
@@ -383,7 +388,7 @@ module NonFungibleToken {
383
388
  * In the case of an external (non-contract) caller, the caller's identity is derived from the `wit_NonFungibleTokenSK`
384
389
  * witness as `persistentHash(secretKey)`.
385
390
  *
386
- * @circuitInfo k=13, rows=2947
391
+ * @constraints k=13, rows=2938
387
392
  *
388
393
  * Requirements:
389
394
  *
@@ -406,7 +411,7 @@ module NonFungibleToken {
406
411
  /**
407
412
  * @description Returns if the `operator` is allowed to manage all of the assets of `owner`.
408
413
  *
409
- * @circuitInfo k=11, rows=1343
414
+ * @constraints k=11, rows=1341
410
415
  *
411
416
  * Requirements:
412
417
  *
@@ -439,7 +444,7 @@ module NonFungibleToken {
439
444
  * In the case of an external (non-contract) caller, the caller's identity is derived from the `wit_NonFungibleTokenSK`
440
445
  * witness as `persistentHash(secretKey)`.
441
446
  *
442
- * @circuitInfo k=13, rows=4739
447
+ * @constraints k=13, rows=4701
443
448
  *
444
449
  * Requirements:
445
450
  *
@@ -477,7 +482,7 @@ module NonFungibleToken {
477
482
  * are not currently supported. Tokens sent to a contract address may become irretrievable.
478
483
  * Once contract-to-contract calls are supported, this circuit may be deprecated.
479
484
  *
480
- * @circuitInfo k=13, rows=4736
485
+ * @constraints k=13, rows=4698
481
486
  *
482
487
  * Requirements:
483
488
  *
@@ -499,14 +504,11 @@ module NonFungibleToken {
499
504
  ): [] {
500
505
  assertInitialized();
501
506
  assert(!Utils_isTargetZero(to), "NonFungibleToken: invalid receiver");
507
+ // Setting an "auth" argument enables the `_isAuthorized` check which verifies that the token exists
508
+ // (fromAddress != 0). Therefore, it is not needed to verify that the return value is not 0 here.
502
509
  const auth = left<Bytes<32>, ContractAddress>(_computeAccountId());
503
510
  const previousOwner = _update(to, tokenId, auth);
504
511
 
505
- // The `_isAuthorized` check inside `_update` already implies the token exists, but that
506
- // holds only while approvals are never recorded for unminted tokens. Assert it directly
507
- // so a misused `_unsafeApprove` cannot turn this circuit into an unauthorized mint.
508
- assert(!Utils_isTargetZero(previousOwner), "NonFungibleToken: nonexistent token");
509
-
510
512
  const canonFrom = Utils_canonicalize<Bytes<32>, ContractAddress>(fromAddress);
511
513
  assert(previousOwner == canonFrom, "NonFungibleToken: incorrect owner");
512
514
  }
@@ -514,7 +516,7 @@ module NonFungibleToken {
514
516
  /**
515
517
  * @description Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist.
516
518
  *
517
- * @circuitInfo k=9, rows=308
519
+ * @constraints k=9, rows=306
518
520
  *
519
521
  * Requirements:
520
522
  *
@@ -535,7 +537,7 @@ module NonFungibleToken {
535
537
  /**
536
538
  * @description Returns the approved address for `tokenId`. Returns the zero value if `tokenId` is not minted.
537
539
  *
538
- * @circuitInfo k=9, rows=308
540
+ * @constraints k=9, rows=306
539
541
  *
540
542
  * Requirements:
541
543
  *
@@ -556,7 +558,7 @@ module NonFungibleToken {
556
558
  * @description Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in
557
559
  * particular (ignoring whether it is owned by `owner`).
558
560
  *
559
- * @circuitInfo k=11, rows=1798
561
+ * @constraints k=11, rows=1796
560
562
  *
561
563
  * Requirements:
562
564
  *
@@ -588,7 +590,7 @@ module NonFungibleToken {
588
590
  /**
589
591
  * @description Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner.
590
592
  *
591
- * @circuitInfo k=11, rows=1804
593
+ * @constraints k=11, rows=1802
592
594
  *
593
595
  * Requirements:
594
596
  *
@@ -646,8 +648,8 @@ module NonFungibleToken {
646
648
 
647
649
  // Execute the update
648
650
  if (!Utils_isTargetZero(disclose(fromAddress))) {
649
- // Clear approval. No need to re-authorize or re-read the owner
650
- _unsafeApprove(Utils_zeroAccount(), tokenId, Utils_zeroAccount(), false);
651
+ // Clear approval. No need to re-authorize
652
+ _approve(Utils_zeroAccount(), tokenId, Utils_zeroAccount());
651
653
  const canonFrom = Utils_canonicalize<Bytes<32>, ContractAddress>(fromAddress);
652
654
  const newBalance = _balances.lookup(disclose(canonFrom)) - 1 as Uint<128>;
653
655
  _balances.insert(disclose(canonFrom), disclose(newBalance));
@@ -669,7 +671,7 @@ module NonFungibleToken {
669
671
  /**
670
672
  * @description Mints `tokenId` and transfers it to `to`.
671
673
  *
672
- * @circuitInfo k=11, rows=1411
674
+ * @constraints k=11, rows=1388
673
675
  *
674
676
  * Requirements:
675
677
  *
@@ -693,7 +695,7 @@ module NonFungibleToken {
693
695
  /**
694
696
  * @description Mints `tokenId` and transfers it to `to`. It does NOT check if the recipient is a ContractAddress.
695
697
  *
696
- * @circuitInfo k=11, rows=1408
698
+ * @constraints k=11, rows=1385
697
699
  *
698
700
  * Requirements:
699
701
  *
@@ -726,7 +728,7 @@ module NonFungibleToken {
726
728
  * The approval is cleared when the token is burned.
727
729
  * This circuit does not check if the sender is authorized to operate on the token.
728
730
  *
729
- * @circuitInfo k=10, rows=512
731
+ * @constraints k=10, rows=507
730
732
  *
731
733
  * Requirements:
732
734
  *
@@ -751,7 +753,7 @@ module NonFungibleToken {
751
753
  * interactions are supported in Compact. This restriction prevents assets from being inadvertently
752
754
  * locked in contracts that cannot currently handle token receipt.
753
755
  *
754
- * @circuitInfo k=11, rows=2005
756
+ * @constraints k=11, rows=1982
755
757
  *
756
758
  * Requirements:
757
759
  *
@@ -782,7 +784,7 @@ module NonFungibleToken {
782
784
  * As opposed to {_unsafeTransferFrom}, this imposes no restrictions on the caller's identity.
783
785
  * It does NOT check if the recipient is a ContractAddress.
784
786
  *
785
- * @circuitInfo k=11, rows=2002
787
+ * @constraints k=11, rows=1979
786
788
  *
787
789
  * Requirements:
788
790
  *
@@ -818,12 +820,11 @@ module NonFungibleToken {
818
820
  /**
819
821
  * @description Approve `to` to operate on `tokenId`.
820
822
  *
821
- * @circuitInfo k=11, rows=1757
823
+ * @constraints k=11, rows=1840
822
824
  *
823
825
  * Requirements:
824
826
  *
825
827
  * - The contract is initialized.
826
- * - `tokenId` must exist.
827
828
  * - If `auth` is non 0, then this function will check that `auth` is either the owner of the token,
828
829
  * or approved to operate on the token (by the owner).
829
830
  *
@@ -837,43 +838,6 @@ module NonFungibleToken {
837
838
  tokenId: Uint<128>,
838
839
  auth: Either<Bytes<32>, ContractAddress>
839
840
  ): [] {
840
- _unsafeApprove(to, tokenId, auth, true);
841
- }
842
-
843
- /**
844
- * @description Approve `to` to operate on `tokenId`, requiring the token to exist
845
- * only when `isExistenceRequired` is true.
846
- *
847
- * @circuitInfo k=11, rows=1870
848
- *
849
- * @warning Passing false skips the check that `tokenId` was minted. Both
850
- * `_unsafeTransferFrom` and `_update` read that invariant back, so a planted approval
851
- * can mint a token nobody authorized or outlive a later mint. Pass false only where
852
- * the owner has already been read, as `_update` does.
853
- *
854
- * @dev Counterpart to Solidity's `_approve(to, tokenId, auth, bool emitEvent)`, where
855
- * the flag also suppresses the `Approval` event. Compact has no events, so it carries
856
- * the existence check alone.
857
- *
858
- * Requirements:
859
- *
860
- * - The contract is initialized.
861
- * - `tokenId` must exist, unless `isExistenceRequired` is false and `auth` is zero.
862
- * - If `auth` is non 0, then this function will check that `auth` is either the owner of the token,
863
- * or approved to operate on the token (by the owner).
864
- *
865
- * @param {Either<Bytes<32>, ContractAddress>} to - The target account to approve
866
- * @param {Uint<128>} tokenId - The token to approve
867
- * @param {Either<Bytes<32>, ContractAddress>} auth - An account authorized to operate on all tokens held by the owner of the token
868
- * @param {Boolean} isExistenceRequired - Whether `tokenId` must exist
869
- * @return {[]} - Empty tuple.
870
- */
871
- export circuit _unsafeApprove(
872
- to: Either<Bytes<32>, ContractAddress>,
873
- tokenId: Uint<128>,
874
- auth: Either<Bytes<32>, ContractAddress>,
875
- isExistenceRequired: Boolean
876
- ): [] {
877
841
  assertInitialized();
878
842
  // Canonicalize + normalize `to`
879
843
  const canonTo = Utils_canonicalize<Bytes<32>, ContractAddress>(to);
@@ -882,14 +846,11 @@ module NonFungibleToken {
882
846
  // Canonicalize auth
883
847
  const canonAuth = Utils_canonicalize<Bytes<32>, ContractAddress>(auth);
884
848
 
885
- // Avoid reading the owner unless necessary
886
- if (disclose(isExistenceRequired) || !Utils_isTargetZero(disclose(canonAuth))) {
849
+ if (!Utils_isTargetZero(disclose(canonAuth))) {
887
850
  const owner = _requireOwned(tokenId);
888
851
 
889
852
  // We do not use _isAuthorized because single-token approvals should not be able to call approve
890
- assert((Utils_isTargetZero(disclose(canonAuth)) ||
891
- owner == disclose(canonAuth) ||
892
- isApprovedForAll(owner, canonAuth)),
853
+ assert((owner == disclose(canonAuth) || isApprovedForAll(owner, canonAuth)),
893
854
  "NonFungibleToken: invalid approver"
894
855
  );
895
856
  }
@@ -900,7 +861,7 @@ module NonFungibleToken {
900
861
  /**
901
862
  * @description Approve `operator` to operate on all of `owner` tokens.
902
863
  *
903
- * @circuitInfo k=11, rows=1282
864
+ * @constraints k=11, rows=1280
904
865
  *
905
866
  * Requirements:
906
867
  *
@@ -939,7 +900,7 @@ module NonFungibleToken {
939
900
  * @description Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned).
940
901
  * Returns the owner.
941
902
  *
942
- * @circuitInfo k=9, rows=331
903
+ * @constraints k=9, rows=329
943
904
  *
944
905
  * Requirements:
945
906
  *
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-rc.1 (token/extensions/ConfidentialFungibleTokenPublicSupply.compact)
2
+ // OpenZeppelin Compact Contracts v0.4.0-alpha.2 (token/extensions/ConfidentialFungibleTokenPublicSupply.compact)
3
3
 
4
- pragma language_version >= 0.23.0;
4
+ pragma language_version >= 0.26.0;
5
5
 
6
6
  /**
7
7
  * @module ConfidentialFungibleTokenPublicSupply
@@ -33,15 +33,20 @@ pragma language_version >= 0.23.0;
33
33
  module ConfidentialFungibleTokenPublicSupply {
34
34
  import CompactStandardLibrary;
35
35
 
36
- // The public circulating supply. Mint and burn disclose their amounts
37
- // through the delta on this value.
36
+ /**
37
+ * @description Total tokens in circulation, tracked in the clear even though
38
+ * balances are encrypted. Raised by `_addSupply` and lowered by `_subSupply`,
39
+ * each rejecting over/underflow.
40
+ *
41
+ * @warning Mint and burn disclose their amounts through the delta on this value
42
+ */
38
43
  export ledger _totalSupply: Uint<128>;
39
44
 
40
45
  /**
41
46
  * @description Increases `totalSupply` by `value`. Call alongside the token
42
47
  * module's `_mint`. The added amount is disclosed via the supply delta.
43
48
  *
44
- * @circuitInfo k=9, rows=401
49
+ * @constraints k=9, rows=399
45
50
  *
46
51
  * Requirements:
47
52
  *
@@ -62,7 +67,7 @@ module ConfidentialFungibleTokenPublicSupply {
62
67
  * module's `_burn` or `_burnFrom`. The removed amount is disclosed via the
63
68
  * supply delta.
64
69
  *
65
- * @circuitInfo k=9, rows=256
70
+ * @constraints k=9, rows=254
66
71
  *
67
72
  * Requirements:
68
73
  *
@@ -80,7 +85,7 @@ module ConfidentialFungibleTokenPublicSupply {
80
85
  /**
81
86
  * @description Returns the public total token supply.
82
87
  *
83
- * @circuitInfo k=6, rows=26
88
+ * @constraints k=6, rows=24
84
89
  *
85
90
  * @return {Uint<128>} - The total supply.
86
91
  */
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
- // OpenZeppelin Compact Contracts v0.3.0-rc.1 (token/extensions/NativeShieldedTokenDerivedNonce.compact)
2
+ // OpenZeppelin Compact Contracts v0.4.0-alpha.2 (token/extensions/NativeShieldedTokenDerivedNonce.compact)
3
3
 
4
- pragma language_version >= 0.23.0;
4
+ pragma language_version >= 0.26.0;
5
5
 
6
6
  /**
7
7
  * @module NativeShieldedTokenDerivedNonce
@@ -59,7 +59,7 @@ module NativeShieldedTokenDerivedNonce {
59
59
  * @notice The derivation input is public ledger state, so mints using this
60
60
  * nonce are recipient-public; see the module notes.
61
61
  *
62
- * @circuitInfo k=9, rows=451
62
+ * @constraints k=9, rows=447
63
63
  *
64
64
  * @return {Bytes<32>} - The next derived coin nonce.
65
65
  */
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // OpenZeppelin Compact Contracts v0.2.0 (token/extensions/NativeShieldedTokenFamilyPublicSupply.compact)
3
3
 
4
- pragma language_version >= 0.23.0;
4
+ pragma language_version >= 0.26.0;
5
5
 
6
6
  /**
7
7
  * @module NativeShieldedTokenFamilyPublicSupply
@@ -20,7 +20,7 @@ pragma language_version >= 0.23.0;
20
20
  *
21
21
  * export circuit mint(
22
22
  * domain: Bytes<32>,
23
- * recipient: ZswapCoinPublicKey,
23
+ * recipient: Either<ZswapCoinPublicKey, ContractAddress>,
24
24
  * amount: Uint<64>,
25
25
  * nonce: Bytes<32>
26
26
  * ): ShieldedCoinInfo {
@@ -33,7 +33,7 @@ pragma language_version >= 0.23.0;
33
33
  * domain: Bytes<32>,
34
34
  * coin: ShieldedCoinInfo,
35
35
  * amount: Uint<128>,
36
- * refundTo: ZswapCoinPublicKey
36
+ * refundTo: Either<ZswapCoinPublicKey, ContractAddress>
37
37
  * ): Maybe<ShieldedCoinInfo> {
38
38
  * const refund = Family__burn(domain, coin, amount, refundTo);
39
39
  * Supply__addBurned(domain, amount);
@@ -76,7 +76,7 @@ module NativeShieldedTokenFamilyPublicSupply {
76
76
  * @description Adds `amount` to the exact minted total for `domain`. Call
77
77
  * once per successful `NativeShieldedTokenFamily._mint`.
78
78
  *
79
- * @circuitInfo k=10, rows=653
79
+ * @constraints k=10, rows=645
80
80
  *
81
81
  * @param {Bytes<32>} domain - 32-byte token discriminator.
82
82
  * @param {Uint<64>} amount - The minted amount.
@@ -93,7 +93,7 @@ module NativeShieldedTokenFamilyPublicSupply {
93
93
  * @dev Enforces per-domain `burned <= minted`; an unpaired, duplicate, or
94
94
  * wrong-domain burn reverts.
95
95
  *
96
- * @circuitInfo k=10, rows=755
96
+ * @constraints k=10, rows=747
97
97
  *
98
98
  * @param {Bytes<32>} domain - 32-byte token discriminator.
99
99
  * @param {Uint<128>} amount - The burned amount.
@@ -106,7 +106,7 @@ module NativeShieldedTokenFamilyPublicSupply {
106
106
  /**
107
107
  * @description Returns the exact amount ever minted for `domain`.
108
108
  *
109
- * @circuitInfo k=9, rows=344
109
+ * @constraints k=9, rows=342
110
110
  *
111
111
  * @param {Bytes<32>} domain - 32-byte token discriminator.
112
112
  * @return {Uint<128>} - The total amount minted.
@@ -120,7 +120,7 @@ module NativeShieldedTokenFamilyPublicSupply {
120
120
  * @notice This is a lower bound: coins sent directly to the burn address
121
121
  * without going through the contract are not counted.
122
122
  *
123
- * @circuitInfo k=9, rows=341
123
+ * @constraints k=9, rows=339
124
124
  *
125
125
  * @param {Bytes<32>} domain - 32-byte token discriminator.
126
126
  * @return {Uint<128>} - The total amount burned through the contract.
@@ -134,7 +134,7 @@ module NativeShieldedTokenFamilyPublicSupply {
134
134
  * @notice This is an UPPER BOUND on circulating supply, not an exact value:
135
135
  * burns that bypass the contract are invisible. See the module notes.
136
136
  *
137
- * @circuitInfo k=9, rows=439
137
+ * @constraints k=9, rows=437
138
138
  *
139
139
  * @param {Bytes<32>} domain - 32-byte token discriminator.
140
140
  * @return {Uint<128>} - The upper bound on tokens in existence.
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // OpenZeppelin Compact Contracts v0.2.0 (token/extensions/NativeShieldedTokenPublicSupply.compact)
3
3
 
4
- pragma language_version >= 0.23.0;
4
+ pragma language_version >= 0.26.0;
5
5
 
6
6
  /**
7
7
  * @module NativeShieldedTokenPublicSupply
@@ -18,7 +18,7 @@ pragma language_version >= 0.23.0;
18
18
  * pieces, calling the accounting block alongside the matching token op:
19
19
  *
20
20
  * export circuit mint(
21
- * recipient: ZswapCoinPublicKey,
21
+ * recipient: Either<ZswapCoinPublicKey, ContractAddress>,
22
22
  * amount: Uint<64>,
23
23
  * nonce: Bytes<32>
24
24
  * ): ShieldedCoinInfo {
@@ -30,7 +30,7 @@ pragma language_version >= 0.23.0;
30
30
  * export circuit burn(
31
31
  * coin: ShieldedCoinInfo,
32
32
  * amount: Uint<128>,
33
- * refundTo: ZswapCoinPublicKey
33
+ * refundTo: Either<ZswapCoinPublicKey, ContractAddress>
34
34
  * ): Maybe<ShieldedCoinInfo> {
35
35
  * const refund = Token__burn(coin, amount, refundTo);
36
36
  * Supply__addBurned(amount);
@@ -80,7 +80,7 @@ module NativeShieldedTokenPublicSupply {
80
80
  * @description Adds `amount` to the exact minted total. Call once per
81
81
  * successful `NativeShieldedToken._mint`.
82
82
  *
83
- * @circuitInfo k=9, rows=375
83
+ * @constraints k=9, rows=373
84
84
  *
85
85
  * @param {Uint<64>} amount - The minted amount.
86
86
  * @return {[]} - Empty tuple.
@@ -94,7 +94,7 @@ module NativeShieldedTokenPublicSupply {
94
94
  * per successful `NativeShieldedToken._burn` / `_burnFromSelf`.
95
95
  * @dev Enforces `burned <= minted`; an unpaired or duplicate burn reverts.
96
96
  *
97
- * @circuitInfo k=9, rows=477
97
+ * @constraints k=9, rows=475
98
98
  *
99
99
  * @param {Uint<128>} amount - The burned amount.
100
100
  * @return {[]} - Empty tuple.
@@ -106,7 +106,7 @@ module NativeShieldedTokenPublicSupply {
106
106
  /**
107
107
  * @description Returns the exact amount ever minted.
108
108
  *
109
- * @circuitInfo k=7, rows=65
109
+ * @constraints k=7, rows=63
110
110
  *
111
111
  * @return {Uint<128>} - The total amount minted.
112
112
  */
@@ -119,7 +119,7 @@ module NativeShieldedTokenPublicSupply {
119
119
  * @notice This is a lower bound: coins sent directly to the burn address
120
120
  * without going through the contract are not counted.
121
121
  *
122
- * @circuitInfo k=7, rows=62
122
+ * @constraints k=7, rows=60
123
123
  *
124
124
  * @return {Uint<128>} - The total amount burned through the contract.
125
125
  */
@@ -132,7 +132,7 @@ module NativeShieldedTokenPublicSupply {
132
132
  * @notice This is an UPPER BOUND on circulating supply, not an exact value:
133
133
  * burns that bypass the contract are invisible. See the module notes.
134
134
  *
135
- * @circuitInfo k=9, rows=160
135
+ * @constraints k=9, rows=158
136
136
  *
137
137
  * @return {Uint<128>} - The upper bound on tokens in existence.
138
138
  */
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // OpenZeppelin Compact Contracts v0.2.0 (token/extensions/NativeShieldedTokenPublicSupplyCore.compact)
3
3
 
4
- pragma language_version >= 0.23.0;
4
+ pragma language_version >= 0.26.0;
5
5
 
6
6
  /**
7
7
  * @module NativeShieldedTokenPublicSupplyCore
@@ -71,7 +71,7 @@ module NativeShieldedTokenPublicSupplyCore {
71
71
  * once per successful token `_mint`.
72
72
  * @dev Checks for overflow in order to output a readable error message.
73
73
  *
74
- * @circuitInfo k=10, rows=653
74
+ * @constraints k=10, rows=645
75
75
  *
76
76
  * @param {Bytes<32>} domain - 32-byte token discriminator.
77
77
  * @param {Uint<64>} amount - The minted amount.
@@ -91,7 +91,7 @@ module NativeShieldedTokenPublicSupplyCore {
91
91
  * The guard also keeps the add and the `totalSupply` subtraction within
92
92
  * bounds, so no separate overflow/underflow check is needed.
93
93
  *
94
- * @circuitInfo k=10, rows=755
94
+ * @constraints k=10, rows=747
95
95
  *
96
96
  * @param {Bytes<32>} domain - 32-byte token discriminator.
97
97
  * @param {Uint<128>} amount - The burned amount.
@@ -111,7 +111,7 @@ module NativeShieldedTokenPublicSupplyCore {
111
111
  /**
112
112
  * @description Returns the exact amount ever minted for `domain`.
113
113
  *
114
- * @circuitInfo k=9, rows=344
114
+ * @constraints k=9, rows=342
115
115
  *
116
116
  * @param {Bytes<32>} domain - 32-byte token discriminator.
117
117
  * @return {Uint<128>} - The total amount minted.
@@ -128,7 +128,7 @@ module NativeShieldedTokenPublicSupplyCore {
128
128
  * @notice This is a lower bound: coins sent directly to the burn address
129
129
  * without going through the contract are not counted.
130
130
  *
131
- * @circuitInfo k=9, rows=341
131
+ * @constraints k=9, rows=339
132
132
  *
133
133
  * @param {Bytes<32>} domain - 32-byte token discriminator.
134
134
  * @return {Uint<128>} - The total amount burned through the contract.
@@ -150,7 +150,7 @@ module NativeShieldedTokenPublicSupplyCore {
150
150
  * fires in normal operation. It is kept so the getter is a total function that
151
151
  * reads cleanly (returning 0) rather than reverting on an out-of-bound state.
152
152
  *
153
- * @circuitInfo k=9, rows=439
153
+ * @constraints k=9, rows=437
154
154
  *
155
155
  * @param {Bytes<32>} domain - 32-byte token discriminator.
156
156
  * @return {Uint<128>} - The upper bound on tokens in existence.