@openzeppelin/compact-contracts 0.4.0-alpha.1 → 0.4.0-alpha.3
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 -5
- package/access/AccessControl.compact +13 -13
- package/access/Ownable.compact +15 -9
- package/access/ShieldedAccessControl.compact +25 -1
- package/access/ZOwnablePK.compact +8 -8
- package/crypto/EcdhMask.compact +1 -1
- package/crypto/Ecdsa.compact +4 -4
- package/crypto/Eip712.compact +168 -0
- package/crypto/ElGamal.compact +44 -3
- package/multisig/EcdsaSignerManager.compact +32 -15
- package/multisig/ForwarderPrivate.compact +11 -5
- package/multisig/ForwarderShielded.compact +2 -2
- package/multisig/ForwarderUnshielded.compact +2 -2
- package/multisig/ProposalManager.compact +194 -22
- package/multisig/ShieldedTreasury.compact +28 -1
- package/multisig/ShieldedTreasuryStateless.compact +1 -1
- package/multisig/Signer.compact +27 -79
- package/multisig/UnshieldedTreasury.compact +9 -1
- package/multisig/{presets/forwarder/ForwarderPrivate.compact → examples/ForwarderPrivateExample.compact} +3 -3
- package/multisig/{presets/forwarder/ForwarderShielded.compact → examples/ForwarderShieldedExample.compact} +3 -3
- package/multisig/{presets/forwarder/ForwarderUnshielded.compact → examples/ForwarderUnshieldedExample.compact} +3 -3
- package/multisig/examples/NativeShieldedTokenIssuerExample.compact +143 -0
- package/multisig/examples/ShieldedMultiSigV2Example.compact +77 -0
- package/multisig/presets/NativeShieldedTokenIssuer.compact +557 -0
- package/multisig/presets/ShieldedMultiSigV2.compact +251 -188
- package/package.json +15 -11
- package/security/Allowlist.compact +5 -5
- package/security/Blocklist.compact +5 -5
- package/security/Initializable.compact +8 -4
- package/security/Pausable.compact +10 -6
- package/token/ConfidentialFungibleToken.compact +337 -79
- package/token/FungibleToken.compact +35 -21
- package/token/MultiToken.compact +15 -15
- package/token/NativeShieldedToken.compact +65 -16
- package/token/NativeShieldedTokenCore.compact +57 -15
- package/token/NativeShieldedTokenFamily.compact +66 -16
- package/token/NonFungibleToken.compact +83 -34
- package/token/extensions/ConfidentialFungibleTokenPublicSupply.compact +11 -6
- package/token/extensions/NativeShieldedTokenDerivedNonce.compact +2 -2
- package/token/extensions/NativeShieldedTokenFamilyPublicSupply.compact +7 -7
- package/token/extensions/NativeShieldedTokenPublicSupply.compact +7 -7
- package/token/extensions/NativeShieldedTokenPublicSupplyCore.compact +5 -5
- package/utils/EvmAbi.compact +134 -0
- package/utils/Utils.compact +11 -1
- package/multisig/presets/ShieldedMultiSig.compact +0 -227
- package/multisig/presets/ShieldedMultiSigV3.compact +0 -311
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.4.0-alpha.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.4.0-alpha.3 (token/FungibleToken.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -93,10 +93,24 @@ module FungibleToken {
|
|
|
93
93
|
export ledger _allowances: Map<Either<Bytes<32>, ContractAddress>,
|
|
94
94
|
Map<Either<Bytes<32>, ContractAddress>, Uint<128>>>;
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* @description Total tokens in circulation. `_update` raises it on a mint and
|
|
98
|
+
* lowers it on a burn, rejecting an increase that would overflow `Uint<128>`.
|
|
99
|
+
*/
|
|
96
100
|
export ledger _totalSupply: Uint<128>;
|
|
97
101
|
|
|
102
|
+
/**
|
|
103
|
+
* @description The token's human-readable name, set once at construction.
|
|
104
|
+
*/
|
|
98
105
|
export sealed ledger _name: Opaque<"string">;
|
|
106
|
+
/**
|
|
107
|
+
* @description The token's ticker symbol, set once at construction.
|
|
108
|
+
*/
|
|
99
109
|
export sealed ledger _symbol: Opaque<"string">;
|
|
110
|
+
/**
|
|
111
|
+
* @description The number of decimals used to display balances, set once at
|
|
112
|
+
* construction. Purely presentational; no circuit scales by it.
|
|
113
|
+
*/
|
|
100
114
|
export sealed ledger _decimals: Uint<8>;
|
|
101
115
|
|
|
102
116
|
|
|
@@ -116,7 +130,7 @@ module FungibleToken {
|
|
|
116
130
|
* @dev This MUST be called in the implementing contract's constructor. Failure to do so
|
|
117
131
|
* can lead to an irreparable contract.
|
|
118
132
|
*
|
|
119
|
-
* @
|
|
133
|
+
* @constraints k=10, rows=71
|
|
120
134
|
*
|
|
121
135
|
* @param {Opaque<"string">} name_ - The name of the token.
|
|
122
136
|
* @param {Opaque<"string">} symbol_ - The symbol of the token.
|
|
@@ -164,7 +178,7 @@ module FungibleToken {
|
|
|
164
178
|
/**
|
|
165
179
|
* @description Returns the token name.
|
|
166
180
|
*
|
|
167
|
-
* @
|
|
181
|
+
* @constraints k=6, rows=26
|
|
168
182
|
*
|
|
169
183
|
* Requirements:
|
|
170
184
|
*
|
|
@@ -180,7 +194,7 @@ module FungibleToken {
|
|
|
180
194
|
/**
|
|
181
195
|
* @description Returns the symbol of the token.
|
|
182
196
|
*
|
|
183
|
-
* @
|
|
197
|
+
* @constraints k=6, rows=26
|
|
184
198
|
*
|
|
185
199
|
* Requirements:
|
|
186
200
|
*
|
|
@@ -196,7 +210,7 @@ module FungibleToken {
|
|
|
196
210
|
/**
|
|
197
211
|
* @description Returns the number of decimals used to get its user representation.
|
|
198
212
|
*
|
|
199
|
-
* @
|
|
213
|
+
* @constraints k=6, rows=26
|
|
200
214
|
*
|
|
201
215
|
* Requirements:
|
|
202
216
|
*
|
|
@@ -212,7 +226,7 @@ module FungibleToken {
|
|
|
212
226
|
/**
|
|
213
227
|
* @description Returns the value of tokens in existence.
|
|
214
228
|
*
|
|
215
|
-
* @
|
|
229
|
+
* @constraints k=6, rows=26
|
|
216
230
|
*
|
|
217
231
|
* Requirements:
|
|
218
232
|
*
|
|
@@ -228,7 +242,7 @@ module FungibleToken {
|
|
|
228
242
|
/**
|
|
229
243
|
* @description Returns the value of tokens owned by `account`.
|
|
230
244
|
*
|
|
231
|
-
* @
|
|
245
|
+
* @constraints k=10, rows=668
|
|
232
246
|
*
|
|
233
247
|
* @dev Manually checks if `account` is a key in the map and returns 0 if it is not.
|
|
234
248
|
*
|
|
@@ -253,7 +267,7 @@ module FungibleToken {
|
|
|
253
267
|
/**
|
|
254
268
|
* @description Moves a `value` amount of tokens from the caller's account to `to`.
|
|
255
269
|
*
|
|
256
|
-
* @
|
|
270
|
+
* @constraints k=13, rows=3743
|
|
257
271
|
*
|
|
258
272
|
* @notice Transfers to contract addresses are currently disallowed until contract-to-contract
|
|
259
273
|
* interactions are supported in Compact. This restriction prevents assets from
|
|
@@ -284,7 +298,7 @@ module FungibleToken {
|
|
|
284
298
|
/**
|
|
285
299
|
* @description Unsafe variant of `transfer` which allows transfers to contract addresses.
|
|
286
300
|
*
|
|
287
|
-
* @
|
|
301
|
+
* @constraints k=13, rows=3740
|
|
288
302
|
*
|
|
289
303
|
* @warning Transfers to contract addresses are considered unsafe because contract-to-contract
|
|
290
304
|
* calls are not currently supported. Tokens sent to a contract address may become irretrievable.
|
|
@@ -314,7 +328,7 @@ module FungibleToken {
|
|
|
314
328
|
* @description Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner`
|
|
315
329
|
* through `transferFrom`. This value changes when `approve` or `transferFrom` are called.
|
|
316
330
|
*
|
|
317
|
-
* @
|
|
331
|
+
* @constraints k=11, rows=1350
|
|
318
332
|
*
|
|
319
333
|
* @dev Manually checks if `owner` and `spender` are keys in the map and returns 0 if they are not.
|
|
320
334
|
*
|
|
@@ -344,7 +358,7 @@ module FungibleToken {
|
|
|
344
358
|
/**
|
|
345
359
|
* @description Sets a `value` amount of tokens as allowance of `spender` over the caller's tokens.
|
|
346
360
|
*
|
|
347
|
-
* @
|
|
361
|
+
* @constraints k=13, rows=3066
|
|
348
362
|
*
|
|
349
363
|
* Requirements:
|
|
350
364
|
*
|
|
@@ -369,7 +383,7 @@ module FungibleToken {
|
|
|
369
383
|
* @description Moves `value` tokens from `fromAddress` to `to` using the allowance mechanism.
|
|
370
384
|
* `value` is the deducted from the caller's allowance.
|
|
371
385
|
*
|
|
372
|
-
* @
|
|
386
|
+
* @constraints k=13, rows=4906
|
|
373
387
|
*
|
|
374
388
|
* @notice Transfers to contract addresses are currently disallowed until contract-to-contract
|
|
375
389
|
* interactions are supported in Compact. This restriction prevents assets from
|
|
@@ -403,7 +417,7 @@ module FungibleToken {
|
|
|
403
417
|
/**
|
|
404
418
|
* @description Unsafe variant of `transferFrom` which allows transfers to contract addresses.
|
|
405
419
|
*
|
|
406
|
-
* @
|
|
420
|
+
* @constraints k=13, rows=4903
|
|
407
421
|
*
|
|
408
422
|
* @warning Transfers to contract addresses are considered unsafe because contract-to-contract
|
|
409
423
|
* calls are not currently supported. Tokens sent to a contract address may become irretrievable.
|
|
@@ -440,7 +454,7 @@ module FungibleToken {
|
|
|
440
454
|
* This circuit is equivalent to {transfer}, and can be used to
|
|
441
455
|
* e.g. implement automatic token fees, slashing mechanisms, etc.
|
|
442
456
|
*
|
|
443
|
-
* @
|
|
457
|
+
* @constraints k=12, rows=2125
|
|
444
458
|
*
|
|
445
459
|
* @notice Transfers to contract addresses are currently disallowed until contract-to-contract
|
|
446
460
|
* interactions are supported in Compact. This restriction prevents assets from
|
|
@@ -473,7 +487,7 @@ module FungibleToken {
|
|
|
473
487
|
/**
|
|
474
488
|
* @description Unsafe variant of `transferFrom` which allows transfers to contract addresses.
|
|
475
489
|
*
|
|
476
|
-
* @
|
|
490
|
+
* @constraints k=12, rows=2122
|
|
477
491
|
*
|
|
478
492
|
* @warning Transfers to contract addresses are considered unsafe because contract-to-contract
|
|
479
493
|
* calls are not currently supported. Tokens sent to a contract address may become irretrievable.
|
|
@@ -507,7 +521,7 @@ module FungibleToken {
|
|
|
507
521
|
* (or `to`) is the zero address.
|
|
508
522
|
* @dev Checks for a mint overflow in order to output a more readable error message.
|
|
509
523
|
*
|
|
510
|
-
* @
|
|
524
|
+
* @constraints k=11, rows=1305
|
|
511
525
|
*
|
|
512
526
|
* Requirements:
|
|
513
527
|
*
|
|
@@ -551,7 +565,7 @@ module FungibleToken {
|
|
|
551
565
|
* @description Creates a `value` amount of tokens and assigns them to `account`,
|
|
552
566
|
* by transferring it from the zero address. Relies on the `update` mechanism.
|
|
553
567
|
*
|
|
554
|
-
* @
|
|
568
|
+
* @constraints k=11, rows=1328
|
|
555
569
|
*
|
|
556
570
|
* @notice Transfers to contract addresses are currently disallowed until contract-to-contract
|
|
557
571
|
* interactions are supported in Compact. This restriction prevents assets from
|
|
@@ -577,7 +591,7 @@ module FungibleToken {
|
|
|
577
591
|
/**
|
|
578
592
|
* @description Unsafe variant of `_mint` which allows transfers to contract addresses.
|
|
579
593
|
*
|
|
580
|
-
* @
|
|
594
|
+
* @constraints k=11, rows=1325
|
|
581
595
|
*
|
|
582
596
|
* @warning Transfers to contract addresses are considered unsafe because contract-to-contract
|
|
583
597
|
* calls are not currently supported. Tokens sent to a contract address may become irretrievable.
|
|
@@ -605,7 +619,7 @@ module FungibleToken {
|
|
|
605
619
|
* @description Destroys a `value` amount of tokens from `account`, lowering the total supply.
|
|
606
620
|
* Relies on the `_update` mechanism.
|
|
607
621
|
*
|
|
608
|
-
* @
|
|
622
|
+
* @constraints k=11, rows=1268
|
|
609
623
|
*
|
|
610
624
|
* Requirements:
|
|
611
625
|
*
|
|
@@ -628,7 +642,7 @@ module FungibleToken {
|
|
|
628
642
|
* This circuit is equivalent to `approve`, and can be used to
|
|
629
643
|
* e.g. set automatic allowances for certain subsystems, etc.
|
|
630
644
|
*
|
|
631
|
-
* @
|
|
645
|
+
* @constraints k=11, rows=1407
|
|
632
646
|
*
|
|
633
647
|
* Requirements:
|
|
634
648
|
*
|
|
@@ -667,7 +681,7 @@ module FungibleToken {
|
|
|
667
681
|
* @description Updates `owner`'s allowance for `spender` based on spent `value`.
|
|
668
682
|
* Does not update the allowance value in case of infinite allowance.
|
|
669
683
|
*
|
|
670
|
-
* @
|
|
684
|
+
* @constraints k=11, rows=1935
|
|
671
685
|
*
|
|
672
686
|
* Requirements:
|
|
673
687
|
*
|
package/token/MultiToken.compact
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.4.0-alpha.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.4.0-alpha.3 (token/MultiToken.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -176,7 +176,7 @@ module MultiToken {
|
|
|
176
176
|
/**
|
|
177
177
|
* @description Initializes the contract by setting the base URI for all tokens.
|
|
178
178
|
*
|
|
179
|
-
* @
|
|
179
|
+
* @constraints k=6, rows=31
|
|
180
180
|
*
|
|
181
181
|
* Requirements:
|
|
182
182
|
*
|
|
@@ -224,7 +224,7 @@ module MultiToken {
|
|
|
224
224
|
* Clients calling this function must replace the `\{id\}` substring with the
|
|
225
225
|
* actual token type ID.
|
|
226
226
|
*
|
|
227
|
-
* @
|
|
227
|
+
* @constraints k=8, rows=176
|
|
228
228
|
*
|
|
229
229
|
* Requirements:
|
|
230
230
|
*
|
|
@@ -241,7 +241,7 @@ module MultiToken {
|
|
|
241
241
|
/**
|
|
242
242
|
* @description Returns the amount of `id` tokens owned by `account`.
|
|
243
243
|
*
|
|
244
|
-
* @
|
|
244
|
+
* @constraints k=10, rows=867
|
|
245
245
|
*
|
|
246
246
|
* Requirements:
|
|
247
247
|
*
|
|
@@ -270,7 +270,7 @@ module MultiToken {
|
|
|
270
270
|
* In the case of an external (non-contract) caller, the caller's identity is derived from the `wit_MultiTokenSK`
|
|
271
271
|
* witness as `persistentHash(secretKey)`.
|
|
272
272
|
*
|
|
273
|
-
* @
|
|
273
|
+
* @constraints k=13, rows=2938
|
|
274
274
|
*
|
|
275
275
|
* Requirements:
|
|
276
276
|
*
|
|
@@ -295,7 +295,7 @@ module MultiToken {
|
|
|
295
295
|
/**
|
|
296
296
|
* @description Queries if `operator` is an authorized operator for `account`.
|
|
297
297
|
*
|
|
298
|
-
* @
|
|
298
|
+
* @constraints k=11, rows=1347
|
|
299
299
|
*
|
|
300
300
|
* Requirements:
|
|
301
301
|
*
|
|
@@ -332,7 +332,7 @@ module MultiToken {
|
|
|
332
332
|
* interactions are supported in Compact. This restriction prevents assets from
|
|
333
333
|
* being inadvertently locked in contracts that cannot currently handle token receipt.
|
|
334
334
|
*
|
|
335
|
-
* @
|
|
335
|
+
* @constraints k=13, rows=4833
|
|
336
336
|
*
|
|
337
337
|
* Requirements:
|
|
338
338
|
*
|
|
@@ -369,7 +369,7 @@ module MultiToken {
|
|
|
369
369
|
* interactions are supported in Compact. This restriction prevents assets from
|
|
370
370
|
* being inadvertently locked in contracts that cannot currently handle token receipt.
|
|
371
371
|
*
|
|
372
|
-
* @
|
|
372
|
+
* @constraints k=12, rows=2381
|
|
373
373
|
*
|
|
374
374
|
* Requirements:
|
|
375
375
|
*
|
|
@@ -462,7 +462,7 @@ module MultiToken {
|
|
|
462
462
|
* calls are not currently supported. Tokens sent to a contract address may become irretrievable.
|
|
463
463
|
* Once contract-to-contract calls are supported, this circuit may be deprecated.
|
|
464
464
|
*
|
|
465
|
-
* @
|
|
465
|
+
* @constraints k=13, rows=4832
|
|
466
466
|
*
|
|
467
467
|
* Requirements:
|
|
468
468
|
*
|
|
@@ -504,7 +504,7 @@ module MultiToken {
|
|
|
504
504
|
* calls are not currently supported. Tokens sent to a contract address may become irretrievable.
|
|
505
505
|
* Once contract-to-contract calls are supported, this circuit may be deprecated.
|
|
506
506
|
*
|
|
507
|
-
* @
|
|
507
|
+
* @constraints k=12, rows=2380
|
|
508
508
|
*
|
|
509
509
|
* Requirements:
|
|
510
510
|
*
|
|
@@ -546,7 +546,7 @@ module MultiToken {
|
|
|
546
546
|
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
|
|
547
547
|
* for token type ID 0x4cce0.
|
|
548
548
|
*
|
|
549
|
-
* @
|
|
549
|
+
* @constraints k=6, rows=26
|
|
550
550
|
*
|
|
551
551
|
* Requirements:
|
|
552
552
|
*
|
|
@@ -567,7 +567,7 @@ module MultiToken {
|
|
|
567
567
|
* interactions are supported in Compact. This restriction prevents assets from
|
|
568
568
|
* being inadvertently locked in contracts that cannot currently handle token receipt.
|
|
569
569
|
*
|
|
570
|
-
* @
|
|
570
|
+
* @constraints k=11, rows=1449
|
|
571
571
|
*
|
|
572
572
|
* Requirements:
|
|
573
573
|
*
|
|
@@ -596,7 +596,7 @@ module MultiToken {
|
|
|
596
596
|
* calls are not currently supported. Tokens sent to a contract address may become irretrievable.
|
|
597
597
|
* Once contract-to-contract calls are supported, this circuit may be deprecated.
|
|
598
598
|
*
|
|
599
|
-
* @
|
|
599
|
+
* @constraints k=11, rows=1448
|
|
600
600
|
*
|
|
601
601
|
* Requirements:
|
|
602
602
|
*
|
|
@@ -621,7 +621,7 @@ module MultiToken {
|
|
|
621
621
|
/**
|
|
622
622
|
* @description Destroys a `value` amount of tokens of type `id` from `fromAddress`.
|
|
623
623
|
*
|
|
624
|
-
* @
|
|
624
|
+
* @constraints k=11, rows=1275
|
|
625
625
|
*
|
|
626
626
|
* Requirements:
|
|
627
627
|
*
|
|
@@ -649,7 +649,7 @@ module MultiToken {
|
|
|
649
649
|
* @notice This circuit does not check for access permissions but can be useful as a building block
|
|
650
650
|
* for more complex contract logic.
|
|
651
651
|
*
|
|
652
|
-
* @
|
|
652
|
+
* @constraints k=11, rows=1280
|
|
653
653
|
*
|
|
654
654
|
* Requirements:
|
|
655
655
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// OpenZeppelin Compact Contracts v0.4.0-alpha.
|
|
2
|
+
// OpenZeppelin Compact Contracts v0.4.0-alpha.3 (token/NativeShieldedToken.compact)
|
|
3
3
|
|
|
4
4
|
pragma language_version >= 0.26.0;
|
|
5
5
|
|
|
@@ -20,6 +20,10 @@ pragma language_version >= 0.26.0;
|
|
|
20
20
|
* share one set of core state (a single init flag and one name/symbol/decimals).
|
|
21
21
|
* Pick one flavor per contract.
|
|
22
22
|
*
|
|
23
|
+
* @notice Recipients must be coin public keys: contract-addressed recipients
|
|
24
|
+
* are not supported at this layer. For a coin the contract holds itself, use
|
|
25
|
+
* `_mintToSelf`, which mints to `kernel.self()` and claims it in the same call.
|
|
26
|
+
*
|
|
23
27
|
* @notice This module exposes composable building blocks for minting and
|
|
24
28
|
* burning native shielded coins. It does NOT include access control: consuming
|
|
25
29
|
* contracts compose that via the module/contract pattern (Ownable,
|
|
@@ -106,7 +110,7 @@ module NativeShieldedToken {
|
|
|
106
110
|
/**
|
|
107
111
|
* @description Returns whether the contract has been initialized.
|
|
108
112
|
*
|
|
109
|
-
* @
|
|
113
|
+
* @constraints k=6, rows=24
|
|
110
114
|
*
|
|
111
115
|
* @return {Boolean} - True once `initialize` has run.
|
|
112
116
|
*/
|
|
@@ -117,7 +121,7 @@ module NativeShieldedToken {
|
|
|
117
121
|
/**
|
|
118
122
|
* @description Returns the token name.
|
|
119
123
|
*
|
|
120
|
-
* @
|
|
124
|
+
* @constraints k=6, rows=26
|
|
121
125
|
*
|
|
122
126
|
* Requirements:
|
|
123
127
|
*
|
|
@@ -132,7 +136,7 @@ module NativeShieldedToken {
|
|
|
132
136
|
/**
|
|
133
137
|
* @description Returns the symbol of the token.
|
|
134
138
|
*
|
|
135
|
-
* @
|
|
139
|
+
* @constraints k=6, rows=26
|
|
136
140
|
*
|
|
137
141
|
* Requirements:
|
|
138
142
|
*
|
|
@@ -147,7 +151,7 @@ module NativeShieldedToken {
|
|
|
147
151
|
/**
|
|
148
152
|
* @description Returns the number of decimals used to get its user representation.
|
|
149
153
|
*
|
|
150
|
-
* @
|
|
154
|
+
* @constraints k=6, rows=26
|
|
151
155
|
*
|
|
152
156
|
* Requirements:
|
|
153
157
|
*
|
|
@@ -163,7 +167,7 @@ module NativeShieldedToken {
|
|
|
163
167
|
* @description Returns this token's coin color:
|
|
164
168
|
* `tokenType(_domain, kernel.self())`, computed at call time.
|
|
165
169
|
*
|
|
166
|
-
* @
|
|
170
|
+
* @constraints k=13, rows=3962
|
|
167
171
|
*
|
|
168
172
|
* Requirements:
|
|
169
173
|
*
|
|
@@ -190,25 +194,65 @@ module NativeShieldedToken {
|
|
|
190
194
|
* recipient; callers SHOULD deliver it out of band. Wallets cannot detect
|
|
191
195
|
* contract-minted coins by scanning the chain.
|
|
192
196
|
*
|
|
193
|
-
* @
|
|
197
|
+
* @constraints k=14, rows=10450
|
|
194
198
|
*
|
|
195
199
|
* Requirements:
|
|
196
200
|
*
|
|
197
201
|
* - Contract is initialized.
|
|
198
202
|
* - `recipient` is not zero.
|
|
199
203
|
*
|
|
200
|
-
* @param {
|
|
204
|
+
* @param {ZswapCoinPublicKey} recipient - The coin recipient.
|
|
201
205
|
* @param {Uint<64>} amount - Quantity to mint. Capped at `Uint<64>` by the protocol.
|
|
202
206
|
* @param {Bytes<32>} nonce - Caller-supplied nonce. Must be unique for this
|
|
203
207
|
* contract's color.
|
|
204
208
|
* @return {ShieldedCoinInfo} - The newly created coin's info (nonce, color, value).
|
|
205
209
|
*/
|
|
206
210
|
export circuit _mint(
|
|
207
|
-
recipient:
|
|
211
|
+
recipient: ZswapCoinPublicKey,
|
|
212
|
+
amount: Uint<64>,
|
|
213
|
+
nonce: Bytes<32>
|
|
214
|
+
): ShieldedCoinInfo {
|
|
215
|
+
return Core__mint(
|
|
216
|
+
_domain,
|
|
217
|
+
left<ZswapCoinPublicKey, ContractAddress>(recipient),
|
|
218
|
+
amount,
|
|
219
|
+
nonce
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @description Mints `amount` to this contract itself, claiming the coin in
|
|
225
|
+
* the same call. Forwards to `NativeShieldedTokenCore._mint` with
|
|
226
|
+
* `right(kernel.self())`.
|
|
227
|
+
*
|
|
228
|
+
* @dev Nonce uniqueness is the caller's responsibility, as in `_mint`. Spend
|
|
229
|
+
* the coin later with `_burnFromSelf`, once it carries an `mt_index`.
|
|
230
|
+
*
|
|
231
|
+
* @notice The consumer SHOULD persist the returned coin info in its own
|
|
232
|
+
* ledger state: it is the contract's holding and is not otherwise
|
|
233
|
+
* recoverable.
|
|
234
|
+
*
|
|
235
|
+
* @constraints k=14, rows=16033
|
|
236
|
+
*
|
|
237
|
+
* Requirements:
|
|
238
|
+
*
|
|
239
|
+
* - Contract is initialized.
|
|
240
|
+
*
|
|
241
|
+
* @param {Uint<64>} amount - Quantity to mint. Capped at `Uint<64>` by the protocol.
|
|
242
|
+
* @param {Bytes<32>} nonce - Caller-supplied nonce. Must be unique for this
|
|
243
|
+
* contract's color.
|
|
244
|
+
* @return {ShieldedCoinInfo} - The newly created coin's info (nonce, color, value).
|
|
245
|
+
*/
|
|
246
|
+
export circuit _mintToSelf(
|
|
208
247
|
amount: Uint<64>,
|
|
209
248
|
nonce: Bytes<32>
|
|
210
249
|
): ShieldedCoinInfo {
|
|
211
|
-
return Core__mint(
|
|
250
|
+
return Core__mint(
|
|
251
|
+
_domain,
|
|
252
|
+
right<ZswapCoinPublicKey, ContractAddress>(kernel.self()),
|
|
253
|
+
amount,
|
|
254
|
+
nonce
|
|
255
|
+
);
|
|
212
256
|
}
|
|
213
257
|
|
|
214
258
|
/**
|
|
@@ -229,7 +273,7 @@ module NativeShieldedToken {
|
|
|
229
273
|
* `refundTo`; callers SHOULD deliver it out of band. Wallets cannot detect
|
|
230
274
|
* contract-sent coins by scanning the chain.
|
|
231
275
|
*
|
|
232
|
-
* @
|
|
276
|
+
* @constraints k=16, rows=41327
|
|
233
277
|
*
|
|
234
278
|
* Requirements:
|
|
235
279
|
*
|
|
@@ -241,17 +285,22 @@ module NativeShieldedToken {
|
|
|
241
285
|
*
|
|
242
286
|
* @param {ShieldedCoinInfo} coin - The coin to burn from.
|
|
243
287
|
* @param {Uint<128>} amount - Value to destroy. Must be <= `coin.value`.
|
|
244
|
-
* @param {
|
|
245
|
-
*
|
|
288
|
+
* @param {ZswapCoinPublicKey} refundTo - Where to route the unspent
|
|
289
|
+
* portion (`coin.value - amount`).
|
|
246
290
|
* @return {Maybe<ShieldedCoinInfo>} - The refund coin created for `refundTo`,
|
|
247
291
|
* or `none` if the coin was burned in full.
|
|
248
292
|
*/
|
|
249
293
|
export circuit _burn(
|
|
250
294
|
coin: ShieldedCoinInfo,
|
|
251
295
|
amount: Uint<128>,
|
|
252
|
-
refundTo:
|
|
296
|
+
refundTo: ZswapCoinPublicKey
|
|
253
297
|
): Maybe<ShieldedCoinInfo> {
|
|
254
|
-
return Core__burn(
|
|
298
|
+
return Core__burn(
|
|
299
|
+
_domain,
|
|
300
|
+
coin,
|
|
301
|
+
amount,
|
|
302
|
+
left<ZswapCoinPublicKey, ContractAddress>(refundTo)
|
|
303
|
+
);
|
|
255
304
|
}
|
|
256
305
|
|
|
257
306
|
/**
|
|
@@ -263,7 +312,7 @@ module NativeShieldedToken {
|
|
|
263
312
|
* ledger state: the change replaces `coin` as the contract's holding, and
|
|
264
313
|
* its info is not otherwise recoverable.
|
|
265
314
|
*
|
|
266
|
-
* @
|
|
315
|
+
* @constraints k=15, rows=23208
|
|
267
316
|
*
|
|
268
317
|
* Requirements:
|
|
269
318
|
*
|