Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 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 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 | 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 1006x 45x 45x 1015x 6x 6x 6x 20x 20x 1x 1x 1x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 1x 1x 24x 24x 24x 24x 24x 24x 24x 24x 24x 1x 1x 1x 1x 6x 6x 6x 6x 3x 3x 1137x 1137x 1137x 1137x 1106x 1106x 1106x 1106x 1106x 1106x 1106x 1106x 1106x 1106x 1106x 1106x 1106x 1106x 1106x 4x 4x 1068x 1230x 1230x 1230x 1230x 1230x 1230x | import { Field, PublicKey, Bool, VerificationKey, Struct, UInt32, UInt8, UInt64, Encoding, Provable, DynamicProof, FeatureFlags, Option, Account, } from "o1js"; export { Storage, MintParams, MintParamsOption, MintRequest, NFTData, CollectionData, NFTState, NFTImmutableState, NFTUpdateProof, CollectionDataPacked, CollectionConfigurationUpdate, NFTStateStruct, }; /** * Represents the off-chain storage information for an NFT, * such as an IPFS hash. */ class Storage extends Struct({ url: Provable.Array(Field, 2), }) { constructor(value: { url: [Field, Field] }) { super(value); } /** * Asserts that two Storage instances are equal. * @param a The first Storage instance. * @param b The second Storage instance. */ static assertEquals(a: Storage, b: Storage) { a.url[0].assertEquals(b.url[0]); a.url[1].assertEquals(b.url[1]); } /** * Checks if two Storage instances are equal. * @param a The first Storage instance. * @param b The second Storage instance. * @returns A Bool indicating whether the two instances are equal. */ static equals(a: Storage, b: Storage): Bool { return a.url[0].equals(b.url[0]).and(a.url[1].equals(b.url[1])); } /** * Creates a Storage instance from a string. * @param url The string representing the storage URL. * @returns A new Storage instance. */ static fromString(url: string): Storage { const fields = Encoding.stringToFields(url); Iif (fields.length !== 2) throw new Error("Invalid string length"); return new Storage({ url: [fields[0], fields[1]] }); } /** * Converts the Storage instance to a string. * @returns The string representation of the storage URL. */ toString(): string { Iif (this.url[0].toBigInt() === 0n && this.url[1].toBigInt() === 0n) { throw new Error("Invalid string"); } return Encoding.stringFromFields([this.url[0], this.url[1]]); } } /** * Represents the on-chain state structure of an NFT. * The order of the fields is important and should match the NFT SmartContract. */ class NFTStateStruct extends Struct({ name: Field, metadata: Field, owner: PublicKey, storage: Storage, packedData: Field, metadataVerificationKeyHash: Field, }) { /** * Creates an NFTStateStruct from an account's app state. * @param account The account containing the zkApp state. * @returns A new NFTStateStruct instance. */ static fromAccount(account: Account) { Iif (!account.zkapp?.appState) { throw new Error("Invalid zkApp account state"); } Iif (NFTStateStruct.sizeInFields() !== account.zkapp?.appState.length) { throw new Error("Invalid NFTStateStruct size"); } return NFTStateStruct.fromFields(account.zkapp?.appState); } /** * Asserts that two NFTStateStruct instances are equal. * @param a The first NFTStateStruct instance. * @param b The second NFTStateStruct instance. */ static assertEqual(a: NFTStateStruct, b: NFTStateStruct) { a.name.assertEquals(b.name); a.metadata.assertEquals(b.metadata); a.owner.assertEquals(b.owner); Storage.assertEquals(a.storage, b.storage); a.packedData.assertEquals(b.packedData); a.metadataVerificationKeyHash.assertEquals(b.metadataVerificationKeyHash); } } /** * Represents the immutable state of an NFT, containing read-only properties * and flags that determine the NFT's behavior and permissions. */ class NFTImmutableState extends Struct({ /** The public key of the creator of the NFT (readonly). */ creator: PublicKey, // readonly /** Determines if the NFT's ownership can be changed via a zero-knowledge proof (readonly). */ canChangeOwnerByProof: Bool, // readonly /** Specifies if the NFT's ownership can be transferred through the owner's signature (readonly). */ canChangeOwnerBySignature: Bool, // readonly /** Indicates whether the NFT's metadata can be updated (readonly). */ canChangeMetadata: Bool, // readonly /** Indicates if the price of the NFT can be modified (readonly). */ canChangePrice: Bool, // readonly /** Determines whether the storage associated with the NFT can be altered (readonly). */ canChangeStorage: Bool, // readonly /** Specifies if the name of the NFT can be changed (readonly). */ canChangeName: Bool, // readonly /** Indicates whether the verification key hash for the metadata can be changed (readonly). */ canChangeMetadataVerificationKeyHash: Bool, // readonly /** Specifies if the NFT contract can be paused, preventing certain operations (readonly). */ canPause: Bool, // readonly /** The address of the NFT contract (readonly). */ address: PublicKey, // readonly /** The token ID associated with the NFT (readonly). */ tokenId: Field, // readonly /** The unique identifier of the NFT within the collection (readonly). */ id: UInt32, // readonly }) { /** * Asserts that two NFTImmutableState instances are equal. * @param a The first NFTImmutableState instance. * @param b The second NFTImmutableState instance. */ static assertEqual(a: NFTImmutableState, b: NFTImmutableState) { a.creator.assertEquals(b.creator); a.canChangeOwnerByProof.assertEquals(b.canChangeOwnerByProof); a.canChangeOwnerBySignature.assertEquals(b.canChangeOwnerBySignature); a.canChangeMetadata.assertEquals(b.canChangeMetadata); a.canChangePrice.assertEquals(b.canChangePrice); a.canChangeStorage.assertEquals(b.canChangeStorage); a.canChangeName.assertEquals(b.canChangeName); a.canChangeMetadataVerificationKeyHash.assertEquals( b.canChangeMetadataVerificationKeyHash ); a.canPause.assertEquals(b.canPause); a.address.assertEquals(b.address); a.tokenId.assertEquals(b.tokenId); a.id.assertEquals(b.id); } /** * Creates a new NFTImmutableState from NFTData and other parameters. * @param params The parameters including nftData, creator, address, and tokenId. * @returns A new NFTImmutableState instance. */ static fromNFTData(params: { nftData: NFTData; creator: PublicKey; address: PublicKey; tokenId: Field; }) { const { nftData, creator, address, tokenId } = params; return new NFTImmutableState({ creator, address, tokenId, id: nftData.id, canChangeOwnerByProof: nftData.canChangeOwnerByProof, canChangeOwnerBySignature: nftData.canChangeOwnerBySignature, canChangeMetadata: nftData.canChangeMetadata, canChangePrice: nftData.canChangePrice, canChangeStorage: nftData.canChangeStorage, canChangeName: nftData.canChangeName, canChangeMetadataVerificationKeyHash: nftData.canChangeMetadataVerificationKeyHash, canPause: nftData.canPause, }); } } /** * Represents the full state of an NFT, including both immutable and mutable properties. */ class NFTState extends Struct({ /** The immutable state of the NFT. */ immutableState: NFTImmutableState, /** The name of the NFT. */ name: Field, /** The metadata associated with the NFT. */ metadata: Field, /** The off-chain storage information (e.g., IPFS hash). */ storage: Storage, /** The current owner of the NFT. */ owner: PublicKey, /** The price of the NFT. */ price: UInt64, /** The version number of the NFT state. */ version: UInt32, /** Indicates whether the NFT contract is currently paused. */ isPaused: Bool, /** The hash of the verification key used for metadata proofs. */ metadataVerificationKeyHash: Field, }) { /** * Asserts that two NFTState instances are equal. * @param a The first NFTState instance. * @param b The second NFTState instance. */ static assertEqual(a: NFTState, b: NFTState) { NFTImmutableState.assertEqual(a.immutableState, b.immutableState); a.name.assertEquals(b.name); a.metadata.assertEquals(b.metadata); Storage.assertEquals(a.storage, b.storage); a.owner.assertEquals(b.owner); a.price.assertEquals(b.price); a.version.assertEquals(b.version); a.isPaused.assertEquals(b.isPaused); a.metadataVerificationKeyHash.assertEquals(b.metadataVerificationKeyHash); } /** * Creates a new NFTState from an NFTStateStruct and other parameters. * @param params The parameters including nftState, creator, address, and tokenId. * @returns A new NFTState instance. */ static fromNFTState(params: { nftState: NFTStateStruct; creator: PublicKey; address: PublicKey; tokenId: Field; }) { const { nftState, creator, address, tokenId } = params; const nftData = NFTData.unpack(nftState.packedData); const immutableState = NFTImmutableState.fromNFTData({ nftData, creator, address, tokenId, }); return new NFTState({ immutableState, name: nftState.name, metadata: nftState.metadata, storage: nftState.storage, owner: nftState.owner, price: nftData.price, version: nftData.version, isPaused: nftData.isPaused, metadataVerificationKeyHash: nftState.metadataVerificationKeyHash, }); } } /** * Represents a dynamic proof used for updating the state of an NFT. */ class NFTUpdateProof extends DynamicProof<NFTState, NFTState> { static publicInputType = NFTState; static publicOutputType = NFTState; static maxProofsVerified = 2 as const; static featureFlags = FeatureFlags.allMaybe; } /** * Represents the data associated with an NFT, including state and permission flags. */ class NFTData extends Struct({ /** The price of the NFT. */ price: UInt64, /** The version number of the NFT state. */ version: UInt32, /** The unique identifier of the NFT within the collection. */ id: UInt32, /** Determines whether the NFT's ownership can be changed via a zero-knowledge proof (readonly). */ canChangeOwnerByProof: Bool, // readonly /** Specifies if the NFT's ownership can be transferred through the owner's signature (readonly). */ canChangeOwnerBySignature: Bool, // readonly /** Indicates whether the NFT's metadata can be updated (readonly). */ canChangeMetadata: Bool, // readonly /** Indicates if the price of the NFT can be modified (readonly). */ canChangePrice: Bool, // readonly /** Determines whether the storage associated with the NFT can be altered (readonly). */ canChangeStorage: Bool, // readonly /** Specifies if the name of the NFT can be changed (readonly). */ canChangeName: Bool, // readonly /** Indicates whether the verification key hash for the metadata can be changed (readonly). */ canChangeMetadataVerificationKeyHash: Bool, // readonly /** Specifies if the NFT contract can be paused, preventing certain operations (readonly). */ canPause: Bool, // readonly /** Indicates whether the NFT contract is currently paused. */ isPaused: Bool, /** Determines whether the owner's signature is required to upgrade the NFT's verification key (readonly). */ requireOwnerSignatureToUpgrade: Bool, // readonly }) { /** * Creates a new NFTData instance with optional parameters. * @param params The parameters to create the NFTData. * @returns A new NFTData instance. */ static new( params: { price?: number; version?: number; id?: number; canChangeOwnerByProof?: boolean; canChangeOwnerBySignature?: boolean; canChangeMetadata?: boolean; canChangePrice?: boolean; canChangeStorage?: boolean; canChangeName?: boolean; canChangeMetadataVerificationKeyHash?: boolean; canPause?: boolean; isPaused?: boolean; requireOwnerSignatureToUpgrade?: boolean; } = {} ): NFTData { const { price, version, id, canChangeOwnerByProof, canChangeOwnerBySignature, canChangeMetadata, canChangePrice, canChangeStorage, canChangeName, canChangeMetadataVerificationKeyHash, canPause, isPaused, requireOwnerSignatureToUpgrade, } = params; return new NFTData({ price: UInt64.from(price ?? 0), version: UInt32.from(version ?? 0), id: UInt32.from(id ?? 0), canChangeOwnerByProof: Bool(canChangeOwnerByProof ?? false), canChangeOwnerBySignature: Bool(canChangeOwnerBySignature ?? true), canChangeMetadata: Bool(canChangeMetadata ?? false), canChangePrice: Bool(canChangePrice ?? true), canChangeStorage: Bool(canChangeStorage ?? false), canChangeName: Bool(canChangeName ?? false), canChangeMetadataVerificationKeyHash: Bool( canChangeMetadataVerificationKeyHash ?? false ), canPause: Bool(canPause ?? false), isPaused: Bool(isPaused ?? false), requireOwnerSignatureToUpgrade: Bool( requireOwnerSignatureToUpgrade ?? false ), }); } /** * Packs the NFTData into a single Field for efficient storage. * @returns The packed Field representation of the NFTData. */ pack(): Field { const price = this.price.value.toBits(64); const version = this.version.value.toBits(32); const id = this.id.value.toBits(32); return Field.fromBits([ ...price, ...version, ...id, this.canChangeOwnerByProof, this.canChangeOwnerBySignature, this.canChangeMetadata, this.canChangePrice, this.canChangeStorage, this.canChangeName, this.canChangeMetadataVerificationKeyHash, this.canPause, this.isPaused, this.requireOwnerSignatureToUpgrade, ]); } /** * Unpacks a Field into an NFTData instance. * @param packed The packed Field representation of the NFTData. * @returns A new NFTData instance. */ static unpack(packed: Field) { const bits = packed.toBits(64 + 32 + 32 + 10); const price = UInt64.Unsafe.fromField(Field.fromBits(bits.slice(0, 64))); const version = UInt32.Unsafe.fromField( Field.fromBits(bits.slice(64, 64 + 32)) ); const id = UInt32.Unsafe.fromField( Field.fromBits(bits.slice(64 + 32, 64 + 32 + 32)) ); const canChangeOwnerByProof = bits[64 + 32 + 32]; const canChangeOwnerBySignature = bits[64 + 32 + 32 + 1]; const canChangeMetadata = bits[64 + 32 + 32 + 2]; const canChangePrice = bits[64 + 32 + 32 + 3]; const canChangeStorage = bits[64 + 32 + 32 + 4]; const canChangeName = bits[64 + 32 + 32 + 5]; const canChangeMetadataVerificationKeyHash = bits[64 + 32 + 32 + 6]; const canPause = bits[64 + 32 + 32 + 7]; const isPaused = bits[64 + 32 + 32 + 8]; const requireOwnerSignatureToUpgrade = bits[64 + 32 + 32 + 9]; return new NFTData({ price, version, id, canChangeOwnerByProof, canChangeOwnerBySignature, canChangeMetadata, canChangePrice, canChangeStorage, canChangeName, canChangeMetadataVerificationKeyHash, canPause, isPaused, requireOwnerSignatureToUpgrade, }); } } /** * Represents an update to the collection's configuration, such as name, base URL, fees, and admin. */ class CollectionConfigurationUpdate extends Struct({ /** The name of the collection. */ name: Field, /** The base URL for the metadata of the NFTs in the collection. */ baseURL: Field, /** The royalty fee percentage (e.g., 1000 = 1%). */ royaltyFee: UInt32, /** The transfer fee amount. */ transferFee: UInt64, /** The public key of the admin contract. */ admin: PublicKey, }) {} /** * Represents the packed collection data, including the upgrade authority's x-coordinate and packed data fields. */ class CollectionDataPacked extends Struct({ /** The x-coordinate of the upgrade authority's public key. */ upgradeAuthorityX: Field, /** The packed data field containing collection parameters and flags. */ packedData: Field, }) {} /** * Represents the data associated with an NFT collection, including configuration parameters and permission flags. */ class CollectionData extends Struct({ /** The public key of the upgrade authority contract. */ upgradeAuthority: PublicKey, /** The royalty fee percentage (e.g., 1000 = 1%, 100 = 0.1%). */ royaltyFee: UInt32, // 1000 = 1%, 100 = 0.1%, 10000 = 10% /** The transfer fee amount. */ transferFee: UInt64, /** If true, transferring NFTs requires approval from the admin contract. */ requireTransferApproval: Bool, /** If true, updating NFTs requires approval from the admin contract. */ requireUpdateApproval: Bool, /** If true, listing NFTs for sale requires approval from the admin contract. */ requireSaleApproval: Bool, /** If true, purchasing NFTs requires approval from the admin contract. */ requireBuyApproval: Bool, /** If true, upgrading the collection's verification key requires the creator's signature. */ requireCreatorSignatureToUpgradeCollection: Bool, /** If true, upgrading an NFT's verification key requires the creator's signature. */ requireCreatorSignatureToUpgradeNFT: Bool, /** If true, new NFTs can be minted in this collection. */ canMint: Bool, /** If true, the collection can be paused and resumed by authorized parties. */ canPause: Bool, /** If true, the name of the collection can be changed. */ canChangeName: Bool, /** If true, the creator of the collection can be changed. */ canChangeCreator: Bool, /** If true, the base URI for the collection's metadata can be changed. */ canChangeBaseUri: Bool, /** If true, the royalty fee configuration can be changed. */ canChangeRoyalty: Bool, /** If true, the transfer fee configuration can be changed. */ canChangeTransferFee: Bool, /** If true, the admin contract associated with the collection can be changed. */ canSetAdmin: Bool, /** Indicates whether the collection is currently paused. */ isPaused: Bool, }) { /** * Creates a new CollectionData instance with specified parameters. * @param params The parameters to create the CollectionData. * @returns A new CollectionData instance. */ static new(params: { upgradeAuthority?: PublicKey; royaltyFee?: number; transferFee?: number; requireTransferApproval?: boolean; requireUpdateApproval?: boolean; requireSaleApproval?: boolean; requireBuyApproval?: boolean; requireCreatorSignatureToUpgradeCollection?: boolean; requireCreatorSignatureToUpgradeNFT?: boolean; canMint?: boolean; canChangeName?: boolean; canChangeCreator?: boolean; canChangeBaseUri?: boolean; canChangeRoyalty?: boolean; canChangeTransferFee?: boolean; canSetAdmin?: boolean; canPause?: boolean; isPaused?: boolean; }): CollectionData { const { upgradeAuthority, royaltyFee, transferFee, requireTransferApproval, requireUpdateApproval, requireSaleApproval, requireBuyApproval, requireCreatorSignatureToUpgradeCollection, requireCreatorSignatureToUpgradeNFT, canMint, canChangeName, canChangeCreator, canChangeBaseUri, canChangeRoyalty, canChangeTransferFee, canSetAdmin, canPause, isPaused, } = params; return new CollectionData({ upgradeAuthority: upgradeAuthority ?? PublicKey.empty(), royaltyFee: UInt32.from(royaltyFee ?? 0), transferFee: UInt64.from(transferFee ?? 0), requireTransferApproval: Bool(requireTransferApproval ?? false), requireUpdateApproval: Bool(requireUpdateApproval ?? false), requireSaleApproval: Bool(requireSaleApproval ?? false), requireBuyApproval: Bool(requireBuyApproval ?? false), requireCreatorSignatureToUpgradeCollection: Bool( requireCreatorSignatureToUpgradeCollection ?? false ), requireCreatorSignatureToUpgradeNFT: Bool( requireCreatorSignatureToUpgradeNFT ?? false ), canMint: Bool(canMint ?? true), canPause: Bool(canPause ?? true), canChangeName: Bool(canChangeName ?? false), canChangeCreator: Bool(canChangeCreator ?? false), canChangeBaseUri: Bool(canChangeBaseUri ?? false), canChangeRoyalty: Bool(canChangeRoyalty ?? false), canChangeTransferFee: Bool(canChangeTransferFee ?? false), canSetAdmin: Bool(canSetAdmin ?? false), isPaused: Bool(isPaused ?? false), }); } /** * Packs the CollectionData into a CollectionDataPacked representation for efficient storage. * @returns The packed CollectionDataPacked instance. */ pack(): CollectionDataPacked { return new CollectionDataPacked({ upgradeAuthorityX: this.upgradeAuthority.x, packedData: Field.fromBits([ ...this.royaltyFee.value.toBits(32), ...this.transferFee.value.toBits(64), this.requireTransferApproval, this.requireUpdateApproval, this.requireSaleApproval, this.requireBuyApproval, this.requireCreatorSignatureToUpgradeCollection, this.requireCreatorSignatureToUpgradeNFT, this.canMint, this.canChangeName, this.canChangeCreator, this.canChangeBaseUri, this.canChangeRoyalty, this.canChangeTransferFee, this.canSetAdmin, this.canPause, this.isPaused, this.upgradeAuthority.isOdd, ]), }); } /** * Unpacks a CollectionDataPacked instance into a CollectionData instance. * @param packed The packed CollectionDataPacked instance. * @returns A new CollectionData instance. */ static unpack(packed: CollectionDataPacked) { const bits = packed.packedData.toBits(32 + 64 + 16); const royaltyFee = UInt32.Unsafe.fromField( Field.fromBits(bits.slice(0, 32)) ); const transferFee = UInt64.Unsafe.fromField( Field.fromBits(bits.slice(32, 32 + 64)) ); const upgradeAuthorityIsOdd = bits[32 + 64 + 15]; const upgradeAuthority = PublicKey.from({ x: packed.upgradeAuthorityX, isOdd: upgradeAuthorityIsOdd, }); return new CollectionData({ royaltyFee, transferFee, upgradeAuthority, requireTransferApproval: bits[32 + 64], requireUpdateApproval: bits[32 + 64 + 1], requireSaleApproval: bits[32 + 64 + 2], requireBuyApproval: bits[32 + 64 + 3], requireCreatorSignatureToUpgradeCollection: bits[32 + 64 + 4], requireCreatorSignatureToUpgradeNFT: bits[32 + 64 + 5], canMint: bits[32 + 64 + 6], canChangeName: bits[32 + 64 + 7], canChangeCreator: bits[32 + 64 + 8], canChangeBaseUri: bits[32 + 64 + 9], canChangeRoyalty: bits[32 + 64 + 10], canChangeTransferFee: bits[32 + 64 + 11], canSetAdmin: bits[32 + 64 + 12], canPause: bits[32 + 64 + 13], isPaused: bits[32 + 64 + 14], }); } } /** * Represents the parameters required for minting a new NFT. */ class MintParams extends Struct({ /** The name of the NFT. */ name: Field, /** The address of the NFT contract. */ address: PublicKey, /** The token ID of the NFT. */ tokenId: Field, /** The owner of the NFT. */ owner: PublicKey, /** The data associated with the NFT, including permissions and flags. */ data: NFTData, /** The fee associated with minting the NFT. */ fee: UInt64, /** The metadata associated with the NFT. */ metadata: Field, /** The off-chain storage information (e.g., IPFS hash). */ storage: Storage, /** The hash of the verification key used for metadata proofs. */ metadataVerificationKeyHash: Field, /** The expiry time for minting the NFT. */ expiry: UInt32, }) {} /** * Represents an optional MintParams, used in scenarios where minting may or may not be allowed. */ class MintParamsOption extends Option(MintParams) {} /** * Represents a request to mint a new NFT, used by the admin contract to determine if minting is allowed. */ class MintRequest extends Struct({ /** The address of the NFT contract where the NFT will be minted. */ address: PublicKey, /** The owner of the new NFT (can be different from the sender). */ owner: PublicKey, // can be different from the sender /** A custom identifier that can be interpreted by the admin contract. */ customId: Field, // should be interpreted by the admin contract /** A custom flag that can be interpreted by the admin contract, possibly forming a PublicKey with customId. */ customFlag: Bool, // should be interpreted by the admin contract, can form PublicKey together with customId }) {} |