@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.
Files changed (81) hide show
  1. package/README.md +12 -0
  2. package/dist/node/contracts/admin.d.ts +100 -10
  3. package/dist/node/contracts/admin.js +130 -29
  4. package/dist/node/contracts/admin.js.map +1 -1
  5. package/dist/node/contracts/collection.d.ts +51 -34
  6. package/dist/node/contracts/collection.js +162 -71
  7. package/dist/node/contracts/collection.js.map +1 -1
  8. package/dist/node/contracts/nft.js +3 -0
  9. package/dist/node/contracts/nft.js.map +1 -1
  10. package/dist/node/contracts.d.ts +36 -30
  11. package/dist/node/index.cjs +447 -182
  12. package/dist/node/interfaces/collection.d.ts +5 -5
  13. package/dist/node/interfaces/events.d.ts +306 -16
  14. package/dist/node/interfaces/events.js +42 -4
  15. package/dist/node/interfaces/events.js.map +1 -1
  16. package/dist/node/interfaces/ownable.d.ts +7 -7
  17. package/dist/node/interfaces/ownable.js.map +1 -1
  18. package/dist/node/interfaces/pausable.d.ts +3 -3
  19. package/dist/node/interfaces/pausable.js.map +1 -1
  20. package/dist/node/interfaces/types.d.ts +182 -27
  21. package/dist/node/interfaces/types.js +120 -71
  22. package/dist/node/interfaces/types.js.map +1 -1
  23. package/dist/node/marketplace/auction.d.ts +2 -2
  24. package/dist/node/marketplace/auction.js +4 -4
  25. package/dist/node/marketplace/auction.js.map +1 -1
  26. package/dist/node/marketplace/bid.js +3 -5
  27. package/dist/node/marketplace/bid.js.map +1 -1
  28. package/dist/node/marketplace/nft-shares.d.ts +2 -2
  29. package/dist/node/util/div.js +10 -5
  30. package/dist/node/util/div.js.map +1 -1
  31. package/dist/node/vk.js +6 -6
  32. package/dist/node/vk.js.map +1 -1
  33. package/dist/node/zkprogram-example/game.d.ts +2 -2
  34. package/dist/node/zkprogram-example/update.d.ts +2 -2
  35. package/dist/tsconfig.node.tsbuildinfo +1 -1
  36. package/dist/tsconfig.web.tsbuildinfo +1 -1
  37. package/dist/web/contracts/admin.d.ts +100 -10
  38. package/dist/web/contracts/admin.js +130 -29
  39. package/dist/web/contracts/admin.js.map +1 -1
  40. package/dist/web/contracts/collection.d.ts +51 -34
  41. package/dist/web/contracts/collection.js +162 -71
  42. package/dist/web/contracts/collection.js.map +1 -1
  43. package/dist/web/contracts/nft.js +3 -0
  44. package/dist/web/contracts/nft.js.map +1 -1
  45. package/dist/web/contracts.d.ts +36 -30
  46. package/dist/web/interfaces/collection.d.ts +5 -5
  47. package/dist/web/interfaces/events.d.ts +306 -16
  48. package/dist/web/interfaces/events.js +42 -4
  49. package/dist/web/interfaces/events.js.map +1 -1
  50. package/dist/web/interfaces/ownable.d.ts +7 -7
  51. package/dist/web/interfaces/ownable.js.map +1 -1
  52. package/dist/web/interfaces/pausable.d.ts +3 -3
  53. package/dist/web/interfaces/pausable.js.map +1 -1
  54. package/dist/web/interfaces/types.d.ts +182 -27
  55. package/dist/web/interfaces/types.js +120 -71
  56. package/dist/web/interfaces/types.js.map +1 -1
  57. package/dist/web/marketplace/auction.d.ts +2 -2
  58. package/dist/web/marketplace/auction.js +4 -4
  59. package/dist/web/marketplace/auction.js.map +1 -1
  60. package/dist/web/marketplace/bid.js +3 -5
  61. package/dist/web/marketplace/bid.js.map +1 -1
  62. package/dist/web/marketplace/nft-shares.d.ts +2 -2
  63. package/dist/web/util/div.js +10 -5
  64. package/dist/web/util/div.js.map +1 -1
  65. package/dist/web/vk.js +6 -6
  66. package/dist/web/vk.js.map +1 -1
  67. package/dist/web/zkprogram-example/game.d.ts +2 -2
  68. package/dist/web/zkprogram-example/update.d.ts +2 -2
  69. package/package.json +8 -8
  70. package/src/contracts/admin.ts +137 -24
  71. package/src/contracts/collection.ts +188 -96
  72. package/src/contracts/nft.ts +3 -0
  73. package/src/interfaces/collection.ts +11 -5
  74. package/src/interfaces/events.ts +47 -3
  75. package/src/interfaces/ownable.ts +1 -1
  76. package/src/interfaces/pausable.ts +1 -1
  77. package/src/interfaces/types.ts +152 -78
  78. package/src/marketplace/auction.ts +5 -4
  79. package/src/marketplace/bid.ts +4 -6
  80. package/src/util/div.ts +12 -5
  81. package/src/vk.ts +6 -6
@@ -5,8 +5,8 @@
5
5
  *
6
6
  * @module CollectionContract
7
7
  */
8
- import { Field, PublicKey, AccountUpdate, Bool, State, DeployArgs, AccountUpdateForest, VerificationKey, UInt32, UInt64, SmartContract } from "o1js";
9
- import { MintParams, MintRequest, TransferParams, CollectionData, NFTUpdateProof, NFTStateStruct, MintEvent, TransferEvent, ApproveEvent, UpgradeVerificationKeyEvent, LimitMintingEvent, PauseNFTEvent, NFTAdminBase, NFTAdminContractConstructor, PauseEvent, OwnershipChangeEvent, NFTOwnerBase, NFTOwnerContractConstructor, UpgradeVerificationKeyData, NFTApprovalContractConstructor, NFTApprovalBase, NFTUpdateContractConstructor, NFTUpdateBase, TransferExtendedParams } from "../interfaces/index.js";
8
+ import { Field, PublicKey, AccountUpdate, Bool, State, DeployArgs, AccountUpdateForest, VerificationKey, UInt32, UInt64 } from "o1js";
9
+ import { MintParams, MintRequest, TransferBySignatureParams, TransferByProofParams, CollectionData, NFTUpdateProof, NFTStateStruct, MintEvent, NFTUpdateEvent, TransferEvent, ApproveEvent, UpgradeVerificationKeyEvent, LimitMintingEvent, PauseNFTEvent, NFTAdminBase, NFTAdminContractConstructor, PauseEvent, SetNameEvent, SetBaseURLEvent, SetRoyaltyFeeEvent, SetTransferFeeEvent, SetAdminEvent, OwnershipChangeEvent, NFTOwnerBase, NFTOwnerContractConstructor, UpgradeVerificationKeyData, NFTApprovalContractConstructor, NFTApprovalBase, NFTUpdateContractConstructor, NFTUpdateBase, TransferExtendedParams } from "../interfaces/index.js";
10
10
  export { CollectionDeployProps, CollectionFactory, CollectionErrors };
11
11
  declare const CollectionErrors: {
12
12
  wrongMasterNFTaddress: string;
@@ -30,6 +30,7 @@ declare const CollectionErrors: {
30
30
  onlyOwnerCanUpgradeVerificationKey: string;
31
31
  invalidRoyaltyFee: string;
32
32
  invalidOracleAddress: string;
33
+ pendingCreatorIsEmpty: string;
33
34
  };
34
35
  interface CollectionDeployProps extends Exclude<DeployArgs, undefined> {
35
36
  collectionName: Field;
@@ -65,6 +66,8 @@ declare function CollectionFactory(params: {
65
66
  * such as flags and fee configurations.
66
67
  */
67
68
  packedData: State<import("node_modules/o1js/dist/node/lib/provable/field.js").Field>;
69
+ /** The public key part (x) of the pending creator. The isOdd field is written to the packedData */
70
+ pendingCreatorX: State<import("node_modules/o1js/dist/node/lib/provable/field.js").Field>;
68
71
  /**
69
72
  * Deploys the NFT Collection Contract with the initial settings.
70
73
  *
@@ -83,22 +86,23 @@ declare function CollectionFactory(params: {
83
86
  */
84
87
  events: {
85
88
  mint: typeof MintEvent;
86
- update: typeof PublicKey;
89
+ update: typeof NFTUpdateEvent;
87
90
  transfer: typeof TransferEvent;
88
91
  approve: typeof ApproveEvent;
89
92
  upgradeNFTVerificationKey: typeof UpgradeVerificationKeyEvent;
90
- upgradeVerificationKey: typeof import("node_modules/o1js/dist/node/lib/provable/field.js").Field & ((x: string | number | bigint | import("node_modules/o1js/dist/node/lib/provable/core/fieldvar.js").FieldConst | import("node_modules/o1js/dist/node/lib/provable/core/fieldvar.js").FieldVar | import("node_modules/o1js/dist/node/lib/provable/field.js").Field) => import("node_modules/o1js/dist/node/lib/provable/field.js").Field);
93
+ upgradeVerificationKey: typeof UpgradeVerificationKeyEvent;
91
94
  limitMinting: typeof LimitMintingEvent;
92
95
  pause: typeof PauseEvent;
93
96
  resume: typeof PauseEvent;
94
97
  pauseNFT: typeof PauseNFTEvent;
95
98
  resumeNFT: typeof PauseNFTEvent;
96
- ownershipChange: typeof OwnershipChangeEvent;
97
- setName: typeof import("node_modules/o1js/dist/node/lib/provable/field.js").Field & ((x: string | number | bigint | import("node_modules/o1js/dist/node/lib/provable/core/fieldvar.js").FieldConst | import("node_modules/o1js/dist/node/lib/provable/core/fieldvar.js").FieldVar | import("node_modules/o1js/dist/node/lib/provable/field.js").Field) => import("node_modules/o1js/dist/node/lib/provable/field.js").Field);
98
- setBaseURL: typeof import("node_modules/o1js/dist/node/lib/provable/field.js").Field & ((x: string | number | bigint | import("node_modules/o1js/dist/node/lib/provable/core/fieldvar.js").FieldConst | import("node_modules/o1js/dist/node/lib/provable/core/fieldvar.js").FieldVar | import("node_modules/o1js/dist/node/lib/provable/field.js").Field) => import("node_modules/o1js/dist/node/lib/provable/field.js").Field);
99
- setRoyaltyFee: typeof UInt32;
100
- setTransferFee: typeof UInt64;
101
- setAdmin: typeof PublicKey;
99
+ ownershipTransfer: typeof OwnershipChangeEvent;
100
+ ownershipAccepted: typeof OwnershipChangeEvent;
101
+ setName: typeof SetNameEvent;
102
+ setBaseURL: typeof SetBaseURLEvent;
103
+ setRoyaltyFee: typeof SetRoyaltyFeeEvent;
104
+ setTransferFee: typeof SetTransferFeeEvent;
105
+ setAdmin: typeof SetAdminEvent;
102
106
  };
103
107
  /**
104
108
  * Overrides the approveBase method to prevent transfers of tokens.
@@ -147,7 +151,7 @@ declare function CollectionFactory(params: {
147
151
  *
148
152
  * @returns The packed data of the collection.
149
153
  */
150
- ensureNotPaused(): Promise<void>;
154
+ ensureNotPaused(): Promise<CollectionData>;
151
155
  /**
152
156
  * Mints a new NFT directly by the creator.
153
157
  *
@@ -208,8 +212,8 @@ declare function CollectionFactory(params: {
208
212
  /**
209
213
  * Transfers ownership of an NFT without admin approval.
210
214
  *
211
- * @param address - The address of the NFT.
212
- * @param to - The recipient's public key.
215
+ * @param nftAddress - The address of the NFT.
216
+ * @param approved - The approved public key.
213
217
  */
214
218
  approveAddressByProof(nftAddress: PublicKey, approved: PublicKey): Promise<void>;
215
219
  /**
@@ -221,7 +225,7 @@ declare function CollectionFactory(params: {
221
225
  * @param to - The recipient's public key.
222
226
  * @param price - The price of the NFT (optional).
223
227
  */
224
- transferBySignature(params: TransferParams): Promise<void>;
228
+ transferBySignature(params: TransferBySignatureParams): Promise<void>;
225
229
  /**
226
230
  * Transfers ownership of an NFT using a proof in case the owner is a contract
227
231
  * Can be called by the owner or approved that should be a contracts
@@ -229,7 +233,7 @@ declare function CollectionFactory(params: {
229
233
  *
230
234
  * @param params - The transfer parameters.
231
235
  */
232
- transferByProof(params: TransferParams): Promise<void>;
236
+ transferByProof(params: TransferByProofParams): Promise<void>;
233
237
  /**
234
238
  * Transfers ownership of an NFT using a proof in case the owner is a contract
235
239
  * Can be called by the owner or approved that should be a contracts
@@ -237,7 +241,7 @@ declare function CollectionFactory(params: {
237
241
  *
238
242
  * @param params - The transfer parameters.
239
243
  */
240
- approvedTransferByProof(params: TransferParams): Promise<void>;
244
+ adminApprovedTransferByProof(params: TransferByProofParams): Promise<void>;
241
245
  /**
242
246
  * Transfers ownership of an NFT with admin approval.
243
247
  *
@@ -245,13 +249,21 @@ declare function CollectionFactory(params: {
245
249
  * @param to - The recipient's public key.
246
250
  * @param price - The price of the NFT (optional).
247
251
  */
248
- approvedTransferBySignature(params: TransferParams): Promise<void>;
252
+ adminApprovedTransferBySignature(params: TransferBySignatureParams): Promise<void>;
249
253
  /**
250
254
  * Internal method to transfer an NFT.
251
255
  *
252
- * @param address - The address of the NFT.
253
- * @param to - The recipient's public key.
256
+ * This method handles the transfer logic and fee calculation. The fee is determined as follows:
257
+ * - If a price is provided, the fee is calculated as (price * royaltyFee / MAX_ROYALTY_FEE)
258
+ * - If no price is provided, the fixed transferFee is used to handle two cases:
259
+ * when NFT is being sold and the price is not provided to the contract
260
+ * when NFT is being transferred by the owner (without price)
261
+ * - If the sender is the creator, no fee is charged
262
+ * - The minimum fee is always the transferFee (unless sender is creator)
263
+ *
264
+ * @param transferEventDraft - The transfer event draft, containing the information about the transfer
254
265
  * @param transferFee - The transfer fee amount.
266
+ * @param royaltyFee - The royalty fee amount.
255
267
  * @returns The TransferEvent emitted.
256
268
  */
257
269
  _transfer(params: {
@@ -361,27 +373,36 @@ declare function CollectionFactory(params: {
361
373
  * @throws {Error} If caller lacks permission to change transfer fee
362
374
  */
363
375
  setTransferFee(transferFee: UInt64): Promise<void>;
376
+ /**
377
+ * Transfers ownership of the collection to a new creator.
378
+ * This method is called transferOwnership as the Collection is implementing OwnableContract interface
379
+ * For the Collection, the creator is the owner of the collection
380
+ *
381
+ * @param to - The public key of the new creator.
382
+ * @returns The public key of the old creator.
383
+ */
384
+ transferOwnership(to: PublicKey): Promise<PublicKey>;
364
385
  /**
365
386
  * Transfers ownership of the collection to a new owner.
366
387
  *
367
388
  * @param to - The public key of the new owner.
368
389
  * @returns The public key of the old owner.
369
390
  */
370
- transferOwnership(to: PublicKey): Promise<PublicKey>;
391
+ acceptOwnership(): Promise<PublicKey>;
371
392
  getNFTState(address: PublicKey): Promise<NFTStateStruct>;
372
393
  deriveTokenId(): import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
373
394
  readonly internal: {
374
395
  mint({ address, amount, }: {
375
- address: PublicKey | AccountUpdate | SmartContract;
396
+ address: PublicKey | AccountUpdate | import("o1js").SmartContract;
376
397
  amount: number | bigint | UInt64;
377
398
  }): AccountUpdate;
378
399
  burn({ address, amount, }: {
379
- address: PublicKey | AccountUpdate | SmartContract;
400
+ address: PublicKey | AccountUpdate | import("o1js").SmartContract;
380
401
  amount: number | bigint | UInt64;
381
402
  }): AccountUpdate;
382
403
  send({ from, to, amount, }: {
383
- from: PublicKey | AccountUpdate | SmartContract;
384
- to: PublicKey | AccountUpdate | SmartContract;
404
+ from: PublicKey | AccountUpdate | import("o1js").SmartContract;
405
+ to: PublicKey | AccountUpdate | import("o1js").SmartContract;
385
406
  amount: number | bigint | UInt64;
386
407
  }): AccountUpdate;
387
408
  };
@@ -399,7 +420,7 @@ declare function CollectionFactory(params: {
399
420
  readonly self: AccountUpdate;
400
421
  newSelf(methodName?: string): AccountUpdate;
401
422
  sender: {
402
- self: SmartContract;
423
+ self: import("o1js").SmartContract;
403
424
  getUnconstrained(): PublicKey;
404
425
  getAndRequireSignature(): PublicKey;
405
426
  };
@@ -408,15 +429,15 @@ declare function CollectionFactory(params: {
408
429
  readonly currentSlot: import("node_modules/o1js/dist/node/lib/mina/v1/precondition.js").CurrentSlot;
409
430
  approve(update: AccountUpdate | import("o1js").AccountUpdateTree | AccountUpdateForest): void;
410
431
  send(args: {
411
- to: PublicKey | AccountUpdate | SmartContract;
432
+ to: PublicKey | AccountUpdate | import("o1js").SmartContract;
412
433
  amount: number | bigint | UInt64;
413
434
  }): AccountUpdate;
414
435
  readonly balance: {
415
436
  addInPlace(x: string | number | bigint | UInt64 | UInt32 | import("o1js").Int64): void;
416
437
  subInPlace(x: string | number | bigint | UInt64 | UInt32 | import("o1js").Int64): void;
417
438
  };
418
- emitEventIf<K extends "update" | "approve" | "transfer" | "upgradeVerificationKey" | "pause" | "resume" | "mint" | "upgradeNFTVerificationKey" | "limitMinting" | "pauseNFT" | "resumeNFT" | "ownershipChange" | "setName" | "setBaseURL" | "setRoyaltyFee" | "setTransferFee" | "setAdmin">(condition: Bool, type: K, event: any): void;
419
- emitEvent<K extends "update" | "approve" | "transfer" | "upgradeVerificationKey" | "pause" | "resume" | "mint" | "upgradeNFTVerificationKey" | "limitMinting" | "pauseNFT" | "resumeNFT" | "ownershipChange" | "setName" | "setBaseURL" | "setRoyaltyFee" | "setTransferFee" | "setAdmin">(type: K, event: any): void;
439
+ emitEventIf<K extends "update" | "approve" | "transfer" | "upgradeVerificationKey" | "pause" | "resume" | "mint" | "upgradeNFTVerificationKey" | "limitMinting" | "pauseNFT" | "resumeNFT" | "ownershipTransfer" | "ownershipAccepted" | "setName" | "setBaseURL" | "setRoyaltyFee" | "setTransferFee" | "setAdmin">(condition: Bool, type: K, event: any): void;
440
+ emitEvent<K extends "update" | "approve" | "transfer" | "upgradeVerificationKey" | "pause" | "resume" | "mint" | "upgradeNFTVerificationKey" | "limitMinting" | "pauseNFT" | "resumeNFT" | "ownershipTransfer" | "ownershipAccepted" | "setName" | "setBaseURL" | "setRoyaltyFee" | "setTransferFee" | "setAdmin">(type: K, event: any): void;
420
441
  fetchEvents(start?: UInt32, end?: UInt32): Promise<{
421
442
  type: string;
422
443
  event: {
@@ -489,11 +510,7 @@ declare function CollectionFactory(params: {
489
510
  packed?: [import("node_modules/o1js/dist/node/lib/provable/field.js").Field, number][] | undefined;
490
511
  };
491
512
  toJSON: (x: {
492
- accountUpdate: import("node_modules/o1js/dist/node/lib/provable/field.js" /**
493
- * Deploys the NFT Collection Contract with the initial settings.
494
- *
495
- * @param props - Deployment properties including collection name, creator, admin, baseURL, symbol, and URL.
496
- */).Field;
513
+ accountUpdate: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
497
514
  calls: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
498
515
  }) => {
499
516
  accountUpdate: string;
@@ -512,7 +529,7 @@ declare function CollectionFactory(params: {
512
529
  };
513
530
  };
514
531
  publicOutputType: import("node_modules/o1js/dist/node/lib/provable/types/struct.js").ProvablePureExtended<undefined, undefined, null>;
515
- tag: () => typeof SmartContract;
532
+ tag: () => typeof import("o1js").SmartContract;
516
533
  fromJSON<S extends import("node_modules/o1js/dist/node/lib/util/types.js").Subclass<typeof import("o1js").Proof>>(this: S, { maxProofsVerified, proof: proofString, publicInput: publicInputJson, publicOutput: publicOutputJson, }: import("o1js").JsonProof): Promise<import("o1js").Proof<import("o1js").InferProvable<S["publicInputType"]>, import("o1js").InferProvable<S["publicOutputType"]>>>;
517
534
  dummy<Input, OutPut>(publicInput: Input, publicOutput: OutPut, maxProofsVerified: 0 | 2 | 1, domainLog2?: number): Promise<import("o1js").Proof<Input, OutPut>>;
518
535
  readonly provable: {