@zoralabs/protocol-sdk 0.11.6-COMMENTS.0 → 0.11.7-BUGFIX.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/.env +1 -0
- package/.turbo/turbo-build.log +18 -18
- package/CHANGELOG.md +10 -8
- package/dist/create/mint-from-create.d.ts +1 -2
- package/dist/create/mint-from-create.d.ts.map +1 -1
- package/dist/index.cjs +42 -196
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -202
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-client.d.ts +1 -3
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/mint-queries.d.ts +3 -5
- package/dist/mint/mint-queries.d.ts.map +1 -1
- package/dist/mint/mint-transactions.d.ts +2 -4
- package/dist/mint/mint-transactions.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +8 -0
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/secondary/secondary-client.d.ts +1 -2
- package/dist/secondary/secondary-client.d.ts.map +1 -1
- package/dist/secondary/types.d.ts +0 -1
- package/dist/secondary/types.d.ts.map +1 -1
- package/dist/test-utils.d.ts +1 -3
- package/dist/test-utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/create/1155-create-helper.test.ts +12 -2
- package/src/create/1155-create-helper.ts +0 -2
- package/src/create/mint-from-create.ts +0 -3
- package/src/mint/mint-client.test.ts +30 -67
- package/src/mint/mint-client.ts +1 -10
- package/src/mint/mint-queries.ts +5 -16
- package/src/mint/mint-transactions.ts +16 -80
- package/src/rewards/subgraph-queries.ts +1 -1
- package/src/sdk.ts +0 -1
- package/src/secondary/secondary-client.test.ts +2 -118
- package/src/secondary/secondary-client.ts +6 -136
- package/src/secondary/types.ts +0 -2
- package/src/sparks/sparks-sponsored-sparks-spender.test.ts +1 -1
- package/src/test-utils.ts +0 -12
- package/yarn-error.log +8602 -0
- package/src/comments/comments.test.ts +0 -342
|
@@ -11,8 +11,6 @@ import {
|
|
|
11
11
|
erc20MinterABI,
|
|
12
12
|
zoraCreator1155ImplABI,
|
|
13
13
|
zoraTimedSaleStrategyABI,
|
|
14
|
-
callerAndCommenterABI,
|
|
15
|
-
callerAndCommenterAddress,
|
|
16
14
|
} from "@zoralabs/protocol-deployments";
|
|
17
15
|
import { zora721Abi, zora1155LegacyAbi } from "src/constants";
|
|
18
16
|
import {
|
|
@@ -34,11 +32,9 @@ import { AllowListEntry } from "src/allow-list/types";
|
|
|
34
32
|
export function makeOnchainMintCall({
|
|
35
33
|
token,
|
|
36
34
|
mintParams,
|
|
37
|
-
chainId,
|
|
38
35
|
}: {
|
|
39
36
|
token: Concrete<OnchainSalesConfigAndTokenInfo>;
|
|
40
37
|
mintParams: Omit<MakeMintParametersArgumentsBase, "tokenContract">;
|
|
41
|
-
chainId: number;
|
|
42
38
|
}): SimulateContractParametersWithAccount {
|
|
43
39
|
if (token.mintType === "721") {
|
|
44
40
|
return makePrepareMint721TokenParams({
|
|
@@ -52,7 +48,6 @@ export function makeOnchainMintCall({
|
|
|
52
48
|
salesConfigAndTokenInfo: token,
|
|
53
49
|
tokenContract: token.contract.address,
|
|
54
50
|
tokenId: token.tokenId!,
|
|
55
|
-
chainId,
|
|
56
51
|
...mintParams,
|
|
57
52
|
});
|
|
58
53
|
}
|
|
@@ -62,69 +57,6 @@ export type MintableParameters = Pick<
|
|
|
62
57
|
"contractVersion" | "salesConfig"
|
|
63
58
|
>;
|
|
64
59
|
|
|
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
|
-
|
|
128
60
|
export function makePrepareMint1155TokenParams({
|
|
129
61
|
tokenContract: tokenContract,
|
|
130
62
|
tokenId,
|
|
@@ -135,11 +67,9 @@ export function makePrepareMint1155TokenParams({
|
|
|
135
67
|
mintRecipient,
|
|
136
68
|
quantityToMint,
|
|
137
69
|
allowListEntry,
|
|
138
|
-
chainId,
|
|
139
70
|
}: {
|
|
140
71
|
salesConfigAndTokenInfo: Concrete<MintableParameters>;
|
|
141
72
|
tokenId: GenericTokenIdTypes;
|
|
142
|
-
chainId: number;
|
|
143
73
|
} & Pick<
|
|
144
74
|
MakeMintParametersArgumentsBase,
|
|
145
75
|
| "minterAccount"
|
|
@@ -171,16 +101,22 @@ export function makePrepareMint1155TokenParams({
|
|
|
171
101
|
}
|
|
172
102
|
|
|
173
103
|
if (saleType === "timed") {
|
|
174
|
-
return
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
mintReferral,
|
|
182
|
-
|
|
183
|
-
|
|
104
|
+
return makeContractParameters({
|
|
105
|
+
abi: zoraTimedSaleStrategyABI,
|
|
106
|
+
functionName: "mint",
|
|
107
|
+
account: minterAccount,
|
|
108
|
+
address: salesConfigAndTokenInfo.salesConfig.address,
|
|
109
|
+
value:
|
|
110
|
+
salesConfigAndTokenInfo.salesConfig.mintFeePerQuantity * mintQuantity,
|
|
111
|
+
/* args: mintTo, quantity, collection, tokenId, mintReferral, comment */
|
|
112
|
+
args: [
|
|
113
|
+
mintTo,
|
|
114
|
+
mintQuantity,
|
|
115
|
+
tokenContract,
|
|
116
|
+
BigInt(tokenId),
|
|
117
|
+
mintReferral || zeroAddress,
|
|
118
|
+
mintComment || "",
|
|
119
|
+
],
|
|
184
120
|
});
|
|
185
121
|
}
|
|
186
122
|
|
|
@@ -26,7 +26,7 @@ export function buildCreatorERC20zs({
|
|
|
26
26
|
query: `
|
|
27
27
|
query ($address: Bytes!) {
|
|
28
28
|
zoraCreateTokens(
|
|
29
|
-
where: { royalties_: {
|
|
29
|
+
where: { royalties_: { royaltyRecipient: $address }, salesStrategies_: { type: "ZORA_TIMED" } }
|
|
30
30
|
) {
|
|
31
31
|
royalties {
|
|
32
32
|
user
|
package/src/sdk.ts
CHANGED
|
@@ -116,7 +116,6 @@ export function createCollectorClient(
|
|
|
116
116
|
publicClient: params.publicClient,
|
|
117
117
|
premintGetter: premintGetterToUse,
|
|
118
118
|
mintGetter: mintGetterToUse,
|
|
119
|
-
chainId: params.chainId,
|
|
120
119
|
});
|
|
121
120
|
const secondaryClient = new SecondaryClient({
|
|
122
121
|
publicClient: params.publicClient,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, vi } from "vitest";
|
|
2
|
-
import { parseEther, Address
|
|
2
|
+
import { parseEther, Address } from "viem";
|
|
3
3
|
import { zoraSepolia } from "viem/chains";
|
|
4
4
|
import {
|
|
5
5
|
forkUrls,
|
|
@@ -7,11 +7,7 @@ import {
|
|
|
7
7
|
simulateAndWriteContractWithRetries,
|
|
8
8
|
} from "src/anvil";
|
|
9
9
|
import { createCollectorClient } from "src/sdk";
|
|
10
|
-
import {
|
|
11
|
-
zoraCreator1155ImplABI,
|
|
12
|
-
commentsABI,
|
|
13
|
-
callerAndCommenterABI,
|
|
14
|
-
} from "@zoralabs/protocol-deployments";
|
|
10
|
+
import { zoraCreator1155ImplABI } from "@zoralabs/protocol-deployments";
|
|
15
11
|
import { SubgraphMintGetter } from "src/mint/subgraph-mint-getter";
|
|
16
12
|
import { ERROR_SECONDARY_NOT_STARTED } from "./secondary-client";
|
|
17
13
|
import { ISubgraphQuerier } from "src/apis/subgraph-querier";
|
|
@@ -261,116 +257,4 @@ describe("secondary", () => {
|
|
|
261
257
|
},
|
|
262
258
|
30_000,
|
|
263
259
|
);
|
|
264
|
-
|
|
265
|
-
makeAnvilTest({
|
|
266
|
-
forkBlockNumber: 16123365,
|
|
267
|
-
forkUrl: forkUrls.zoraSepolia,
|
|
268
|
-
anvilChainId: zoraSepolia.id,
|
|
269
|
-
})(
|
|
270
|
-
"it can buy on secondary with a comment",
|
|
271
|
-
async ({
|
|
272
|
-
viemClients: { publicClient, chain, walletClient, testClient },
|
|
273
|
-
}) => {
|
|
274
|
-
const collectorAccount = (await walletClient.getAddresses()!)[1]!;
|
|
275
|
-
|
|
276
|
-
const mintGetter = new SubgraphMintGetter(chain.id);
|
|
277
|
-
const contractAddress: Address =
|
|
278
|
-
"0xd42557f24034b53e7340a40bb5813ef9ba88f2b4";
|
|
279
|
-
const newTokenId = 4n;
|
|
280
|
-
|
|
281
|
-
await testClient.setBalance({
|
|
282
|
-
address: collectorAccount,
|
|
283
|
-
value: parseEther("100"),
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
mintGetter.subgraphQuerier.query = vi
|
|
287
|
-
.fn<ISubgraphQuerier["query"]>()
|
|
288
|
-
.mockResolvedValue({
|
|
289
|
-
zoraCreateToken: mockTimedSaleStrategyTokenQueryResult({
|
|
290
|
-
chainId: chain.id,
|
|
291
|
-
tokenId: newTokenId,
|
|
292
|
-
contractAddress,
|
|
293
|
-
contractVersion:
|
|
294
|
-
new1155ContractVersion[
|
|
295
|
-
chain.id as keyof typeof new1155ContractVersion
|
|
296
|
-
],
|
|
297
|
-
}),
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
const collectorClient = createCollectorClient({
|
|
301
|
-
chainId: chain.id,
|
|
302
|
-
publicClient,
|
|
303
|
-
mintGetter,
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
const secondaryInfo = await collectorClient.getSecondaryInfo({
|
|
307
|
-
contract: contractAddress,
|
|
308
|
-
tokenId: newTokenId,
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
// mint enough to start the countdown
|
|
312
|
-
const quantityToMint =
|
|
313
|
-
secondaryInfo!.minimumMintsForCountdown! - secondaryInfo!.mintCount;
|
|
314
|
-
|
|
315
|
-
const { parameters: collectParameters } = await collectorClient.mint({
|
|
316
|
-
minterAccount: collectorAccount,
|
|
317
|
-
mintType: "1155",
|
|
318
|
-
quantityToMint: quantityToMint,
|
|
319
|
-
tokenId: newTokenId,
|
|
320
|
-
tokenContract: contractAddress,
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
await simulateAndWriteContractWithRetries({
|
|
324
|
-
parameters: collectParameters,
|
|
325
|
-
walletClient,
|
|
326
|
-
publicClient,
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
await advanceToSaleAndAndLaunchMarket({
|
|
330
|
-
contractAddress,
|
|
331
|
-
tokenId: newTokenId,
|
|
332
|
-
testClient,
|
|
333
|
-
publicClient,
|
|
334
|
-
walletClient,
|
|
335
|
-
collectorClient,
|
|
336
|
-
chainId: chain.id,
|
|
337
|
-
account: collectorAccount,
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
const buyResult = await collectorClient.buy1155OnSecondary({
|
|
341
|
-
account: collectorAccount,
|
|
342
|
-
quantity: 5n,
|
|
343
|
-
contract: contractAddress,
|
|
344
|
-
tokenId: newTokenId,
|
|
345
|
-
comment: "test comment",
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
const receipt = await simulateAndWriteContractWithRetries({
|
|
349
|
-
parameters: buyResult.parameters!,
|
|
350
|
-
walletClient,
|
|
351
|
-
publicClient,
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
const commentedEvent = parseEventLogs({
|
|
355
|
-
abi: commentsABI,
|
|
356
|
-
logs: receipt.logs,
|
|
357
|
-
eventName: "Commented",
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
expect(commentedEvent[0]).toBeDefined();
|
|
361
|
-
expect(commentedEvent[0]!.args.text).toBe("test comment");
|
|
362
|
-
|
|
363
|
-
const boughtAndCommentedEvent = parseEventLogs({
|
|
364
|
-
abi: callerAndCommenterABI,
|
|
365
|
-
logs: receipt.logs,
|
|
366
|
-
eventName: "SwappedOnSecondaryAndCommented",
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
expect(boughtAndCommentedEvent[0]).toBeDefined();
|
|
370
|
-
expect(boughtAndCommentedEvent[0]!.args.comment).toBe("test comment");
|
|
371
|
-
expect(boughtAndCommentedEvent[0]!.args.quantity).toBe(5n);
|
|
372
|
-
expect(boughtAndCommentedEvent[0]!.args.swapDirection).toBe(0);
|
|
373
|
-
},
|
|
374
|
-
20_000,
|
|
375
|
-
);
|
|
376
260
|
});
|
|
@@ -4,8 +4,6 @@ import {
|
|
|
4
4
|
zoraCreator1155ImplABI,
|
|
5
5
|
safeTransferSwapAbiParameters,
|
|
6
6
|
secondarySwapABI,
|
|
7
|
-
callerAndCommenterABI,
|
|
8
|
-
callerAndCommenterAddress,
|
|
9
7
|
} from "@zoralabs/protocol-deployments";
|
|
10
8
|
import { makeContractParameters, PublicClient } from "src/utils";
|
|
11
9
|
import { getUniswapQuote } from "./uniswap/uniswapQuote";
|
|
@@ -29,8 +27,6 @@ const ERROR_INSUFFICIENT_POOL_SUPPLY = "Insufficient pool supply";
|
|
|
29
27
|
const ERROR_SECONDARY_NOT_CONFIGURED =
|
|
30
28
|
"Secondary not configured for given contract and token";
|
|
31
29
|
export const ERROR_SECONDARY_NOT_STARTED = "Secondary market has not started";
|
|
32
|
-
export const ERROR_RECIPIENT_MISMATCH =
|
|
33
|
-
"Recipient must be the same as the caller if there is a comment";
|
|
34
30
|
|
|
35
31
|
// Helper function to create error objects
|
|
36
32
|
function makeError(errorMessage: string) {
|
|
@@ -50,8 +46,6 @@ type Call =
|
|
|
50
46
|
};
|
|
51
47
|
|
|
52
48
|
async function makeBuy({
|
|
53
|
-
contract,
|
|
54
|
-
tokenId,
|
|
55
49
|
erc20z,
|
|
56
50
|
poolBalance,
|
|
57
51
|
amount,
|
|
@@ -61,11 +55,8 @@ async function makeBuy({
|
|
|
61
55
|
chainId,
|
|
62
56
|
slippage,
|
|
63
57
|
publicClient,
|
|
64
|
-
comment,
|
|
65
58
|
}: {
|
|
66
59
|
erc20z: Address;
|
|
67
|
-
contract: Address;
|
|
68
|
-
tokenId: bigint;
|
|
69
60
|
poolBalance: { erc20z: bigint };
|
|
70
61
|
amount: bigint;
|
|
71
62
|
quantity: bigint;
|
|
@@ -73,144 +64,27 @@ async function makeBuy({
|
|
|
73
64
|
recipient?: Address;
|
|
74
65
|
chainId: number;
|
|
75
66
|
slippage: number;
|
|
76
|
-
comment: string | undefined;
|
|
77
67
|
publicClient: PublicClient;
|
|
78
68
|
}): Promise<Call> {
|
|
79
69
|
const costWithSlippage = calculateSlippageUp(amount, slippage);
|
|
80
|
-
const accountAddress = addressOrAccountAddress(account);
|
|
81
|
-
|
|
82
|
-
const validationResult = await validateBuyConditions({
|
|
83
|
-
poolBalance,
|
|
84
|
-
quantity,
|
|
85
|
-
costWithSlippage,
|
|
86
|
-
accountAddress,
|
|
87
|
-
publicClient,
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
if (validationResult.error) {
|
|
91
|
-
return makeError(validationResult.error);
|
|
92
|
-
}
|
|
93
70
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
accountAddress,
|
|
97
|
-
recipient,
|
|
98
|
-
chainId,
|
|
99
|
-
quantity,
|
|
100
|
-
contract,
|
|
101
|
-
tokenId,
|
|
102
|
-
costWithSlippage,
|
|
103
|
-
comment,
|
|
104
|
-
account,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
71
|
+
// we cannot buy all the available tokens in a pool (the quote fails if we try doing that)
|
|
72
|
+
const availableToBuy = poolBalance.erc20z / BigInt(1e18) - 1n;
|
|
107
73
|
|
|
108
|
-
|
|
109
|
-
erc20z,
|
|
110
|
-
quantity,
|
|
111
|
-
recipient,
|
|
112
|
-
accountAddress,
|
|
113
|
-
costWithSlippage,
|
|
114
|
-
chainId,
|
|
115
|
-
account,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
74
|
+
const accountAddress = addressOrAccountAddress(account);
|
|
118
75
|
|
|
119
|
-
async function validateBuyConditions({
|
|
120
|
-
poolBalance,
|
|
121
|
-
quantity,
|
|
122
|
-
costWithSlippage,
|
|
123
|
-
accountAddress,
|
|
124
|
-
publicClient,
|
|
125
|
-
}: {
|
|
126
|
-
poolBalance: { erc20z: bigint };
|
|
127
|
-
quantity: bigint;
|
|
128
|
-
costWithSlippage: bigint;
|
|
129
|
-
accountAddress: Address;
|
|
130
|
-
publicClient: PublicClient;
|
|
131
|
-
}): Promise<{ error?: string }> {
|
|
132
|
-
const availableToBuy = poolBalance.erc20z / BigInt(1e18) - 1n;
|
|
133
76
|
const availableToSpend = await publicClient.getBalance({
|
|
134
77
|
address: accountAddress,
|
|
135
78
|
});
|
|
136
79
|
|
|
137
80
|
if (costWithSlippage > availableToSpend) {
|
|
138
|
-
return
|
|
81
|
+
return makeError(ERROR_INSUFFICIENT_WALLET_FUNDS);
|
|
139
82
|
}
|
|
140
83
|
|
|
141
84
|
if (availableToBuy < BigInt(quantity)) {
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return {};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function handleBuyWithComment({
|
|
149
|
-
accountAddress,
|
|
150
|
-
recipient,
|
|
151
|
-
chainId,
|
|
152
|
-
quantity,
|
|
153
|
-
contract,
|
|
154
|
-
tokenId,
|
|
155
|
-
costWithSlippage,
|
|
156
|
-
comment,
|
|
157
|
-
account,
|
|
158
|
-
}: {
|
|
159
|
-
accountAddress: Address;
|
|
160
|
-
recipient?: Address;
|
|
161
|
-
chainId: number;
|
|
162
|
-
quantity: bigint;
|
|
163
|
-
contract: Address;
|
|
164
|
-
tokenId: bigint;
|
|
165
|
-
costWithSlippage: bigint;
|
|
166
|
-
comment: string;
|
|
167
|
-
account: Address | Account;
|
|
168
|
-
}): Call {
|
|
169
|
-
if (recipient && recipient !== accountAddress) {
|
|
170
|
-
return makeError(ERROR_RECIPIENT_MISMATCH);
|
|
85
|
+
return makeError(ERROR_INSUFFICIENT_POOL_SUPPLY);
|
|
171
86
|
}
|
|
172
87
|
|
|
173
|
-
return {
|
|
174
|
-
parameters: makeContractParameters({
|
|
175
|
-
abi: callerAndCommenterABI,
|
|
176
|
-
address:
|
|
177
|
-
callerAndCommenterAddress[
|
|
178
|
-
chainId as keyof typeof callerAndCommenterAddress
|
|
179
|
-
],
|
|
180
|
-
functionName: "buyOnSecondaryAndComment",
|
|
181
|
-
args: [
|
|
182
|
-
accountAddress,
|
|
183
|
-
quantity,
|
|
184
|
-
contract,
|
|
185
|
-
tokenId,
|
|
186
|
-
accountAddress,
|
|
187
|
-
costWithSlippage,
|
|
188
|
-
0n,
|
|
189
|
-
comment,
|
|
190
|
-
],
|
|
191
|
-
account,
|
|
192
|
-
value: costWithSlippage,
|
|
193
|
-
}),
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function handleBuyWithoutComment({
|
|
198
|
-
erc20z,
|
|
199
|
-
quantity,
|
|
200
|
-
recipient,
|
|
201
|
-
accountAddress,
|
|
202
|
-
costWithSlippage,
|
|
203
|
-
chainId,
|
|
204
|
-
account,
|
|
205
|
-
}: {
|
|
206
|
-
erc20z: Address;
|
|
207
|
-
quantity: bigint;
|
|
208
|
-
recipient?: Address;
|
|
209
|
-
accountAddress: Address;
|
|
210
|
-
costWithSlippage: bigint;
|
|
211
|
-
chainId: number;
|
|
212
|
-
account: Address | Account;
|
|
213
|
-
}): Call {
|
|
214
88
|
return {
|
|
215
89
|
parameters: makeContractParameters({
|
|
216
90
|
abi: secondarySwapABI,
|
|
@@ -225,7 +99,7 @@ function handleBuyWithoutComment({
|
|
|
225
99
|
costWithSlippage,
|
|
226
100
|
0n,
|
|
227
101
|
],
|
|
228
|
-
account,
|
|
102
|
+
account: account,
|
|
229
103
|
value: costWithSlippage,
|
|
230
104
|
}),
|
|
231
105
|
};
|
|
@@ -251,7 +125,6 @@ export async function buyWithSlippage({
|
|
|
251
125
|
account,
|
|
252
126
|
slippage = UNISWAP_SLIPPAGE,
|
|
253
127
|
recipient,
|
|
254
|
-
comment,
|
|
255
128
|
}: BuyWithSlippageInput & {
|
|
256
129
|
chainId: number;
|
|
257
130
|
publicClient: PublicClient;
|
|
@@ -286,8 +159,6 @@ export async function buyWithSlippage({
|
|
|
286
159
|
|
|
287
160
|
const call = await makeBuy({
|
|
288
161
|
erc20z,
|
|
289
|
-
contract,
|
|
290
|
-
tokenId,
|
|
291
162
|
poolBalance,
|
|
292
163
|
amount,
|
|
293
164
|
quantity,
|
|
@@ -295,7 +166,6 @@ export async function buyWithSlippage({
|
|
|
295
166
|
recipient,
|
|
296
167
|
chainId,
|
|
297
168
|
slippage,
|
|
298
|
-
comment,
|
|
299
169
|
publicClient,
|
|
300
170
|
});
|
|
301
171
|
|
package/src/secondary/types.ts
CHANGED
|
@@ -47,8 +47,6 @@ export type BuyWithSlippageInput = {
|
|
|
47
47
|
slippage?: number;
|
|
48
48
|
// Optional recipient address (if different from buyer/seller)
|
|
49
49
|
recipient?: Address;
|
|
50
|
-
// Optional comment to add to the swap
|
|
51
|
-
comment?: string;
|
|
52
50
|
};
|
|
53
51
|
|
|
54
52
|
// Same structure as BuyWithSlippageInput
|
|
@@ -19,7 +19,7 @@ import { zoraSparksManagerImplABI } from "@zoralabs/protocol-deployments";
|
|
|
19
19
|
const anvilTest = makeAnvilTest({
|
|
20
20
|
forkUrl: forkUrls.zoraMainnet,
|
|
21
21
|
anvilChainId: zora.id,
|
|
22
|
-
forkBlockNumber:
|
|
22
|
+
forkBlockNumber: 22160611,
|
|
23
23
|
});
|
|
24
24
|
describe("Sponsored Mints Spender with Relay", () => {
|
|
25
25
|
anvilTest(
|
package/src/test-utils.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
encodeAbiParameters,
|
|
10
10
|
parseAbiParameters,
|
|
11
11
|
} from "viem";
|
|
12
|
-
import { NewContractParams } from "./create/types";
|
|
13
12
|
import { expect } from "vitest";
|
|
14
13
|
|
|
15
14
|
export const waitForSuccess = async (hash: Hex, publicClient: PublicClient) => {
|
|
@@ -18,8 +17,6 @@ export const waitForSuccess = async (hash: Hex, publicClient: PublicClient) => {
|
|
|
18
17
|
});
|
|
19
18
|
|
|
20
19
|
expect(receipt.status).toBe("success");
|
|
21
|
-
|
|
22
|
-
return receipt;
|
|
23
20
|
};
|
|
24
21
|
|
|
25
22
|
export const getFixedPricedMinter = async ({
|
|
@@ -40,12 +37,3 @@ export const fixedPriceMinterMinterArguments = ({
|
|
|
40
37
|
}: {
|
|
41
38
|
mintRecipient: Address;
|
|
42
39
|
}) => encodeAbiParameters(parseAbiParameters("address"), [mintRecipient]);
|
|
43
|
-
|
|
44
|
-
const demoContractMetadataURI = "ipfs://DUMMY/contract.json";
|
|
45
|
-
|
|
46
|
-
export function randomNewContract(): NewContractParams {
|
|
47
|
-
return {
|
|
48
|
-
name: `testContract-${Math.round(Math.random() * 1_000_000)}`,
|
|
49
|
-
uri: demoContractMetadataURI,
|
|
50
|
-
};
|
|
51
|
-
}
|