@silvana-one/nft 0.2.11 → 1.0.0
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 +12 -0
- package/dist/node/contracts/admin.d.ts +100 -10
- package/dist/node/contracts/admin.js +130 -29
- package/dist/node/contracts/admin.js.map +1 -1
- package/dist/node/contracts/collection.d.ts +51 -34
- package/dist/node/contracts/collection.js +162 -71
- package/dist/node/contracts/collection.js.map +1 -1
- package/dist/node/contracts/nft.js +3 -0
- package/dist/node/contracts/nft.js.map +1 -1
- package/dist/node/contracts.d.ts +36 -30
- package/dist/node/index.cjs +447 -182
- package/dist/node/interfaces/collection.d.ts +5 -5
- package/dist/node/interfaces/events.d.ts +306 -16
- package/dist/node/interfaces/events.js +42 -4
- package/dist/node/interfaces/events.js.map +1 -1
- package/dist/node/interfaces/ownable.d.ts +7 -7
- package/dist/node/interfaces/ownable.js.map +1 -1
- package/dist/node/interfaces/pausable.d.ts +3 -3
- package/dist/node/interfaces/pausable.js.map +1 -1
- package/dist/node/interfaces/types.d.ts +182 -27
- package/dist/node/interfaces/types.js +120 -71
- package/dist/node/interfaces/types.js.map +1 -1
- package/dist/node/marketplace/auction.d.ts +2 -2
- package/dist/node/marketplace/auction.js +4 -4
- package/dist/node/marketplace/auction.js.map +1 -1
- package/dist/node/marketplace/bid.js +3 -5
- package/dist/node/marketplace/bid.js.map +1 -1
- package/dist/node/marketplace/nft-shares.d.ts +2 -2
- package/dist/node/util/div.js +10 -5
- package/dist/node/util/div.js.map +1 -1
- package/dist/node/vk.js +6 -6
- package/dist/node/vk.js.map +1 -1
- package/dist/node/zkprogram-example/game.d.ts +2 -2
- package/dist/node/zkprogram-example/update.d.ts +2 -2
- package/dist/tsconfig.node.tsbuildinfo +1 -1
- package/dist/tsconfig.web.tsbuildinfo +1 -1
- package/dist/web/contracts/admin.d.ts +100 -10
- package/dist/web/contracts/admin.js +130 -29
- package/dist/web/contracts/admin.js.map +1 -1
- package/dist/web/contracts/collection.d.ts +51 -34
- package/dist/web/contracts/collection.js +162 -71
- package/dist/web/contracts/collection.js.map +1 -1
- package/dist/web/contracts/nft.js +3 -0
- package/dist/web/contracts/nft.js.map +1 -1
- package/dist/web/contracts.d.ts +36 -30
- package/dist/web/interfaces/collection.d.ts +5 -5
- package/dist/web/interfaces/events.d.ts +306 -16
- package/dist/web/interfaces/events.js +42 -4
- package/dist/web/interfaces/events.js.map +1 -1
- package/dist/web/interfaces/ownable.d.ts +7 -7
- package/dist/web/interfaces/ownable.js.map +1 -1
- package/dist/web/interfaces/pausable.d.ts +3 -3
- package/dist/web/interfaces/pausable.js.map +1 -1
- package/dist/web/interfaces/types.d.ts +182 -27
- package/dist/web/interfaces/types.js +120 -71
- package/dist/web/interfaces/types.js.map +1 -1
- package/dist/web/marketplace/auction.d.ts +2 -2
- package/dist/web/marketplace/auction.js +4 -4
- package/dist/web/marketplace/auction.js.map +1 -1
- package/dist/web/marketplace/bid.js +3 -5
- package/dist/web/marketplace/bid.js.map +1 -1
- package/dist/web/marketplace/nft-shares.d.ts +2 -2
- package/dist/web/util/div.js +10 -5
- package/dist/web/util/div.js.map +1 -1
- package/dist/web/vk.js +6 -6
- package/dist/web/vk.js.map +1 -1
- package/dist/web/zkprogram-example/game.d.ts +2 -2
- package/dist/web/zkprogram-example/update.d.ts +2 -2
- package/package.json +8 -8
- package/src/contracts/admin.ts +137 -24
- package/src/contracts/collection.ts +188 -96
- package/src/contracts/nft.ts +3 -0
- package/src/interfaces/collection.ts +11 -5
- package/src/interfaces/events.ts +47 -3
- package/src/interfaces/ownable.ts +1 -1
- package/src/interfaces/pausable.ts +1 -1
- package/src/interfaces/types.ts +152 -78
- package/src/marketplace/auction.ts +5 -4
- package/src/marketplace/bid.ts +4 -6
- package/src/util/div.ts +12 -5
- package/src/vk.ts +6 -6
package/dist/node/index.cjs
CHANGED
|
@@ -67,6 +67,7 @@ __export(index_exports, {
|
|
|
67
67
|
NFT: () => NFT,
|
|
68
68
|
NFTAddress: () => NFTAddress,
|
|
69
69
|
NFTAdmin: () => NFTAdmin,
|
|
70
|
+
NFTAdminAllowFlags: () => NFTAdminAllowFlags,
|
|
70
71
|
NFTAdvancedAdmin: () => NFTAdvancedAdmin,
|
|
71
72
|
NFTAdvancedAdminContract: () => NFTAdvancedAdminContract,
|
|
72
73
|
NFTData: () => NFTData,
|
|
@@ -83,6 +84,7 @@ __export(index_exports, {
|
|
|
83
84
|
NFTState: () => NFTState,
|
|
84
85
|
NFTStateStruct: () => NFTStateStruct,
|
|
85
86
|
NFTTransactionContext: () => NFTTransactionContext,
|
|
87
|
+
NFTUpdateEvent: () => NFTUpdateEvent,
|
|
86
88
|
NFTUpdateProof: () => NFTUpdateProof,
|
|
87
89
|
NonFungibleTokenContractsFactory: () => NonFungibleTokenContractsFactory,
|
|
88
90
|
Offer: () => Offer,
|
|
@@ -92,11 +94,17 @@ __export(index_exports, {
|
|
|
92
94
|
PauseEvent: () => PauseEvent,
|
|
93
95
|
PauseNFTEvent: () => PauseNFTEvent,
|
|
94
96
|
SellEvent: () => SellEvent,
|
|
97
|
+
SetAdminEvent: () => SetAdminEvent,
|
|
98
|
+
SetBaseURLEvent: () => SetBaseURLEvent,
|
|
99
|
+
SetNameEvent: () => SetNameEvent,
|
|
100
|
+
SetRoyaltyFeeEvent: () => SetRoyaltyFeeEvent,
|
|
101
|
+
SetTransferFeeEvent: () => SetTransferFeeEvent,
|
|
95
102
|
TEXT_TREE_HEIGHT: () => TEXT_TREE_HEIGHT,
|
|
96
103
|
Text: () => Text,
|
|
104
|
+
TransferByProofParams: () => TransferByProofParams,
|
|
105
|
+
TransferBySignatureParams: () => TransferBySignatureParams,
|
|
97
106
|
TransferEvent: () => TransferEvent,
|
|
98
107
|
TransferExtendedParams: () => TransferExtendedParams,
|
|
99
|
-
TransferParams: () => TransferParams,
|
|
100
108
|
UInt64Option: () => UInt64Option,
|
|
101
109
|
Update: () => Update,
|
|
102
110
|
UpdateEvent: () => UpdateEvent,
|
|
@@ -197,7 +205,10 @@ var NFTImmutableState = class _NFTImmutableState extends (0, import_o1js.Struct)
|
|
|
197
205
|
/** The token ID associated with the NFT (readonly). */
|
|
198
206
|
tokenId: import_o1js.Field,
|
|
199
207
|
// readonly
|
|
200
|
-
/** The
|
|
208
|
+
/** The identifier of the NFT within the collection to be used off-chain(readonly).
|
|
209
|
+
* It can be set to any value chosen by the creator for the new NFTs
|
|
210
|
+
* and by default is set to 0. To uniquely identify the NFT, use the pair (NFT address, tokenId) or (collection address, NFT address)
|
|
211
|
+
*/
|
|
201
212
|
id: import_o1js.UInt64
|
|
202
213
|
// readonly
|
|
203
214
|
}) {
|
|
@@ -269,7 +280,7 @@ var NFTState = class _NFTState extends (0, import_o1js.Struct)({
|
|
|
269
280
|
/** The off-chain storage information (e.g., IPFS hash). */
|
|
270
281
|
storage: import_storage.Storage,
|
|
271
282
|
/** The version number of the NFT state. */
|
|
272
|
-
version: import_o1js.
|
|
283
|
+
version: import_o1js.UInt64,
|
|
273
284
|
/** Indicates whether the NFT contract is currently paused. */
|
|
274
285
|
isPaused: import_o1js.Bool,
|
|
275
286
|
/** The hash of the verification key used for metadata proofs. */
|
|
@@ -301,6 +312,7 @@ var NFTState = class _NFTState extends (0, import_o1js.Struct)({
|
|
|
301
312
|
a.metadataVerificationKeyHash.assertEquals(b.metadataVerificationKeyHash);
|
|
302
313
|
a.creator.assertEquals(b.creator);
|
|
303
314
|
NFTTransactionContext.assertEqual(a.context, b.context);
|
|
315
|
+
a.oracleAddress.assertEquals(b.oracleAddress);
|
|
304
316
|
}
|
|
305
317
|
/**
|
|
306
318
|
* Creates a new NFTState from an NFTStateStruct and other parameters.
|
|
@@ -344,16 +356,24 @@ var NFTData = class _NFTData extends (0, import_o1js.Struct)({
|
|
|
344
356
|
/** The approved address of the NFT. */
|
|
345
357
|
approved: import_o1js.PublicKey,
|
|
346
358
|
/** The version number of the NFT state. */
|
|
347
|
-
version: import_o1js.
|
|
359
|
+
version: import_o1js.UInt64,
|
|
348
360
|
/** The unique identifier of the NFT within the collection. */
|
|
349
361
|
id: import_o1js.UInt64,
|
|
350
|
-
/** Determines whether the NFT's ownership can be changed via a zero-knowledge proof (readonly).
|
|
362
|
+
/** Determines whether the NFT's ownership can be changed via a zero-knowledge proof (readonly).
|
|
363
|
+
*
|
|
364
|
+
* It can be used only with update() and updateWithOracle() methods and
|
|
365
|
+
* in this case overrides both canTransfer and canApprove flags used in the transfer methods
|
|
366
|
+
*/
|
|
351
367
|
canChangeOwnerByProof: import_o1js.Bool,
|
|
352
368
|
// readonly
|
|
353
|
-
/** Specifies if the NFT's ownership can be transferred (readonly).
|
|
369
|
+
/** Specifies if the NFT's ownership can be transferred (readonly). Applies
|
|
370
|
+
* to transfer methods and can be bypassed by the update() and updateWithOracle() methods
|
|
371
|
+
*/
|
|
354
372
|
canTransfer: import_o1js.Bool,
|
|
355
373
|
// readonly
|
|
356
|
-
/** Specifies if the NFT's approved address can be changed (readonly).
|
|
374
|
+
/** Specifies if the NFT's approved address can be changed (readonly). Transfer methods reset approved address to PublicKey.empty()
|
|
375
|
+
* on transfer independently from the canApprove flag value
|
|
376
|
+
*/
|
|
357
377
|
canApprove: import_o1js.Bool,
|
|
358
378
|
// readonly
|
|
359
379
|
/** Indicates whether the NFT's metadata can be updated (readonly). */
|
|
@@ -387,7 +407,7 @@ var NFTData = class _NFTData extends (0, import_o1js.Struct)({
|
|
|
387
407
|
return new _NFTData({
|
|
388
408
|
owner: typeof owner === "string" ? import_o1js.PublicKey.fromBase58(owner) : owner,
|
|
389
409
|
approved: approved ? typeof approved === "string" ? import_o1js.PublicKey.fromBase58(approved) : approved : import_o1js.PublicKey.empty(),
|
|
390
|
-
version: import_o1js.
|
|
410
|
+
version: import_o1js.UInt64.from(BigInt(version ?? 0)),
|
|
391
411
|
id: import_o1js.UInt64.from(BigInt(id ?? 0)),
|
|
392
412
|
canChangeOwnerByProof: (0, import_o1js.Bool)(canChangeOwnerByProof ?? false),
|
|
393
413
|
canTransfer: (0, import_o1js.Bool)(canTransfer ?? true),
|
|
@@ -406,14 +426,10 @@ var NFTData = class _NFTData extends (0, import_o1js.Struct)({
|
|
|
406
426
|
* @returns The packed Field representation of the NFTData.
|
|
407
427
|
*/
|
|
408
428
|
pack() {
|
|
409
|
-
const id = this.id.value.toBits(64);
|
|
410
|
-
const version = this.version.value.toBits(32);
|
|
411
429
|
return new NFTDataPacked({
|
|
412
430
|
ownerX: this.owner.x,
|
|
413
431
|
approvedX: this.approved.x,
|
|
414
432
|
data: import_o1js.Field.fromBits([
|
|
415
|
-
...id,
|
|
416
|
-
...version,
|
|
417
433
|
this.canChangeOwnerByProof,
|
|
418
434
|
this.canTransfer,
|
|
419
435
|
this.canApprove,
|
|
@@ -426,7 +442,7 @@ var NFTData = class _NFTData extends (0, import_o1js.Struct)({
|
|
|
426
442
|
this.requireOwnerAuthorizationToUpgrade,
|
|
427
443
|
this.owner.isOdd,
|
|
428
444
|
this.approved.isOdd
|
|
429
|
-
])
|
|
445
|
+
]).add((0, import_o1js.Field)(this.id.value).mul((0, import_o1js.Field)(2 ** 12))).add((0, import_o1js.Field)(this.version.value).mul((0, import_o1js.Field)(2 ** (12 + 64))))
|
|
430
446
|
});
|
|
431
447
|
}
|
|
432
448
|
/**
|
|
@@ -435,42 +451,52 @@ var NFTData = class _NFTData extends (0, import_o1js.Struct)({
|
|
|
435
451
|
* @returns A new NFTData instance.
|
|
436
452
|
*/
|
|
437
453
|
static unpack(packed) {
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
454
|
+
const unpacked = import_o1js.Provable.witness(_NFTData, () => {
|
|
455
|
+
const bits = import_o1js.Gadgets.and(packed.data, (0, import_o1js.Field)(0xfffn), 12 + 64 + 64).toBits(12);
|
|
456
|
+
const idField = import_o1js.Gadgets.and(packed.data, (0, import_o1js.Field)(0xffffffffffffffff000n), 12 + 64 + 64);
|
|
457
|
+
const idBits = idField.toBits(64 + 12);
|
|
458
|
+
const id = import_o1js.UInt64.Unsafe.fromField(import_o1js.Field.fromBits(idBits.slice(12, 64 + 12)));
|
|
459
|
+
id.value.mul((0, import_o1js.Field)(2 ** 12)).assertEquals(idField);
|
|
460
|
+
const versionField = import_o1js.Gadgets.and(packed.data, (0, import_o1js.Field)(0xffffffffffffffff0000000000000000000n), 64 + 64 + 12);
|
|
461
|
+
const versionBits = versionField.toBits(12 + 64 + 64);
|
|
462
|
+
const version = import_o1js.UInt64.Unsafe.fromField(import_o1js.Field.fromBits(versionBits.slice(12 + 64, 12 + 64 + 64)));
|
|
463
|
+
version.value.mul((0, import_o1js.Field)(2 ** (12 + 64))).assertEquals(versionField);
|
|
464
|
+
const canChangeOwnerByProof = bits[0];
|
|
465
|
+
const canTransfer = bits[1];
|
|
466
|
+
const canApprove = bits[2];
|
|
467
|
+
const canChangeMetadata = bits[3];
|
|
468
|
+
const canChangeStorage = bits[4];
|
|
469
|
+
const canChangeName = bits[5];
|
|
470
|
+
const canChangeMetadataVerificationKeyHash = bits[6];
|
|
471
|
+
const canPause = bits[7];
|
|
472
|
+
const isPaused = bits[8];
|
|
473
|
+
const requireOwnerAuthorizationToUpgrade = bits[9];
|
|
474
|
+
const ownerIsOdd = bits[10];
|
|
475
|
+
const approvedIsOdd = bits[11];
|
|
476
|
+
const owner = import_o1js.PublicKey.from({ x: packed.ownerX, isOdd: ownerIsOdd });
|
|
477
|
+
const approved = import_o1js.PublicKey.from({
|
|
478
|
+
x: packed.approvedX,
|
|
479
|
+
isOdd: approvedIsOdd
|
|
480
|
+
});
|
|
481
|
+
return new _NFTData({
|
|
482
|
+
owner,
|
|
483
|
+
approved,
|
|
484
|
+
id,
|
|
485
|
+
version,
|
|
486
|
+
canChangeOwnerByProof,
|
|
487
|
+
canTransfer,
|
|
488
|
+
canApprove,
|
|
489
|
+
canChangeMetadata,
|
|
490
|
+
canChangeStorage,
|
|
491
|
+
canChangeName,
|
|
492
|
+
canChangeMetadataVerificationKeyHash,
|
|
493
|
+
canPause,
|
|
494
|
+
isPaused,
|
|
495
|
+
requireOwnerAuthorizationToUpgrade
|
|
496
|
+
});
|
|
473
497
|
});
|
|
498
|
+
NFTDataPacked.assertEqual(unpacked.pack(), packed);
|
|
499
|
+
return unpacked;
|
|
474
500
|
}
|
|
475
501
|
};
|
|
476
502
|
var MAX_ROYALTY_FEE = 1e5;
|
|
@@ -485,7 +511,9 @@ var CollectionData = class _CollectionData extends (0, import_o1js.Struct)({
|
|
|
485
511
|
/** If true, the minting is stopped and cannot be resumed. */
|
|
486
512
|
mintingIsLimited: import_o1js.Bool,
|
|
487
513
|
/** Indicates whether the collection is currently paused. */
|
|
488
|
-
isPaused: import_o1js.Bool
|
|
514
|
+
isPaused: import_o1js.Bool,
|
|
515
|
+
/** The public key part (isOdd) of the pending creator. The x field is written to the contract state as pendingCreatorX */
|
|
516
|
+
pendingCreatorIsOdd: import_o1js.Bool
|
|
489
517
|
}) {
|
|
490
518
|
/**
|
|
491
519
|
* Creates a new CollectionData instance with specified parameters.
|
|
@@ -499,7 +527,8 @@ var CollectionData = class _CollectionData extends (0, import_o1js.Struct)({
|
|
|
499
527
|
transferFee: import_o1js.UInt64.from(BigInt(transferFee ?? 0)),
|
|
500
528
|
requireTransferApproval: (0, import_o1js.Bool)(requireTransferApproval ?? false),
|
|
501
529
|
mintingIsLimited: (0, import_o1js.Bool)(mintingIsLimited ?? false),
|
|
502
|
-
isPaused: (0, import_o1js.Bool)(isPaused ?? false)
|
|
530
|
+
isPaused: (0, import_o1js.Bool)(isPaused ?? false),
|
|
531
|
+
pendingCreatorIsOdd: (0, import_o1js.Bool)(import_o1js.PublicKey.empty().isOdd)
|
|
503
532
|
});
|
|
504
533
|
}
|
|
505
534
|
/**
|
|
@@ -511,9 +540,8 @@ var CollectionData = class _CollectionData extends (0, import_o1js.Struct)({
|
|
|
511
540
|
this.isPaused,
|
|
512
541
|
this.requireTransferApproval,
|
|
513
542
|
this.mintingIsLimited,
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
]);
|
|
543
|
+
this.pendingCreatorIsOdd
|
|
544
|
+
]).add((0, import_o1js.Field)(this.royaltyFee.value).mul((0, import_o1js.Field)(2 ** 4))).add((0, import_o1js.Field)(this.transferFee.value).mul((0, import_o1js.Field)(2 ** (4 + 32))));
|
|
517
545
|
}
|
|
518
546
|
/**
|
|
519
547
|
* Unpacks a CollectionDataPacked instance into a CollectionData instance.
|
|
@@ -521,28 +549,33 @@ var CollectionData = class _CollectionData extends (0, import_o1js.Struct)({
|
|
|
521
549
|
* @returns A new CollectionData instance.
|
|
522
550
|
*/
|
|
523
551
|
static unpack(packed) {
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
transferFee
|
|
552
|
+
const unpacked = import_o1js.Provable.witness(_CollectionData, () => {
|
|
553
|
+
const bits = import_o1js.Gadgets.and(packed, (0, import_o1js.Field)(0xfn), 4 + 32 + 64).toBits(4);
|
|
554
|
+
const royaltyFeeField = import_o1js.Gadgets.and(packed, (0, import_o1js.Field)(0xffffffff0n), 4 + 32 + 64);
|
|
555
|
+
const royaltyFeeBits = royaltyFeeField.toBits(4 + 32);
|
|
556
|
+
const royaltyFee = import_o1js.UInt32.Unsafe.fromField(import_o1js.Field.fromBits(royaltyFeeBits.slice(4, 4 + 32)));
|
|
557
|
+
royaltyFee.value.mul((0, import_o1js.Field)(2 ** 4)).assertEquals(royaltyFeeField);
|
|
558
|
+
const transferFeeField = import_o1js.Gadgets.and(packed, (0, import_o1js.Field)(0xffffffffffffffff000000000n), 4 + 32 + 64);
|
|
559
|
+
const transferFeeBits = transferFeeField.toBits(4 + 32 + 64);
|
|
560
|
+
const transferFee = import_o1js.UInt64.Unsafe.fromField(import_o1js.Field.fromBits(transferFeeBits.slice(4 + 32, 4 + 32 + 64)));
|
|
561
|
+
transferFee.value.mul((0, import_o1js.Field)(2 ** (4 + 32))).assertEquals(transferFeeField);
|
|
562
|
+
return new _CollectionData({
|
|
563
|
+
isPaused: bits[0],
|
|
564
|
+
requireTransferApproval: bits[1],
|
|
565
|
+
mintingIsLimited: bits[2],
|
|
566
|
+
pendingCreatorIsOdd: bits[3],
|
|
567
|
+
royaltyFee,
|
|
568
|
+
transferFee
|
|
569
|
+
});
|
|
533
570
|
});
|
|
571
|
+
unpacked.pack().assertEquals(packed);
|
|
572
|
+
return unpacked;
|
|
534
573
|
}
|
|
535
574
|
static isPaused(packed) {
|
|
536
|
-
return packed.toBits(
|
|
575
|
+
return packed.toBits(4 + 32 + 64)[0];
|
|
537
576
|
}
|
|
538
577
|
static requireTransferApproval(packed) {
|
|
539
|
-
return packed.toBits(
|
|
540
|
-
}
|
|
541
|
-
static mintingIsLimited(packed) {
|
|
542
|
-
const bits = packed.toBits(3 + 32 + 64);
|
|
543
|
-
const isPaused = bits[0];
|
|
544
|
-
const mintingIsLimited = bits[2];
|
|
545
|
-
return isPaused.or(mintingIsLimited);
|
|
578
|
+
return packed.toBits(4 + 32 + 64)[1];
|
|
546
579
|
}
|
|
547
580
|
};
|
|
548
581
|
var MintParams = class extends (0, import_o1js.Struct)({
|
|
@@ -579,7 +612,18 @@ var MintRequest = class extends (0, import_o1js.Struct)({
|
|
|
579
612
|
// should be interpreted by the admin contract
|
|
580
613
|
}) {
|
|
581
614
|
};
|
|
582
|
-
var
|
|
615
|
+
var TransferBySignatureParams = class extends (0, import_o1js.Struct)({
|
|
616
|
+
/** The address of the NFT contract. */
|
|
617
|
+
address: import_o1js.PublicKey,
|
|
618
|
+
/** The receiver's public key. */
|
|
619
|
+
to: import_o1js.PublicKey,
|
|
620
|
+
/** Optional price for the transfer. */
|
|
621
|
+
price: UInt64Option,
|
|
622
|
+
/** Custom value that can be interpreted by the owner or approved contract. */
|
|
623
|
+
context: NFTTransactionContext
|
|
624
|
+
}) {
|
|
625
|
+
};
|
|
626
|
+
var TransferByProofParams = class extends (0, import_o1js.Struct)({
|
|
583
627
|
/** The address of the NFT contract. */
|
|
584
628
|
address: import_o1js.PublicKey,
|
|
585
629
|
/** The sender's public key. */
|
|
@@ -633,7 +677,15 @@ var MintEvent = class extends (0, import_o1js3.Struct)({
|
|
|
633
677
|
/** The initial state of the NFT at the time of minting. */
|
|
634
678
|
initialState: NFTStateStruct,
|
|
635
679
|
/** The public key address of the minted NFT. */
|
|
636
|
-
address: import_o1js3.PublicKey
|
|
680
|
+
address: import_o1js3.PublicKey,
|
|
681
|
+
/** The token ID of the minted NFT. */
|
|
682
|
+
tokenId: import_o1js3.Field,
|
|
683
|
+
/** The fee paid for the minting.
|
|
684
|
+
* This fee is controlled by the admin contract
|
|
685
|
+
* and is not checked by the Collection contract
|
|
686
|
+
* Please check the admin contract code before using this fee
|
|
687
|
+
*/
|
|
688
|
+
fee: import_o1js3.UInt64
|
|
637
689
|
}) {
|
|
638
690
|
};
|
|
639
691
|
var UpdateEvent = class extends (0, import_o1js3.Struct)({
|
|
@@ -648,7 +700,7 @@ var UpdateEvent = class extends (0, import_o1js3.Struct)({
|
|
|
648
700
|
/** The approved address of the NFT after the update. */
|
|
649
701
|
approved: import_o1js3.PublicKey,
|
|
650
702
|
/** The version number of the NFT state. */
|
|
651
|
-
version: import_o1js3.
|
|
703
|
+
version: import_o1js3.UInt64,
|
|
652
704
|
/** Indicates whether the NFT is paused after the update. */
|
|
653
705
|
isPaused: import_o1js3.Bool,
|
|
654
706
|
/** The hash of the verification key used for metadata proofs. */
|
|
@@ -693,7 +745,7 @@ var UpgradeVerificationKeyEvent = class extends (0, import_o1js3.Struct)({
|
|
|
693
745
|
verificationKeyHash: import_o1js3.Field,
|
|
694
746
|
/** The public key address of the NFT whose verification key is upgraded. */
|
|
695
747
|
address: import_o1js3.PublicKey,
|
|
696
|
-
/** The
|
|
748
|
+
/** The tokenId of the upgraded contract */
|
|
697
749
|
tokenId: import_o1js3.Field
|
|
698
750
|
}) {
|
|
699
751
|
};
|
|
@@ -709,6 +761,36 @@ var LimitMintingEvent = class extends (0, import_o1js3.Struct)({
|
|
|
709
761
|
mintingLimited: import_o1js3.Bool
|
|
710
762
|
}) {
|
|
711
763
|
};
|
|
764
|
+
var NFTUpdateEvent = class extends (0, import_o1js3.Struct)({
|
|
765
|
+
/** The public key address of the NFT. */
|
|
766
|
+
address: import_o1js3.PublicKey
|
|
767
|
+
}) {
|
|
768
|
+
};
|
|
769
|
+
var SetNameEvent = class extends (0, import_o1js3.Struct)({
|
|
770
|
+
/** The updated name of the Collection. */
|
|
771
|
+
name: import_o1js3.Field
|
|
772
|
+
}) {
|
|
773
|
+
};
|
|
774
|
+
var SetBaseURLEvent = class extends (0, import_o1js3.Struct)({
|
|
775
|
+
/** The updated base URL of the Collection. */
|
|
776
|
+
baseURL: import_o1js3.Field
|
|
777
|
+
}) {
|
|
778
|
+
};
|
|
779
|
+
var SetRoyaltyFeeEvent = class extends (0, import_o1js3.Struct)({
|
|
780
|
+
/** The updated royalty fee of the Collection. */
|
|
781
|
+
royaltyFee: import_o1js3.UInt32
|
|
782
|
+
}) {
|
|
783
|
+
};
|
|
784
|
+
var SetTransferFeeEvent = class extends (0, import_o1js3.Struct)({
|
|
785
|
+
/** The updated transfer fee of the Collection. */
|
|
786
|
+
transferFee: import_o1js3.UInt64
|
|
787
|
+
}) {
|
|
788
|
+
};
|
|
789
|
+
var SetAdminEvent = class extends (0, import_o1js3.Struct)({
|
|
790
|
+
/** The updated admin contract of the Collection. */
|
|
791
|
+
admin: import_o1js3.PublicKey
|
|
792
|
+
}) {
|
|
793
|
+
};
|
|
712
794
|
|
|
713
795
|
// dist/node/interfaces/pausable.js
|
|
714
796
|
var import_o1js4 = require("o1js");
|
|
@@ -1429,6 +1511,7 @@ var import_storage4 = require("@silvana-one/storage");
|
|
|
1429
1511
|
var NftErrors = {
|
|
1430
1512
|
cannotChangeMetadataVerificationKeyHash: "Cannot change metadata verification key hash",
|
|
1431
1513
|
cannotChangeOwner: "Cannot change owner",
|
|
1514
|
+
cannotChangeApproval: "Cannot change approval",
|
|
1432
1515
|
cannotChangeStorage: "Cannot change storage",
|
|
1433
1516
|
cannotChangePauseState: "Cannot change pause state",
|
|
1434
1517
|
noPermissionToPause: "No permission to pause",
|
|
@@ -1530,6 +1613,7 @@ var NFT = class extends import_o1js10.SmartContract {
|
|
|
1530
1613
|
data.owner = output.owner;
|
|
1531
1614
|
data.approved = output.approved;
|
|
1532
1615
|
data.version = output.version;
|
|
1616
|
+
data.isPaused = output.isPaused;
|
|
1533
1617
|
this.packedData.set(data.pack());
|
|
1534
1618
|
const event = new UpdateEvent({
|
|
1535
1619
|
name: output.name,
|
|
@@ -1580,6 +1664,7 @@ var NFT = class extends import_o1js10.SmartContract {
|
|
|
1580
1664
|
async approveAddress(approved) {
|
|
1581
1665
|
const data = NFTData.unpack(this.packedData.getAndRequireEquals());
|
|
1582
1666
|
data.isPaused.assertFalse(NftErrors.nftIsPaused);
|
|
1667
|
+
data.canApprove.assertTrue(NftErrors.cannotChangeApproval);
|
|
1583
1668
|
data.approved = approved;
|
|
1584
1669
|
this.packedData.set(data.pack());
|
|
1585
1670
|
this.emitEvent("approve", approved);
|
|
@@ -1720,38 +1805,40 @@ function mulDiv(params) {
|
|
|
1720
1805
|
if (denominatorBigInt === 0n) {
|
|
1721
1806
|
return { result: import_o1js11.Field.from(0n), remainder: import_o1js11.Field.from(0n) };
|
|
1722
1807
|
}
|
|
1723
|
-
const
|
|
1724
|
-
const
|
|
1725
|
-
return { result: import_o1js11.Field.from(
|
|
1808
|
+
const result2 = valueBigInt * multiplierBigInt / denominatorBigInt;
|
|
1809
|
+
const remainder2 = valueBigInt * multiplierBigInt - result2 * denominatorBigInt;
|
|
1810
|
+
return { result: import_o1js11.Field.from(result2), remainder: import_o1js11.Field.from(remainder2) };
|
|
1726
1811
|
});
|
|
1727
1812
|
import_o1js11.Gadgets.rangeCheck64(fields.result);
|
|
1813
|
+
const result = import_o1js11.UInt64.Unsafe.fromField(fields.result);
|
|
1728
1814
|
import_o1js11.Gadgets.rangeCheck64(fields.remainder);
|
|
1729
|
-
|
|
1730
|
-
|
|
1815
|
+
const remainder = import_o1js11.UInt64.Unsafe.fromField(fields.remainder);
|
|
1816
|
+
remainder.assertLessThan(denominator);
|
|
1817
|
+
result.value.mul(denominator.value).add(remainder.value).assertEquals(value.value.mul(multiplier.value));
|
|
1731
1818
|
return {
|
|
1732
|
-
result
|
|
1733
|
-
remainder
|
|
1819
|
+
result,
|
|
1820
|
+
remainder
|
|
1734
1821
|
};
|
|
1735
1822
|
}
|
|
1736
1823
|
|
|
1737
1824
|
// dist/node/vk.js
|
|
1738
1825
|
var nftVerificationKeys = {
|
|
1739
1826
|
devnet: {
|
|
1740
|
-
o1js: "2.
|
|
1827
|
+
o1js: "2.3.0",
|
|
1741
1828
|
vk: {
|
|
1742
1829
|
NFT: {
|
|
1743
|
-
hash: "
|
|
1744
|
-
data: "AADUTaZ5kJK+C2TL7P/tc4MlgEq5zWOLFDtgDU/u9ry3Es1Ek79TcLqIWg8s6TJJcXzM0D/6xz1y8FQn2tGjjcspfNtNRAmG3FdldAatVpnkTwS6Otpm88gl7lOPX8bRJjhHfEtdvEsQ0OudcDzB5iCqu268zqkBvXrXT3xaNN+sIIqLTtxltMz4RS/2layxzL6mg1J+kkTsNIJsg6MufeMI6Xn5pAYOaWFqgo0N0WZsnF3EYcYq1LcDucyyFS2RqRninioewrlEDzjY8y6rmf9+GibQasJCE+mkbfB4wCOuFMiSrRIN/73BODz9siBxs/bU/p7xffJsOL8JvitK7ngRyG3PfGGdW22njv9MYxNhb/YhKnPA0qPTOQjxg1a/Pg8NyjB9RM7eypPJNLFaWFzNM4JRxjI7wGVVOfE0D7DUAL32SzQ1Jmr4mILqDhnDREu2ETq0Lb+c1cxPgb4x1nYbWcSgdAOtKJBvXHkWs7JlJdL1q9yiRrzYb1kPMPNGACnSB3N3Omm//FhxitOOM4yucxZyKpKst/otZu51/gGBDW5tIwKYpfl5ETSNvDFY+9rLUHv+LxSz+
|
|
1830
|
+
hash: "9783798445384315170525620826037823720996093317060506623212107011216804106668",
|
|
1831
|
+
data: "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",
|
|
1745
1832
|
type: "nft"
|
|
1746
1833
|
}
|
|
1747
1834
|
}
|
|
1748
1835
|
},
|
|
1749
1836
|
mainnet: {
|
|
1750
|
-
o1js: "2.
|
|
1837
|
+
o1js: "2.3.0",
|
|
1751
1838
|
vk: {
|
|
1752
1839
|
NFT: {
|
|
1753
|
-
hash: "
|
|
1754
|
-
data: "AADUTaZ5kJK+C2TL7P/tc4MlgEq5zWOLFDtgDU/u9ry3Es1Ek79TcLqIWg8s6TJJcXzM0D/6xz1y8FQn2tGjjcspfNtNRAmG3FdldAatVpnkTwS6Otpm88gl7lOPX8bRJjhHfEtdvEsQ0OudcDzB5iCqu268zqkBvXrXT3xaNN+sIIqLTtxltMz4RS/2layxzL6mg1J+kkTsNIJsg6MufeMI6Xn5pAYOaWFqgo0N0WZsnF3EYcYq1LcDucyyFS2RqRninioewrlEDzjY8y6rmf9+GibQasJCE+mkbfB4wCOuFMiSrRIN/73BODz9siBxs/bU/p7xffJsOL8JvitK7ngRyG3PfGGdW22njv9MYxNhb/YhKnPA0qPTOQjxg1a/Pg8NyjB9RM7eypPJNLFaWFzNM4JRxjI7wGVVOfE0D7DUAL32SzQ1Jmr4mILqDhnDREu2ETq0Lb+c1cxPgb4x1nYbWcSgdAOtKJBvXHkWs7JlJdL1q9yiRrzYb1kPMPNGACnSB3N3Omm//FhxitOOM4yucxZyKpKst/otZu51/gGBDW5tIwKYpfl5ETSNvDFY+9rLUHv+LxSz+
|
|
1840
|
+
hash: "22175359608429605539570936386638550990144108869927626059283446793366639887120",
|
|
1841
|
+
data: "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",
|
|
1755
1842
|
type: "nft"
|
|
1756
1843
|
}
|
|
1757
1844
|
}
|
|
@@ -1780,7 +1867,8 @@ var CollectionErrors = {
|
|
|
1780
1867
|
adminContractAddressNotSet: "Admin contract address is not set",
|
|
1781
1868
|
onlyOwnerCanUpgradeVerificationKey: "Only owner can upgrade verification key",
|
|
1782
1869
|
invalidRoyaltyFee: "Royalty fee is too high, cannot be more than 100%",
|
|
1783
|
-
invalidOracleAddress: "Oracle address is invalid"
|
|
1870
|
+
invalidOracleAddress: "Oracle address is invalid",
|
|
1871
|
+
pendingCreatorIsEmpty: "Pending creator address is empty"
|
|
1784
1872
|
};
|
|
1785
1873
|
function CollectionFactory(params) {
|
|
1786
1874
|
const { adminContract, ownerContract, approvalContract, updateContract } = params;
|
|
@@ -1792,24 +1880,26 @@ function CollectionFactory(params) {
|
|
|
1792
1880
|
this.admin = (0, import_o1js12.State)();
|
|
1793
1881
|
this.baseURL = (0, import_o1js12.State)();
|
|
1794
1882
|
this.packedData = (0, import_o1js12.State)();
|
|
1883
|
+
this.pendingCreatorX = (0, import_o1js12.State)();
|
|
1795
1884
|
this.events = {
|
|
1796
1885
|
mint: MintEvent,
|
|
1797
|
-
update:
|
|
1886
|
+
update: NFTUpdateEvent,
|
|
1798
1887
|
transfer: TransferEvent,
|
|
1799
1888
|
approve: ApproveEvent,
|
|
1800
1889
|
upgradeNFTVerificationKey: UpgradeVerificationKeyEvent,
|
|
1801
|
-
upgradeVerificationKey:
|
|
1890
|
+
upgradeVerificationKey: UpgradeVerificationKeyEvent,
|
|
1802
1891
|
limitMinting: LimitMintingEvent,
|
|
1803
1892
|
pause: PauseEvent,
|
|
1804
1893
|
resume: PauseEvent,
|
|
1805
1894
|
pauseNFT: PauseNFTEvent,
|
|
1806
1895
|
resumeNFT: PauseNFTEvent,
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1896
|
+
ownershipTransfer: OwnershipChangeEvent,
|
|
1897
|
+
ownershipAccepted: OwnershipChangeEvent,
|
|
1898
|
+
setName: SetNameEvent,
|
|
1899
|
+
setBaseURL: SetBaseURLEvent,
|
|
1900
|
+
setRoyaltyFee: SetRoyaltyFeeEvent,
|
|
1901
|
+
setTransferFee: SetTransferFeeEvent,
|
|
1902
|
+
setAdmin: SetAdminEvent
|
|
1813
1903
|
};
|
|
1814
1904
|
}
|
|
1815
1905
|
/**
|
|
@@ -1826,6 +1916,7 @@ function CollectionFactory(params) {
|
|
|
1826
1916
|
this.packedData.set(CollectionData.new({
|
|
1827
1917
|
isPaused: true
|
|
1828
1918
|
}).pack());
|
|
1919
|
+
this.pendingCreatorX.set(import_o1js12.PublicKey.empty().x);
|
|
1829
1920
|
this.account.zkappUri.set(props.url);
|
|
1830
1921
|
this.account.tokenSymbol.set(props.symbol);
|
|
1831
1922
|
this.account.permissions.set({
|
|
@@ -1834,8 +1925,8 @@ function CollectionFactory(params) {
|
|
|
1834
1925
|
setPermissions: import_o1js12.Permissions.impossible(),
|
|
1835
1926
|
access: import_o1js12.Permissions.proof(),
|
|
1836
1927
|
send: import_o1js12.Permissions.proof(),
|
|
1837
|
-
setZkappUri: import_o1js12.Permissions.
|
|
1838
|
-
setTokenSymbol: import_o1js12.Permissions.
|
|
1928
|
+
setZkappUri: import_o1js12.Permissions.proof(),
|
|
1929
|
+
setTokenSymbol: import_o1js12.Permissions.proof()
|
|
1839
1930
|
});
|
|
1840
1931
|
}
|
|
1841
1932
|
/**
|
|
@@ -1923,7 +2014,9 @@ function CollectionFactory(params) {
|
|
|
1923
2014
|
* @returns The packed data of the collection.
|
|
1924
2015
|
*/
|
|
1925
2016
|
async ensureNotPaused() {
|
|
1926
|
-
CollectionData.
|
|
2017
|
+
const collectionData = CollectionData.unpack(this.packedData.getAndRequireEquals());
|
|
2018
|
+
collectionData.isPaused.assertFalse(CollectionErrors.collectionPaused);
|
|
2019
|
+
return collectionData;
|
|
1927
2020
|
}
|
|
1928
2021
|
/**
|
|
1929
2022
|
* Mints a new NFT directly by the creator.
|
|
@@ -1940,7 +2033,8 @@ function CollectionFactory(params) {
|
|
|
1940
2033
|
* @param params - The mint parameters containing details of the NFT to be minted.
|
|
1941
2034
|
*/
|
|
1942
2035
|
async mintByCreator(params2) {
|
|
1943
|
-
|
|
2036
|
+
const collectionData = await this.ensureNotPaused();
|
|
2037
|
+
collectionData.mintingIsLimited.assertFalse(CollectionErrors.cannotMint);
|
|
1944
2038
|
const creatorUpdate = await this.ensureCreatorSignature();
|
|
1945
2039
|
creatorUpdate.balance.subInPlace(1e9);
|
|
1946
2040
|
await this._mint(params2);
|
|
@@ -1951,9 +2045,12 @@ function CollectionFactory(params) {
|
|
|
1951
2045
|
* @param mintRequest - The minting request containing parameters and proofs.
|
|
1952
2046
|
*/
|
|
1953
2047
|
async mint(mintRequest) {
|
|
1954
|
-
|
|
2048
|
+
const collectionData = await this.ensureNotPaused();
|
|
2049
|
+
collectionData.mintingIsLimited.assertFalse(CollectionErrors.cannotMint);
|
|
1955
2050
|
const adminContract2 = this.getAdminContract();
|
|
1956
2051
|
const mintParams = (await adminContract2.canMint(mintRequest)).assertSome(CollectionErrors.cannotMint);
|
|
2052
|
+
mintParams.address.assertEquals(mintRequest.address);
|
|
2053
|
+
mintParams.data.owner.assertEquals(mintRequest.owner);
|
|
1957
2054
|
mintParams.address.equals(this.address).assertFalse(CollectionErrors.cannotMintMasterNFT);
|
|
1958
2055
|
await this._mint(mintParams);
|
|
1959
2056
|
}
|
|
@@ -1965,11 +2062,13 @@ function CollectionFactory(params) {
|
|
|
1965
2062
|
* @returns The MintEvent emitted.
|
|
1966
2063
|
*/
|
|
1967
2064
|
async _mint(params2) {
|
|
1968
|
-
const { name, address, data, metadata, storage, metadataVerificationKeyHash, expiry } = params2;
|
|
2065
|
+
const { name, address, data, metadata, storage, metadataVerificationKeyHash, expiry, fee, tokenId } = params2;
|
|
1969
2066
|
this.network.globalSlotSinceGenesis.requireBetween(import_o1js12.UInt32.zero, expiry);
|
|
1970
|
-
data.version.assertEquals(import_o1js12.
|
|
2067
|
+
data.version.assertEquals(import_o1js12.UInt64.zero);
|
|
2068
|
+
data.isPaused.equals((0, import_o1js12.Bool)(false)).or(data.canPause.equals((0, import_o1js12.Bool)(true))).assertTrue(CollectionErrors.cannotMint);
|
|
1971
2069
|
const packedData = data.pack();
|
|
1972
|
-
const
|
|
2070
|
+
const collectionTokenId = this.deriveTokenId();
|
|
2071
|
+
collectionTokenId.assertEquals(tokenId);
|
|
1973
2072
|
const update = import_o1js12.AccountUpdate.createSigned(address, tokenId);
|
|
1974
2073
|
update.body.useFullCommitment = (0, import_o1js12.Bool)(true);
|
|
1975
2074
|
update.account.isNew.getAndRequireEquals().assertTrue();
|
|
@@ -1989,10 +2088,11 @@ function CollectionFactory(params) {
|
|
|
1989
2088
|
});
|
|
1990
2089
|
const mainnetVerificationKeyHash = (0, import_o1js12.Field)(nftVerificationKeys.mainnet.vk.NFT.hash);
|
|
1991
2090
|
const devnetVerificationKeyHash = (0, import_o1js12.Field)(nftVerificationKeys.devnet.vk.NFT.hash);
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
}
|
|
1995
|
-
|
|
2091
|
+
if (import_o1js12.Mina.getNetworkId() === "mainnet") {
|
|
2092
|
+
verificationKey.hash.assertEquals(mainnetVerificationKeyHash);
|
|
2093
|
+
} else {
|
|
2094
|
+
verificationKey.hash.assertEquals(devnetVerificationKeyHash);
|
|
2095
|
+
}
|
|
1996
2096
|
update.body.update.verificationKey = {
|
|
1997
2097
|
isSome: (0, import_o1js12.Bool)(true),
|
|
1998
2098
|
value: verificationKey
|
|
@@ -2025,7 +2125,9 @@ function CollectionFactory(params) {
|
|
|
2025
2125
|
}));
|
|
2026
2126
|
const event = new MintEvent({
|
|
2027
2127
|
initialState,
|
|
2028
|
-
address
|
|
2128
|
+
address,
|
|
2129
|
+
tokenId,
|
|
2130
|
+
fee
|
|
2029
2131
|
});
|
|
2030
2132
|
this.emitEvent("mint", event);
|
|
2031
2133
|
return event;
|
|
@@ -2037,6 +2139,8 @@ function CollectionFactory(params) {
|
|
|
2037
2139
|
* @param vk - The verification key.
|
|
2038
2140
|
*/
|
|
2039
2141
|
async update(proof, vk) {
|
|
2142
|
+
const oracleAddress = proof.publicInput.oracleAddress;
|
|
2143
|
+
oracleAddress.equals(import_o1js12.PublicKey.empty()).assertTrue(CollectionErrors.invalidOracleAddress);
|
|
2040
2144
|
await this._update(proof, vk);
|
|
2041
2145
|
}
|
|
2042
2146
|
/**
|
|
@@ -2072,7 +2176,9 @@ function CollectionFactory(params) {
|
|
|
2072
2176
|
const metadataVerificationKeyHash = await nft.update(proof.publicInput, proof.publicOutput, creator);
|
|
2073
2177
|
metadataVerificationKeyHash.assertEquals(vk.hash);
|
|
2074
2178
|
proof.verify(vk);
|
|
2075
|
-
this.emitEvent("update",
|
|
2179
|
+
this.emitEvent("update", new NFTUpdateEvent({
|
|
2180
|
+
address: proof.publicInput.immutableState.address
|
|
2181
|
+
}));
|
|
2076
2182
|
}
|
|
2077
2183
|
/**
|
|
2078
2184
|
* Approves an address to transfer an NFT.
|
|
@@ -2091,10 +2197,11 @@ function CollectionFactory(params) {
|
|
|
2091
2197
|
/**
|
|
2092
2198
|
* Transfers ownership of an NFT without admin approval.
|
|
2093
2199
|
*
|
|
2094
|
-
* @param
|
|
2095
|
-
* @param
|
|
2200
|
+
* @param nftAddress - The address of the NFT.
|
|
2201
|
+
* @param approved - The approved public key.
|
|
2096
2202
|
*/
|
|
2097
2203
|
async approveAddressByProof(nftAddress, approved) {
|
|
2204
|
+
await this.ensureNotPaused();
|
|
2098
2205
|
const tokenId = this.deriveTokenId();
|
|
2099
2206
|
const nft = new NFT(nftAddress, tokenId);
|
|
2100
2207
|
const owner = await nft.approveAddress(approved);
|
|
@@ -2114,8 +2221,7 @@ function CollectionFactory(params) {
|
|
|
2114
2221
|
*/
|
|
2115
2222
|
async transferBySignature(params2) {
|
|
2116
2223
|
const { address, to, price, context } = params2;
|
|
2117
|
-
const collectionData =
|
|
2118
|
-
collectionData.isPaused.assertFalse(CollectionErrors.collectionPaused);
|
|
2224
|
+
const collectionData = await this.ensureNotPaused();
|
|
2119
2225
|
collectionData.requireTransferApproval.assertFalse(CollectionErrors.transferApprovalRequired);
|
|
2120
2226
|
const transferEventDraft = new TransferExtendedParams({
|
|
2121
2227
|
from: import_o1js12.PublicKey.empty(),
|
|
@@ -2147,8 +2253,8 @@ function CollectionFactory(params) {
|
|
|
2147
2253
|
*/
|
|
2148
2254
|
async transferByProof(params2) {
|
|
2149
2255
|
const { address, from, to, price, context } = params2;
|
|
2150
|
-
const collectionData =
|
|
2151
|
-
collectionData.
|
|
2256
|
+
const collectionData = await this.ensureNotPaused();
|
|
2257
|
+
collectionData.requireTransferApproval.assertFalse(CollectionErrors.transferApprovalRequired);
|
|
2152
2258
|
const transferEventDraft = new TransferExtendedParams({
|
|
2153
2259
|
from,
|
|
2154
2260
|
to,
|
|
@@ -2179,10 +2285,9 @@ function CollectionFactory(params) {
|
|
|
2179
2285
|
*
|
|
2180
2286
|
* @param params - The transfer parameters.
|
|
2181
2287
|
*/
|
|
2182
|
-
async
|
|
2288
|
+
async adminApprovedTransferByProof(params2) {
|
|
2183
2289
|
const { address, from, to, price, context } = params2;
|
|
2184
|
-
const collectionData =
|
|
2185
|
-
collectionData.isPaused.assertFalse(CollectionErrors.collectionPaused);
|
|
2290
|
+
const collectionData = await this.ensureNotPaused();
|
|
2186
2291
|
const transferEventDraft = new TransferExtendedParams({
|
|
2187
2292
|
from,
|
|
2188
2293
|
to,
|
|
@@ -2216,10 +2321,9 @@ function CollectionFactory(params) {
|
|
|
2216
2321
|
* @param to - The recipient's public key.
|
|
2217
2322
|
* @param price - The price of the NFT (optional).
|
|
2218
2323
|
*/
|
|
2219
|
-
async
|
|
2324
|
+
async adminApprovedTransferBySignature(params2) {
|
|
2220
2325
|
const { address, to, price, context } = params2;
|
|
2221
|
-
const collectionData =
|
|
2222
|
-
collectionData.isPaused.assertFalse(CollectionErrors.collectionPaused);
|
|
2326
|
+
const collectionData = await this.ensureNotPaused();
|
|
2223
2327
|
const transferEventDraft = new TransferExtendedParams({
|
|
2224
2328
|
from: import_o1js12.PublicKey.empty(),
|
|
2225
2329
|
// will be added later
|
|
@@ -2243,14 +2347,21 @@ function CollectionFactory(params) {
|
|
|
2243
2347
|
const adminContract2 = this.getAdminContract();
|
|
2244
2348
|
const canTransfer = await adminContract2.canTransfer(transferEvent);
|
|
2245
2349
|
canTransfer.assertTrue();
|
|
2246
|
-
this.emitEvent("transfer", transferEvent);
|
|
2247
2350
|
}
|
|
2248
2351
|
/**
|
|
2249
2352
|
* Internal method to transfer an NFT.
|
|
2250
2353
|
*
|
|
2251
|
-
*
|
|
2252
|
-
*
|
|
2354
|
+
* This method handles the transfer logic and fee calculation. The fee is determined as follows:
|
|
2355
|
+
* - If a price is provided, the fee is calculated as (price * royaltyFee / MAX_ROYALTY_FEE)
|
|
2356
|
+
* - If no price is provided, the fixed transferFee is used to handle two cases:
|
|
2357
|
+
* when NFT is being sold and the price is not provided to the contract
|
|
2358
|
+
* when NFT is being transferred by the owner (without price)
|
|
2359
|
+
* - If the sender is the creator, no fee is charged
|
|
2360
|
+
* - The minimum fee is always the transferFee (unless sender is creator)
|
|
2361
|
+
*
|
|
2362
|
+
* @param transferEventDraft - The transfer event draft, containing the information about the transfer
|
|
2253
2363
|
* @param transferFee - The transfer fee amount.
|
|
2364
|
+
* @param royaltyFee - The royalty fee amount.
|
|
2254
2365
|
* @returns The TransferEvent emitted.
|
|
2255
2366
|
*/
|
|
2256
2367
|
async _transfer(params2) {
|
|
@@ -2305,6 +2416,7 @@ function CollectionFactory(params) {
|
|
|
2305
2416
|
* @param vk - The new verification key.
|
|
2306
2417
|
*/
|
|
2307
2418
|
async upgradeNFTVerificationKeyBySignature(address, vk) {
|
|
2419
|
+
await this.ensureNotPaused();
|
|
2308
2420
|
const sender = this.sender.getAndRequireSignature();
|
|
2309
2421
|
const data = await this._upgrade(address, vk);
|
|
2310
2422
|
data.owner.equals(sender).or(data.isOwnerApprovalRequired.not()).assertTrue(CollectionErrors.onlyOwnerCanUpgradeVerificationKey);
|
|
@@ -2316,6 +2428,7 @@ function CollectionFactory(params) {
|
|
|
2316
2428
|
* @param vk - The new verification key.
|
|
2317
2429
|
*/
|
|
2318
2430
|
async upgradeNFTVerificationKeyByProof(address, vk) {
|
|
2431
|
+
await this.ensureNotPaused();
|
|
2319
2432
|
const data = await this._upgrade(address, vk);
|
|
2320
2433
|
const ownerContract2 = this.getOwnerContract(data.owner);
|
|
2321
2434
|
const canUpgrade = await ownerContract2.canChangeVerificationKey(this.address, address, vk);
|
|
@@ -2342,19 +2455,23 @@ function CollectionFactory(params) {
|
|
|
2342
2455
|
* @param vk - The new verification key.
|
|
2343
2456
|
*/
|
|
2344
2457
|
async upgradeVerificationKey(vk) {
|
|
2458
|
+
await this.ensureNotPaused();
|
|
2345
2459
|
const adminContract2 = this.getAdminContract();
|
|
2346
2460
|
const canUpgrade = await adminContract2.canChangeVerificationKey(vk, this.address, this.tokenId);
|
|
2347
2461
|
canUpgrade.assertTrue(CollectionErrors.cannotUpgradeVerificationKey);
|
|
2348
2462
|
this.account.verificationKey.set(vk);
|
|
2349
|
-
this.emitEvent("upgradeVerificationKey",
|
|
2463
|
+
this.emitEvent("upgradeVerificationKey", new UpgradeVerificationKeyEvent({
|
|
2464
|
+
address: this.address,
|
|
2465
|
+
tokenId: this.tokenId,
|
|
2466
|
+
verificationKeyHash: vk.hash
|
|
2467
|
+
}));
|
|
2350
2468
|
}
|
|
2351
2469
|
/**
|
|
2352
2470
|
* Limits further minting of NFTs in the collection.
|
|
2353
2471
|
*/
|
|
2354
2472
|
async limitMinting() {
|
|
2355
2473
|
await this.ensureCreatorSignature();
|
|
2356
|
-
const collectionData =
|
|
2357
|
-
collectionData.isPaused.assertFalse(CollectionErrors.collectionPaused);
|
|
2474
|
+
const collectionData = await this.ensureNotPaused();
|
|
2358
2475
|
collectionData.mintingIsLimited = (0, import_o1js12.Bool)(true);
|
|
2359
2476
|
this.packedData.set(collectionData.pack());
|
|
2360
2477
|
this.emitEvent("limitMinting", new LimitMintingEvent({ mintingLimited: (0, import_o1js12.Bool)(true) }));
|
|
@@ -2363,8 +2480,7 @@ function CollectionFactory(params) {
|
|
|
2363
2480
|
* Pauses the collection, disabling certain actions.
|
|
2364
2481
|
*/
|
|
2365
2482
|
async pause() {
|
|
2366
|
-
const collectionData =
|
|
2367
|
-
collectionData.isPaused.assertFalse(CollectionErrors.collectionPaused);
|
|
2483
|
+
const collectionData = await this.ensureNotPaused();
|
|
2368
2484
|
const adminContract2 = this.getAdminContract();
|
|
2369
2485
|
const canPause = await adminContract2.canPause();
|
|
2370
2486
|
canPause.assertTrue(CollectionErrors.noPermissionToPause);
|
|
@@ -2391,6 +2507,7 @@ function CollectionFactory(params) {
|
|
|
2391
2507
|
* @param address - The address of the NFT to pause.
|
|
2392
2508
|
*/
|
|
2393
2509
|
async pauseNFTBySignature(address) {
|
|
2510
|
+
await this.ensureNotPaused();
|
|
2394
2511
|
const tokenId = this.deriveTokenId();
|
|
2395
2512
|
const nft = new NFT(address, tokenId);
|
|
2396
2513
|
const owner = await nft.pause();
|
|
@@ -2403,6 +2520,7 @@ function CollectionFactory(params) {
|
|
|
2403
2520
|
* @param address - The address of the NFT to pause.
|
|
2404
2521
|
*/
|
|
2405
2522
|
async pauseNFTByProof(address) {
|
|
2523
|
+
await this.ensureNotPaused();
|
|
2406
2524
|
const tokenId = this.deriveTokenId();
|
|
2407
2525
|
const nft = new NFT(address, tokenId);
|
|
2408
2526
|
const owner = await nft.pause();
|
|
@@ -2417,6 +2535,7 @@ function CollectionFactory(params) {
|
|
|
2417
2535
|
* @param address - The address of the NFT to resume.
|
|
2418
2536
|
*/
|
|
2419
2537
|
async resumeNFT(address) {
|
|
2538
|
+
await this.ensureNotPaused();
|
|
2420
2539
|
const tokenId = this.deriveTokenId();
|
|
2421
2540
|
const nft = new NFT(address, tokenId);
|
|
2422
2541
|
const owner = await nft.resume();
|
|
@@ -2429,6 +2548,7 @@ function CollectionFactory(params) {
|
|
|
2429
2548
|
* @param address - The address of the NFT to resume.
|
|
2430
2549
|
*/
|
|
2431
2550
|
async resumeNFTByProof(address) {
|
|
2551
|
+
await this.ensureNotPaused();
|
|
2432
2552
|
const tokenId = this.deriveTokenId();
|
|
2433
2553
|
const nft = new NFT(address, tokenId);
|
|
2434
2554
|
const owner = await nft.resume();
|
|
@@ -2451,7 +2571,7 @@ function CollectionFactory(params) {
|
|
|
2451
2571
|
const canChangeName = await adminContract2.canChangeName(name);
|
|
2452
2572
|
canChangeName.assertTrue(CollectionErrors.noPermissionToChangeName);
|
|
2453
2573
|
this.collectionName.set(name);
|
|
2454
|
-
this.emitEvent("setName", name);
|
|
2574
|
+
this.emitEvent("setName", new SetNameEvent({ name }));
|
|
2455
2575
|
}
|
|
2456
2576
|
/**
|
|
2457
2577
|
* Updates the base URL for the collection's metadata.
|
|
@@ -2467,7 +2587,7 @@ function CollectionFactory(params) {
|
|
|
2467
2587
|
const canChangeBaseUri = await adminContract2.canChangeBaseUri(baseURL);
|
|
2468
2588
|
canChangeBaseUri.assertTrue(CollectionErrors.noPermissionToChangeBaseUri);
|
|
2469
2589
|
this.baseURL.set(baseURL);
|
|
2470
|
-
this.emitEvent("setBaseURL", baseURL);
|
|
2590
|
+
this.emitEvent("setBaseURL", new SetBaseURLEvent({ baseURL }));
|
|
2471
2591
|
}
|
|
2472
2592
|
/**
|
|
2473
2593
|
* Sets a new admin address for the collection.
|
|
@@ -2483,7 +2603,7 @@ function CollectionFactory(params) {
|
|
|
2483
2603
|
const canSetAdmin = await adminContract2.canSetAdmin(admin);
|
|
2484
2604
|
canSetAdmin.assertTrue(CollectionErrors.noPermissionToSetAdmin);
|
|
2485
2605
|
this.admin.set(admin);
|
|
2486
|
-
this.emitEvent("setAdmin", admin);
|
|
2606
|
+
this.emitEvent("setAdmin", new SetAdminEvent({ admin }));
|
|
2487
2607
|
}
|
|
2488
2608
|
/**
|
|
2489
2609
|
* Updates the royalty fee for the collection.
|
|
@@ -2494,15 +2614,14 @@ function CollectionFactory(params) {
|
|
|
2494
2614
|
* @throws {Error} If caller lacks permission to change royalty fee
|
|
2495
2615
|
*/
|
|
2496
2616
|
async setRoyaltyFee(royaltyFee) {
|
|
2497
|
-
const collectionData =
|
|
2498
|
-
collectionData.isPaused.assertFalse(CollectionErrors.collectionPaused);
|
|
2617
|
+
const collectionData = await this.ensureNotPaused();
|
|
2499
2618
|
royaltyFee.assertLessThanOrEqual(import_o1js12.UInt32.from(MAX_ROYALTY_FEE), CollectionErrors.invalidRoyaltyFee);
|
|
2500
2619
|
const adminContract2 = this.getAdminContract();
|
|
2501
2620
|
const canChangeRoyalty = await adminContract2.canChangeRoyalty(royaltyFee);
|
|
2502
2621
|
canChangeRoyalty.assertTrue(CollectionErrors.noPermissionToChangeRoyalty);
|
|
2503
2622
|
collectionData.royaltyFee = royaltyFee;
|
|
2504
2623
|
this.packedData.set(collectionData.pack());
|
|
2505
|
-
this.emitEvent("setRoyaltyFee", royaltyFee);
|
|
2624
|
+
this.emitEvent("setRoyaltyFee", new SetRoyaltyFeeEvent({ royaltyFee }));
|
|
2506
2625
|
}
|
|
2507
2626
|
/**
|
|
2508
2627
|
* Updates the transfer fee for the collection.
|
|
@@ -2513,35 +2632,71 @@ function CollectionFactory(params) {
|
|
|
2513
2632
|
* @throws {Error} If caller lacks permission to change transfer fee
|
|
2514
2633
|
*/
|
|
2515
2634
|
async setTransferFee(transferFee) {
|
|
2516
|
-
const collectionData =
|
|
2517
|
-
collectionData.isPaused.assertFalse(CollectionErrors.collectionPaused);
|
|
2635
|
+
const collectionData = await this.ensureNotPaused();
|
|
2518
2636
|
const adminContract2 = this.getAdminContract();
|
|
2519
2637
|
const canChangeTransferFee = await adminContract2.canChangeTransferFee(transferFee);
|
|
2520
2638
|
canChangeTransferFee.assertTrue(CollectionErrors.noPermissionToChangeTransferFee);
|
|
2521
2639
|
collectionData.transferFee = transferFee;
|
|
2522
2640
|
this.packedData.set(collectionData.pack());
|
|
2523
|
-
this.emitEvent("setTransferFee", transferFee);
|
|
2641
|
+
this.emitEvent("setTransferFee", new SetTransferFeeEvent({ transferFee }));
|
|
2524
2642
|
}
|
|
2525
2643
|
/**
|
|
2526
|
-
* Transfers ownership of the collection to a new
|
|
2644
|
+
* Transfers ownership of the collection to a new creator.
|
|
2645
|
+
* This method is called transferOwnership as the Collection is implementing OwnableContract interface
|
|
2646
|
+
* For the Collection, the creator is the owner of the collection
|
|
2527
2647
|
*
|
|
2528
|
-
* @param to - The public key of the new
|
|
2529
|
-
* @returns The public key of the old
|
|
2648
|
+
* @param to - The public key of the new creator.
|
|
2649
|
+
* @returns The public key of the old creator.
|
|
2530
2650
|
*/
|
|
2531
2651
|
async transferOwnership(to) {
|
|
2532
2652
|
await this.ensureCreatorSignature();
|
|
2533
|
-
|
|
2653
|
+
const collectionData = CollectionData.unpack(this.packedData.getAndRequireEquals());
|
|
2654
|
+
collectionData.isPaused.assertFalse(CollectionErrors.collectionNotPaused);
|
|
2534
2655
|
const adminContract2 = this.getAdminContract();
|
|
2535
2656
|
const canChangeCreator = await adminContract2.canChangeCreator(to);
|
|
2536
2657
|
canChangeCreator.assertTrue(CollectionErrors.noPermissionToChangeCreator);
|
|
2537
2658
|
const from = this.creator.getAndRequireEquals();
|
|
2538
|
-
this.
|
|
2539
|
-
|
|
2659
|
+
this.pendingCreatorX.set(to.x);
|
|
2660
|
+
collectionData.pendingCreatorIsOdd = to.isOdd;
|
|
2661
|
+
this.packedData.set(collectionData.pack());
|
|
2662
|
+
this.emitEvent("ownershipTransfer", new OwnershipChangeEvent({
|
|
2540
2663
|
from,
|
|
2541
2664
|
to
|
|
2542
2665
|
}));
|
|
2543
2666
|
return from;
|
|
2544
2667
|
}
|
|
2668
|
+
/**
|
|
2669
|
+
* Transfers ownership of the collection to a new owner.
|
|
2670
|
+
*
|
|
2671
|
+
* @param to - The public key of the new owner.
|
|
2672
|
+
* @returns The public key of the old owner.
|
|
2673
|
+
*/
|
|
2674
|
+
async acceptOwnership() {
|
|
2675
|
+
const collectionData = CollectionData.unpack(this.packedData.getAndRequireEquals());
|
|
2676
|
+
collectionData.isPaused.assertFalse(CollectionErrors.collectionNotPaused);
|
|
2677
|
+
const pendingCreatorX = this.pendingCreatorX.getAndRequireEquals();
|
|
2678
|
+
const pendingCreator = import_o1js12.PublicKey.from({
|
|
2679
|
+
x: pendingCreatorX,
|
|
2680
|
+
isOdd: collectionData.pendingCreatorIsOdd
|
|
2681
|
+
});
|
|
2682
|
+
const emptyPublicKey = import_o1js12.PublicKey.empty();
|
|
2683
|
+
pendingCreator.equals(emptyPublicKey).assertFalse(CollectionErrors.pendingCreatorIsEmpty);
|
|
2684
|
+
const pendingCreatorUpdate = import_o1js12.AccountUpdate.createSigned(pendingCreator);
|
|
2685
|
+
pendingCreatorUpdate.body.useFullCommitment = (0, import_o1js12.Bool)(true);
|
|
2686
|
+
const adminContract2 = this.getAdminContract();
|
|
2687
|
+
const canChangeCreator = await adminContract2.canChangeCreator(pendingCreator);
|
|
2688
|
+
canChangeCreator.assertTrue(CollectionErrors.noPermissionToChangeCreator);
|
|
2689
|
+
const from = this.creator.getAndRequireEquals();
|
|
2690
|
+
this.pendingCreatorX.set(emptyPublicKey.x);
|
|
2691
|
+
collectionData.pendingCreatorIsOdd = (0, import_o1js12.Bool)(emptyPublicKey.isOdd);
|
|
2692
|
+
this.creator.set(pendingCreator);
|
|
2693
|
+
this.packedData.set(collectionData.pack());
|
|
2694
|
+
this.emitEvent("ownershipAccepted", new OwnershipChangeEvent({
|
|
2695
|
+
from,
|
|
2696
|
+
to: pendingCreator
|
|
2697
|
+
}));
|
|
2698
|
+
return from;
|
|
2699
|
+
}
|
|
2545
2700
|
async getNFTState(address) {
|
|
2546
2701
|
const tokenId = this.deriveTokenId();
|
|
2547
2702
|
const nft = new NFT(address, tokenId);
|
|
@@ -2569,6 +2724,10 @@ function CollectionFactory(params) {
|
|
|
2569
2724
|
(0, import_o1js12.state)(import_o1js12.Field),
|
|
2570
2725
|
(0, import_tslib6.__metadata)("design:type", Object)
|
|
2571
2726
|
], Collection2.prototype, "packedData", void 0);
|
|
2727
|
+
(0, import_tslib6.__decorate)([
|
|
2728
|
+
(0, import_o1js12.state)(import_o1js12.Field),
|
|
2729
|
+
(0, import_tslib6.__metadata)("design:type", Object)
|
|
2730
|
+
], Collection2.prototype, "pendingCreatorX", void 0);
|
|
2572
2731
|
(0, import_tslib6.__decorate)([
|
|
2573
2732
|
import_o1js12.method,
|
|
2574
2733
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
@@ -2626,27 +2785,27 @@ function CollectionFactory(params) {
|
|
|
2626
2785
|
(0, import_tslib6.__decorate)([
|
|
2627
2786
|
import_o1js12.method,
|
|
2628
2787
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2629
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2788
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [TransferBySignatureParams]),
|
|
2630
2789
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2631
2790
|
], Collection2.prototype, "transferBySignature", null);
|
|
2632
2791
|
(0, import_tslib6.__decorate)([
|
|
2633
2792
|
import_o1js12.method,
|
|
2634
2793
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2635
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2794
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [TransferByProofParams]),
|
|
2636
2795
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2637
2796
|
], Collection2.prototype, "transferByProof", null);
|
|
2638
2797
|
(0, import_tslib6.__decorate)([
|
|
2639
2798
|
import_o1js12.method,
|
|
2640
2799
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2641
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2800
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [TransferByProofParams]),
|
|
2642
2801
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2643
|
-
], Collection2.prototype, "
|
|
2802
|
+
], Collection2.prototype, "adminApprovedTransferByProof", null);
|
|
2644
2803
|
(0, import_tslib6.__decorate)([
|
|
2645
2804
|
import_o1js12.method,
|
|
2646
2805
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2647
|
-
(0, import_tslib6.__metadata)("design:paramtypes", [
|
|
2806
|
+
(0, import_tslib6.__metadata)("design:paramtypes", [TransferBySignatureParams]),
|
|
2648
2807
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2649
|
-
], Collection2.prototype, "
|
|
2808
|
+
], Collection2.prototype, "adminApprovedTransferBySignature", null);
|
|
2650
2809
|
(0, import_tslib6.__decorate)([
|
|
2651
2810
|
import_o1js12.method,
|
|
2652
2811
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
@@ -2749,6 +2908,12 @@ function CollectionFactory(params) {
|
|
|
2749
2908
|
(0, import_tslib6.__metadata)("design:paramtypes", [import_o1js12.PublicKey]),
|
|
2750
2909
|
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2751
2910
|
], Collection2.prototype, "transferOwnership", null);
|
|
2911
|
+
(0, import_tslib6.__decorate)([
|
|
2912
|
+
import_o1js12.method.returns(import_o1js12.PublicKey),
|
|
2913
|
+
(0, import_tslib6.__metadata)("design:type", Function),
|
|
2914
|
+
(0, import_tslib6.__metadata)("design:paramtypes", []),
|
|
2915
|
+
(0, import_tslib6.__metadata)("design:returntype", Promise)
|
|
2916
|
+
], Collection2.prototype, "acceptOwnership", null);
|
|
2752
2917
|
(0, import_tslib6.__decorate)([
|
|
2753
2918
|
import_o1js12.method.returns(NFTStateStruct),
|
|
2754
2919
|
(0, import_tslib6.__metadata)("design:type", Function),
|
|
@@ -2761,14 +2926,47 @@ function CollectionFactory(params) {
|
|
|
2761
2926
|
// dist/node/contracts/admin.js
|
|
2762
2927
|
var import_tslib7 = require("tslib");
|
|
2763
2928
|
var import_o1js13 = require("o1js");
|
|
2929
|
+
var NFTAdminAllowFlags = class _NFTAdminAllowFlags extends (0, import_o1js13.Struct)({
|
|
2930
|
+
allowChangeRoyalty: import_o1js13.Bool,
|
|
2931
|
+
allowChangeTransferFee: import_o1js13.Bool,
|
|
2932
|
+
allowPauseCollection: import_o1js13.Bool
|
|
2933
|
+
}) {
|
|
2934
|
+
/**
|
|
2935
|
+
* Packs the NFTAdminAllowFlags into a UInt8 representation for efficient storage.
|
|
2936
|
+
* @returns The packed UInt8 instance.
|
|
2937
|
+
*/
|
|
2938
|
+
pack() {
|
|
2939
|
+
return import_o1js13.UInt8.from(import_o1js13.Field.fromBits([
|
|
2940
|
+
this.allowChangeRoyalty,
|
|
2941
|
+
this.allowChangeTransferFee,
|
|
2942
|
+
this.allowPauseCollection
|
|
2943
|
+
]));
|
|
2944
|
+
}
|
|
2945
|
+
/**
|
|
2946
|
+
* Unpacks a UInt8 instance into a NFTAdminAllowFlags instance.
|
|
2947
|
+
* @param packed The packed UInt8 instance.
|
|
2948
|
+
* @returns A new NFTAdminAllowFlags instance.
|
|
2949
|
+
*/
|
|
2950
|
+
static unpack(packed) {
|
|
2951
|
+
const bits = packed.value.toBits(3);
|
|
2952
|
+
const allowChangeRoyalty = bits[0];
|
|
2953
|
+
const allowChangeTransferFee = bits[1];
|
|
2954
|
+
const allowPauseCollection = bits[2];
|
|
2955
|
+
return new _NFTAdminAllowFlags({
|
|
2956
|
+
allowChangeRoyalty,
|
|
2957
|
+
allowChangeTransferFee,
|
|
2958
|
+
allowPauseCollection
|
|
2959
|
+
});
|
|
2960
|
+
}
|
|
2961
|
+
};
|
|
2764
2962
|
var NFTAdmin = class extends import_o1js13.SmartContract {
|
|
2765
2963
|
constructor() {
|
|
2766
2964
|
super(...arguments);
|
|
2767
2965
|
this.admin = (0, import_o1js13.State)();
|
|
2966
|
+
this.pendingAdmin = (0, import_o1js13.State)();
|
|
2768
2967
|
this.isPaused = (0, import_o1js13.State)();
|
|
2769
2968
|
this.canBePaused = (0, import_o1js13.State)();
|
|
2770
|
-
this.
|
|
2771
|
-
this.allowChangeTransferFee = (0, import_o1js13.State)();
|
|
2969
|
+
this.flags = (0, import_o1js13.State)();
|
|
2772
2970
|
this.events = {
|
|
2773
2971
|
/** Emitted when the verification key is upgraded. */
|
|
2774
2972
|
upgradeVerificationKey: import_o1js13.Field,
|
|
@@ -2777,7 +2975,9 @@ var NFTAdmin = class extends import_o1js13.SmartContract {
|
|
|
2777
2975
|
/** Emitted when the contract is resumed. */
|
|
2778
2976
|
resume: PauseEvent,
|
|
2779
2977
|
/** Emitted when ownership of the contract changes. */
|
|
2780
|
-
|
|
2978
|
+
ownershipTransfer: OwnershipChangeEvent,
|
|
2979
|
+
/** Emitted when ownership of the contract is accepted. */
|
|
2980
|
+
ownershipAccepted: OwnershipChangeEvent
|
|
2781
2981
|
};
|
|
2782
2982
|
}
|
|
2783
2983
|
/**
|
|
@@ -2786,11 +2986,18 @@ var NFTAdmin = class extends import_o1js13.SmartContract {
|
|
|
2786
2986
|
*/
|
|
2787
2987
|
async deploy(props) {
|
|
2788
2988
|
await super.deploy(props);
|
|
2989
|
+
const isPaused = props.isPaused ?? (0, import_o1js13.Bool)(false);
|
|
2990
|
+
const canBePaused = props.canBePaused ?? (0, import_o1js13.Bool)(true);
|
|
2991
|
+
(0, import_o1js13.assert)(isPaused.equals((0, import_o1js13.Bool)(false)).or(canBePaused.equals((0, import_o1js13.Bool)(true))), "Cannot deploy paused contract that cannot be resumed");
|
|
2789
2992
|
this.admin.set(props.admin);
|
|
2790
|
-
this.
|
|
2791
|
-
this.
|
|
2792
|
-
this.
|
|
2793
|
-
this.
|
|
2993
|
+
this.pendingAdmin.set(import_o1js13.PublicKey.empty());
|
|
2994
|
+
this.isPaused.set(isPaused);
|
|
2995
|
+
this.canBePaused.set(canBePaused);
|
|
2996
|
+
this.flags.set(new NFTAdminAllowFlags({
|
|
2997
|
+
allowChangeRoyalty: props.allowChangeRoyalty ?? (0, import_o1js13.Bool)(false),
|
|
2998
|
+
allowChangeTransferFee: props.allowChangeTransferFee ?? (0, import_o1js13.Bool)(false),
|
|
2999
|
+
allowPauseCollection: props.allowPauseCollection ?? (0, import_o1js13.Bool)(true)
|
|
3000
|
+
}).pack());
|
|
2794
3001
|
this.account.zkappUri.set(props.uri);
|
|
2795
3002
|
this.account.permissions.set({
|
|
2796
3003
|
...import_o1js13.Permissions.default(),
|
|
@@ -2800,8 +3007,8 @@ var NFTAdmin = class extends import_o1js13.SmartContract {
|
|
|
2800
3007
|
setPermissions: import_o1js13.Permissions.impossible(),
|
|
2801
3008
|
access: import_o1js13.Permissions.proof(),
|
|
2802
3009
|
send: import_o1js13.Permissions.proof(),
|
|
2803
|
-
setZkappUri: import_o1js13.Permissions.
|
|
2804
|
-
setTokenSymbol: import_o1js13.Permissions.
|
|
3010
|
+
setZkappUri: import_o1js13.Permissions.proof(),
|
|
3011
|
+
setTokenSymbol: import_o1js13.Permissions.proof()
|
|
2805
3012
|
});
|
|
2806
3013
|
}
|
|
2807
3014
|
/**
|
|
@@ -2830,6 +3037,8 @@ var NFTAdmin = class extends import_o1js13.SmartContract {
|
|
|
2830
3037
|
* @returns A `MintParamsOption` indicating if minting is permitted.
|
|
2831
3038
|
*/
|
|
2832
3039
|
async canMint(mintRequest) {
|
|
3040
|
+
const isPaused = this.isPaused.getAndRequireEquals();
|
|
3041
|
+
isPaused.assertFalse("Contract is paused");
|
|
2833
3042
|
return MintParamsOption.none();
|
|
2834
3043
|
}
|
|
2835
3044
|
/**
|
|
@@ -2840,6 +3049,8 @@ var NFTAdmin = class extends import_o1js13.SmartContract {
|
|
|
2840
3049
|
* @returns A `Bool` indicating whether the update is allowed.
|
|
2841
3050
|
*/
|
|
2842
3051
|
async canUpdate(input, output) {
|
|
3052
|
+
const isPaused = this.isPaused.getAndRequireEquals();
|
|
3053
|
+
isPaused.assertFalse("Contract is paused");
|
|
2843
3054
|
return (0, import_o1js13.Bool)(true);
|
|
2844
3055
|
}
|
|
2845
3056
|
/**
|
|
@@ -2848,6 +3059,8 @@ var NFTAdmin = class extends import_o1js13.SmartContract {
|
|
|
2848
3059
|
* @returns A `Bool` indicating whether the transfer is allowed.
|
|
2849
3060
|
*/
|
|
2850
3061
|
async canTransfer(transferEvent) {
|
|
3062
|
+
const isPaused = this.isPaused.getAndRequireEquals();
|
|
3063
|
+
isPaused.assertFalse("Contract is paused");
|
|
2851
3064
|
return (0, import_o1js13.Bool)(true);
|
|
2852
3065
|
}
|
|
2853
3066
|
/**
|
|
@@ -2873,20 +3086,40 @@ var NFTAdmin = class extends import_o1js13.SmartContract {
|
|
|
2873
3086
|
/**
|
|
2874
3087
|
* Transfers ownership of the contract to a new admin.
|
|
2875
3088
|
* @param to - The public key of the new owner.
|
|
2876
|
-
* @returns The public key of the previous
|
|
3089
|
+
* @returns The public key of the previous admin.
|
|
2877
3090
|
*/
|
|
2878
3091
|
async transferOwnership(to) {
|
|
2879
3092
|
const isPaused = this.isPaused.getAndRequireEquals();
|
|
2880
|
-
isPaused.
|
|
3093
|
+
isPaused.assertFalse("Contract is paused");
|
|
2881
3094
|
await this.ensureOwnerSignature();
|
|
2882
3095
|
const from = this.admin.getAndRequireEquals();
|
|
2883
|
-
this.
|
|
2884
|
-
this.emitEvent("
|
|
3096
|
+
this.pendingAdmin.set(to);
|
|
3097
|
+
this.emitEvent("ownershipTransfer", new OwnershipChangeEvent({
|
|
2885
3098
|
from,
|
|
2886
3099
|
to
|
|
2887
3100
|
}));
|
|
2888
3101
|
return from;
|
|
2889
3102
|
}
|
|
3103
|
+
/**
|
|
3104
|
+
* Accept transfer of the ownership of the contract.
|
|
3105
|
+
* @returns The public key of the previous admin.
|
|
3106
|
+
*/
|
|
3107
|
+
async acceptOwnership() {
|
|
3108
|
+
const isPaused = this.isPaused.getAndRequireEquals();
|
|
3109
|
+
isPaused.assertFalse("Contract is paused");
|
|
3110
|
+
const admin = this.admin.getAndRequireEquals();
|
|
3111
|
+
const pendingAdmin = this.pendingAdmin.getAndRequireEquals();
|
|
3112
|
+
pendingAdmin.equals(import_o1js13.PublicKey.empty()).assertFalse("Pending admin is not set");
|
|
3113
|
+
const pendingAminUpdate = import_o1js13.AccountUpdate.createSigned(pendingAdmin);
|
|
3114
|
+
pendingAminUpdate.body.useFullCommitment = (0, import_o1js13.Bool)(true);
|
|
3115
|
+
this.admin.set(pendingAdmin);
|
|
3116
|
+
this.pendingAdmin.set(import_o1js13.PublicKey.empty());
|
|
3117
|
+
this.emitEvent("ownershipAccepted", new OwnershipChangeEvent({
|
|
3118
|
+
from: admin,
|
|
3119
|
+
to: pendingAdmin
|
|
3120
|
+
}));
|
|
3121
|
+
return admin;
|
|
3122
|
+
}
|
|
2890
3123
|
async canChangeVerificationKey(vk, address, tokenId) {
|
|
2891
3124
|
await this.ensureOwnerSignature();
|
|
2892
3125
|
return (0, import_o1js13.Bool)(true);
|
|
@@ -2895,53 +3128,73 @@ var NFTAdmin = class extends import_o1js13.SmartContract {
|
|
|
2895
3128
|
* Determines if the name can be changed for a Collection.
|
|
2896
3129
|
*/
|
|
2897
3130
|
async canChangeName(name) {
|
|
3131
|
+
const isPaused = this.isPaused.getAndRequireEquals();
|
|
3132
|
+
isPaused.assertFalse("Contract is paused");
|
|
2898
3133
|
return (0, import_o1js13.Bool)(false);
|
|
2899
3134
|
}
|
|
2900
3135
|
/**
|
|
2901
3136
|
* Determines if the creator can be changed for a Collection.
|
|
2902
3137
|
*/
|
|
2903
3138
|
async canChangeCreator(creator) {
|
|
3139
|
+
const isPaused = this.isPaused.getAndRequireEquals();
|
|
3140
|
+
isPaused.assertFalse("Contract is paused");
|
|
2904
3141
|
return (0, import_o1js13.Bool)(false);
|
|
2905
3142
|
}
|
|
2906
3143
|
/**
|
|
2907
3144
|
* Determines if the base URI can be changed for a Collection.
|
|
2908
3145
|
*/
|
|
2909
3146
|
async canChangeBaseUri(baseUri) {
|
|
3147
|
+
const isPaused = this.isPaused.getAndRequireEquals();
|
|
3148
|
+
isPaused.assertFalse("Contract is paused");
|
|
2910
3149
|
return (0, import_o1js13.Bool)(false);
|
|
2911
3150
|
}
|
|
2912
3151
|
/**
|
|
2913
3152
|
* Determines if the royalty fee can be changed for a Collection.
|
|
2914
3153
|
*/
|
|
2915
3154
|
async canChangeRoyalty(royaltyFee) {
|
|
3155
|
+
const isPaused = this.isPaused.getAndRequireEquals();
|
|
3156
|
+
isPaused.assertFalse("Contract is paused");
|
|
2916
3157
|
await this.ensureOwnerSignature();
|
|
2917
|
-
|
|
3158
|
+
const flags = NFTAdminAllowFlags.unpack(this.flags.getAndRequireEquals());
|
|
3159
|
+
return flags.allowChangeRoyalty;
|
|
2918
3160
|
}
|
|
2919
3161
|
/**
|
|
2920
3162
|
* Determines if the transfer fee can be changed for a Collection.
|
|
2921
3163
|
*/
|
|
2922
3164
|
async canChangeTransferFee(transferFee) {
|
|
3165
|
+
const isPaused = this.isPaused.getAndRequireEquals();
|
|
3166
|
+
isPaused.assertFalse("Contract is paused");
|
|
2923
3167
|
await this.ensureOwnerSignature();
|
|
2924
|
-
|
|
3168
|
+
const flags = NFTAdminAllowFlags.unpack(this.flags.getAndRequireEquals());
|
|
3169
|
+
return flags.allowChangeTransferFee;
|
|
2925
3170
|
}
|
|
2926
3171
|
/**
|
|
2927
3172
|
* Determines if the admin contract can be changed for a Collection.
|
|
2928
3173
|
*/
|
|
2929
3174
|
async canSetAdmin(admin) {
|
|
3175
|
+
const isPaused = this.isPaused.getAndRequireEquals();
|
|
3176
|
+
isPaused.assertFalse("Contract is paused");
|
|
2930
3177
|
return (0, import_o1js13.Bool)(false);
|
|
2931
3178
|
}
|
|
2932
3179
|
/**
|
|
2933
3180
|
* Determines if the collection can be paused.
|
|
2934
3181
|
*/
|
|
2935
3182
|
async canPause() {
|
|
3183
|
+
const isPaused = this.isPaused.getAndRequireEquals();
|
|
3184
|
+
isPaused.assertFalse("Contract is paused");
|
|
2936
3185
|
await this.ensureOwnerSignature();
|
|
2937
|
-
|
|
3186
|
+
const flags = NFTAdminAllowFlags.unpack(this.flags.getAndRequireEquals());
|
|
3187
|
+
return flags.allowPauseCollection;
|
|
2938
3188
|
}
|
|
2939
3189
|
/**
|
|
2940
3190
|
* Determines if the collection can be resumed.
|
|
2941
3191
|
*/
|
|
2942
3192
|
async canResume() {
|
|
3193
|
+
const isPaused = this.isPaused.getAndRequireEquals();
|
|
3194
|
+
isPaused.assertFalse("Contract is paused");
|
|
2943
3195
|
await this.ensureOwnerSignature();
|
|
2944
|
-
|
|
3196
|
+
const flags = NFTAdminAllowFlags.unpack(this.flags.getAndRequireEquals());
|
|
3197
|
+
return flags.allowPauseCollection;
|
|
2945
3198
|
}
|
|
2946
3199
|
};
|
|
2947
3200
|
(0, import_tslib7.__decorate)([
|
|
@@ -2949,21 +3202,21 @@ var NFTAdmin = class extends import_o1js13.SmartContract {
|
|
|
2949
3202
|
(0, import_tslib7.__metadata)("design:type", Object)
|
|
2950
3203
|
], NFTAdmin.prototype, "admin", void 0);
|
|
2951
3204
|
(0, import_tslib7.__decorate)([
|
|
2952
|
-
(0, import_o1js13.state)(import_o1js13.
|
|
3205
|
+
(0, import_o1js13.state)(import_o1js13.PublicKey),
|
|
2953
3206
|
(0, import_tslib7.__metadata)("design:type", Object)
|
|
2954
|
-
], NFTAdmin.prototype, "
|
|
3207
|
+
], NFTAdmin.prototype, "pendingAdmin", void 0);
|
|
2955
3208
|
(0, import_tslib7.__decorate)([
|
|
2956
3209
|
(0, import_o1js13.state)(import_o1js13.Bool),
|
|
2957
3210
|
(0, import_tslib7.__metadata)("design:type", Object)
|
|
2958
|
-
], NFTAdmin.prototype, "
|
|
3211
|
+
], NFTAdmin.prototype, "isPaused", void 0);
|
|
2959
3212
|
(0, import_tslib7.__decorate)([
|
|
2960
3213
|
(0, import_o1js13.state)(import_o1js13.Bool),
|
|
2961
3214
|
(0, import_tslib7.__metadata)("design:type", Object)
|
|
2962
|
-
], NFTAdmin.prototype, "
|
|
3215
|
+
], NFTAdmin.prototype, "canBePaused", void 0);
|
|
2963
3216
|
(0, import_tslib7.__decorate)([
|
|
2964
|
-
(0, import_o1js13.state)(import_o1js13.
|
|
3217
|
+
(0, import_o1js13.state)(import_o1js13.UInt8),
|
|
2965
3218
|
(0, import_tslib7.__metadata)("design:type", Object)
|
|
2966
|
-
], NFTAdmin.prototype, "
|
|
3219
|
+
], NFTAdmin.prototype, "flags", void 0);
|
|
2967
3220
|
(0, import_tslib7.__decorate)([
|
|
2968
3221
|
import_o1js13.method,
|
|
2969
3222
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
@@ -3006,6 +3259,12 @@ var NFTAdmin = class extends import_o1js13.SmartContract {
|
|
|
3006
3259
|
(0, import_tslib7.__metadata)("design:paramtypes", [import_o1js13.PublicKey]),
|
|
3007
3260
|
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
3008
3261
|
], NFTAdmin.prototype, "transferOwnership", null);
|
|
3262
|
+
(0, import_tslib7.__decorate)([
|
|
3263
|
+
import_o1js13.method.returns(import_o1js13.PublicKey),
|
|
3264
|
+
(0, import_tslib7.__metadata)("design:type", Function),
|
|
3265
|
+
(0, import_tslib7.__metadata)("design:paramtypes", []),
|
|
3266
|
+
(0, import_tslib7.__metadata)("design:returntype", Promise)
|
|
3267
|
+
], NFTAdmin.prototype, "acceptOwnership", null);
|
|
3009
3268
|
(0, import_tslib7.__decorate)([
|
|
3010
3269
|
import_o1js13.method.returns(import_o1js13.Bool),
|
|
3011
3270
|
(0, import_tslib7.__metadata)("design:type", Function),
|
|
@@ -4075,9 +4334,8 @@ function BidFactory(params) {
|
|
|
4075
4334
|
const buyer = this.buyer.getAndRequireEquals();
|
|
4076
4335
|
const Collection2 = collectionContract();
|
|
4077
4336
|
const collection = new Collection2(nftAddress.collection);
|
|
4078
|
-
await collection.transferBySignature(new
|
|
4337
|
+
await collection.transferBySignature(new TransferBySignatureParams({
|
|
4079
4338
|
address: nftAddress.nft,
|
|
4080
|
-
from: import_o1js21.PublicKey.empty(),
|
|
4081
4339
|
to: buyer,
|
|
4082
4340
|
price: UInt64Option.fromValue(price),
|
|
4083
4341
|
context: new NFTTransactionContext({
|
|
@@ -4090,9 +4348,8 @@ function BidFactory(params) {
|
|
|
4090
4348
|
const buyer = this.buyer.getAndRequireEquals();
|
|
4091
4349
|
const Collection2 = collectionContract();
|
|
4092
4350
|
const collection = new Collection2(nftAddress.collection);
|
|
4093
|
-
await collection.
|
|
4351
|
+
await collection.adminApprovedTransferBySignature(new TransferBySignatureParams({
|
|
4094
4352
|
address: nftAddress.nft,
|
|
4095
|
-
from: import_o1js21.PublicKey.empty(),
|
|
4096
4353
|
to: buyer,
|
|
4097
4354
|
price: UInt64Option.fromValue(price),
|
|
4098
4355
|
context: new NFTTransactionContext({
|
|
@@ -4463,7 +4720,7 @@ function AuctionFactory(params) {
|
|
|
4463
4720
|
this.settled = (0, import_o1js23.State)((0, import_o1js23.Bool)(false));
|
|
4464
4721
|
this.events = {
|
|
4465
4722
|
bid: AuctionBidEvent,
|
|
4466
|
-
settleAuction:
|
|
4723
|
+
settleAuction: TransferByProofParams,
|
|
4467
4724
|
canTransfer: TransferEvent,
|
|
4468
4725
|
settlePayment: import_o1js23.UInt64,
|
|
4469
4726
|
settleAuctioneerPayment: import_o1js23.UInt64,
|
|
@@ -4562,7 +4819,7 @@ function AuctionFactory(params) {
|
|
|
4562
4819
|
auction.bidder.equals(import_o1js23.PublicKey.empty()).assertFalse("No bidder");
|
|
4563
4820
|
bidAmount.assertGreaterThanOrEqual(auction.minimumPrice, "Bidder does not have enough balance");
|
|
4564
4821
|
const collection = this.getCollectionContract(auction.collection);
|
|
4565
|
-
const transferParams = new
|
|
4822
|
+
const transferParams = new TransferByProofParams({
|
|
4566
4823
|
address: nftAddress,
|
|
4567
4824
|
from: this.address,
|
|
4568
4825
|
to: auction.bidder,
|
|
@@ -4586,7 +4843,7 @@ function AuctionFactory(params) {
|
|
|
4586
4843
|
this.network.globalSlotSinceGenesis.requireBetween(auction.auctionEndTime.add(auction.withdrawPeriod), import_o1js23.UInt32.MAXINT());
|
|
4587
4844
|
const nftAddress = auction.nft;
|
|
4588
4845
|
const collection = this.getCollectionContract(auction.collection);
|
|
4589
|
-
const transferParams = new
|
|
4846
|
+
const transferParams = new TransferByProofParams({
|
|
4590
4847
|
address: nftAddress,
|
|
4591
4848
|
from: this.address,
|
|
4592
4849
|
to: auction.owner,
|
|
@@ -5561,6 +5818,7 @@ var AdvancedOffer = AdvancedApproval;
|
|
|
5561
5818
|
NFT,
|
|
5562
5819
|
NFTAddress,
|
|
5563
5820
|
NFTAdmin,
|
|
5821
|
+
NFTAdminAllowFlags,
|
|
5564
5822
|
NFTAdvancedAdmin,
|
|
5565
5823
|
NFTAdvancedAdminContract,
|
|
5566
5824
|
NFTData,
|
|
@@ -5577,6 +5835,7 @@ var AdvancedOffer = AdvancedApproval;
|
|
|
5577
5835
|
NFTState,
|
|
5578
5836
|
NFTStateStruct,
|
|
5579
5837
|
NFTTransactionContext,
|
|
5838
|
+
NFTUpdateEvent,
|
|
5580
5839
|
NFTUpdateProof,
|
|
5581
5840
|
NonFungibleTokenContractsFactory,
|
|
5582
5841
|
Offer,
|
|
@@ -5586,11 +5845,17 @@ var AdvancedOffer = AdvancedApproval;
|
|
|
5586
5845
|
PauseEvent,
|
|
5587
5846
|
PauseNFTEvent,
|
|
5588
5847
|
SellEvent,
|
|
5848
|
+
SetAdminEvent,
|
|
5849
|
+
SetBaseURLEvent,
|
|
5850
|
+
SetNameEvent,
|
|
5851
|
+
SetRoyaltyFeeEvent,
|
|
5852
|
+
SetTransferFeeEvent,
|
|
5589
5853
|
TEXT_TREE_HEIGHT,
|
|
5590
5854
|
Text,
|
|
5855
|
+
TransferByProofParams,
|
|
5856
|
+
TransferBySignatureParams,
|
|
5591
5857
|
TransferEvent,
|
|
5592
5858
|
TransferExtendedParams,
|
|
5593
|
-
TransferParams,
|
|
5594
5859
|
UInt64Option,
|
|
5595
5860
|
Update,
|
|
5596
5861
|
UpdateEvent,
|