@zoralabs/protocol-sdk 0.5.17 → 0.7.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/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +19 -0
- package/README.md +1 -416
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/create/1155-create-helper.d.ts +16 -55
- package/dist/create/1155-create-helper.d.ts.map +1 -1
- package/dist/create/contract-setup.d.ts +14 -0
- package/dist/create/contract-setup.d.ts.map +1 -0
- package/dist/create/token-setup.d.ts +27 -0
- package/dist/create/token-setup.d.ts.map +1 -0
- package/dist/create/types.d.ts +45 -0
- package/dist/create/types.d.ts.map +1 -0
- package/dist/index.cjs +1745 -891
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1698 -858
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-client.d.ts +48 -51
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/mint-queries.d.ts +38 -0
- package/dist/mint/mint-queries.d.ts.map +1 -0
- package/dist/mint/mint-transactions.d.ts +20 -0
- package/dist/mint/mint-transactions.d.ts.map +1 -0
- package/dist/mint/subgraph-mint-getter.d.ts +24 -0
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -0
- package/dist/mint/subgraph-queries.d.ts +55 -0
- package/dist/mint/subgraph-queries.d.ts.map +1 -0
- package/dist/mint/types.d.ts +177 -0
- package/dist/mint/types.d.ts.map +1 -0
- package/dist/mint/utils.d.ts +2 -0
- package/dist/mint/utils.d.ts.map +1 -0
- package/dist/mints/mints-contracts.d.ts +27 -4518
- package/dist/mints/mints-contracts.d.ts.map +1 -1
- package/dist/premint/contract-types.d.ts +4 -4
- package/dist/premint/contract-types.d.ts.map +1 -1
- package/dist/premint/conversions.d.ts +15 -16
- package/dist/premint/conversions.d.ts.map +1 -1
- package/dist/premint/premint-api-client.d.ts +32 -16
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +76 -50
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +20 -8
- package/dist/premint/preminter.d.ts.map +1 -1
- package/dist/sdk.d.ts +45 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +24 -6869
- package/dist/utils.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/constants.ts +0 -36
- package/src/create/1155-create-helper.test.ts +236 -55
- package/src/create/1155-create-helper.ts +141 -309
- package/src/create/contract-setup.ts +88 -0
- package/src/create/token-setup.ts +379 -0
- package/src/create/types.ts +57 -0
- package/src/index.ts +5 -1
- package/src/mint/mint-client.test.ts +116 -78
- package/src/mint/mint-client.ts +130 -234
- package/src/mint/mint-queries.ts +320 -0
- package/src/mint/mint-transactions.ts +253 -0
- package/src/mint/subgraph-mint-getter.ts +247 -0
- package/src/mint/subgraph-queries.ts +170 -0
- package/src/mint/types.ts +239 -0
- package/src/mint/utils.ts +14 -0
- package/src/mints/mints-contracts.test.ts +1 -1
- package/src/mints/mints-contracts.ts +4 -4
- package/src/premint/contract-types.ts +4 -4
- package/src/premint/conversions.ts +38 -4
- package/src/premint/premint-api-client.ts +92 -48
- package/src/premint/premint-client.test.ts +100 -84
- package/src/premint/premint-client.ts +186 -185
- package/src/premint/preminter.test.ts +4 -5
- package/src/premint/preminter.ts +63 -14
- package/src/sdk.ts +101 -0
- package/src/types.ts +18 -0
- package/src/utils.ts +54 -46
- package/test-integration/setup-test-contracts.ts +96 -0
- package/dist/mint/mint-api-client.d.ts +0 -35
- package/dist/mint/mint-api-client.d.ts.map +0 -1
- package/src/mint/mint-api-client.ts +0 -177
- package/test-integration/premint-client.test.ts +0 -148
package/.turbo/turbo-build.log
CHANGED
|
@@ -7,9 +7,9 @@ $ tsup
|
|
|
7
7
|
[34mCLI[39m Cleaning output folder
|
|
8
8
|
[34mCJS[39m Build start
|
|
9
9
|
[34mESM[39m Build start
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
10
|
+
[32mESM[39m [1mdist/index.js [22m[32m78.65 KB[39m
|
|
11
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m185.21 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 148ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m85.33 KB[39m
|
|
14
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m185.36 KB[39m
|
|
15
|
+
[32mCJS[39m ⚡️ Build success in 150ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @zoralabs/protocol-sdk
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f52f28f3: Added methods to Collector Client: getToken, getTokensOfContract
|
|
8
|
+
|
|
9
|
+
## 0.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 8c23f05b: - new high-level sdks: `createCreatorClient` and `createCollectorClient`. `createPremintClient`, `createMintClient`, `create1155CreatorClient`, and `createPremintClient` are removed.
|
|
14
|
+
- external apis, such as the premint api can be stubbed/replaced/mocked.
|
|
15
|
+
- new function `mint` on the collector sdk that works with `1155`, `premint`, and `721`s.
|
|
16
|
+
- `create1155` now supports creating erc20, free, and paid mints. Setup actions now mimic what's on zora.co.
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- b0f0fb74: premintClient - fix default mint duration to be unlimited (it was one week before)
|
|
21
|
+
|
|
3
22
|
## 0.5.17
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -2,419 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
Protocol SDK allows developers to create tokens using the Zora Protocol and mint them.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[viem](https://viem.sh/) is a peerDependency of protocol-sdk. If not already installed, it needs to be installed alongside the protocol sdk.
|
|
8
|
-
|
|
9
|
-
- `npm install viem`
|
|
10
|
-
- `npm install `
|
|
11
|
-
|
|
12
|
-
## Examples
|
|
13
|
-
|
|
14
|
-
- [Creating a mint from an on-chain contract](#creating-a-mint-from-an-on-chain-contract)
|
|
15
|
-
- [Creating an 1155 contract](#creating-an-1155-contract)
|
|
16
|
-
- [Premint: create a mint without paying gas](#premint-create-a-mint-without-paying-gas)
|
|
17
|
-
- [Updating a premint before it is brought onchain](#updating-a-premint-before-it-is-brought-onchain)
|
|
18
|
-
- [Deleting a premint before it is brought onchain](#deleting-a-premint-before-it-is-brought-onchain)
|
|
19
|
-
- [Minting a premint and bringing it onchain](#minting-a-premint-and-bringing-it-onchain)
|
|
20
|
-
|
|
21
|
-
### Creating a mint from an on-chain contract
|
|
22
|
-
|
|
23
|
-
#### Using viem
|
|
24
|
-
|
|
25
|
-
```ts
|
|
26
|
-
import { createMintClient } from "@zoralabs/protocol-sdk";
|
|
27
|
-
import type { Address, PublicClient, WalletClient } from "viem";
|
|
28
|
-
|
|
29
|
-
async function mintNFT({
|
|
30
|
-
walletClient,
|
|
31
|
-
publicClient,
|
|
32
|
-
tokenContract,
|
|
33
|
-
tokenId,
|
|
34
|
-
mintToAddress,
|
|
35
|
-
quantityToMint,
|
|
36
|
-
mintReferral,
|
|
37
|
-
}: {
|
|
38
|
-
// wallet client that will submit the transaction
|
|
39
|
-
walletClient: WalletClient;
|
|
40
|
-
// public client that will simulate the transaction
|
|
41
|
-
publicClient: PublicClient;
|
|
42
|
-
// address of the token contract
|
|
43
|
-
tokenContract: Address;
|
|
44
|
-
// id of the token to mint
|
|
45
|
-
tokenId: bigint;
|
|
46
|
-
// address that will receive the minted token
|
|
47
|
-
mintToAddress: Address;
|
|
48
|
-
// quantity of tokens to mint
|
|
49
|
-
quantityToMint: number;
|
|
50
|
-
// optional address that will receive a mint referral reward
|
|
51
|
-
mintReferral?: Address;
|
|
52
|
-
}) {
|
|
53
|
-
const mintClient = createMintClient({ chain: walletClient.chain! });
|
|
54
|
-
|
|
55
|
-
// prepare the mint transaction, which can be simulated via an rpc with the public client.
|
|
56
|
-
const prepared = await mintClient.makePrepareMintTokenParams({
|
|
57
|
-
// token to mint
|
|
58
|
-
tokenContract,
|
|
59
|
-
tokenId,
|
|
60
|
-
mintArguments: {
|
|
61
|
-
// address that will receive the token
|
|
62
|
-
mintToAddress,
|
|
63
|
-
// quantity of tokens to mint
|
|
64
|
-
quantityToMint,
|
|
65
|
-
// comment to include with the mint
|
|
66
|
-
mintComment: "My comment",
|
|
67
|
-
// optional address that will receive a mint referral reward
|
|
68
|
-
mintReferral,
|
|
69
|
-
},
|
|
70
|
-
// account that is to invoke the mint transaction
|
|
71
|
-
minterAccount: walletClient.account!.address,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// simulate the transaction and get any validation errors
|
|
75
|
-
const { request } = await publicClient.simulateContract(prepared);
|
|
76
|
-
|
|
77
|
-
// submit the transaction to the network
|
|
78
|
-
const txHash = await walletClient.writeContract(request);
|
|
79
|
-
|
|
80
|
-
// wait for the transaction to be complete
|
|
81
|
-
await publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Minting an NFT with an ERC20 minter
|
|
86
|
-
|
|
87
|
-
If an 1155 token is set to be an ERC20 mint, use the `makePrepareMintTokenParams` the same way as for
|
|
88
|
-
eth based mints. The underlying function should handle preparing arguments for the ERC20 mint.
|
|
89
|
-
|
|
90
|
-
```ts
|
|
91
|
-
import type { PublicClient } from "viem";
|
|
92
|
-
|
|
93
|
-
async function mint1155TokenWithERC20Currency(
|
|
94
|
-
publicClient: PublicClient,
|
|
95
|
-
minterAddress: Address,
|
|
96
|
-
) {
|
|
97
|
-
const mintClient = createMintClient({ chain: zora });
|
|
98
|
-
const exampleCurrency = "0xb6b701878a1f80197dF2c209D0BDd292EA73164D";
|
|
99
|
-
// nft collection address
|
|
100
|
-
const targetContract = "0x689bc305456c38656856d12469aed282fbd89fe0";
|
|
101
|
-
const tokenId = 17;
|
|
102
|
-
// the NFT token price in WEI value
|
|
103
|
-
const erc20PricePerToken = 2000000000000000000;
|
|
104
|
-
|
|
105
|
-
const tokenParams = await mintClient.makePrepareMintTokenParams({
|
|
106
|
-
minterAccount: minterAddress,
|
|
107
|
-
tokenId: tokenId,
|
|
108
|
-
tokenAddress: targetContract,
|
|
109
|
-
mintArguments: {
|
|
110
|
-
mintToAddress: minterAddress,
|
|
111
|
-
quantityToMint: 1,
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const simulationResult = await publicClient.simulateContract(params);
|
|
116
|
-
const hash = await walletClient.writeContract(simulationResult.request);
|
|
117
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
118
|
-
|
|
119
|
-
return receipt;
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
#### Using wagmi
|
|
124
|
-
|
|
125
|
-
```tsx
|
|
126
|
-
import { createMintClient } from "@zoralabs/protocol-sdk";
|
|
127
|
-
import { useEffect, useMemo, useState } from "react";
|
|
128
|
-
import { BaseError, SimulateContractParameters, stringify } from "viem";
|
|
129
|
-
import {
|
|
130
|
-
Address,
|
|
131
|
-
useAccount,
|
|
132
|
-
useContractWrite,
|
|
133
|
-
useNetwork,
|
|
134
|
-
usePrepareContractWrite,
|
|
135
|
-
usePublicClient,
|
|
136
|
-
useWaitForTransaction,
|
|
137
|
-
} from "wagmi";
|
|
138
|
-
|
|
139
|
-
// custom hook that gets the mintClient for the current chain
|
|
140
|
-
const useMintClient = () => {
|
|
141
|
-
const publicClient = usePublicClient();
|
|
142
|
-
|
|
143
|
-
const { chain } = useNetwork();
|
|
144
|
-
|
|
145
|
-
const mintClient = useMemo(
|
|
146
|
-
() => chain && createMintClient({ chain, publicClient }),
|
|
147
|
-
[chain, publicClient],
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
return mintClient;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export const Mint = ({
|
|
154
|
-
tokenId,
|
|
155
|
-
tokenContract,
|
|
156
|
-
}: {
|
|
157
|
-
tokenId: string;
|
|
158
|
-
tokenContract: Address;
|
|
159
|
-
}) => {
|
|
160
|
-
// call custom hook to get the mintClient
|
|
161
|
-
const mintClient = useMintClient();
|
|
162
|
-
|
|
163
|
-
// value will be set by the form
|
|
164
|
-
const [quantityToMint, setQuantityToMint] = useState<number>(1);
|
|
165
|
-
|
|
166
|
-
// params for the prepare contract write hook
|
|
167
|
-
const [params, setParams] = useState<SimulateContractParameters>();
|
|
168
|
-
|
|
169
|
-
const { address } = useAccount();
|
|
170
|
-
|
|
171
|
-
useEffect(() => {
|
|
172
|
-
if (!mintClient || !address) return;
|
|
173
|
-
|
|
174
|
-
const makeParams = async () => {
|
|
175
|
-
// make the params for the prepare contract write hook
|
|
176
|
-
const params = await mintClient.makePrepareMintTokenParams({
|
|
177
|
-
tokenId,
|
|
178
|
-
tokenContract,
|
|
179
|
-
minterAccount: address,
|
|
180
|
-
mintArguments: {
|
|
181
|
-
mintToAddress: address,
|
|
182
|
-
quantityToMint,
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
setParams(params);
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
makeParams();
|
|
189
|
-
}, [mintClient, address, quantityToMint]);
|
|
190
|
-
|
|
191
|
-
const { config } = usePrepareContractWrite(params);
|
|
192
|
-
|
|
193
|
-
const { write, data, error, isLoading, isError } = useContractWrite(config);
|
|
194
|
-
const {
|
|
195
|
-
data: receipt,
|
|
196
|
-
isLoading: isPending,
|
|
197
|
-
isSuccess,
|
|
198
|
-
} = useWaitForTransaction({ hash: data?.hash });
|
|
199
|
-
|
|
200
|
-
return (
|
|
201
|
-
<>
|
|
202
|
-
<h3>Mint a token</h3>
|
|
203
|
-
<form
|
|
204
|
-
onSubmit={(e) => {
|
|
205
|
-
e.preventDefault();
|
|
206
|
-
write?.();
|
|
207
|
-
}}
|
|
208
|
-
>
|
|
209
|
-
{/* input for quantity to mint: */}
|
|
210
|
-
<input
|
|
211
|
-
placeholder="quantity to mint"
|
|
212
|
-
onChange={(e) => setQuantityToMint(Number(e.target.value))}
|
|
213
|
-
/>
|
|
214
|
-
<button disabled={!write} type="submit">
|
|
215
|
-
Mint
|
|
216
|
-
</button>
|
|
217
|
-
</form>
|
|
218
|
-
|
|
219
|
-
{isLoading && <div>Check wallet...</div>}
|
|
220
|
-
{isPending && <div>Transaction pending...</div>}
|
|
221
|
-
{isSuccess && (
|
|
222
|
-
<>
|
|
223
|
-
<div>Transaction Hash: {data?.hash}</div>
|
|
224
|
-
<div>
|
|
225
|
-
Transaction Receipt: <pre>{stringify(receipt, null, 2)}</pre>
|
|
226
|
-
</div>
|
|
227
|
-
</>
|
|
228
|
-
)}
|
|
229
|
-
{isError && <div>{(error as BaseError)?.shortMessage}</div>}
|
|
230
|
-
</>
|
|
231
|
-
);
|
|
232
|
-
};
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### Creating an 1155 contract
|
|
236
|
-
|
|
237
|
-
If an object with {name, uri} is passed in to this helper, it uses the creatorAccount and those values to either 1) create or 2) mint to that existing contract.
|
|
238
|
-
|
|
239
|
-
If you wish to mint on an existing contract, pass that contract in the contract field. The return value is the prepared transaction that you can use viem or wagmi to send.
|
|
240
|
-
|
|
241
|
-
```ts
|
|
242
|
-
import type { PublicClient } from "viem";
|
|
243
|
-
import { create1155CreatorClient } from "@zoralabs/protocol-sdk";
|
|
244
|
-
|
|
245
|
-
export async function createContract({
|
|
246
|
-
publicClient,
|
|
247
|
-
walletClient,
|
|
248
|
-
}: {
|
|
249
|
-
publicClient: PublicClient;
|
|
250
|
-
walletClient: WalletClient;
|
|
251
|
-
}) {
|
|
252
|
-
const creatorClient = create1155CreatorClient({ publicClient });
|
|
253
|
-
const { request } = await creatorClient.createNew1155Token({
|
|
254
|
-
contract: {
|
|
255
|
-
name: "testContract",
|
|
256
|
-
uri: demoContractMetadataURI,
|
|
257
|
-
},
|
|
258
|
-
tokenMetadataURI: demoTokenMetadataURI,
|
|
259
|
-
account: creatorAccount,
|
|
260
|
-
mintToCreatorCount: 1,
|
|
261
|
-
});
|
|
262
|
-
const { request: simulateRequest } = publicClient.simulateContract(request);
|
|
263
|
-
const hash = await walletClient.writeContract(simulateRequest);
|
|
264
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
265
|
-
return receipt;
|
|
266
|
-
}
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
### Premint: create a mint without paying gas
|
|
270
|
-
|
|
271
|
-
```ts
|
|
272
|
-
import { createPremintClient } from "@zoralabs/protocol-sdk";
|
|
273
|
-
import type { Address, PublicClient, WalletClient } from "viem";
|
|
274
|
-
|
|
275
|
-
async function createForFree({
|
|
276
|
-
walletClient,
|
|
277
|
-
publicClient,
|
|
278
|
-
creatorAccount,
|
|
279
|
-
}: {
|
|
280
|
-
// wallet client that will submit the transaction
|
|
281
|
-
walletClient: WalletClient;
|
|
282
|
-
// public client that will simulate the transaction
|
|
283
|
-
publicClient: PublicClient;
|
|
284
|
-
// address of the token contract
|
|
285
|
-
creatorAccount: Account | Address;
|
|
286
|
-
}) {
|
|
287
|
-
const premintClient = createPremintClient({
|
|
288
|
-
chain: walletClient.chain!,
|
|
289
|
-
publicClient,
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
// create and sign a free token creation.
|
|
293
|
-
const createdPremint = await premintClient.createPremint({
|
|
294
|
-
walletClient,
|
|
295
|
-
creatorAccount,
|
|
296
|
-
// if true, will validate that the creator is authorized to create premints on the contract.
|
|
297
|
-
checkSignature: true,
|
|
298
|
-
// collection info of collection to create
|
|
299
|
-
collection: {
|
|
300
|
-
contractAdmin:
|
|
301
|
-
typeof creatorAccount === "string"
|
|
302
|
-
? creatorAccount
|
|
303
|
-
: creatorAccount.address,
|
|
304
|
-
contractName: "Testing Contract",
|
|
305
|
-
contractURI:
|
|
306
|
-
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
307
|
-
},
|
|
308
|
-
// token info of token to create
|
|
309
|
-
tokenCreationConfig: {
|
|
310
|
-
tokenURI:
|
|
311
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
312
|
-
},
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
const premintUid = createdPremint.uid;
|
|
316
|
-
const premintCollectionAddress = createdPremint.verifyingContract;
|
|
317
|
-
|
|
318
|
-
return {
|
|
319
|
-
// unique id of created premint, which can be used later to
|
|
320
|
-
// update or delete the premint
|
|
321
|
-
uid: premintUid,
|
|
322
|
-
tokenContractAddress: premintCollectionAddress,
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
### Updating a premint before it is brought onchain
|
|
328
|
-
|
|
329
|
-
Before a premint is brought onchain, it can be updated by the original creator of that token, by having that creator sign a message indicating the update. This is useful for updating the tokenURI, other metadata, or token sale configuration (price, duration, limits, etc.):
|
|
330
|
-
|
|
331
|
-
```ts
|
|
332
|
-
import { createPremintClient } from "@zoralabs/protocol-sdk";
|
|
333
|
-
import type { Address, PublicClient, WalletClient } from "viem";
|
|
334
|
-
|
|
335
|
-
async function updateCreatedForFreeToken(
|
|
336
|
-
walletClient: WalletClient,
|
|
337
|
-
premintUid: number,
|
|
338
|
-
) {
|
|
339
|
-
const premintClient = createPremintClient({ chain: walletClient.chain! });
|
|
340
|
-
|
|
341
|
-
// sign a message to update the created for free token, and store the update
|
|
342
|
-
await premintClient.updatePremint({
|
|
343
|
-
collection: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
344
|
-
uid: premintUid,
|
|
345
|
-
// WalletClient doing the signature
|
|
346
|
-
walletClient,
|
|
347
|
-
// Token information, falls back to defaults set in DefaultMintArguments.
|
|
348
|
-
tokenConfigUpdates: {
|
|
349
|
-
tokenURI:
|
|
350
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
351
|
-
},
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
### Deleting a premint before it is brought onchain
|
|
357
|
-
|
|
358
|
-
Before a premint is brought onchain, it can be deleted by the original creator of that token, by having that creator sign a message indicating the deletion:
|
|
359
|
-
|
|
360
|
-
```ts
|
|
361
|
-
async function deleteCreatedForFreeToken(walletClient: WalletClient) {
|
|
362
|
-
const premintClient = createPremintClient({ chain: walletClient.chain! });
|
|
363
|
-
|
|
364
|
-
// sign a message to delete the premint, and store the deletion
|
|
365
|
-
await premintClient.deletePremint({
|
|
366
|
-
// Extra step to check the signature on-chain before attempting to sign
|
|
367
|
-
collection: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
368
|
-
uid: 23,
|
|
369
|
-
// WalletClient doing the signature
|
|
370
|
-
walletClient,
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
### Minting a premint and bringing it onchain
|
|
376
|
-
|
|
377
|
-
```ts
|
|
378
|
-
import { createPremintClient } from "@zoralabs/protocol-sdk";
|
|
379
|
-
import type { Address, PublicClient, WalletClient } from "viem";
|
|
380
|
-
|
|
381
|
-
async function mintCreatedForFreeToken(
|
|
382
|
-
walletClient: WalletClient,
|
|
383
|
-
publicClient: PublicClient,
|
|
384
|
-
minterAccount: Address,
|
|
385
|
-
) {
|
|
386
|
-
const premintClient = createPremintClient({ chain: walletClient.chain! });
|
|
387
|
-
|
|
388
|
-
const simulateContractParameters = await premintClient.makeMintParameters({
|
|
389
|
-
minterAccount,
|
|
390
|
-
tokenContract: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
|
|
391
|
-
uid: 3,
|
|
392
|
-
mintArguments: {
|
|
393
|
-
quantityToMint: 1,
|
|
394
|
-
mintComment: "",
|
|
395
|
-
},
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
// simulate the transaction and get any validation errors
|
|
399
|
-
const { request } = await publicClient.simulateContract(
|
|
400
|
-
simulateContractParameters,
|
|
401
|
-
);
|
|
402
|
-
|
|
403
|
-
// submit the transaction to the network
|
|
404
|
-
const txHash = await walletClient.writeContract(request);
|
|
405
|
-
|
|
406
|
-
// wait for the transaction to be complete
|
|
407
|
-
const receipt = await publicClient.waitForTransactionReceipt({
|
|
408
|
-
hash: txHash,
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
const { urls } = await premintClient.getDataFromPremintReceipt(receipt);
|
|
412
|
-
|
|
413
|
-
// block explorer url:
|
|
414
|
-
console.log(urls.explorer);
|
|
415
|
-
// collect url:
|
|
416
|
-
console.log(urls.zoraCollect);
|
|
417
|
-
// manage url:
|
|
418
|
-
console.log(urls.zoraManage);
|
|
419
|
-
}
|
|
420
|
-
```
|
|
5
|
+
For documentation and guides, [head to the documentation site.](https://ourzora.github.io/zora-protocol/protocol-sdk/introduction)
|
package/dist/constants.d.ts
CHANGED
|
@@ -33,5 +33,4 @@ export declare const zora721Abi: readonly [{
|
|
|
33
33
|
readonly type: "uint256";
|
|
34
34
|
}];
|
|
35
35
|
}];
|
|
36
|
-
export declare const NFT_SALE_QUERY = "\nfragment SaleStrategy on SalesStrategyConfig {\n type\n fixedPrice {\n address\n pricePerToken\n saleEnd\n saleStart\n maxTokensPerAddress\n }\n erc20Minter {\n address\n pricePerToken\n currency\n saleEnd\n saleStart\n maxTokensPerAddress\n }\n}\n\nquery ($id: ID!) {\n zoraCreateToken(id: $id) {\n id\n contract {\n mintFeePerQuantity\n salesStrategies(where: {type_in: [\"FIXED_PRICE\", \"ERC_20_MINTER\"]}) {\n ...SaleStrategy\n }\n }\n salesStrategies(where: {type_in: [\"FIXED_PRICE\", \"ERC_20_MINTER\"]}) {\n ...SaleStrategy\n }\n }\n}\n";
|
|
37
36
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,yBAAyB,CAAC;AACpD,eAAO,MAAM,sBAAsB,QAAiC,CAAC;AAMrE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGZ,CAAC
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,yBAAyB,CAAC;AACpD,eAAO,MAAM,sBAAsB,QAAiC,CAAC;AAMrE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGZ,CAAC"}
|
|
@@ -1,62 +1,23 @@
|
|
|
1
|
-
import type { Account, Address, Hex, SimulateContractParameters, TransactionReceipt } from "viem";
|
|
2
|
-
import {
|
|
3
|
-
type SalesConfigParamsType = {
|
|
4
|
-
pricePerToken?: bigint;
|
|
5
|
-
saleStart?: bigint;
|
|
6
|
-
saleEnd?: bigint;
|
|
7
|
-
maxTokensPerAddress?: bigint;
|
|
8
|
-
fundsRecipient?: Address;
|
|
9
|
-
};
|
|
10
|
-
export declare const DEFAULT_SALE_SETTINGS: {
|
|
11
|
-
fundsRecipient: "0x0000000000000000000000000000000000000000";
|
|
12
|
-
pricePerToken: bigint;
|
|
13
|
-
saleStart: bigint;
|
|
14
|
-
saleEnd: bigint;
|
|
15
|
-
maxTokensPerAddress: bigint;
|
|
16
|
-
};
|
|
17
|
-
type ContractType = {
|
|
18
|
-
name: string;
|
|
19
|
-
uri: string;
|
|
20
|
-
defaultAdmin?: Address;
|
|
21
|
-
} | Address;
|
|
22
|
-
type RoyaltySettingsType = {
|
|
23
|
-
royaltyBPS: number;
|
|
24
|
-
royaltyRecipient: Address;
|
|
25
|
-
};
|
|
26
|
-
export declare function create1155TokenSetupArgs({ nextTokenId, mintToCreatorCount, tokenMetadataURI, fixedPriceMinterAddress, createReferral, maxSupply, account, salesConfig, royaltySettings, }: {
|
|
27
|
-
maxSupply?: bigint | number;
|
|
28
|
-
createReferral?: Address;
|
|
29
|
-
nextTokenId: bigint;
|
|
30
|
-
mintToCreatorCount: bigint | number;
|
|
31
|
-
account: Address;
|
|
32
|
-
tokenMetadataURI: string;
|
|
33
|
-
fixedPriceMinterAddress: Address;
|
|
34
|
-
salesConfig: SalesConfigParamsType;
|
|
35
|
-
royaltySettings?: RoyaltySettingsType;
|
|
36
|
-
}): `0x${string}`[];
|
|
1
|
+
import type { Account, Address, Hex, PublicClient, SimulateContractParameters, TransactionReceipt } from "viem";
|
|
2
|
+
import { CreateNew1155Params, New1155Token } from "./types";
|
|
37
3
|
export declare const getTokenIdFromCreateReceipt: (receipt: TransactionReceipt) => bigint | undefined;
|
|
38
4
|
type CreateNew1155TokenReturn = {
|
|
39
|
-
|
|
5
|
+
parameters: SimulateContractParameters<any, any, any, any, any, Account | Address>;
|
|
40
6
|
tokenSetupActions: Hex[];
|
|
41
|
-
|
|
7
|
+
collectionAddress: Address;
|
|
8
|
+
newTokenId: bigint;
|
|
9
|
+
newToken: New1155Token;
|
|
10
|
+
minter: Address;
|
|
42
11
|
contractExists: boolean;
|
|
43
12
|
};
|
|
44
|
-
export declare
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
salesConfig?: SalesConfigParamsType | undefined;
|
|
54
|
-
createReferral?: `0x${string}` | undefined;
|
|
55
|
-
getAdditionalSetupActions?: ((args: {
|
|
56
|
-
tokenId: bigint;
|
|
57
|
-
contractAddress: Address;
|
|
58
|
-
}) => Hex[]) | undefined;
|
|
59
|
-
}) => Promise<CreateNew1155TokenReturn>;
|
|
60
|
-
};
|
|
13
|
+
export declare class Create1155Client {
|
|
14
|
+
private readonly chainId;
|
|
15
|
+
private readonly publicClient;
|
|
16
|
+
constructor({ chainId, publicClient, }: {
|
|
17
|
+
chainId: number;
|
|
18
|
+
publicClient: Pick<PublicClient, "readContract">;
|
|
19
|
+
});
|
|
20
|
+
createNew1155Token(props: CreateNew1155Params): Promise<CreateNew1155TokenReturn>;
|
|
21
|
+
}
|
|
61
22
|
export {};
|
|
62
23
|
//# sourceMappingURL=1155-create-helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1155-create-helper.d.ts","sourceRoot":"","sources":["../../src/create/1155-create-helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"1155-create-helper.d.ts","sourceRoot":"","sources":["../../src/create/1155-create-helper.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,GAAG,EACH,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,EACnB,MAAM,MAAM,CAAC;AAId,OAAO,EAAgB,mBAAmB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAM1E,eAAO,MAAM,2BAA2B,YAC7B,kBAAkB,KAC1B,MAAM,GAAG,SAaX,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,UAAU,EAAE,0BAA0B,CACpC,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,OAAO,GAAG,OAAO,CAClB,CAAC;IACF,iBAAiB,EAAE,GAAG,EAAE,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,YAAY,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AA2DF,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqC;gBAEtD,EACV,OAAO,EACP,YAAY,GACb,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;KAClD;IAKK,kBAAkB,CAAC,KAAK,EAAE,mBAAmB;CAOpD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Address, PublicClient } from "viem";
|
|
2
|
+
import { ContractType } from "./types";
|
|
3
|
+
export declare function getContractInfo({ publicClient, chainId, contract, account, }: {
|
|
4
|
+
publicClient: Pick<PublicClient, "readContract">;
|
|
5
|
+
chainId: number;
|
|
6
|
+
contract: ContractType;
|
|
7
|
+
account: Address;
|
|
8
|
+
}): Promise<{
|
|
9
|
+
contractExists: boolean;
|
|
10
|
+
contractAddress: Address;
|
|
11
|
+
contractVersion: string;
|
|
12
|
+
nextTokenId: bigint;
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=contract-setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-setup.d.ts","sourceRoot":"","sources":["../../src/create/contract-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAkBvC,wBAAsB,eAAe,CAAC,EACpC,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,OAAO,GACR,EAAE;IACD,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAC;IAEvB,OAAO,EAAE,OAAO,CAAC;CAClB,GAAG,OAAO,CAAC;IACV,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAoDD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Address, Hex } from "viem";
|
|
2
|
+
import { ContractProps, CreateNew1155TokenProps, New1155Token, SalesConfigParamsType } from "./types";
|
|
3
|
+
import { Concrete } from "src/utils";
|
|
4
|
+
export declare const PERMISSION_BITS: {
|
|
5
|
+
MINTER: bigint;
|
|
6
|
+
};
|
|
7
|
+
type SetupMintersProps = {
|
|
8
|
+
tokenId: bigint;
|
|
9
|
+
chainId: number;
|
|
10
|
+
fundsRecipient: Address;
|
|
11
|
+
salesConfig: Concrete<SalesConfigParamsType>;
|
|
12
|
+
};
|
|
13
|
+
export declare function setupMinters({ salesConfig, ...rest }: SetupMintersProps): {
|
|
14
|
+
minter: Address;
|
|
15
|
+
setupActions: Hex[];
|
|
16
|
+
};
|
|
17
|
+
export declare function constructCreate1155TokenCalls(props: CreateNew1155TokenProps & ContractProps & {
|
|
18
|
+
ownerAddress: Address;
|
|
19
|
+
chainId: number;
|
|
20
|
+
}): {
|
|
21
|
+
setupActions: `0x${string}`[];
|
|
22
|
+
newToken: New1155Token;
|
|
23
|
+
minter: Address;
|
|
24
|
+
};
|
|
25
|
+
export declare const contractSupportsMintRewards: (contractVersion?: string | null, contractStandard?: "ERC721" | "ERC1155") => boolean;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=token-setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-setup.d.ts","sourceRoot":"","sources":["../../src/create/token-setup.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAmC,GAAG,EAAE,MAAM,MAAM,CAAC;AAErE,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,YAAY,EACZ,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,eAAO,MAAM,eAAe;;CAE3B,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;CAC9C,CAAC;AAkKF,wBAAgB,YAAY,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,EAAE,iBAAiB,GAAG;IACzE,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,GAAG,EAAE,CAAC;CACrB,CAeA;AAmFD,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,uBAAuB,GAC5B,aAAa,GAAG;IACd,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,GACF;IACD,YAAY,EAAE,KAAK,MAAM,EAAE,EAAE,CAAC;IAC9B,QAAQ,EAAE,YAAY,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;CACjB,CA2DA;AAED,eAAO,MAAM,2BAA2B,qBACpB,MAAM,GAAG,IAAI,qBACZ,QAAQ,GAAG,SAAS,YAexC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Concrete } from "src/utils";
|
|
2
|
+
import { Address, Hex } from "viem";
|
|
3
|
+
export type ContractType = {
|
|
4
|
+
name: string;
|
|
5
|
+
uri: string;
|
|
6
|
+
defaultAdmin?: Address;
|
|
7
|
+
} | Address;
|
|
8
|
+
export type SalesConfigParamsType = {
|
|
9
|
+
pricePerToken?: bigint;
|
|
10
|
+
saleStart?: bigint;
|
|
11
|
+
saleEnd?: bigint;
|
|
12
|
+
maxTokensPerAddress?: bigint;
|
|
13
|
+
currency?: Address;
|
|
14
|
+
};
|
|
15
|
+
export type CreateNew1155Params = {
|
|
16
|
+
account: Address;
|
|
17
|
+
contract: ContractType;
|
|
18
|
+
getAdditionalSetupActions?: (args: {
|
|
19
|
+
tokenId: bigint;
|
|
20
|
+
contractAddress: Address;
|
|
21
|
+
}) => Hex[];
|
|
22
|
+
token: CreateNew1155TokenProps;
|
|
23
|
+
};
|
|
24
|
+
export interface CreateNew1155TokenProps {
|
|
25
|
+
maxSupply?: bigint | number;
|
|
26
|
+
tokenMetadataURI: string;
|
|
27
|
+
royaltyBPS?: number;
|
|
28
|
+
salesConfig?: SalesConfigParamsType;
|
|
29
|
+
createReferral?: Address;
|
|
30
|
+
mintToCreatorCount?: number;
|
|
31
|
+
payoutRecipient?: Address;
|
|
32
|
+
}
|
|
33
|
+
export interface ContractProps {
|
|
34
|
+
nextTokenId: bigint;
|
|
35
|
+
contractVersion: string;
|
|
36
|
+
}
|
|
37
|
+
export type New1155Token = {
|
|
38
|
+
payoutRecipient: Address;
|
|
39
|
+
createReferral: Address;
|
|
40
|
+
maxSupply: bigint;
|
|
41
|
+
royaltyBPS: number;
|
|
42
|
+
salesConfig: Concrete<SalesConfigParamsType>;
|
|
43
|
+
tokenMetadataURI: string;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/create/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEpC,MAAM,MAAM,YAAY,GACpB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,GACD,OAAO,CAAC;AAEZ,MAAM,MAAM,qBAAqB,GAAG;IAElC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,YAAY,CAAC;IACvB,yBAAyB,CAAC,EAAE,CAAC,IAAI,EAAE;QACjC,OAAO,EAAE,MAAM,CAAC;QAChB,eAAe,EAAE,OAAO,CAAC;KAC1B,KAAK,GAAG,EAAE,CAAC;IACZ,KAAK,EAAE,uBAAuB,CAAC;CAChC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IAC7C,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC"}
|