@zoralabs/protocol-sdk 0.11.3-COMMENTS.0 → 0.11.3-COMMENTS.3
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 +22 -0
- package/dist/anvil.d.ts.map +1 -1
- package/dist/create/minter-defaults.d.ts +1 -1
- package/dist/create/minter-defaults.d.ts.map +1 -1
- package/dist/create/types.d.ts +1 -1
- package/dist/create/types.d.ts.map +1 -1
- package/dist/fixtures/contract-setup.d.ts +2 -0
- package/dist/fixtures/contract-setup.d.ts.map +1 -1
- package/dist/fixtures/secondary.d.ts +13 -0
- package/dist/fixtures/secondary.d.ts.map +1 -0
- package/dist/index.cjs +60 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/preminter.d.ts +2 -2
- package/dist/preminter.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 +3 -3
- package/src/comments/comments.test.ts +343 -0
- package/src/create/1155-create-helper.test.ts +9 -14
- package/src/create/1155-create-helper.ts +2 -2
- package/src/create/minter-defaults.ts +3 -4
- package/src/create/types.ts +1 -1
- package/src/fixtures/contract-setup.ts +4 -4
- package/src/fixtures/secondary.ts +69 -0
- package/src/mint/subgraph-mint-getter.ts +1 -1
- package/src/rewards/rewards-client.test.ts +2 -2
- package/src/secondary/secondary-client.test.ts +39 -70
- package/src/test-utils.ts +12 -0
- package/dist/create/1155-create-helper.test.d.ts +0 -3
- package/dist/create/1155-create-helper.test.d.ts.map +0 -1
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { describe, expect, vi } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
Address,
|
|
4
|
-
parseEther,
|
|
5
|
-
PublicClient,
|
|
6
|
-
TestClient,
|
|
7
|
-
WalletClient,
|
|
8
|
-
Account,
|
|
9
|
-
} from "viem";
|
|
2
|
+
import { parseEther } from "viem";
|
|
10
3
|
import { zoraSepolia } from "viem/chains";
|
|
11
4
|
import {
|
|
12
5
|
forkUrls,
|
|
@@ -14,69 +7,13 @@ import {
|
|
|
14
7
|
simulateAndWriteContractWithRetries,
|
|
15
8
|
} from "src/anvil";
|
|
16
9
|
import { createCollectorClient } from "src/sdk";
|
|
17
|
-
import {
|
|
18
|
-
zoraCreator1155ImplABI,
|
|
19
|
-
zoraTimedSaleStrategyABI,
|
|
20
|
-
zoraTimedSaleStrategyAddress,
|
|
21
|
-
} from "@zoralabs/protocol-deployments";
|
|
22
|
-
import { makeContractParameters } from "src/utils";
|
|
10
|
+
import { zoraCreator1155ImplABI } from "@zoralabs/protocol-deployments";
|
|
23
11
|
import { setupContractAndToken } from "src/fixtures/contract-setup";
|
|
24
|
-
import { CollectorClient } from "src/sdk";
|
|
25
12
|
import { ERROR_SECONDARY_NOT_STARTED } from "./secondary-client";
|
|
26
13
|
import { ISubgraphQuerier } from "src/apis/subgraph-querier";
|
|
27
14
|
import { mockTimedSaleStrategyTokenQueryResult } from "src/fixtures/mint-query-results";
|
|
28
15
|
import { new1155ContractVersion } from "src/create/contract-setup";
|
|
29
|
-
|
|
30
|
-
export async function advanceToSaleAndAndLaunchMarket({
|
|
31
|
-
contractAddress,
|
|
32
|
-
tokenId,
|
|
33
|
-
testClient,
|
|
34
|
-
publicClient,
|
|
35
|
-
walletClient,
|
|
36
|
-
collectorClient,
|
|
37
|
-
chainId,
|
|
38
|
-
account,
|
|
39
|
-
}: {
|
|
40
|
-
contractAddress: Address;
|
|
41
|
-
tokenId: bigint;
|
|
42
|
-
testClient: TestClient;
|
|
43
|
-
publicClient: PublicClient;
|
|
44
|
-
walletClient: WalletClient;
|
|
45
|
-
collectorClient: CollectorClient;
|
|
46
|
-
chainId: number;
|
|
47
|
-
account: Address | Account;
|
|
48
|
-
}) {
|
|
49
|
-
const saleEnd = (await collectorClient.getSecondaryInfo({
|
|
50
|
-
contract: contractAddress,
|
|
51
|
-
tokenId,
|
|
52
|
-
}))!.saleEnd!;
|
|
53
|
-
|
|
54
|
-
// advance to end of sale
|
|
55
|
-
await testClient.setNextBlockTimestamp({
|
|
56
|
-
timestamp: saleEnd,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
await testClient.mine({
|
|
60
|
-
blocks: 1,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
// advance to end of sale
|
|
64
|
-
// launch the market
|
|
65
|
-
await simulateAndWriteContractWithRetries({
|
|
66
|
-
parameters: makeContractParameters({
|
|
67
|
-
abi: zoraTimedSaleStrategyABI,
|
|
68
|
-
functionName: "launchMarket",
|
|
69
|
-
args: [contractAddress, tokenId],
|
|
70
|
-
address:
|
|
71
|
-
zoraTimedSaleStrategyAddress[
|
|
72
|
-
chainId as keyof typeof zoraTimedSaleStrategyAddress
|
|
73
|
-
],
|
|
74
|
-
account: account,
|
|
75
|
-
}),
|
|
76
|
-
publicClient,
|
|
77
|
-
walletClient,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
16
|
+
import { advanceToSaleAndAndLaunchMarket } from "src/fixtures/secondary";
|
|
80
17
|
|
|
81
18
|
describe("secondary", () => {
|
|
82
19
|
makeAnvilTest({
|
|
@@ -152,8 +89,6 @@ describe("secondary", () => {
|
|
|
152
89
|
value: parseEther("100"),
|
|
153
90
|
});
|
|
154
91
|
|
|
155
|
-
const quantityToMint = 100_000n;
|
|
156
|
-
|
|
157
92
|
mintGetter.subgraphQuerier.query = vi
|
|
158
93
|
.fn<ISubgraphQuerier["query"]>()
|
|
159
94
|
.mockResolvedValue({
|
|
@@ -174,10 +109,13 @@ describe("secondary", () => {
|
|
|
174
109
|
mintGetter,
|
|
175
110
|
});
|
|
176
111
|
|
|
112
|
+
// mint 1 less than expected minimum market.
|
|
113
|
+
// make sure that there is no sale end
|
|
177
114
|
const { parameters: collectParameters } = await collectorClient.mint({
|
|
178
115
|
minterAccount: collectorAccount,
|
|
179
116
|
mintType: "1155",
|
|
180
|
-
|
|
117
|
+
// mint 1 less than expected minimum market.
|
|
118
|
+
quantityToMint: 1111n - 1n,
|
|
181
119
|
tokenId: newTokenId,
|
|
182
120
|
tokenContract: contractAddress,
|
|
183
121
|
});
|
|
@@ -188,6 +126,37 @@ describe("secondary", () => {
|
|
|
188
126
|
publicClient,
|
|
189
127
|
});
|
|
190
128
|
|
|
129
|
+
// make sure that there is no sale end
|
|
130
|
+
let saleEnd = (await collectorClient.getSecondaryInfo({
|
|
131
|
+
contract: contractAddress,
|
|
132
|
+
tokenId: newTokenId,
|
|
133
|
+
}))!.saleEnd;
|
|
134
|
+
|
|
135
|
+
expect(saleEnd).toBeUndefined();
|
|
136
|
+
|
|
137
|
+
// mint 1 more - this should cause the countdown to start
|
|
138
|
+
const { parameters: collectMoreParameters } = await collectorClient.mint({
|
|
139
|
+
minterAccount: collectorAccount,
|
|
140
|
+
mintType: "1155",
|
|
141
|
+
quantityToMint: 1n,
|
|
142
|
+
tokenId: newTokenId,
|
|
143
|
+
tokenContract: contractAddress,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
await simulateAndWriteContractWithRetries({
|
|
147
|
+
parameters: collectMoreParameters,
|
|
148
|
+
walletClient,
|
|
149
|
+
publicClient,
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// now there should be a sale end
|
|
153
|
+
saleEnd = (await collectorClient.getSecondaryInfo({
|
|
154
|
+
contract: contractAddress,
|
|
155
|
+
tokenId: newTokenId,
|
|
156
|
+
}))!.saleEnd;
|
|
157
|
+
|
|
158
|
+
expect(saleEnd).toBeDefined();
|
|
159
|
+
|
|
191
160
|
await advanceToSaleAndAndLaunchMarket({
|
|
192
161
|
contractAddress,
|
|
193
162
|
tokenId: newTokenId,
|
|
@@ -276,7 +245,7 @@ describe("secondary", () => {
|
|
|
276
245
|
args: [collectorAccount, newTokenId],
|
|
277
246
|
});
|
|
278
247
|
|
|
279
|
-
expect(balance).toBe(
|
|
248
|
+
expect(balance).toBe(1111n + quantityToBuy - quantityToSell);
|
|
280
249
|
},
|
|
281
250
|
30_000,
|
|
282
251
|
);
|
package/src/test-utils.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
encodeAbiParameters,
|
|
10
10
|
parseAbiParameters,
|
|
11
11
|
} from "viem";
|
|
12
|
+
import { NewContractParams } from "./create/types";
|
|
12
13
|
import { expect } from "vitest";
|
|
13
14
|
|
|
14
15
|
export const waitForSuccess = async (hash: Hex, publicClient: PublicClient) => {
|
|
@@ -17,6 +18,8 @@ export const waitForSuccess = async (hash: Hex, publicClient: PublicClient) => {
|
|
|
17
18
|
});
|
|
18
19
|
|
|
19
20
|
expect(receipt.status).toBe("success");
|
|
21
|
+
|
|
22
|
+
return receipt;
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
export const getFixedPricedMinter = async ({
|
|
@@ -37,3 +40,12 @@ export const fixedPriceMinterMinterArguments = ({
|
|
|
37
40
|
}: {
|
|
38
41
|
mintRecipient: Address;
|
|
39
42
|
}) => 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
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"1155-create-helper.test.d.ts","sourceRoot":"","sources":["../../src/create/1155-create-helper.test.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,oBAAoB,uEACqC,CAAC;AACvE,eAAO,MAAM,uBAAuB,+BAA+B,CAAC"}
|