@zoralabs/protocol-sdk 0.11.3-COMMENTS.0 → 0.11.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.
@@ -27,8 +27,8 @@ export declare const preminterTypedDataDefinition: ({ verifyingContract, premint
27
27
  domain?: {
28
28
  chainId?: number | undefined;
29
29
  name?: string | undefined;
30
- salt?: import("abitype").ResolvedRegister["bytesType"]["outputs"] | undefined;
31
- verifyingContract?: Address | undefined;
30
+ salt?: import("viem").ResolvedRegister["bytesType"]["outputs"] | undefined;
31
+ verifyingContract?: import("viem").Address | undefined;
32
32
  version?: string | undefined;
33
33
  } | undefined;
34
34
  message: Record<string, unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"preminter.d.ts","sourceRoot":"","sources":["../src/preminter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EACL,qCAAqC,IAAI,YAAY,EAEtD,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAGL,GAAG,EACH,YAAY,EACb,MAAM,MAAM,CAAC;AAEd,KAAK,aAAa,GAAG,kBAAkB,CACrC,OAAO,YAAY,EACnB,WAAW,CACZ,CAAC,QAAQ,CAAC,CAAC;AAEZ,KAAK,sBAAsB,GAAG,6BAA6B,CAAC,aAAa,CAAC,CAAC;AAE3E,MAAM,MAAM,sBAAsB,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC;AAC/D,MAAM,MAAM,aAAa,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC;AACtD,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC,aAAa,CAAC,CAAC;AAI/D,eAAO,MAAM,4BAA4B,mDAItC;IACD,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,MAAM,CAA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AAO,EAAE,MAAM,CAAC;CACjB;;;;;;;;;;;;;;;;eAsGgoE,4CAA8B;;;;;CAzD9pE,CAAC;AAEF,wBAAsB,kBAAkB,CAAC,EACvC,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,SAAS,EACT,OAAO,EACP,YAAY,GACb,EAAE;IACD,eAAe,EAAE,OAAO,CAAC;IACzB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,GAAG,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,YAAY,CAAC;CAC5B,GAAG,OAAO,CAAC;IACV,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC,CAqCD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zoralabs/protocol-sdk",
3
- "version": "0.11.3-COMMENTS.0",
3
+ "version": "0.11.3",
4
4
  "repository": "https://github.com/ourzora/zora-protocol",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,10 +17,10 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "abitype": "^1.0.2",
20
- "@zoralabs/protocol-deployments": "^0.3.5-COMMENTS.0"
20
+ "@zoralabs/protocol-deployments": "^0.3.5"
21
21
  },
22
22
  "peerDependencies": {
23
- "viem": "^2.13.2"
23
+ "viem": "^2.21.21"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@lavamoat/preinstall-always-fail": "2.0.0",
@@ -22,10 +22,10 @@ import {
22
22
  DEFAULT_MINIMUM_MARKET_ETH,
23
23
  DEFAULT_MARKET_COUNTDOWN,
24
24
  } from "./minter-defaults";
25
-
26
- export const demoTokenMetadataURI =
27
- "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u";
28
- export const demoContractMetadataURI = "ipfs://DUMMY/contract.json";
25
+ import {
26
+ demoContractMetadataURI,
27
+ demoTokenMetadataURI,
28
+ } from "src/fixtures/contract-setup";
29
29
 
30
30
  const anvilTest = makeAnvilTest({
31
31
  forkUrl: forkUrls.zoraMainnet,
@@ -101,7 +101,9 @@ describe("create-helper", () => {
101
101
  publicClient,
102
102
  });
103
103
  expect(receipt).not.toBeNull();
104
- expect(receipt.to).to.equal("0x777777c338d93e2c7adf08d102d45ca7cc4ed021");
104
+ expect(receipt.to?.toLowerCase()).to.equal(
105
+ "0x777777c338d93e2c7adf08d102d45ca7cc4ed021".toLowerCase(),
106
+ );
105
107
  expect(getTokenIdFromCreateReceipt(receipt)).to.be.equal(1n);
106
108
  expect(getContractAddressFromReceipt(receipt)).to.be.equal(
107
109
  contractAddress,
@@ -299,7 +301,10 @@ describe("create-helper", () => {
299
301
  walletClient,
300
302
  publicClient,
301
303
  });
302
- expect(receipt.to).to.equal("0x777777c338d93e2c7adf08d102d45ca7cc4ed021");
304
+
305
+ expect(receipt.to?.toLowerCase()).to.equal(
306
+ "0x777777c338d93e2c7adf08d102d45ca7cc4ed021".toLowerCase(),
307
+ );
303
308
  expect(getTokenIdFromCreateReceipt(receipt)).to.be.equal(newTokenId);
304
309
 
305
310
  expect(
@@ -219,7 +219,7 @@ async function createNew1155ContractAndToken({
219
219
  });
220
220
 
221
221
  const contractAddress = await getDeterministicContractAddress({
222
- account,
222
+ account: typeof account === "string" ? account : account.address,
223
223
  publicClient,
224
224
  setupActions: tokenSetupActions,
225
225
  chainId,
@@ -327,7 +327,7 @@ function prepareSetupActions({
327
327
  setupActions: tokenSetupActions,
328
328
  } = constructCreate1155TokenCalls({
329
329
  chainId: chainId,
330
- ownerAddress: account,
330
+ ownerAddress: typeof account === "string" ? account : account.address,
331
331
  contractVersion,
332
332
  nextTokenId,
333
333
  ...token,
@@ -9,10 +9,9 @@ import {
9
9
  ConcreteSalesConfig,
10
10
  TimedSaleParamsType,
11
11
  } from "./types";
12
-
13
- // 200 mints worth of eth
14
- export const DEFAULT_MINIMUM_MARKET_ETH = 2220000000000000n;
15
-
12
+ import { parseEther } from "viem";
13
+ // 1111 mints worth of market reward eth - 0.0000111 eth * 1,111 = 0.0123321 eth
14
+ export const DEFAULT_MINIMUM_MARKET_ETH = parseEther("0.0123321");
16
15
  // 24 hour countdown
17
16
  export const DEFAULT_MARKET_COUNTDOWN = BigInt(24 * 60 * 60);
18
17
 
@@ -63,7 +63,7 @@ export type SalesConfigParamsType =
63
63
  | TimedSaleParamsType;
64
64
 
65
65
  export type CreateNew1155ParamsBase = {
66
- account: Address;
66
+ account: Address | Account;
67
67
  getAdditionalSetupActions?: (args: { tokenId: bigint }) => Hex[];
68
68
  token: CreateNew1155TokenProps;
69
69
  };
@@ -1,13 +1,13 @@
1
1
  import { Address, Chain, PublicClient, WalletClient } from "viem";
2
2
  import { simulateAndWriteContractWithRetries } from "src/anvil";
3
3
  import { createCreatorClient } from "src/sdk";
4
- import {
5
- demoContractMetadataURI,
6
- demoTokenMetadataURI,
7
- } from "src/create/1155-create-helper.test";
8
4
  import { SubgraphMintGetter } from "src/mint/subgraph-mint-getter";
9
5
  import { SubgraphRewardsGetter } from "../rewards/subgraph-rewards-getter";
10
6
 
7
+ export const demoTokenMetadataURI =
8
+ "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u";
9
+ export const demoContractMetadataURI = "ipfs://DUMMY/contract.json";
10
+
11
11
  export async function setupContractAndToken({
12
12
  chain,
13
13
  publicClient,
@@ -0,0 +1,69 @@
1
+ import { Address, Account, PublicClient, TestClient, WalletClient } from "viem";
2
+ import { CollectorClient } from "../sdk";
3
+ import { simulateAndWriteContractWithRetries } from "../anvil";
4
+ import { makeContractParameters } from "../utils";
5
+ import {
6
+ zoraTimedSaleStrategyABI,
7
+ zoraTimedSaleStrategyAddress,
8
+ } from "@zoralabs/protocol-deployments";
9
+
10
+ export async function advanceToSaleAndAndLaunchMarket({
11
+ contractAddress,
12
+ tokenId,
13
+ testClient,
14
+ publicClient,
15
+ walletClient,
16
+ collectorClient,
17
+ chainId,
18
+ account,
19
+ }: {
20
+ contractAddress: Address;
21
+ tokenId: bigint;
22
+ testClient: TestClient;
23
+ publicClient: PublicClient;
24
+ walletClient: WalletClient;
25
+ collectorClient: CollectorClient;
26
+ chainId: number;
27
+ account: Address | Account;
28
+ }) {
29
+ const saleInfo = await collectorClient.getSecondaryInfo({
30
+ contract: contractAddress,
31
+ tokenId,
32
+ });
33
+
34
+ if (!saleInfo) {
35
+ throw new Error("Sale not set");
36
+ }
37
+
38
+ if (!saleInfo.saleEnd) {
39
+ throw new Error("Sale end not set");
40
+ }
41
+
42
+ const saleEnd = saleInfo.saleEnd;
43
+
44
+ // advance to end of sale
45
+ await testClient.setNextBlockTimestamp({
46
+ timestamp: saleEnd,
47
+ });
48
+
49
+ await testClient.mine({
50
+ blocks: 1,
51
+ });
52
+
53
+ // advance to end of sale
54
+ // launch the market
55
+ await simulateAndWriteContractWithRetries({
56
+ parameters: makeContractParameters({
57
+ abi: zoraTimedSaleStrategyABI,
58
+ functionName: "launchMarket",
59
+ args: [contractAddress, tokenId],
60
+ address:
61
+ zoraTimedSaleStrategyAddress[
62
+ chainId as keyof typeof zoraTimedSaleStrategyAddress
63
+ ],
64
+ account: account,
65
+ }),
66
+ publicClient,
67
+ walletClient,
68
+ });
69
+ }
@@ -180,7 +180,7 @@ function getTargetStrategy({
180
180
  );
181
181
 
182
182
  const stillValidSalesStrategies = parsedStrategies.filter(
183
- (strategy) => strategy.saleActive,
183
+ (strategy) => strategy.saleActive || strategy.secondaryMarketActive,
184
184
  );
185
185
 
186
186
  const saleStrategies = stillValidSalesStrategies.sort((a, b) =>
@@ -18,7 +18,7 @@ import {
18
18
  import { makeContractParameters } from "src/utils";
19
19
  import { mockRewardsQueryResults } from "src/fixtures/rewards-query-results";
20
20
  import { setupContractAndToken } from "src/fixtures/contract-setup";
21
- import { advanceToSaleAndAndLaunchMarket } from "src/secondary/secondary-client.test";
21
+ import { advanceToSaleAndAndLaunchMarket } from "src/fixtures/secondary";
22
22
 
23
23
  describe("rewardsClient", () => {
24
24
  makeAnvilTest({
@@ -146,7 +146,7 @@ describe("rewardsClient", () => {
146
146
  value: parseEther("100"),
147
147
  });
148
148
 
149
- const quantityToMint = 10_000n;
149
+ const quantityToMint = 1111n;
150
150
 
151
151
  mintGetter.subgraphQuerier.query = vi
152
152
  .fn<ISubgraphQuerier["query"]>()
@@ -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
- quantityToMint,
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(quantityToMint + quantityToBuy - quantityToSell);
248
+ expect(balance).toBe(1111n + quantityToBuy - quantityToSell);
280
249
  },
281
250
  30_000,
282
251
  );
@@ -1,3 +0,0 @@
1
- export declare const demoTokenMetadataURI = "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u";
2
- export declare const demoContractMetadataURI = "ipfs://DUMMY/contract.json";
3
- //# sourceMappingURL=1155-create-helper.test.d.ts.map
@@ -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"}