@silvana-one/nft 0.1.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 +1400 -0
- package/dist/node/admin/advanced.d.ts +469 -0
- package/dist/node/admin/advanced.js +525 -0
- package/dist/node/admin/advanced.js.map +1 -0
- package/dist/node/admin/index.d.ts +1 -0
- package/dist/node/admin/index.js +2 -0
- package/dist/node/admin/index.js.map +1 -0
- package/dist/node/contracts/admin.d.ts +140 -0
- package/dist/node/contracts/admin.js +336 -0
- package/dist/node/contracts/admin.js.map +1 -0
- package/dist/node/contracts/collection.d.ts +551 -0
- package/dist/node/contracts/collection.js +1049 -0
- package/dist/node/contracts/collection.js.map +1 -0
- package/dist/node/contracts/index.d.ts +3 -0
- package/dist/node/contracts/index.js +4 -0
- package/dist/node/contracts/index.js.map +1 -0
- package/dist/node/contracts/nft.d.ts +76 -0
- package/dist/node/contracts/nft.js +329 -0
- package/dist/node/contracts/nft.js.map +1 -0
- package/dist/node/contracts.d.ts +709 -0
- package/dist/node/contracts.js +61 -0
- package/dist/node/contracts.js.map +1 -0
- package/dist/node/index.cjs +5032 -0
- package/dist/node/index.d.ts +8 -0
- package/dist/node/index.js +9 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/interfaces/admin.d.ts +102 -0
- package/dist/node/interfaces/admin.js +2 -0
- package/dist/node/interfaces/admin.js.map +1 -0
- package/dist/node/interfaces/approval.d.ts +57 -0
- package/dist/node/interfaces/approval.js +62 -0
- package/dist/node/interfaces/approval.js.map +1 -0
- package/dist/node/interfaces/collection.d.ts +57 -0
- package/dist/node/interfaces/collection.js +2 -0
- package/dist/node/interfaces/collection.js.map +1 -0
- package/dist/node/interfaces/encoding.d.ts +24 -0
- package/dist/node/interfaces/encoding.js +32 -0
- package/dist/node/interfaces/encoding.js.map +1 -0
- package/dist/node/interfaces/events.d.ts +833 -0
- package/dist/node/interfaces/events.js +106 -0
- package/dist/node/interfaces/events.js.map +1 -0
- package/dist/node/interfaces/index.d.ts +10 -0
- package/dist/node/interfaces/index.js +11 -0
- package/dist/node/interfaces/index.js.map +1 -0
- package/dist/node/interfaces/ownable.d.ts +94 -0
- package/dist/node/interfaces/ownable.js +12 -0
- package/dist/node/interfaces/ownable.js.map +1 -0
- package/dist/node/interfaces/owner.d.ts +61 -0
- package/dist/node/interfaces/owner.js +101 -0
- package/dist/node/interfaces/owner.js.map +1 -0
- package/dist/node/interfaces/pausable.d.ts +74 -0
- package/dist/node/interfaces/pausable.js +14 -0
- package/dist/node/interfaces/pausable.js.map +1 -0
- package/dist/node/interfaces/types.d.ts +2297 -0
- package/dist/node/interfaces/types.js +507 -0
- package/dist/node/interfaces/types.js.map +1 -0
- package/dist/node/interfaces/update.d.ts +53 -0
- package/dist/node/interfaces/update.js +58 -0
- package/dist/node/interfaces/update.js.map +1 -0
- package/dist/node/marketplace/auction.d.ts +775 -0
- package/dist/node/marketplace/auction.js +430 -0
- package/dist/node/marketplace/auction.js.map +1 -0
- package/dist/node/marketplace/bid.d.ts +254 -0
- package/dist/node/marketplace/bid.js +260 -0
- package/dist/node/marketplace/bid.js.map +1 -0
- package/dist/node/marketplace/index.d.ts +5 -0
- package/dist/node/marketplace/index.js +6 -0
- package/dist/node/marketplace/index.js.map +1 -0
- package/dist/node/marketplace/nft-shares.d.ts +1083 -0
- package/dist/node/marketplace/nft-shares.js +398 -0
- package/dist/node/marketplace/nft-shares.js.map +1 -0
- package/dist/node/marketplace/offer.d.ts +192 -0
- package/dist/node/marketplace/offer.js +132 -0
- package/dist/node/marketplace/offer.js.map +1 -0
- package/dist/node/marketplace/types.d.ts +374 -0
- package/dist/node/marketplace/types.js +33 -0
- package/dist/node/marketplace/types.js.map +1 -0
- package/dist/node/metadata/index.d.ts +3 -0
- package/dist/node/metadata/index.js +4 -0
- package/dist/node/metadata/index.js.map +1 -0
- package/dist/node/metadata/metadata.d.ts +337 -0
- package/dist/node/metadata/metadata.js +439 -0
- package/dist/node/metadata/metadata.js.map +1 -0
- package/dist/node/metadata/text.d.ts +44 -0
- package/dist/node/metadata/text.js +42 -0
- package/dist/node/metadata/text.js.map +1 -0
- package/dist/node/metadata/tree.d.ts +75 -0
- package/dist/node/metadata/tree.js +85 -0
- package/dist/node/metadata/tree.js.map +1 -0
- package/dist/node/vk.d.ts +42 -0
- package/dist/node/vk.js +45 -0
- package/dist/node/vk.js.map +1 -0
- package/dist/node/zkprogram-example/game.d.ts +76 -0
- package/dist/node/zkprogram-example/game.js +108 -0
- package/dist/node/zkprogram-example/game.js.map +1 -0
- package/dist/node/zkprogram-example/index.d.ts +2 -0
- package/dist/node/zkprogram-example/index.js +3 -0
- package/dist/node/zkprogram-example/index.js.map +1 -0
- package/dist/node/zkprogram-example/update.d.ts +76 -0
- package/dist/node/zkprogram-example/update.js +85 -0
- package/dist/node/zkprogram-example/update.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/tsconfig.web.tsbuildinfo +1 -0
- package/dist/web/admin/advanced.d.ts +469 -0
- package/dist/web/admin/advanced.js +525 -0
- package/dist/web/admin/advanced.js.map +1 -0
- package/dist/web/admin/index.d.ts +1 -0
- package/dist/web/admin/index.js +2 -0
- package/dist/web/admin/index.js.map +1 -0
- package/dist/web/contracts/admin.d.ts +140 -0
- package/dist/web/contracts/admin.js +336 -0
- package/dist/web/contracts/admin.js.map +1 -0
- package/dist/web/contracts/collection.d.ts +551 -0
- package/dist/web/contracts/collection.js +1049 -0
- package/dist/web/contracts/collection.js.map +1 -0
- package/dist/web/contracts/index.d.ts +3 -0
- package/dist/web/contracts/index.js +4 -0
- package/dist/web/contracts/index.js.map +1 -0
- package/dist/web/contracts/nft.d.ts +76 -0
- package/dist/web/contracts/nft.js +329 -0
- package/dist/web/contracts/nft.js.map +1 -0
- package/dist/web/contracts.d.ts +709 -0
- package/dist/web/contracts.js +61 -0
- package/dist/web/contracts.js.map +1 -0
- package/dist/web/index.d.ts +8 -0
- package/dist/web/index.js +9 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/interfaces/admin.d.ts +102 -0
- package/dist/web/interfaces/admin.js +2 -0
- package/dist/web/interfaces/admin.js.map +1 -0
- package/dist/web/interfaces/approval.d.ts +57 -0
- package/dist/web/interfaces/approval.js +62 -0
- package/dist/web/interfaces/approval.js.map +1 -0
- package/dist/web/interfaces/collection.d.ts +57 -0
- package/dist/web/interfaces/collection.js +2 -0
- package/dist/web/interfaces/collection.js.map +1 -0
- package/dist/web/interfaces/encoding.d.ts +24 -0
- package/dist/web/interfaces/encoding.js +32 -0
- package/dist/web/interfaces/encoding.js.map +1 -0
- package/dist/web/interfaces/events.d.ts +833 -0
- package/dist/web/interfaces/events.js +106 -0
- package/dist/web/interfaces/events.js.map +1 -0
- package/dist/web/interfaces/index.d.ts +10 -0
- package/dist/web/interfaces/index.js +11 -0
- package/dist/web/interfaces/index.js.map +1 -0
- package/dist/web/interfaces/ownable.d.ts +94 -0
- package/dist/web/interfaces/ownable.js +12 -0
- package/dist/web/interfaces/ownable.js.map +1 -0
- package/dist/web/interfaces/owner.d.ts +61 -0
- package/dist/web/interfaces/owner.js +101 -0
- package/dist/web/interfaces/owner.js.map +1 -0
- package/dist/web/interfaces/pausable.d.ts +74 -0
- package/dist/web/interfaces/pausable.js +14 -0
- package/dist/web/interfaces/pausable.js.map +1 -0
- package/dist/web/interfaces/types.d.ts +2297 -0
- package/dist/web/interfaces/types.js +507 -0
- package/dist/web/interfaces/types.js.map +1 -0
- package/dist/web/interfaces/update.d.ts +53 -0
- package/dist/web/interfaces/update.js +58 -0
- package/dist/web/interfaces/update.js.map +1 -0
- package/dist/web/marketplace/auction.d.ts +775 -0
- package/dist/web/marketplace/auction.js +430 -0
- package/dist/web/marketplace/auction.js.map +1 -0
- package/dist/web/marketplace/bid.d.ts +254 -0
- package/dist/web/marketplace/bid.js +260 -0
- package/dist/web/marketplace/bid.js.map +1 -0
- package/dist/web/marketplace/index.d.ts +5 -0
- package/dist/web/marketplace/index.js +6 -0
- package/dist/web/marketplace/index.js.map +1 -0
- package/dist/web/marketplace/nft-shares.d.ts +1083 -0
- package/dist/web/marketplace/nft-shares.js +398 -0
- package/dist/web/marketplace/nft-shares.js.map +1 -0
- package/dist/web/marketplace/offer.d.ts +192 -0
- package/dist/web/marketplace/offer.js +132 -0
- package/dist/web/marketplace/offer.js.map +1 -0
- package/dist/web/marketplace/types.d.ts +374 -0
- package/dist/web/marketplace/types.js +33 -0
- package/dist/web/marketplace/types.js.map +1 -0
- package/dist/web/metadata/index.d.ts +3 -0
- package/dist/web/metadata/index.js +4 -0
- package/dist/web/metadata/index.js.map +1 -0
- package/dist/web/metadata/metadata.d.ts +337 -0
- package/dist/web/metadata/metadata.js +439 -0
- package/dist/web/metadata/metadata.js.map +1 -0
- package/dist/web/metadata/text.d.ts +44 -0
- package/dist/web/metadata/text.js +42 -0
- package/dist/web/metadata/text.js.map +1 -0
- package/dist/web/metadata/tree.d.ts +75 -0
- package/dist/web/metadata/tree.js +85 -0
- package/dist/web/metadata/tree.js.map +1 -0
- package/dist/web/vk.d.ts +42 -0
- package/dist/web/vk.js +45 -0
- package/dist/web/vk.js.map +1 -0
- package/dist/web/zkprogram-example/game.d.ts +76 -0
- package/dist/web/zkprogram-example/game.js +108 -0
- package/dist/web/zkprogram-example/game.js.map +1 -0
- package/dist/web/zkprogram-example/index.d.ts +2 -0
- package/dist/web/zkprogram-example/index.js +3 -0
- package/dist/web/zkprogram-example/index.js.map +1 -0
- package/dist/web/zkprogram-example/update.d.ts +76 -0
- package/dist/web/zkprogram-example/update.js +85 -0
- package/dist/web/zkprogram-example/update.js.map +1 -0
- package/package.json +65 -0
- package/src/admin/advanced.ts +601 -0
- package/src/admin/index.ts +1 -0
- package/src/contracts/admin.ts +301 -0
- package/src/contracts/collection.ts +1172 -0
- package/src/contracts/index.ts +3 -0
- package/src/contracts/nft.ts +344 -0
- package/src/contracts.ts +107 -0
- package/src/index.ts +8 -0
- package/src/interfaces/admin.ts +127 -0
- package/src/interfaces/approval.ts +99 -0
- package/src/interfaces/collection.ts +68 -0
- package/src/interfaces/encoding.ts +32 -0
- package/src/interfaces/events.ts +115 -0
- package/src/interfaces/index.ts +10 -0
- package/src/interfaces/ownable.ts +32 -0
- package/src/interfaces/owner.ts +143 -0
- package/src/interfaces/pausable.ts +41 -0
- package/src/interfaces/types.ts +623 -0
- package/src/interfaces/update.ts +104 -0
- package/src/marketplace/auction.ts +527 -0
- package/src/marketplace/bid.ts +294 -0
- package/src/marketplace/index.ts +5 -0
- package/src/marketplace/nft-shares.ts +388 -0
- package/src/marketplace/offer.ts +153 -0
- package/src/marketplace/types.ts +33 -0
- package/src/metadata/index.ts +3 -0
- package/src/metadata/metadata.ts +603 -0
- package/src/metadata/text.ts +60 -0
- package/src/metadata/tree.ts +128 -0
- package/src/vk.ts +64 -0
- package/src/zkprogram-example/game.ts +136 -0
- package/src/zkprogram-example/index.ts +2 -0
- package/src/zkprogram-example/update.ts +98 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./admin/index.js";
|
|
2
|
+
export * from "./contracts/index.js";
|
|
3
|
+
export * from "./metadata/index.js";
|
|
4
|
+
export * from "./zkprogram-example/index.js";
|
|
5
|
+
export * from "./marketplace/index.js";
|
|
6
|
+
export * from "./vk.js";
|
|
7
|
+
export * from "./contracts.js";
|
|
8
|
+
export * from "./interfaces/index.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./admin/index.js";
|
|
2
|
+
export * from "./contracts/index.js";
|
|
3
|
+
export * from "./metadata/index.js";
|
|
4
|
+
export * from "./zkprogram-example/index.js";
|
|
5
|
+
export * from "./marketplace/index.js";
|
|
6
|
+
export * from "./vk.js";
|
|
7
|
+
export * from "./contracts.js";
|
|
8
|
+
export * from "./interfaces/index.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Bool, PublicKey, SmartContract, VerificationKey, Field, UInt32, UInt64 } from "o1js";
|
|
2
|
+
import { MintParamsOption, MintRequest, NFTState } from "./types.js";
|
|
3
|
+
import { TransferEvent } from "./events.js";
|
|
4
|
+
export { NFTAdminBase, NFTAdminContractConstructor };
|
|
5
|
+
/**
|
|
6
|
+
* The `NFTAdminBase` interface defines the administrative functionalities required for managing an NFT collection on the Mina Protocol.
|
|
7
|
+
* It extends the `SmartContract` class and specifies methods that enforce permissions and validations for various NFT operations.
|
|
8
|
+
*/
|
|
9
|
+
type NFTAdminBase = SmartContract & {
|
|
10
|
+
/**
|
|
11
|
+
* Validates whether a new NFT can be minted based on the provided `MintRequest`.
|
|
12
|
+
*
|
|
13
|
+
* @param nft - The mint request containing details of the NFT to be minted.
|
|
14
|
+
* @returns A `Promise` resolving to `MintParamsOption`, containing mint parameters if minting is allowed, or an empty option if not.
|
|
15
|
+
*/
|
|
16
|
+
canMint(nft: MintRequest): Promise<MintParamsOption>;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if an NFT can be updated from its current state (`input`) to a new state (`output`).
|
|
19
|
+
*
|
|
20
|
+
* @param input - The current state of the NFT.
|
|
21
|
+
* @param output - The desired new state of the NFT.
|
|
22
|
+
* @returns A `Promise` resolving to a `Bool` indicating whether the update is permitted.
|
|
23
|
+
*/
|
|
24
|
+
canUpdate(input: NFTState, output: NFTState): Promise<Bool>;
|
|
25
|
+
/**
|
|
26
|
+
* Determines if an NFT can be transferred from one owner (`from`) to another (`to`) for a specific NFT contract address.
|
|
27
|
+
*
|
|
28
|
+
* @param transferEvent - The transfer event containing details of the transfer.
|
|
29
|
+
* @returns A `Promise` resolving to a `Bool` indicating whether the transfer is allowed.
|
|
30
|
+
*/
|
|
31
|
+
canTransfer(transferEvent: TransferEvent): Promise<Bool>;
|
|
32
|
+
/**
|
|
33
|
+
* Determines if the name can be changed for a Collection.
|
|
34
|
+
*
|
|
35
|
+
* @param name - The new name for the Collection.
|
|
36
|
+
* @returns A `Promise` resolving to a `Bool` indicating whether the name change is allowed.
|
|
37
|
+
*/
|
|
38
|
+
canChangeName(name: Field): Promise<Bool>;
|
|
39
|
+
/**
|
|
40
|
+
* Determines if the creator can be changed for a Collection.
|
|
41
|
+
*
|
|
42
|
+
* @param creator - The new creator for the Collection.
|
|
43
|
+
* @returns A `Promise` resolving to a `Bool` indicating whether the creator change is allowed.
|
|
44
|
+
*/
|
|
45
|
+
canChangeCreator(creator: PublicKey): Promise<Bool>;
|
|
46
|
+
/**
|
|
47
|
+
* Determines if the base URI can be changed for a Collection.
|
|
48
|
+
*
|
|
49
|
+
* @param baseUri - The new base URI for the Collection.
|
|
50
|
+
* @returns A `Promise` resolving to a `Bool` indicating whether the base URI change is allowed.
|
|
51
|
+
*/
|
|
52
|
+
canChangeBaseUri(baseUri: Field): Promise<Bool>;
|
|
53
|
+
/**
|
|
54
|
+
* Determines if the royalty fee can be changed for a Collection.
|
|
55
|
+
*
|
|
56
|
+
* @param royaltyFee - The new royalty fee for the Collection.
|
|
57
|
+
* @returns A `Promise` resolving to a `Bool` indicating whether the royalty fee change is allowed.
|
|
58
|
+
*/
|
|
59
|
+
canChangeRoyalty(royaltyFee: UInt32): Promise<Bool>;
|
|
60
|
+
/**
|
|
61
|
+
* Determines if the transfer fee can be changed for a Collection.
|
|
62
|
+
*
|
|
63
|
+
* @param transferFee - The new transfer fee for the Collection.
|
|
64
|
+
* @returns A `Promise` resolving to a `Bool` indicating whether the transfer fee change is allowed.
|
|
65
|
+
*/
|
|
66
|
+
canChangeTransferFee(transferFee: UInt64): Promise<Bool>;
|
|
67
|
+
/**
|
|
68
|
+
* Determines if the admin contract can be changed for a Collection.
|
|
69
|
+
*
|
|
70
|
+
* @param admin - The new admin for the Collection.
|
|
71
|
+
* @returns A `Promise` resolving to a `Bool` indicating whether the admin contract change is allowed.
|
|
72
|
+
*/
|
|
73
|
+
canSetAdmin(admin: PublicKey): Promise<Bool>;
|
|
74
|
+
/**
|
|
75
|
+
* Determines if the collection can be paused.
|
|
76
|
+
*
|
|
77
|
+
* @returns A `Promise` resolving to a `Bool` indicating whether the collection can be paused.
|
|
78
|
+
*/
|
|
79
|
+
canPause(): Promise<Bool>;
|
|
80
|
+
/**
|
|
81
|
+
* Determines if the collection can be resumed.
|
|
82
|
+
*
|
|
83
|
+
* @returns A `Promise` resolving to a `Bool` indicating whether the collection can be resumed.
|
|
84
|
+
*/
|
|
85
|
+
canResume(): Promise<Bool>;
|
|
86
|
+
/**
|
|
87
|
+
* Determines if the verification key can be changed for a specific NFT contract address and token ID.
|
|
88
|
+
*
|
|
89
|
+
* @param vk - The verification key to be changed.
|
|
90
|
+
* @param address - The public key of the NFT contract address or CollectionContract address.
|
|
91
|
+
* @param tokenId - The token ID of the NFT.
|
|
92
|
+
* @returns A `Promise` resolving to a `Bool` indicating whether the verification key change is allowed.
|
|
93
|
+
*/
|
|
94
|
+
canChangeVerificationKey(vk: VerificationKey, address: PublicKey, tokenId: Field): Promise<Bool>;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Defines a constructor for contracts implementing `NFTAdminBase`, accepting an `address` public key and returning an instance of `NFTAdminBase`.
|
|
98
|
+
*
|
|
99
|
+
* @param address - The contract's address.
|
|
100
|
+
* @returns An instance of `NFTAdminBase`.
|
|
101
|
+
*/
|
|
102
|
+
type NFTAdminContractConstructor = new (address: PublicKey) => NFTAdminBase;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../../src/interfaces/admin.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AccountUpdate, Bool, PublicKey, SmartContract, State, DeployArgs } from "o1js";
|
|
2
|
+
import { NFTCollectionContractConstructor } from "./collection.js";
|
|
3
|
+
import { TransferExtendedParams } from "./types.js";
|
|
4
|
+
export { NFTApprovalBase, NFTApprovalContractConstructor, NFTStandardApproval, NFTApprovalDeployProps, DefineApprovalFactory, };
|
|
5
|
+
type DefineApprovalFactory = (params: {
|
|
6
|
+
collectionContract: () => NFTCollectionContractConstructor;
|
|
7
|
+
}) => NFTApprovalContractConstructor;
|
|
8
|
+
/**
|
|
9
|
+
* The `NFTApprovalBase` interface defines the administrative functionalities required for managing an NFT transfer approval on the Mina Protocol.
|
|
10
|
+
*/
|
|
11
|
+
type NFTApprovalBase = SmartContract & {
|
|
12
|
+
/**
|
|
13
|
+
* Determines if an NFT can be transferred from one owner (`from`) to another (`to`) for a specific NFT contract address.
|
|
14
|
+
*
|
|
15
|
+
* @param params - The transfer details.
|
|
16
|
+
* @returns A `Promise` resolving to a `Bool` indicating whether the transfer is allowed.
|
|
17
|
+
*/
|
|
18
|
+
canTransfer(params: TransferExtendedParams): Promise<Bool>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Defines a constructor for contracts implementing `NFTApprovalBase`, accepting an `address` public key and returning an instance of `NFTApprovalBase`.
|
|
22
|
+
*
|
|
23
|
+
* @param address - The public key of the contract's owner.
|
|
24
|
+
* @returns An instance of `NFTApprovalBase`.
|
|
25
|
+
*/
|
|
26
|
+
type NFTApprovalContractConstructor = new (address: PublicKey) => NFTApprovalBase;
|
|
27
|
+
interface NFTApprovalDeployProps extends Exclude<DeployArgs, undefined> {
|
|
28
|
+
admin: PublicKey;
|
|
29
|
+
uri: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The **NFTStandardApproval** contract is the default implementation of the `NFTApprovalBase` interface.
|
|
33
|
+
*/
|
|
34
|
+
declare class NFTStandardApproval extends SmartContract implements NFTApprovalBase {
|
|
35
|
+
/**
|
|
36
|
+
* The public key of the contract's administrator.
|
|
37
|
+
* This account has the authority to perform administrative actions such as pausing the contract or upgrading the verification key.
|
|
38
|
+
*/
|
|
39
|
+
admin: State<PublicKey>;
|
|
40
|
+
/**
|
|
41
|
+
* Deploys the contract with initial settings.
|
|
42
|
+
* @param props - Deployment properties including admin, upgradeAuthority, uri, canPause, and isPaused.
|
|
43
|
+
*/
|
|
44
|
+
deploy(props: NFTApprovalDeployProps): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Ensures that the transaction is authorized by the contract owner.
|
|
47
|
+
* @returns A signed `AccountUpdate` from the admin.
|
|
48
|
+
*/
|
|
49
|
+
ensureOwnerSignature(): Promise<AccountUpdate>;
|
|
50
|
+
/**
|
|
51
|
+
* Determines if an NFT can be transferred.
|
|
52
|
+
*
|
|
53
|
+
* @param params - The transfer details.
|
|
54
|
+
* @returns A `Promise` resolving to a `Bool` indicating whether the transfer is allowed.
|
|
55
|
+
*/
|
|
56
|
+
canTransfer(params: TransferExtendedParams): Promise<Bool>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { AccountUpdate, Bool, method, PublicKey, SmartContract, state, State, Permissions, } from "o1js";
|
|
3
|
+
import { TransferExtendedParams } from "./types.js";
|
|
4
|
+
export { NFTStandardApproval, };
|
|
5
|
+
/**
|
|
6
|
+
* The **NFTStandardApproval** contract is the default implementation of the `NFTApprovalBase` interface.
|
|
7
|
+
*/
|
|
8
|
+
class NFTStandardApproval extends SmartContract {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
/**
|
|
12
|
+
* The public key of the contract's administrator.
|
|
13
|
+
* This account has the authority to perform administrative actions such as pausing the contract or upgrading the verification key.
|
|
14
|
+
*/
|
|
15
|
+
this.admin = State();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Deploys the contract with initial settings.
|
|
19
|
+
* @param props - Deployment properties including admin, upgradeAuthority, uri, canPause, and isPaused.
|
|
20
|
+
*/
|
|
21
|
+
async deploy(props) {
|
|
22
|
+
await super.deploy(props);
|
|
23
|
+
this.admin.set(props.admin);
|
|
24
|
+
this.account.zkappUri.set(props.uri);
|
|
25
|
+
this.account.permissions.set({
|
|
26
|
+
...Permissions.default(),
|
|
27
|
+
setVerificationKey: Permissions.VerificationKey.signature(),
|
|
28
|
+
setPermissions: Permissions.impossible(),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Ensures that the transaction is authorized by the contract owner.
|
|
33
|
+
* @returns A signed `AccountUpdate` from the admin.
|
|
34
|
+
*/
|
|
35
|
+
async ensureOwnerSignature() {
|
|
36
|
+
const admin = this.admin.getAndRequireEquals();
|
|
37
|
+
const adminUpdate = AccountUpdate.createSigned(admin);
|
|
38
|
+
adminUpdate.body.useFullCommitment = Bool(true); // Prevent memo and fee change
|
|
39
|
+
return adminUpdate;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Determines if an NFT can be transferred.
|
|
43
|
+
*
|
|
44
|
+
* @param params - The transfer details.
|
|
45
|
+
* @returns A `Promise` resolving to a `Bool` indicating whether the transfer is allowed.
|
|
46
|
+
*/
|
|
47
|
+
async canTransfer(params) {
|
|
48
|
+
await this.ensureOwnerSignature();
|
|
49
|
+
return Bool(true);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
__decorate([
|
|
53
|
+
state(PublicKey),
|
|
54
|
+
__metadata("design:type", Object)
|
|
55
|
+
], NFTStandardApproval.prototype, "admin", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
method.returns(Bool),
|
|
58
|
+
__metadata("design:type", Function),
|
|
59
|
+
__metadata("design:paramtypes", [TransferExtendedParams]),
|
|
60
|
+
__metadata("design:returntype", Promise)
|
|
61
|
+
], NFTStandardApproval.prototype, "canTransfer", null);
|
|
62
|
+
//# sourceMappingURL=approval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval.js","sourceRoot":"","sources":["../../../src/interfaces/approval.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,IAAI,EACJ,MAAM,EACN,SAAS,EACT,aAAa,EACb,KAAK,EACL,KAAK,EACL,WAAW,GAEZ,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAGL,mBAAmB,GAGpB,CAAC;AAiCF;;GAEG;AACH,MAAM,mBAAoB,SAAQ,aAAa;IAA/C;;QACE;;;WAGG;QACe,UAAK,GAAG,KAAK,EAAa,CAAC;IAsC/C,CAAC;IApCC;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,KAA6B;QACxC,MAAM,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC;YAC3B,GAAG,WAAW,CAAC,OAAO,EAAE;YACxB,kBAAkB,EAAE,WAAW,CAAC,eAAe,CAAC,SAAS,EAAE;YAC3D,cAAc,EAAE,WAAW,CAAC,UAAU,EAAE;SACzC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,oBAAoB;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC;QAC/C,MAAM,WAAW,GAAG,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACtD,WAAW,CAAC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,8BAA8B;QAC/E,OAAO,WAAW,CAAC;IACrB,CAAC;IACD;;;;;OAKG;IAEG,AAAN,KAAK,CAAC,WAAW,CAAC,MAA8B;QAC9C,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;CACF;AAtCmB;IAAjB,KAAK,CAAC,SAAS,CAAC;;kDAA4B;AAkCvC;IADL,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;;qCACK,sBAAsB;;sDAG/C"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { PublicKey, TokenContract } from "o1js";
|
|
2
|
+
import { TransferParams, NFTStateStruct } from "./types.js";
|
|
3
|
+
import { NFTOwnerContractConstructor } from "./owner.js";
|
|
4
|
+
import { NFTApprovalContractConstructor } from "./approval.js";
|
|
5
|
+
import { NFTUpdateContractConstructor } from "./update.js";
|
|
6
|
+
import { NFTAdminContractConstructor } from "./admin.js";
|
|
7
|
+
export { NFTCollectionBase, NFTCollectionContractConstructor, DefineCollectionFactory, };
|
|
8
|
+
/**
|
|
9
|
+
* The `NFTCollectionBase` interface defines the functionalities required for managing an NFT collection on the Mina Protocol.
|
|
10
|
+
* It extends the `SmartContract` class and specifies methods that enforce permissions and validations for various NFT operations.
|
|
11
|
+
*/
|
|
12
|
+
type NFTCollectionBase = TokenContract & {
|
|
13
|
+
/**
|
|
14
|
+
* Transfers ownership of an NFT from contract without admin approval using a proof.
|
|
15
|
+
*
|
|
16
|
+
* @param params - The transfer details.
|
|
17
|
+
*/
|
|
18
|
+
transferByProof(params: TransferParams): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Transfers ownership of an NFT from contract without admin approval.
|
|
21
|
+
*
|
|
22
|
+
* @param params - The transfer details.
|
|
23
|
+
*/
|
|
24
|
+
transferBySignature(params: TransferParams): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Transfers ownership of an NFT from contract without admin approval using a proof.
|
|
27
|
+
*
|
|
28
|
+
* @param params - The transfer details.
|
|
29
|
+
*/
|
|
30
|
+
approvedTransferByProof(params: TransferParams): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Transfers ownership of an NFT from contract without admin approval.
|
|
33
|
+
*
|
|
34
|
+
* @param params - The transfer details.
|
|
35
|
+
*/
|
|
36
|
+
approvedTransferBySignature(params: TransferParams): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the state of an NFT.
|
|
39
|
+
*
|
|
40
|
+
* @param address - The address of the NFT.
|
|
41
|
+
* @returns The state of the NFT.
|
|
42
|
+
*/
|
|
43
|
+
getNFTState(address: PublicKey): Promise<NFTStateStruct>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Defines a constructor for contracts implementing `NFTCollectionBase`, accepting an `address` public key and returning an instance of `NFTCollectionBase`.
|
|
47
|
+
*
|
|
48
|
+
* @param address - The contract's address.
|
|
49
|
+
* @returns An instance of `NFTCollectionBase`.
|
|
50
|
+
*/
|
|
51
|
+
type NFTCollectionContractConstructor = new (address: PublicKey) => NFTCollectionBase;
|
|
52
|
+
type DefineCollectionFactory = (params: {
|
|
53
|
+
adminContract: () => NFTAdminContractConstructor;
|
|
54
|
+
ownerContract: () => NFTOwnerContractConstructor;
|
|
55
|
+
approvalContract: () => NFTApprovalContractConstructor;
|
|
56
|
+
updateContract: () => NFTUpdateContractConstructor;
|
|
57
|
+
}) => NFTCollectionContractConstructor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../../src/interfaces/collection.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for encoding and decoding `Field` elements to and from strings.
|
|
3
|
+
* These functions are used throughout the NFT standard for handling off-chain storage references and metadata.
|
|
4
|
+
*/
|
|
5
|
+
import { Field } from "o1js";
|
|
6
|
+
export { fieldToString, fieldFromString };
|
|
7
|
+
/**
|
|
8
|
+
* Converts a `Field` element to a string representation.
|
|
9
|
+
* This is used for serializing `Field` values into strings suitable for storage or transmission.
|
|
10
|
+
*
|
|
11
|
+
* @param {Field} field - The `Field` element to convert.
|
|
12
|
+
* @returns {string} The string representation of the `Field`.
|
|
13
|
+
*/
|
|
14
|
+
declare function fieldToString(field: Field): string;
|
|
15
|
+
/**
|
|
16
|
+
* Reconstructs a `Field` element from its string representation.
|
|
17
|
+
* This function is essential for deserializing strings back into `Field` elements,
|
|
18
|
+
* which can then be used within the smart contract logic.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} storage - The string representation of the `Field`.
|
|
21
|
+
* @returns {Field} The reconstructed `Field` element.
|
|
22
|
+
* @throws Will throw an error if the input string does not correspond to exactly one `Field`.
|
|
23
|
+
*/
|
|
24
|
+
declare function fieldFromString(storage: string): Field;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for encoding and decoding `Field` elements to and from strings.
|
|
3
|
+
* These functions are used throughout the NFT standard for handling off-chain storage references and metadata.
|
|
4
|
+
*/
|
|
5
|
+
import { Encoding } from "o1js";
|
|
6
|
+
export { fieldToString, fieldFromString };
|
|
7
|
+
/**
|
|
8
|
+
* Converts a `Field` element to a string representation.
|
|
9
|
+
* This is used for serializing `Field` values into strings suitable for storage or transmission.
|
|
10
|
+
*
|
|
11
|
+
* @param {Field} field - The `Field` element to convert.
|
|
12
|
+
* @returns {string} The string representation of the `Field`.
|
|
13
|
+
*/
|
|
14
|
+
function fieldToString(field) {
|
|
15
|
+
return Encoding.stringFromFields([field]);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Reconstructs a `Field` element from its string representation.
|
|
19
|
+
* This function is essential for deserializing strings back into `Field` elements,
|
|
20
|
+
* which can then be used within the smart contract logic.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} storage - The string representation of the `Field`.
|
|
23
|
+
* @returns {Field} The reconstructed `Field` element.
|
|
24
|
+
* @throws Will throw an error if the input string does not correspond to exactly one `Field`.
|
|
25
|
+
*/
|
|
26
|
+
function fieldFromString(storage) {
|
|
27
|
+
const fields = Encoding.stringToFields(storage);
|
|
28
|
+
if (fields.length !== 1)
|
|
29
|
+
throw new Error("String is too long");
|
|
30
|
+
return fields[0];
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=encoding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../../src/interfaces/encoding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAS,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;AAE1C;;;;;;GAMG;AACH,SAAS,aAAa,CAAC,KAAY;IACjC,OAAO,QAAQ,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,eAAe,CAAC,OAAe;IACtC,MAAM,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAChD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC"}
|