@zoralabs/protocol-sdk 0.11.4 → 0.11.6-COMMENTS.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 +7 -7
- package/CHANGELOG.md +32 -0
- package/dist/create/mint-from-create.d.ts +2 -1
- package/dist/create/mint-from-create.d.ts.map +1 -1
- package/dist/create/minter-defaults.d.ts.map +1 -1
- package/dist/create/types.d.ts +1 -0
- package/dist/create/types.d.ts.map +1 -1
- package/dist/index.cjs +235 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +239 -58
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-client.d.ts +3 -1
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/mint-queries.d.ts +5 -3
- package/dist/mint/mint-queries.d.ts.map +1 -1
- package/dist/mint/mint-transactions.d.ts +4 -2
- package/dist/mint/mint-transactions.d.ts.map +1 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/secondary/secondary-client.d.ts +4 -3
- package/dist/secondary/secondary-client.d.ts.map +1 -1
- package/dist/secondary/types.d.ts +7 -0
- package/dist/secondary/types.d.ts.map +1 -1
- package/dist/secondary/utils.d.ts.map +1 -1
- package/dist/test-utils.d.ts +3 -1
- package/dist/test-utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/comments/comments.test.ts +342 -0
- package/src/create/1155-create-helper.test.ts +77 -14
- package/src/create/1155-create-helper.ts +2 -0
- package/src/create/mint-from-create.ts +3 -0
- package/src/create/minter-defaults.ts +22 -8
- package/src/create/types.ts +5 -3
- package/src/mint/mint-client.test.ts +67 -30
- package/src/mint/mint-client.ts +10 -1
- package/src/mint/mint-queries.ts +16 -5
- package/src/mint/mint-transactions.ts +80 -16
- package/src/sdk.ts +1 -0
- package/src/secondary/secondary-client.test.ts +149 -25
- package/src/secondary/secondary-client.ts +138 -7
- package/src/secondary/types.ts +19 -4
- package/src/secondary/utils.ts +30 -10
- package/src/sparks/sparks-sponsored-sparks-spender.test.ts +1 -1
- package/src/test-utils.ts +12 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getContractAddressFromReceipt,
|
|
4
4
|
getTokenIdFromCreateReceipt,
|
|
5
5
|
} from "./1155-create-helper";
|
|
6
|
-
import { createCreatorClient } from "src/sdk";
|
|
6
|
+
import { createCollectorClient, createCreatorClient } from "src/sdk";
|
|
7
7
|
import {
|
|
8
8
|
zoraCreator1155ImplABI,
|
|
9
9
|
zoraTimedSaleStrategyABI,
|
|
@@ -12,20 +12,22 @@ import {
|
|
|
12
12
|
import { waitForSuccess } from "src/test-utils";
|
|
13
13
|
import { Address, erc20Abi, parseEther, PublicClient } from "viem";
|
|
14
14
|
import { makePrepareMint1155TokenParams } from "src/mint/mint-transactions";
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
forkUrls,
|
|
17
|
+
makeAnvilTest,
|
|
18
|
+
simulateAndWriteContractWithRetries,
|
|
19
|
+
writeContractWithRetries,
|
|
20
|
+
} from "src/anvil";
|
|
16
21
|
import { zora } from "viem/chains";
|
|
17
22
|
import { AllowList } from "src/allow-list/types";
|
|
18
23
|
import { createAllowList } from "src/allow-list/allow-list-client";
|
|
19
|
-
import { NewContractParams } from "./types";
|
|
20
24
|
import { SubgraphContractGetter } from "./contract-getter";
|
|
21
25
|
import {
|
|
22
26
|
DEFAULT_MINIMUM_MARKET_ETH,
|
|
23
27
|
DEFAULT_MARKET_COUNTDOWN,
|
|
24
28
|
} from "./minter-defaults";
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
demoTokenMetadataURI,
|
|
28
|
-
} from "src/fixtures/contract-setup";
|
|
29
|
+
import { randomNewContract } from "src/test-utils";
|
|
30
|
+
import { demoTokenMetadataURI } from "src/fixtures/contract-setup";
|
|
29
31
|
|
|
30
32
|
const anvilTest = makeAnvilTest({
|
|
31
33
|
forkUrl: forkUrls.zoraMainnet,
|
|
@@ -56,13 +58,6 @@ const minterIsMinterOnToken = async ({
|
|
|
56
58
|
});
|
|
57
59
|
};
|
|
58
60
|
|
|
59
|
-
function randomNewContract(): NewContractParams {
|
|
60
|
-
return {
|
|
61
|
-
name: `testContract-${Math.round(Math.random() * 1_000_000)}`,
|
|
62
|
-
uri: demoContractMetadataURI,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
61
|
describe("create-helper", () => {
|
|
67
62
|
anvilTest(
|
|
68
63
|
"when no sales config is provided, it creates a new 1155 contract and token using the timed sale strategy",
|
|
@@ -143,6 +138,74 @@ describe("create-helper", () => {
|
|
|
143
138
|
],
|
|
144
139
|
}),
|
|
145
140
|
).toBe(true);
|
|
141
|
+
|
|
142
|
+
// get secondary info, minimum mints count should be 1111, sale end should be undefined,
|
|
143
|
+
// market countdown should be 24 hours
|
|
144
|
+
|
|
145
|
+
const collectorClient = createCollectorClient({
|
|
146
|
+
chainId: chain.id,
|
|
147
|
+
publicClient,
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const secondaryInfo = await collectorClient.getSecondaryInfo({
|
|
151
|
+
contract: contractAddress,
|
|
152
|
+
tokenId: newTokenId,
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
expect(secondaryInfo).toBeDefined();
|
|
156
|
+
expect(secondaryInfo!.minimumMintsForCountdown).toBe(1111n);
|
|
157
|
+
expect(secondaryInfo!.secondaryActivated).toBe(false);
|
|
158
|
+
expect(secondaryInfo!.saleEnd).toBeUndefined();
|
|
159
|
+
expect(secondaryInfo!.marketCountdown).toBe(24n * 60n * 60n);
|
|
160
|
+
},
|
|
161
|
+
20 * 1000,
|
|
162
|
+
);
|
|
163
|
+
anvilTest(
|
|
164
|
+
"when minimumMintsForCountdown is set, it uses that as the minimum mints for countdown",
|
|
165
|
+
async ({ viemClients: { publicClient, walletClient, chain } }) => {
|
|
166
|
+
const addresses = await walletClient.getAddresses();
|
|
167
|
+
const creatorAddress = addresses[0]!;
|
|
168
|
+
|
|
169
|
+
const creatorClient = createCreatorClient({
|
|
170
|
+
chainId: chain.id,
|
|
171
|
+
publicClient: publicClient,
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const saleStart = 5n;
|
|
175
|
+
const contract = randomNewContract();
|
|
176
|
+
const { parameters, contractAddress, newTokenId } =
|
|
177
|
+
await creatorClient.create1155({
|
|
178
|
+
contract,
|
|
179
|
+
token: {
|
|
180
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
181
|
+
mintToCreatorCount: 1,
|
|
182
|
+
salesConfig: {
|
|
183
|
+
saleStart,
|
|
184
|
+
minimumMintsForCountdown: 500n,
|
|
185
|
+
marketCountdown: 100n,
|
|
186
|
+
type: "timed",
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
account: creatorAddress,
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
await simulateAndWriteContractWithRetries({
|
|
193
|
+
parameters,
|
|
194
|
+
walletClient,
|
|
195
|
+
publicClient,
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
const secondaryInfo = await createCollectorClient({
|
|
199
|
+
chainId: chain.id,
|
|
200
|
+
publicClient,
|
|
201
|
+
}).getSecondaryInfo({
|
|
202
|
+
contract: contractAddress,
|
|
203
|
+
tokenId: newTokenId,
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
expect(secondaryInfo).toBeDefined();
|
|
207
|
+
expect(secondaryInfo!.minimumMintsForCountdown).toBe(500n);
|
|
208
|
+
expect(secondaryInfo!.marketCountdown).toBe(100n);
|
|
146
209
|
},
|
|
147
210
|
20 * 1000,
|
|
148
211
|
);
|
|
@@ -238,6 +238,7 @@ async function createNew1155ContractAndToken({
|
|
|
238
238
|
publicClient,
|
|
239
239
|
chainId,
|
|
240
240
|
}),
|
|
241
|
+
chainId,
|
|
241
242
|
});
|
|
242
243
|
|
|
243
244
|
return {
|
|
@@ -294,6 +295,7 @@ async function createNew1155Token({
|
|
|
294
295
|
result: newToken.salesConfig,
|
|
295
296
|
tokenId: nextTokenId,
|
|
296
297
|
getContractMintFee: async () => mintFee,
|
|
298
|
+
chainId,
|
|
297
299
|
});
|
|
298
300
|
|
|
299
301
|
return {
|
|
@@ -75,6 +75,7 @@ export function makeOnchainPrepareMintFromCreate({
|
|
|
75
75
|
minter,
|
|
76
76
|
getContractMintFee,
|
|
77
77
|
contractVersion,
|
|
78
|
+
chainId,
|
|
78
79
|
}: {
|
|
79
80
|
contractAddress: Address;
|
|
80
81
|
tokenId: bigint;
|
|
@@ -82,6 +83,7 @@ export function makeOnchainPrepareMintFromCreate({
|
|
|
82
83
|
minter: Address;
|
|
83
84
|
getContractMintFee: () => Promise<bigint>;
|
|
84
85
|
contractVersion: string;
|
|
86
|
+
chainId: number;
|
|
85
87
|
}): AsyncPrepareMint {
|
|
86
88
|
return async (params: MintParametersBase): Promise<PrepareMintReturn> => {
|
|
87
89
|
const subgraphSalesConfig = await toSalesStrategyFromSubgraph({
|
|
@@ -98,6 +100,7 @@ export function makeOnchainPrepareMintFromCreate({
|
|
|
98
100
|
...params,
|
|
99
101
|
tokenContract: contractAddress,
|
|
100
102
|
tokenId,
|
|
103
|
+
chainId,
|
|
101
104
|
}),
|
|
102
105
|
costs: parseMintCosts({
|
|
103
106
|
allowListEntry: params.allowListEntry,
|
|
@@ -79,24 +79,38 @@ export const parseNameIntoSymbol = (name: string) => {
|
|
|
79
79
|
return result;
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
+
const getMinimumMarketEth = (
|
|
83
|
+
params: Pick<
|
|
84
|
+
TimedSaleParamsType,
|
|
85
|
+
"minimumMarketEth" | "minimumMintsForCountdown"
|
|
86
|
+
>,
|
|
87
|
+
) => {
|
|
88
|
+
if (params.minimumMintsForCountdown) {
|
|
89
|
+
return params.minimumMintsForCountdown * parseEther("0.0000111");
|
|
90
|
+
}
|
|
91
|
+
return params.minimumMarketEth || DEFAULT_MINIMUM_MARKET_ETH;
|
|
92
|
+
};
|
|
93
|
+
|
|
82
94
|
const timedSaleSettingsWithDefaults = (
|
|
83
95
|
params: TimedSaleParamsType,
|
|
84
96
|
contractName: string,
|
|
85
97
|
): Concrete<TimedSaleParamsType> => {
|
|
86
98
|
// If the name is not provided, try to fetch it from the metadata
|
|
87
99
|
const erc20Name = params.erc20Name || contractName;
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
100
|
+
const minimumMarketEth = getMinimumMarketEth({
|
|
101
|
+
minimumMarketEth: params.minimumMarketEth,
|
|
102
|
+
minimumMintsForCountdown: params.minimumMintsForCountdown,
|
|
103
|
+
});
|
|
104
|
+
const minimumMintsForCountdown = minimumMarketEth / parseEther("0.0000111");
|
|
92
105
|
|
|
93
106
|
return {
|
|
94
107
|
type: "timed",
|
|
95
108
|
erc20Name: erc20Name,
|
|
96
|
-
erc20Symbol:
|
|
97
|
-
saleStart:
|
|
98
|
-
marketCountdown:
|
|
99
|
-
minimumMarketEth
|
|
109
|
+
erc20Symbol: params.erc20Symbol || parseNameIntoSymbol(erc20Name),
|
|
110
|
+
saleStart: params.saleStart || 0n,
|
|
111
|
+
marketCountdown: params.marketCountdown || DEFAULT_MARKET_COUNTDOWN,
|
|
112
|
+
minimumMarketEth,
|
|
113
|
+
minimumMintsForCountdown,
|
|
100
114
|
};
|
|
101
115
|
};
|
|
102
116
|
|
package/src/create/types.ts
CHANGED
|
@@ -33,12 +33,14 @@ export type TimedSaleParamsType = {
|
|
|
33
33
|
erc20Name?: string;
|
|
34
34
|
// Symbol of the erc20z token to create for the secondary sale. If not provided, extracts it from the name.
|
|
35
35
|
erc20Symbol?: string;
|
|
36
|
-
//
|
|
36
|
+
// Earliest time a token can be minted. If undefined or 0, then it can be minted immediately. Defaults to 0n.
|
|
37
37
|
saleStart?: bigint;
|
|
38
|
-
// Market countdown
|
|
38
|
+
// Market countdown that will start once the minimum mints for countdown is reached. Defaults to 24 hours.
|
|
39
39
|
marketCountdown?: bigint;
|
|
40
|
-
//
|
|
40
|
+
// Deprecated: Use minimumMintsForCountdown instead.
|
|
41
41
|
minimumMarketEth?: bigint;
|
|
42
|
+
// Minimum mints that will trigger the countdown. Defaults to 1111
|
|
43
|
+
minimumMintsForCountdown?: bigint;
|
|
42
44
|
};
|
|
43
45
|
|
|
44
46
|
export type Erc20ParamsType = SaleStartAndEnd &
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import { describe, expect, vi } from "vitest";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Address,
|
|
4
|
+
erc20Abi,
|
|
5
|
+
parseAbi,
|
|
6
|
+
parseEther,
|
|
7
|
+
TransactionReceipt,
|
|
8
|
+
parseEventLogs,
|
|
9
|
+
} from "viem";
|
|
3
10
|
import { zora, zoraSepolia } from "viem/chains";
|
|
4
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
zoraCreator1155ImplABI,
|
|
13
|
+
CommentIdentifier,
|
|
14
|
+
commentsABI,
|
|
15
|
+
callerAndCommenterABI,
|
|
16
|
+
} from "@zoralabs/protocol-deployments";
|
|
5
17
|
import { forkUrls, makeAnvilTest, writeContractWithRetries } from "src/anvil";
|
|
6
18
|
import { createCollectorClient, createCreatorClient } from "src/sdk";
|
|
7
19
|
import { getAllowListEntry } from "src/allow-list/allow-list-client";
|
|
20
|
+
import { SubgraphMintGetter } from "./subgraph-mint-getter";
|
|
21
|
+
import { new1155ContractVersion } from "src/create/contract-setup";
|
|
8
22
|
import {
|
|
9
23
|
demoContractMetadataURI,
|
|
10
24
|
demoTokenMetadataURI,
|
|
11
|
-
} from "src/
|
|
12
|
-
import { SubgraphMintGetter } from "./subgraph-mint-getter";
|
|
13
|
-
import { new1155ContractVersion } from "src/create/contract-setup";
|
|
25
|
+
} from "src/fixtures/contract-setup";
|
|
14
26
|
import { ISubgraphQuerier } from "src/apis/subgraph-querier";
|
|
15
27
|
import { mockTimedSaleStrategyTokenQueryResult } from "src/fixtures/mint-query-results";
|
|
16
28
|
|
|
@@ -18,52 +30,64 @@ const erc721ABI = parseAbi([
|
|
|
18
30
|
"function balanceOf(address owner) public view returns (uint256)",
|
|
19
31
|
] as const);
|
|
20
32
|
|
|
33
|
+
const getCommentIdentifierFromReceipt = (
|
|
34
|
+
receipt: TransactionReceipt,
|
|
35
|
+
): CommentIdentifier => {
|
|
36
|
+
const logs = parseEventLogs({
|
|
37
|
+
abi: commentsABI,
|
|
38
|
+
logs: receipt.logs,
|
|
39
|
+
eventName: "Commented",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (logs.length === 0) {
|
|
43
|
+
throw new Error("No Commented event found in receipt");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return logs[0]!.args.commentIdentifier;
|
|
47
|
+
};
|
|
48
|
+
|
|
21
49
|
describe("mint-helper", () => {
|
|
22
50
|
makeAnvilTest({
|
|
23
|
-
forkBlockNumber:
|
|
24
|
-
forkUrl: forkUrls.
|
|
25
|
-
anvilChainId:
|
|
51
|
+
forkBlockNumber: 16028124,
|
|
52
|
+
forkUrl: forkUrls.zoraSepolia,
|
|
53
|
+
anvilChainId: zoraSepolia.id,
|
|
26
54
|
})(
|
|
27
|
-
"mints a new 1155 token",
|
|
55
|
+
"mints a new 1155 token with a comment",
|
|
28
56
|
async ({ viemClients }) => {
|
|
29
|
-
const { testClient, walletClient, publicClient } = viemClients;
|
|
57
|
+
const { testClient, walletClient, publicClient, chain } = viemClients;
|
|
30
58
|
const creatorAccount = (await walletClient.getAddresses())[0]!;
|
|
31
59
|
await testClient.setBalance({
|
|
32
60
|
address: creatorAccount,
|
|
33
61
|
value: parseEther("2000"),
|
|
34
62
|
});
|
|
35
63
|
const targetContract: Address =
|
|
36
|
-
"
|
|
37
|
-
const targetTokenId =
|
|
64
|
+
"0xD42557F24034b53e7340A40bb5813eF9Ba88F2b4";
|
|
65
|
+
const targetTokenId = 3n;
|
|
38
66
|
const collectorClient = createCollectorClient({
|
|
39
|
-
chainId:
|
|
67
|
+
chainId: chain.id,
|
|
40
68
|
publicClient,
|
|
41
69
|
});
|
|
42
70
|
|
|
43
|
-
const {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
tokenId: targetTokenId,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
mintable.maxSupply;
|
|
54
|
-
mintable.totalMinted;
|
|
55
|
-
mintable.tokenURI;
|
|
56
|
-
mintable;
|
|
71
|
+
const { prepareMint, primaryMintActive } = await collectorClient.getToken(
|
|
72
|
+
{
|
|
73
|
+
tokenContract: targetContract,
|
|
74
|
+
mintType: "1155",
|
|
75
|
+
tokenId: targetTokenId,
|
|
76
|
+
},
|
|
77
|
+
);
|
|
57
78
|
|
|
58
79
|
expect(primaryMintActive).toBe(true);
|
|
59
80
|
expect(prepareMint).toBeDefined();
|
|
60
81
|
|
|
82
|
+
const quantityToMint = 5n;
|
|
83
|
+
|
|
61
84
|
const { parameters, costs } = prepareMint!({
|
|
62
85
|
minterAccount: creatorAccount,
|
|
63
|
-
quantityToMint
|
|
86
|
+
quantityToMint,
|
|
87
|
+
mintComment: "This is a fun comment :)",
|
|
64
88
|
});
|
|
65
89
|
|
|
66
|
-
expect(costs.totalCostEth).toBe(
|
|
90
|
+
expect(costs.totalCostEth).toBe(quantityToMint * parseEther("0.000111"));
|
|
67
91
|
|
|
68
92
|
const oldBalance = await publicClient.readContract({
|
|
69
93
|
abi: zoraCreator1155ImplABI,
|
|
@@ -84,7 +108,20 @@ describe("mint-helper", () => {
|
|
|
84
108
|
});
|
|
85
109
|
expect(receipt).to.not.be.null;
|
|
86
110
|
expect(oldBalance).to.be.equal(0n);
|
|
87
|
-
expect(newBalance).to.be.equal(
|
|
111
|
+
expect(newBalance).to.be.equal(quantityToMint);
|
|
112
|
+
|
|
113
|
+
// search for the Commented event in the logs
|
|
114
|
+
const commentIdentifier = getCommentIdentifierFromReceipt(receipt);
|
|
115
|
+
|
|
116
|
+
expect(commentIdentifier).toBeDefined();
|
|
117
|
+
|
|
118
|
+
const logs = parseEventLogs({
|
|
119
|
+
abi: callerAndCommenterABI,
|
|
120
|
+
logs: receipt.logs,
|
|
121
|
+
eventName: "MintedAndCommented",
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
expect(logs.length).toBe(1);
|
|
88
125
|
},
|
|
89
126
|
12 * 1000,
|
|
90
127
|
);
|
package/src/mint/mint-client.ts
CHANGED
|
@@ -24,19 +24,22 @@ export class MintClient {
|
|
|
24
24
|
private readonly publicClient: IPublicClient;
|
|
25
25
|
private readonly mintGetter: IOnchainMintGetter;
|
|
26
26
|
private readonly premintGetter: IPremintGetter;
|
|
27
|
-
|
|
27
|
+
private readonly chainId: number;
|
|
28
28
|
constructor({
|
|
29
29
|
publicClient,
|
|
30
30
|
premintGetter,
|
|
31
31
|
mintGetter,
|
|
32
|
+
chainId,
|
|
32
33
|
}: {
|
|
33
34
|
publicClient: IPublicClient;
|
|
34
35
|
premintGetter: IPremintGetter;
|
|
35
36
|
mintGetter: IOnchainMintGetter;
|
|
37
|
+
chainId: number;
|
|
36
38
|
}) {
|
|
37
39
|
this.publicClient = publicClient;
|
|
38
40
|
this.mintGetter = mintGetter;
|
|
39
41
|
this.premintGetter = premintGetter;
|
|
42
|
+
this.chainId = chainId;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
/**
|
|
@@ -54,6 +57,7 @@ export class MintClient {
|
|
|
54
57
|
publicClient: this.publicClient,
|
|
55
58
|
mintGetter: this.mintGetter,
|
|
56
59
|
premintGetter: this.premintGetter,
|
|
60
|
+
chainId: this.chainId,
|
|
57
61
|
});
|
|
58
62
|
}
|
|
59
63
|
|
|
@@ -69,6 +73,7 @@ export class MintClient {
|
|
|
69
73
|
mintGetter: this.mintGetter,
|
|
70
74
|
premintGetter: this.premintGetter,
|
|
71
75
|
publicClient: this.publicClient,
|
|
76
|
+
chainId: this.chainId,
|
|
72
77
|
});
|
|
73
78
|
}
|
|
74
79
|
|
|
@@ -87,6 +92,7 @@ export class MintClient {
|
|
|
87
92
|
mintGetter: this.mintGetter,
|
|
88
93
|
premintGetter: this.premintGetter,
|
|
89
94
|
publicClient: this.publicClient,
|
|
95
|
+
chainId: this.chainId,
|
|
90
96
|
});
|
|
91
97
|
}
|
|
92
98
|
|
|
@@ -110,17 +116,20 @@ async function mint({
|
|
|
110
116
|
publicClient,
|
|
111
117
|
mintGetter,
|
|
112
118
|
premintGetter,
|
|
119
|
+
chainId,
|
|
113
120
|
}: {
|
|
114
121
|
parameters: MakeMintParametersArguments;
|
|
115
122
|
publicClient: IPublicClient;
|
|
116
123
|
mintGetter: IOnchainMintGetter;
|
|
117
124
|
premintGetter: IPremintGetter;
|
|
125
|
+
chainId: number;
|
|
118
126
|
}): Promise<PrepareMintReturn> {
|
|
119
127
|
const { prepareMint, primaryMintActive } = await getMint({
|
|
120
128
|
params: parameters,
|
|
121
129
|
mintGetter,
|
|
122
130
|
premintGetter,
|
|
123
131
|
publicClient,
|
|
132
|
+
chainId,
|
|
124
133
|
});
|
|
125
134
|
|
|
126
135
|
if (!primaryMintActive) {
|
package/src/mint/mint-queries.ts
CHANGED
|
@@ -36,11 +36,13 @@ export async function getMint({
|
|
|
36
36
|
mintGetter,
|
|
37
37
|
premintGetter,
|
|
38
38
|
publicClient,
|
|
39
|
+
chainId,
|
|
39
40
|
}: {
|
|
40
41
|
params: GetMintParameters;
|
|
41
42
|
mintGetter: IOnchainMintGetter;
|
|
42
43
|
premintGetter: IPremintGetter;
|
|
43
44
|
publicClient: IPublicClient;
|
|
45
|
+
chainId: number;
|
|
44
46
|
}): Promise<MintableReturn> {
|
|
45
47
|
const { tokenContract } = params;
|
|
46
48
|
if (isOnChainMint(params)) {
|
|
@@ -53,7 +55,7 @@ export async function getMint({
|
|
|
53
55
|
blockTime: blockTime,
|
|
54
56
|
});
|
|
55
57
|
|
|
56
|
-
return toMintableReturn(result);
|
|
58
|
+
return toMintableReturn(result, chainId);
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
const premint = await premintGetter.get({
|
|
@@ -103,17 +105,19 @@ export async function getMintsOfContract({
|
|
|
103
105
|
mintGetter,
|
|
104
106
|
premintGetter,
|
|
105
107
|
publicClient,
|
|
108
|
+
chainId,
|
|
106
109
|
}: {
|
|
107
110
|
params: GetMintsOfContractParameters;
|
|
108
111
|
mintGetter: IOnchainMintGetter;
|
|
109
112
|
premintGetter: IPremintGetter;
|
|
110
113
|
publicClient: IPublicClient;
|
|
114
|
+
chainId: number;
|
|
111
115
|
}): Promise<{ contract?: ContractInfo; tokens: MintableReturn[] }> {
|
|
112
116
|
const onchainMints = (
|
|
113
117
|
await mintGetter.getContractMintable({
|
|
114
118
|
tokenAddress: params.tokenContract,
|
|
115
119
|
})
|
|
116
|
-
).map(toMintableReturn);
|
|
120
|
+
).map((result) => toMintableReturn(result, chainId));
|
|
117
121
|
|
|
118
122
|
const offchainMints = await getPremintsOfContractMintable({
|
|
119
123
|
mintGetter,
|
|
@@ -270,7 +274,7 @@ function parsePremint({
|
|
|
270
274
|
}
|
|
271
275
|
|
|
272
276
|
export const makeOnchainPrepareMint =
|
|
273
|
-
(result: OnchainSalesConfigAndTokenInfo): PrepareMint =>
|
|
277
|
+
(result: OnchainSalesConfigAndTokenInfo, chainId: number): PrepareMint =>
|
|
274
278
|
(params: MintParametersBase) => {
|
|
275
279
|
if (!result.salesConfig) {
|
|
276
280
|
throw new Error("No valid sales config found for token");
|
|
@@ -280,6 +284,7 @@ export const makeOnchainPrepareMint =
|
|
|
280
284
|
parameters: makeOnchainMintCall({
|
|
281
285
|
token: result as Concrete<OnchainSalesConfigAndTokenInfo>,
|
|
282
286
|
mintParams: params,
|
|
287
|
+
chainId,
|
|
283
288
|
}),
|
|
284
289
|
erc20Approval: getRequiredErc20Approvals(params, result.salesConfig),
|
|
285
290
|
costs: parseMintCosts({
|
|
@@ -290,7 +295,10 @@ export const makeOnchainPrepareMint =
|
|
|
290
295
|
};
|
|
291
296
|
};
|
|
292
297
|
|
|
293
|
-
function toMintableReturn(
|
|
298
|
+
function toMintableReturn(
|
|
299
|
+
result: GetMintableReturn,
|
|
300
|
+
chainId: number,
|
|
301
|
+
): MintableReturn {
|
|
294
302
|
const primaryMintActive = result.primaryMintActive;
|
|
295
303
|
if (!primaryMintActive) {
|
|
296
304
|
return {
|
|
@@ -306,7 +314,10 @@ function toMintableReturn(result: GetMintableReturn): MintableReturn {
|
|
|
306
314
|
primaryMintActive,
|
|
307
315
|
primaryMintEnd: result.primaryMintEnd,
|
|
308
316
|
secondaryMarketActive: result.secondaryMarketActive,
|
|
309
|
-
prepareMint: makeOnchainPrepareMint(
|
|
317
|
+
prepareMint: makeOnchainPrepareMint(
|
|
318
|
+
result.salesConfigAndTokenInfo,
|
|
319
|
+
chainId,
|
|
320
|
+
),
|
|
310
321
|
};
|
|
311
322
|
}
|
|
312
323
|
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
erc20MinterABI,
|
|
12
12
|
zoraCreator1155ImplABI,
|
|
13
13
|
zoraTimedSaleStrategyABI,
|
|
14
|
+
callerAndCommenterABI,
|
|
15
|
+
callerAndCommenterAddress,
|
|
14
16
|
} from "@zoralabs/protocol-deployments";
|
|
15
17
|
import { zora721Abi, zora1155LegacyAbi } from "src/constants";
|
|
16
18
|
import {
|
|
@@ -32,9 +34,11 @@ import { AllowListEntry } from "src/allow-list/types";
|
|
|
32
34
|
export function makeOnchainMintCall({
|
|
33
35
|
token,
|
|
34
36
|
mintParams,
|
|
37
|
+
chainId,
|
|
35
38
|
}: {
|
|
36
39
|
token: Concrete<OnchainSalesConfigAndTokenInfo>;
|
|
37
40
|
mintParams: Omit<MakeMintParametersArgumentsBase, "tokenContract">;
|
|
41
|
+
chainId: number;
|
|
38
42
|
}): SimulateContractParametersWithAccount {
|
|
39
43
|
if (token.mintType === "721") {
|
|
40
44
|
return makePrepareMint721TokenParams({
|
|
@@ -48,6 +52,7 @@ export function makeOnchainMintCall({
|
|
|
48
52
|
salesConfigAndTokenInfo: token,
|
|
49
53
|
tokenContract: token.contract.address,
|
|
50
54
|
tokenId: token.tokenId!,
|
|
55
|
+
chainId,
|
|
51
56
|
...mintParams,
|
|
52
57
|
});
|
|
53
58
|
}
|
|
@@ -57,6 +62,69 @@ export type MintableParameters = Pick<
|
|
|
57
62
|
"contractVersion" | "salesConfig"
|
|
58
63
|
>;
|
|
59
64
|
|
|
65
|
+
function makeZoraTimedSaleStrategyMintCall({
|
|
66
|
+
minterAccount,
|
|
67
|
+
salesConfigAndTokenInfo,
|
|
68
|
+
mintQuantity,
|
|
69
|
+
mintTo,
|
|
70
|
+
tokenContract,
|
|
71
|
+
tokenId,
|
|
72
|
+
mintReferral,
|
|
73
|
+
mintComment,
|
|
74
|
+
chainId,
|
|
75
|
+
}: {
|
|
76
|
+
minterAccount: Address | Account;
|
|
77
|
+
salesConfigAndTokenInfo: Concrete<MintableParameters>;
|
|
78
|
+
mintQuantity: bigint;
|
|
79
|
+
mintTo: Address;
|
|
80
|
+
tokenContract: Address;
|
|
81
|
+
tokenId: GenericTokenIdTypes;
|
|
82
|
+
mintReferral?: Address;
|
|
83
|
+
mintComment?: string;
|
|
84
|
+
chainId: number;
|
|
85
|
+
}) {
|
|
86
|
+
// if there is a mint comment, use the caller and commenter
|
|
87
|
+
if (mintComment && mintComment !== "") {
|
|
88
|
+
return makeContractParameters({
|
|
89
|
+
abi: callerAndCommenterABI,
|
|
90
|
+
address:
|
|
91
|
+
callerAndCommenterAddress[
|
|
92
|
+
chainId as keyof typeof callerAndCommenterAddress
|
|
93
|
+
],
|
|
94
|
+
functionName: "timedSaleMintAndComment",
|
|
95
|
+
account: minterAccount,
|
|
96
|
+
value:
|
|
97
|
+
salesConfigAndTokenInfo.salesConfig.mintFeePerQuantity * mintQuantity,
|
|
98
|
+
args: [
|
|
99
|
+
mintTo,
|
|
100
|
+
mintQuantity,
|
|
101
|
+
tokenContract,
|
|
102
|
+
tokenId,
|
|
103
|
+
mintReferral || zeroAddress,
|
|
104
|
+
mintComment,
|
|
105
|
+
],
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return makeContractParameters({
|
|
110
|
+
abi: zoraTimedSaleStrategyABI,
|
|
111
|
+
functionName: "mint",
|
|
112
|
+
account: minterAccount,
|
|
113
|
+
address: salesConfigAndTokenInfo.salesConfig.address,
|
|
114
|
+
value:
|
|
115
|
+
salesConfigAndTokenInfo.salesConfig.mintFeePerQuantity * mintQuantity,
|
|
116
|
+
/* args: mintTo, quantity, collection, tokenId, mintReferral, comment */
|
|
117
|
+
args: [
|
|
118
|
+
mintTo,
|
|
119
|
+
mintQuantity,
|
|
120
|
+
tokenContract,
|
|
121
|
+
BigInt(tokenId),
|
|
122
|
+
mintReferral || zeroAddress,
|
|
123
|
+
"",
|
|
124
|
+
],
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
60
128
|
export function makePrepareMint1155TokenParams({
|
|
61
129
|
tokenContract: tokenContract,
|
|
62
130
|
tokenId,
|
|
@@ -67,9 +135,11 @@ export function makePrepareMint1155TokenParams({
|
|
|
67
135
|
mintRecipient,
|
|
68
136
|
quantityToMint,
|
|
69
137
|
allowListEntry,
|
|
138
|
+
chainId,
|
|
70
139
|
}: {
|
|
71
140
|
salesConfigAndTokenInfo: Concrete<MintableParameters>;
|
|
72
141
|
tokenId: GenericTokenIdTypes;
|
|
142
|
+
chainId: number;
|
|
73
143
|
} & Pick<
|
|
74
144
|
MakeMintParametersArgumentsBase,
|
|
75
145
|
| "minterAccount"
|
|
@@ -101,22 +171,16 @@ export function makePrepareMint1155TokenParams({
|
|
|
101
171
|
}
|
|
102
172
|
|
|
103
173
|
if (saleType === "timed") {
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
mintQuantity,
|
|
115
|
-
tokenContract,
|
|
116
|
-
BigInt(tokenId),
|
|
117
|
-
mintReferral || zeroAddress,
|
|
118
|
-
mintComment || "",
|
|
119
|
-
],
|
|
174
|
+
return makeZoraTimedSaleStrategyMintCall({
|
|
175
|
+
minterAccount,
|
|
176
|
+
salesConfigAndTokenInfo,
|
|
177
|
+
mintQuantity,
|
|
178
|
+
mintTo,
|
|
179
|
+
tokenContract,
|
|
180
|
+
tokenId,
|
|
181
|
+
mintReferral,
|
|
182
|
+
mintComment,
|
|
183
|
+
chainId,
|
|
120
184
|
});
|
|
121
185
|
}
|
|
122
186
|
|
package/src/sdk.ts
CHANGED
|
@@ -116,6 +116,7 @@ export function createCollectorClient(
|
|
|
116
116
|
publicClient: params.publicClient,
|
|
117
117
|
premintGetter: premintGetterToUse,
|
|
118
118
|
mintGetter: mintGetterToUse,
|
|
119
|
+
chainId: params.chainId,
|
|
119
120
|
});
|
|
120
121
|
const secondaryClient = new SecondaryClient({
|
|
121
122
|
publicClient: params.publicClient,
|