@openzeppelin/compact-contracts 0.4.0 → 0.5.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.
- package/README.md +9 -4
- package/access/AccessControl.compact +8 -9
- package/access/Ownable.compact +21 -20
- package/access/ShieldedAccessControl.compact +20 -19
- package/access/ZOwnablePK.compact +5 -3
- package/crypto/Ecdh.compact +153 -0
- package/crypto/EcdhMask.compact +146 -84
- package/crypto/Ecdsa.compact +1 -1
- package/crypto/Eip712.compact +1 -1
- package/crypto/ElGamal.compact +13 -13
- package/math/UintN.compact +82 -0
- package/multisig/ForwarderPrivate.compact +6 -17
- package/multisig/ForwarderShielded.compact +1 -1
- package/multisig/ForwarderUnshielded.compact +1 -1
- package/multisig/ProposalManager.compact +127 -65
- package/multisig/Secp256k1EcdsaMultisig.compact +1 -1
- package/multisig/ShieldedTreasury.compact +8 -20
- package/multisig/ShieldedTreasuryStateless.compact +9 -21
- package/multisig/Signer.compact +1 -1
- package/multisig/UnshieldedTreasury.compact +11 -24
- package/multisig/examples/ForwarderPrivateExample.compact +2 -3
- package/multisig/examples/ForwarderShieldedExample.compact +1 -1
- package/multisig/examples/ForwarderUnshieldedExample.compact +1 -1
- package/multisig/examples/{ShieldedMultiSigV2Example.compact → NativeShieldedStatelessTreasuryExample.compact} +23 -23
- package/multisig/examples/NativeShieldedTokenIssuerExample.compact +1 -1
- package/multisig/presets/NativeShieldedStatelessTreasury.compact +443 -0
- package/multisig/presets/NativeShieldedTokenIssuer.compact +2 -5
- package/package.json +11 -11
- package/security/Allowlist.compact +1 -1
- package/security/Blocklist.compact +1 -1
- package/security/Initializable.compact +3 -1
- package/security/Pausable.compact +1 -1
- package/token/ConfidentialFungibleToken.compact +22 -70
- package/token/ConfidentialNoteFungibleToken.compact +741 -0
- package/token/FungibleToken.compact +36 -30
- package/token/MultiToken.compact +27 -21
- package/token/NativeShieldedToken.compact +4 -12
- package/token/NativeShieldedTokenCore.compact +1 -1
- package/token/NativeShieldedTokenFamily.compact +4 -4
- package/token/NonFungibleToken.compact +28 -22
- package/token/examples/ZOwnableNativeShieldedTokenExample.compact +1 -1
- package/token/extensions/ConfidentialFungibleTokenPublicSupply.compact +1 -1
- package/token/extensions/ConfidentialNoteFungibleTokenDelivery.compact +274 -0
- package/token/extensions/NativeShieldedTokenDerivedNonce.compact +1 -1
- package/token/extensions/NativeShieldedTokenFamilyPublicSupply.compact +1 -1
- package/token/extensions/NativeShieldedTokenPublicSupply.compact +1 -1
- package/token/extensions/NativeShieldedTokenPublicSupplyCore.compact +1 -1
- package/token/presets/ZOwnableNativeShieldedToken.compact +1 -1
- package/utils/EvmAbi.compact +1 -1
- package/utils/Utils.compact +1 -1
- package/multisig/RecipientTypes.compact +0 -48
- package/multisig/presets/ShieldedMultiSigV2.compact +0 -295
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.5.0-alpha.2 (token/FungibleToken.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -22,12 +22,12 @@ pragma language_version >= 0.26.0;
|
|
|
22
22
|
* canonicalized in `balanceOf` and `allowance`. `_spendAllowance` canonicalizes
|
|
23
23
|
* independently to ensure consistent lookups before delegating to `_approve`.
|
|
24
24
|
*
|
|
25
|
-
* @notice
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
25
|
+
* @notice This library has not yet migrated to contract-to-contract (C2C) calls. Thus, the main
|
|
26
|
+
* circuits of this module (`transfer`, `transferFrom`, `_transfer`, `_mint`) reject
|
|
27
|
+
* `ContractAddress` recipients via an `isContract` guard, because a contract that receives tokens
|
|
28
|
+
* currently cannot move them back out. Developers who need to experiment with contract recipients
|
|
29
|
+
* can use the `_unsafe` variants, which skip the guard (the caller accepts that such tokens are
|
|
30
|
+
* stranded until the C2C migration lands).
|
|
31
31
|
*
|
|
32
32
|
* @dev Migration plan (safe -> C2C-capable transfers)
|
|
33
33
|
*
|
|
@@ -39,9 +39,9 @@ pragma language_version >= 0.26.0;
|
|
|
39
39
|
* which is the only kind of upgrade the CMA supports. Widening the types later would instead force
|
|
40
40
|
* a ledger-layout rewrite, which the CMA cannot perform.
|
|
41
41
|
*
|
|
42
|
-
* When C2C lands, an already-deployed token migrates without changing its address or
|
|
43
|
-
* Below, `FN` stands for each guarded circuit (`transfer`, `transferFrom`,
|
|
44
|
-
* and `_unsafeFN` for its unsafe counterpart:
|
|
42
|
+
* When the C2C migration lands, an already-deployed token migrates without changing its address or
|
|
43
|
+
* ledger state. Below, `FN` stands for each guarded circuit (`transfer`, `transferFrom`,
|
|
44
|
+
* `_transfer`, `_mint`) and `_unsafeFN` for its unsafe counterpart:
|
|
45
45
|
*
|
|
46
46
|
* - Minor release: mark `_unsafeFN` deprecated (and emit a warning if possible); keep its
|
|
47
47
|
* implementation intact so existing callers continue to work.
|
|
@@ -130,6 +130,8 @@ module FungibleToken {
|
|
|
130
130
|
* @dev This MUST be called in the implementing contract's constructor. Failure to do so
|
|
131
131
|
* can lead to an irreparable contract.
|
|
132
132
|
*
|
|
133
|
+
* @constraints k=10, rows=71
|
|
134
|
+
*
|
|
133
135
|
* @param {Opaque<"string">} name_ - The name of the token.
|
|
134
136
|
* @param {Opaque<"string">} symbol_ - The symbol of the token.
|
|
135
137
|
* @param {Uint<8>} decimals_ - The number of decimals used to get the user representation.
|
|
@@ -267,8 +269,8 @@ module FungibleToken {
|
|
|
267
269
|
*
|
|
268
270
|
* @constraints k=13, rows=3743
|
|
269
271
|
*
|
|
270
|
-
* @notice Transfers to contract addresses are
|
|
271
|
-
*
|
|
272
|
+
* @notice Transfers to contract addresses are disallowed until this library migrates to
|
|
273
|
+
* contract-to-contract calls. This restriction prevents assets from
|
|
272
274
|
* being inadvertently locked in contracts that cannot currently handle token receipt.
|
|
273
275
|
*
|
|
274
276
|
* Requirements:
|
|
@@ -298,9 +300,10 @@ module FungibleToken {
|
|
|
298
300
|
*
|
|
299
301
|
* @constraints k=13, rows=3740
|
|
300
302
|
*
|
|
301
|
-
* @warning Transfers to contract addresses are considered unsafe because
|
|
302
|
-
*
|
|
303
|
-
*
|
|
303
|
+
* @warning Transfers to contract addresses are considered unsafe because this library has not yet
|
|
304
|
+
* migrated to contract-to-contract calls.
|
|
305
|
+
* Tokens sent to a contract address may become irretrievable.
|
|
306
|
+
* Once this library migrates to contract-to-contract calls, this circuit may be deprecated.
|
|
304
307
|
*
|
|
305
308
|
* Requirements:
|
|
306
309
|
*
|
|
@@ -383,8 +386,8 @@ module FungibleToken {
|
|
|
383
386
|
*
|
|
384
387
|
* @constraints k=13, rows=4906
|
|
385
388
|
*
|
|
386
|
-
* @notice Transfers to contract addresses are
|
|
387
|
-
*
|
|
389
|
+
* @notice Transfers to contract addresses are disallowed until this library migrates to
|
|
390
|
+
* contract-to-contract calls. This restriction prevents assets from
|
|
388
391
|
* being inadvertently locked in contracts that cannot currently handle token receipt.
|
|
389
392
|
*
|
|
390
393
|
* Requirements:
|
|
@@ -417,9 +420,10 @@ module FungibleToken {
|
|
|
417
420
|
*
|
|
418
421
|
* @constraints k=13, rows=4903
|
|
419
422
|
*
|
|
420
|
-
* @warning Transfers to contract addresses are considered unsafe because
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
+
* @warning Transfers to contract addresses are considered unsafe because this library has not yet
|
|
424
|
+
* migrated to contract-to-contract calls.
|
|
425
|
+
* Tokens sent to a contract address may become irretrievable.
|
|
426
|
+
* Once this library migrates to contract-to-contract calls, this circuit may be deprecated.
|
|
423
427
|
*
|
|
424
428
|
* Requirements:
|
|
425
429
|
*
|
|
@@ -454,8 +458,8 @@ module FungibleToken {
|
|
|
454
458
|
*
|
|
455
459
|
* @constraints k=12, rows=2125
|
|
456
460
|
*
|
|
457
|
-
* @notice Transfers to contract addresses are
|
|
458
|
-
*
|
|
461
|
+
* @notice Transfers to contract addresses are disallowed until this library migrates to
|
|
462
|
+
* contract-to-contract calls. This restriction prevents assets from
|
|
459
463
|
* being inadvertently locked in contracts that cannot currently handle token receipt.
|
|
460
464
|
*
|
|
461
465
|
* Requirements:
|
|
@@ -487,9 +491,10 @@ module FungibleToken {
|
|
|
487
491
|
*
|
|
488
492
|
* @constraints k=12, rows=2122
|
|
489
493
|
*
|
|
490
|
-
* @warning Transfers to contract addresses are considered unsafe because
|
|
491
|
-
*
|
|
492
|
-
*
|
|
494
|
+
* @warning Transfers to contract addresses are considered unsafe because this library has not yet
|
|
495
|
+
* migrated to contract-to-contract calls.
|
|
496
|
+
* Tokens sent to a contract address may become irretrievable.
|
|
497
|
+
* Once this library migrates to contract-to-contract calls, this circuit may be deprecated.
|
|
493
498
|
*
|
|
494
499
|
* Requirements:
|
|
495
500
|
*
|
|
@@ -565,8 +570,8 @@ module FungibleToken {
|
|
|
565
570
|
*
|
|
566
571
|
* @constraints k=11, rows=1328
|
|
567
572
|
*
|
|
568
|
-
* @notice Transfers to contract addresses are
|
|
569
|
-
*
|
|
573
|
+
* @notice Transfers to contract addresses are disallowed until this library migrates to
|
|
574
|
+
* contract-to-contract calls. This restriction prevents assets from
|
|
570
575
|
* being inadvertently locked in contracts that cannot currently handle token receipt.
|
|
571
576
|
*
|
|
572
577
|
* Requirements:
|
|
@@ -591,9 +596,10 @@ module FungibleToken {
|
|
|
591
596
|
*
|
|
592
597
|
* @constraints k=11, rows=1325
|
|
593
598
|
*
|
|
594
|
-
* @warning Transfers to contract addresses are considered unsafe because
|
|
595
|
-
*
|
|
596
|
-
*
|
|
599
|
+
* @warning Transfers to contract addresses are considered unsafe because this library has not yet
|
|
600
|
+
* migrated to contract-to-contract calls.
|
|
601
|
+
* Tokens sent to a contract address may become irretrievable.
|
|
602
|
+
* Once this library migrates to contract-to-contract calls, this circuit may be deprecated.
|
|
597
603
|
*
|
|
598
604
|
* Requirements:
|
|
599
605
|
*
|
package/token/MultiToken.compact
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.5.0-alpha.2 (token/MultiToken.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -49,8 +49,8 @@ pragma language_version >= 0.26.0;
|
|
|
49
49
|
* Since this module does not offer mint or transfer batching,
|
|
50
50
|
* balance batching is also not included at this time.
|
|
51
51
|
*
|
|
52
|
-
* 3. Introspection -
|
|
53
|
-
*
|
|
52
|
+
* 3. Introspection - This library has not yet migrated to contract-to-contract
|
|
53
|
+
* calls, so there are no introspection queries. ERC165 (or an equivalent thereof) is NOT
|
|
54
54
|
* included in the contract.
|
|
55
55
|
*
|
|
56
56
|
* 4. Safe transfers - The lack of an introspection mechanism means
|
|
@@ -93,7 +93,7 @@ pragma language_version >= 0.26.0;
|
|
|
93
93
|
* an `isContract` guard, because a contract that receives tokens currently cannot move them back
|
|
94
94
|
* out. The `_unsafe` variants (`_unsafeTransferFrom`, `_unsafeTransfer`, `_unsafeMint`) skip the
|
|
95
95
|
* guard for callers who need contract recipients (accepting that such tokens are stranded until
|
|
96
|
-
* C2C lands).
|
|
96
|
+
* the C2C migration lands).
|
|
97
97
|
*
|
|
98
98
|
* The recipient type is the final `Either<Bytes<32>, ContractAddress>` from day one, in both
|
|
99
99
|
* circuit signatures and ledger maps. This is deliberate. Midnight's upgrade mechanism, the
|
|
@@ -103,7 +103,8 @@ pragma language_version >= 0.26.0;
|
|
|
103
103
|
* which is the only kind of upgrade the CMA supports. Widening the types later would instead force
|
|
104
104
|
* a ledger-layout rewrite, which the CMA cannot perform.
|
|
105
105
|
*
|
|
106
|
-
* When C2C lands, an already-deployed token migrates without changing its address or
|
|
106
|
+
* When the C2C migration lands, an already-deployed token migrates without changing its address or
|
|
107
|
+
* ledger state:
|
|
107
108
|
*
|
|
108
109
|
* - Minor release: mark the `_unsafe` variants deprecated (and emit a warning if possible); keep
|
|
109
110
|
* their implementation intact so existing callers continue to work.
|
|
@@ -120,7 +121,7 @@ pragma language_version >= 0.26.0;
|
|
|
120
121
|
*
|
|
121
122
|
* - Consider changing the underscore in the internal methods to `unsafe` or
|
|
122
123
|
* adopting dot notation for prefixing imports.
|
|
123
|
-
* - Revise logic once contract-to-contract
|
|
124
|
+
* - Revise logic once this library migrates to contract-to-contract calls.
|
|
124
125
|
*/
|
|
125
126
|
module MultiToken {
|
|
126
127
|
import CompactStandardLibrary;
|
|
@@ -176,6 +177,8 @@ module MultiToken {
|
|
|
176
177
|
/**
|
|
177
178
|
* @description Initializes the contract by setting the base URI for all tokens.
|
|
178
179
|
*
|
|
180
|
+
* @constraints k=6, rows=31
|
|
181
|
+
*
|
|
179
182
|
* Requirements:
|
|
180
183
|
*
|
|
181
184
|
* - Must be called in the contract's constructor.
|
|
@@ -326,8 +329,8 @@ module MultiToken {
|
|
|
326
329
|
* In the case of an external (non-contract) caller, the caller's identity is derived from the `wit_MultiTokenSK`
|
|
327
330
|
* witness as `persistentHash(secretKey)`.
|
|
328
331
|
*
|
|
329
|
-
* @notice Transfers to contract addresses are
|
|
330
|
-
*
|
|
332
|
+
* @notice Transfers to contract addresses are disallowed until this library migrates to
|
|
333
|
+
* contract-to-contract calls. This restriction prevents assets from
|
|
331
334
|
* being inadvertently locked in contracts that cannot currently handle token receipt.
|
|
332
335
|
*
|
|
333
336
|
* @constraints k=13, rows=4833
|
|
@@ -363,8 +366,8 @@ module MultiToken {
|
|
|
363
366
|
* Does not impose restrictions on the caller, making it suitable for composition
|
|
364
367
|
* in higher-level contract logic.
|
|
365
368
|
*
|
|
366
|
-
* @notice Transfers to contract addresses are
|
|
367
|
-
*
|
|
369
|
+
* @notice Transfers to contract addresses are disallowed until this library migrates to
|
|
370
|
+
* contract-to-contract calls. This restriction prevents assets from
|
|
368
371
|
* being inadvertently locked in contracts that cannot currently handle token receipt.
|
|
369
372
|
*
|
|
370
373
|
* @constraints k=12, rows=2381
|
|
@@ -456,9 +459,10 @@ module MultiToken {
|
|
|
456
459
|
* In the case of an external (non-contract) caller, the caller's identity is derived from the `wit_MultiTokenSK`
|
|
457
460
|
* witness as `persistentHash(secretKey)`.
|
|
458
461
|
*
|
|
459
|
-
* @warning Transfers to contract addresses are considered unsafe because
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
+
* @warning Transfers to contract addresses are considered unsafe because this library has not yet
|
|
463
|
+
* migrated to contract-to-contract calls.
|
|
464
|
+
* Tokens sent to a contract address may become irretrievable.
|
|
465
|
+
* Once this library migrates to contract-to-contract calls, this circuit may be deprecated.
|
|
462
466
|
*
|
|
463
467
|
* @constraints k=13, rows=4832
|
|
464
468
|
*
|
|
@@ -498,9 +502,10 @@ module MultiToken {
|
|
|
498
502
|
* Does not impose restrictions on the caller, making it suitable as a low-level
|
|
499
503
|
* building block for advanced contract logic.
|
|
500
504
|
*
|
|
501
|
-
* @warning Transfers to contract addresses are considered unsafe because
|
|
502
|
-
*
|
|
503
|
-
*
|
|
505
|
+
* @warning Transfers to contract addresses are considered unsafe because this library has not yet
|
|
506
|
+
* migrated to contract-to-contract calls.
|
|
507
|
+
* Tokens sent to a contract address may become irretrievable.
|
|
508
|
+
* Once this library migrates to contract-to-contract calls, this circuit may be deprecated.
|
|
504
509
|
*
|
|
505
510
|
* @constraints k=12, rows=2380
|
|
506
511
|
*
|
|
@@ -561,8 +566,8 @@ module MultiToken {
|
|
|
561
566
|
/**
|
|
562
567
|
* @description Creates a `value` amount of tokens of type `id`, and assigns them to `to`.
|
|
563
568
|
*
|
|
564
|
-
* @notice Transfers to contract addresses are
|
|
565
|
-
*
|
|
569
|
+
* @notice Transfers to contract addresses are disallowed until this library migrates to
|
|
570
|
+
* contract-to-contract calls. This restriction prevents assets from
|
|
566
571
|
* being inadvertently locked in contracts that cannot currently handle token receipt.
|
|
567
572
|
*
|
|
568
573
|
* @constraints k=11, rows=1449
|
|
@@ -590,9 +595,10 @@ module MultiToken {
|
|
|
590
595
|
/**
|
|
591
596
|
* @description Unsafe variant of `_mint` which allows transfers to contract addresses.
|
|
592
597
|
*
|
|
593
|
-
* @warning Transfers to contract addresses are considered unsafe because
|
|
594
|
-
*
|
|
595
|
-
*
|
|
598
|
+
* @warning Transfers to contract addresses are considered unsafe because this library has not yet
|
|
599
|
+
* migrated to contract-to-contract calls.
|
|
600
|
+
* Tokens sent to a contract address may become irretrievable.
|
|
601
|
+
* Once this library migrates to contract-to-contract calls, this circuit may be deprecated.
|
|
596
602
|
*
|
|
597
603
|
* @constraints k=11, rows=1448
|
|
598
604
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.5.0-alpha.2 (token/NativeShieldedToken.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -62,7 +62,7 @@ pragma language_version >= 0.26.0;
|
|
|
62
62
|
* shared-`Initializable`-flag "one `initialize` per contract" limit no longer
|
|
63
63
|
* applies.)
|
|
64
64
|
*
|
|
65
|
-
* @notice Out of scope (phase two, pending contract-to-contract
|
|
65
|
+
* @notice Out of scope (phase two, pending this library's contract-to-contract migration):
|
|
66
66
|
* `balanceOf`, `allowance`, and transfer mediation are not representable for
|
|
67
67
|
* native shielded UTXOs — once a user holds a coin, the contract cannot observe
|
|
68
68
|
* or restrict its movement.
|
|
@@ -230,13 +230,7 @@ module NativeShieldedToken {
|
|
|
230
230
|
*
|
|
231
231
|
* @notice The consumer SHOULD persist the returned coin info in its own
|
|
232
232
|
* ledger state: it is the contract's holding and is not otherwise
|
|
233
|
-
* recoverable.
|
|
234
|
-
* custody module must record it without calling `receiveShielded` on it
|
|
235
|
-
* again (see the recipient-arm note in `NativeShieldedTokenCore`).
|
|
236
|
-
* `ShieldedTreasury._deposit` claims on the way in and is not that path;
|
|
237
|
-
* a record-only circuit is tracked in compact-contracts#1112. Until a
|
|
238
|
-
* custody module is composed, the only spend of a contract-held coin is
|
|
239
|
-
* `_burnFromSelf`.
|
|
233
|
+
* recoverable.
|
|
240
234
|
*
|
|
241
235
|
* @constraints k=14, rows=10221
|
|
242
236
|
*
|
|
@@ -316,9 +310,7 @@ module NativeShieldedToken {
|
|
|
316
310
|
*
|
|
317
311
|
* @dev The consumer SHOULD persist the returned change coin info in its own
|
|
318
312
|
* ledger state: the change replaces `coin` as the contract's holding, and
|
|
319
|
-
* its info is not otherwise recoverable.
|
|
320
|
-
* change is already claimed as a receive, so a custody module must record
|
|
321
|
-
* it without a second `receiveShielded`.
|
|
313
|
+
* its info is not otherwise recoverable.
|
|
322
314
|
*
|
|
323
315
|
* @constraints k=15, rows=23208
|
|
324
316
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.5.0-alpha.2 (token/NativeShieldedTokenFamily.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -8,8 +8,8 @@ pragma language_version >= 0.26.0;
|
|
|
8
8
|
* @description A module for issuing a FAMILY of native shielded (Zswap)
|
|
9
9
|
* token types from one contract, discriminated by a per-call domain.
|
|
10
10
|
*
|
|
11
|
-
* This flavor exists because of Midnight's composition model:
|
|
12
|
-
* contract-to-contract interaction and
|
|
11
|
+
* This flavor exists because of Midnight's composition model: this library has no
|
|
12
|
+
* contract-to-contract interaction yet and a contract cannot deploy
|
|
13
13
|
* another, so the Ethereum pattern of one token contract per asset (stamped
|
|
14
14
|
* out by a factory) is unavailable. A protocol that issues many related
|
|
15
15
|
* tokens — e.g. a DEX minting one liquidity-share token per pair — must do
|
|
@@ -61,7 +61,7 @@ pragma language_version >= 0.26.0;
|
|
|
61
61
|
* need an on-chain `totalSupply(domain)`; see it for the privacy trade-off it
|
|
62
62
|
* introduces (it makes contract-mediated burn amounts public).
|
|
63
63
|
*
|
|
64
|
-
* @notice Out of scope (phase two, pending contract-to-contract
|
|
64
|
+
* @notice Out of scope (phase two, pending this library's contract-to-contract migration):
|
|
65
65
|
* `balanceOf`, `allowance`, transfer mediation, batch operations, and operator
|
|
66
66
|
* approvals are not representable for native shielded UTXOs — once a user holds
|
|
67
67
|
* a coin, the contract cannot observe or restrict its movement.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.5.0-alpha.2 (token/NonFungibleToken.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -24,12 +24,12 @@ pragma language_version >= 0.26.0;
|
|
|
24
24
|
* This is due to encoding limits on the midnight circuit backend:
|
|
25
25
|
* https://github.com/midnightntwrk/compactc/issues/929
|
|
26
26
|
*
|
|
27
|
-
* @notice
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
27
|
+
* @notice This library has not yet migrated to contract-to-contract (C2C) calls. Thus, the main
|
|
28
|
+
* circuits of this module (`transfer`, `transferFrom`, `_transfer`, `_mint`) reject
|
|
29
|
+
* `ContractAddress` recipients via an `isContract` guard, because a contract that receives a token
|
|
30
|
+
* currently cannot move it back out. Developers who need to experiment with contract recipients can
|
|
31
|
+
* use the `_unsafe` variants, which skip the guard (the caller accepts that such tokens are
|
|
32
|
+
* stranded until the C2C migration lands).
|
|
33
33
|
*
|
|
34
34
|
* @dev Migration plan (safe -> C2C-capable `transfer`)
|
|
35
35
|
*
|
|
@@ -41,7 +41,8 @@ pragma language_version >= 0.26.0;
|
|
|
41
41
|
* which is the only kind of upgrade the CMA supports. Widening the types later would instead force
|
|
42
42
|
* a ledger-layout rewrite, which the CMA cannot perform.
|
|
43
43
|
*
|
|
44
|
-
* When C2C lands, an already-deployed token migrates without changing its address or
|
|
44
|
+
* When the C2C migration lands, an already-deployed token migrates without changing its address or
|
|
45
|
+
* ledger state:
|
|
45
46
|
*
|
|
46
47
|
* - Minor release: mark `_unsafeTransfer` deprecated (and emit a warning if possible); keep its
|
|
47
48
|
* implementation intact so existing callers continue to work.
|
|
@@ -165,6 +166,8 @@ module NonFungibleToken {
|
|
|
165
166
|
* This MUST be called in the implementing contract's constructor.
|
|
166
167
|
* Failure to do so can lead to an irreparable contract.
|
|
167
168
|
*
|
|
169
|
+
* @constraints k=6, rows=52
|
|
170
|
+
*
|
|
168
171
|
* Requirements:
|
|
169
172
|
*
|
|
170
173
|
* - Contract is not initialized.
|
|
@@ -435,9 +438,9 @@ module NonFungibleToken {
|
|
|
435
438
|
/**
|
|
436
439
|
* @description Transfers `tokenId` token from `fromAddress` to `to`.
|
|
437
440
|
*
|
|
438
|
-
* @notice Transfers to contract addresses are
|
|
439
|
-
*
|
|
440
|
-
* currently handle token receipt.
|
|
441
|
+
* @notice Transfers to contract addresses are disallowed until this library migrates to
|
|
442
|
+
* contract-to-contract calls. This restriction prevents assets from being inadvertently
|
|
443
|
+
* locked in contracts that cannot currently handle token receipt.
|
|
441
444
|
*
|
|
442
445
|
* In the case of an external (non-contract) caller, the caller's identity is derived from the `wit_NonFungibleTokenSK`
|
|
443
446
|
* witness as `persistentHash(secretKey)`.
|
|
@@ -476,9 +479,10 @@ module NonFungibleToken {
|
|
|
476
479
|
* In the case of an external (non-contract) caller, the caller's identity is derived from the `wit_NonFungibleTokenSK`
|
|
477
480
|
* witness as `persistentHash(secretKey)`.
|
|
478
481
|
*
|
|
479
|
-
* @warning Transfers to contract addresses are considered unsafe because
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
+
* @warning Transfers to contract addresses are considered unsafe because this library has not yet
|
|
483
|
+
* migrated to contract-to-contract calls.
|
|
484
|
+
* Tokens sent to a contract address may become irretrievable.
|
|
485
|
+
* Once this library migrates to contract-to-contract calls, this circuit may be deprecated.
|
|
482
486
|
*
|
|
483
487
|
* @constraints k=13, rows=4699
|
|
484
488
|
*
|
|
@@ -704,9 +708,10 @@ module NonFungibleToken {
|
|
|
704
708
|
* - `tokenId` must not exist.
|
|
705
709
|
* - `to` is not zero.
|
|
706
710
|
*
|
|
707
|
-
* @warning Transfers to contract addresses are considered unsafe because
|
|
708
|
-
*
|
|
709
|
-
*
|
|
711
|
+
* @warning Transfers to contract addresses are considered unsafe because this library has not yet
|
|
712
|
+
* migrated to contract-to-contract calls.
|
|
713
|
+
* Tokens sent to a contract address may become irretrievable.
|
|
714
|
+
* Once this library migrates to contract-to-contract calls, this circuit may be deprecated.
|
|
710
715
|
*
|
|
711
716
|
* @param {Either<Bytes<32>, ContractAddress>} to - The account receiving `tokenId`
|
|
712
717
|
* @param {Uint<128>} tokenId - The token to transfer
|
|
@@ -750,8 +755,8 @@ module NonFungibleToken {
|
|
|
750
755
|
* @description Transfers `tokenId` from `fromAddress` to `to`.
|
|
751
756
|
* As opposed to {transferFrom}, this imposes no restrictions on the caller's identity.
|
|
752
757
|
*
|
|
753
|
-
* @notice Transfers to contract addresses are
|
|
754
|
-
*
|
|
758
|
+
* @notice Transfers to contract addresses are disallowed until this library migrates to
|
|
759
|
+
* contract-to-contract calls. This restriction prevents assets from being inadvertently
|
|
755
760
|
* locked in contracts that cannot currently handle token receipt.
|
|
756
761
|
*
|
|
757
762
|
* @constraints k=11, rows=1982
|
|
@@ -793,9 +798,10 @@ module NonFungibleToken {
|
|
|
793
798
|
* - `to` is not zero.
|
|
794
799
|
* - `tokenId` token must be owned by `fromAddress`.
|
|
795
800
|
*
|
|
796
|
-
* @warning Transfers to contract addresses are considered unsafe because
|
|
797
|
-
*
|
|
798
|
-
*
|
|
801
|
+
* @warning Transfers to contract addresses are considered unsafe because this library has not yet
|
|
802
|
+
* migrated to contract-to-contract calls.
|
|
803
|
+
* Tokens sent to a contract address may become irretrievable.
|
|
804
|
+
* Once this library migrates to contract-to-contract calls, this circuit may be deprecated.
|
|
799
805
|
*
|
|
800
806
|
* @param {Either<Bytes<32>, ContractAddress>} fromAddress - The source account of the token transfer
|
|
801
807
|
* @param {Either<Bytes<32>, ContractAddress>} to - The target account of the token transfer
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.5.0-alpha.2 (token/examples/ZOwnableNativeShieldedTokenExample.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.5.0-alpha.2 (token/extensions/ConfidentialFungibleTokenPublicSupply.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|