@zoralabs/protocol-sdk 0.5.8 → 0.5.10
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 +13 -0
- package/dist/create/1155-create-helper.d.ts +2 -1
- package/dist/create/1155-create-helper.d.ts.map +1 -1
- package/dist/index.cjs +11516 -1526
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11497 -1480
- package/dist/index.js.map +1 -1
- package/dist/mints/mints-queries.d.ts +0 -27
- package/dist/mints/mints-queries.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/create/1155-create-helper.test.ts +33 -0
- package/src/create/1155-create-helper.ts +3 -0
- package/src/mints/mints-contracts.test.ts +5 -0
- package/src/mints/mints-queries.ts +1 -65
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { Address } from "viem";
|
|
2
|
-
type CollectQueryResult = {
|
|
3
|
-
tokenIds: bigint[];
|
|
4
|
-
quantities: bigint[];
|
|
5
|
-
};
|
|
6
2
|
export declare const getMintsAccountBalanceWithPriceQuery: (account: Address) => {
|
|
7
3
|
query: string;
|
|
8
4
|
variables: {
|
|
@@ -33,27 +29,4 @@ export declare const selectMintsToCollectWithFromQueryResult: (mintAccountBalanc
|
|
|
33
29
|
* @returns Total balance
|
|
34
30
|
*/
|
|
35
31
|
export declare const sumBalances: (mintAccountBalances: Pick<MintAccountBalance, "balance">[]) => bigint;
|
|
36
|
-
/***
|
|
37
|
-
* Given an account and quantity of MINTs to use to collect with, queries for MINTs
|
|
38
|
-
* owned by an account, and selects the best MINTs to use to collect with that will satisfy that quantity.
|
|
39
|
-
* @param account Account to query for MINTs
|
|
40
|
-
* @param chainId
|
|
41
|
-
* @param quantityToCollect How many MINTs to use to collect with
|
|
42
|
-
* @returns
|
|
43
|
-
*/
|
|
44
|
-
export declare const getMINTsToCollectWith: ({ account, chainId, quantityToCollect, }: {
|
|
45
|
-
account: Address;
|
|
46
|
-
chainId: number;
|
|
47
|
-
quantityToCollect: bigint;
|
|
48
|
-
}) => Promise<CollectQueryResult>;
|
|
49
|
-
/***
|
|
50
|
-
* Given an account, queries for MINTs owned by an account, and sums the balances.
|
|
51
|
-
* @param account Account to query for MINTs
|
|
52
|
-
* @returns Total MINTs balance of account
|
|
53
|
-
*/
|
|
54
|
-
export declare const getMINTsBalance: ({ chainId, account, }: {
|
|
55
|
-
account: Address;
|
|
56
|
-
chainId: number;
|
|
57
|
-
}) => Promise<bigint>;
|
|
58
|
-
export {};
|
|
59
32
|
//# sourceMappingURL=mints-queries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mints-queries.d.ts","sourceRoot":"","sources":["../../src/mints/mints-queries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mints-queries.d.ts","sourceRoot":"","sources":["../../src/mints/mints-queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAG/B,eAAO,MAAM,oCAAoC,YAAa,OAAO;;;;;CAiBpE,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE;QACT,EAAE,EAAE,MAAM,CAAC;QACX,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,iBAAiB,EAAE,kBAAkB,EAAE,CAAC;CACzC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uCAAuC,wBAC7B,kBAAkB,EAAE,qBACtB,MAAM;;;CAyC1B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,wBACD,KAAK,kBAAkB,EAAE,SAAS,CAAC,EAAE,WAK3D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zoralabs/protocol-sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.10",
|
|
4
4
|
"repository": "https://github.com/ourzora/zora-protocol",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"abitype": "^0.10.3"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"viem": "^1.19.15"
|
|
33
|
-
"graphql-request": "^6.1.0"
|
|
32
|
+
"viem": "^1.19.15"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
35
|
"@lavamoat/preinstall-always-fail": "2.0.0",
|
|
37
36
|
"graphql-prettier": "^1.0.6",
|
|
37
|
+
"graphql-request": "^6.1.0",
|
|
38
38
|
"typescript": "^5.2.2",
|
|
39
39
|
"vite": "^4.5.0",
|
|
40
40
|
"vitest": "^0.34.6",
|
|
@@ -101,4 +101,37 @@ describe("create-helper", () => {
|
|
|
101
101
|
},
|
|
102
102
|
20 * 1000,
|
|
103
103
|
);
|
|
104
|
+
anvilTest(
|
|
105
|
+
"creates a new token with a create referral address",
|
|
106
|
+
async ({ viemClients: { testClient, publicClient, walletClient } }) => {
|
|
107
|
+
const addresses = await walletClient.getAddresses();
|
|
108
|
+
const creatorAddress = addresses[0]!;
|
|
109
|
+
await testClient.setBalance({
|
|
110
|
+
address: creatorAddress,
|
|
111
|
+
value: parseEther("1"),
|
|
112
|
+
});
|
|
113
|
+
const creatorClient = create1155CreatorClient({
|
|
114
|
+
publicClient: publicClient,
|
|
115
|
+
});
|
|
116
|
+
const { request } = await creatorClient.createNew1155Token({
|
|
117
|
+
contract: {
|
|
118
|
+
name: "testContract",
|
|
119
|
+
uri: demoContractMetadataURI,
|
|
120
|
+
},
|
|
121
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
122
|
+
account: creatorAddress,
|
|
123
|
+
mintToCreatorCount: 1,
|
|
124
|
+
createReferral: creatorAddress,
|
|
125
|
+
});
|
|
126
|
+
const { request: simulationResponse } =
|
|
127
|
+
await publicClient.simulateContract(request);
|
|
128
|
+
const hash = await walletClient.writeContract(simulationResponse);
|
|
129
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
130
|
+
expect(receipt).not.toBeNull();
|
|
131
|
+
console.log(receipt);
|
|
132
|
+
expect(receipt.to).to.equal("0xa72724cc3dcef210141a1b84c61824074151dc99");
|
|
133
|
+
expect(getTokenIdFromCreateReceipt(receipt)).to.be.equal(2n);
|
|
134
|
+
},
|
|
135
|
+
20 * 1000,
|
|
136
|
+
);
|
|
104
137
|
});
|
|
@@ -246,6 +246,7 @@ export function create1155CreatorClient({
|
|
|
246
246
|
maxSupply,
|
|
247
247
|
account,
|
|
248
248
|
royaltySettings,
|
|
249
|
+
createReferral,
|
|
249
250
|
getAdditionalSetupActions,
|
|
250
251
|
}: {
|
|
251
252
|
account: Address;
|
|
@@ -256,6 +257,7 @@ export function create1155CreatorClient({
|
|
|
256
257
|
tokenMetadataURI: string;
|
|
257
258
|
mintToCreatorCount?: bigint | number;
|
|
258
259
|
salesConfig?: SalesConfigParamsType;
|
|
260
|
+
createReferral?: Address;
|
|
259
261
|
getAdditionalSetupActions?: (args: {
|
|
260
262
|
tokenId: bigint;
|
|
261
263
|
contractAddress: Address;
|
|
@@ -296,6 +298,7 @@ export function create1155CreatorClient({
|
|
|
296
298
|
account,
|
|
297
299
|
mintToCreatorCount,
|
|
298
300
|
royaltySettings,
|
|
301
|
+
createReferral,
|
|
299
302
|
});
|
|
300
303
|
if (getAdditionalSetupActions) {
|
|
301
304
|
tokenSetupActions = [
|
|
@@ -214,6 +214,7 @@ describe("MINTs collecting and redeeming.", () => {
|
|
|
214
214
|
|
|
215
215
|
expect(totalMintsBalance).toEqual(initialMintsQuantityToMint);
|
|
216
216
|
},
|
|
217
|
+
20_000,
|
|
217
218
|
);
|
|
218
219
|
anvilTest(
|
|
219
220
|
"can use MINTSs to collect premint and non-premint",
|
|
@@ -362,6 +363,7 @@ describe("MINTs collecting and redeeming.", () => {
|
|
|
362
363
|
(firstQuantityToCollect + secondQuantityToCollect),
|
|
363
364
|
);
|
|
364
365
|
},
|
|
366
|
+
20_000,
|
|
365
367
|
);
|
|
366
368
|
anvilTest(
|
|
367
369
|
"can decode errors from transferBatchToManagerAndCall",
|
|
@@ -440,6 +442,7 @@ describe("MINTs collecting and redeeming.", () => {
|
|
|
440
442
|
}
|
|
441
443
|
}
|
|
442
444
|
},
|
|
445
|
+
20_000,
|
|
443
446
|
);
|
|
444
447
|
anvilTest(
|
|
445
448
|
"can use MINTs to gaslessly collect premint",
|
|
@@ -546,6 +549,7 @@ describe("MINTs collecting and redeeming.", () => {
|
|
|
546
549
|
),
|
|
547
550
|
).toBe(initialMintsBalance - premintQuantityToCollect);
|
|
548
551
|
},
|
|
552
|
+
20_000,
|
|
549
553
|
);
|
|
550
554
|
|
|
551
555
|
anvilTest(
|
|
@@ -715,5 +719,6 @@ describe("MINTs collecting and redeeming.", () => {
|
|
|
715
719
|
|
|
716
720
|
expect(tokenBalance).toBe(quantityToMintOn1155 * 2n);
|
|
717
721
|
},
|
|
722
|
+
20_000,
|
|
718
723
|
);
|
|
719
724
|
});
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import { getSubgraphUrl } from "src/apis/chain-constants";
|
|
2
1
|
import { Address } from "viem";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
type CollectQueryResult = {
|
|
6
|
-
tokenIds: bigint[];
|
|
7
|
-
quantities: bigint[];
|
|
8
|
-
};
|
|
2
|
+
import { gql } from "graphql-request";
|
|
9
3
|
|
|
10
4
|
export const getMintsAccountBalanceWithPriceQuery = (account: Address) => {
|
|
11
5
|
const query = gql`
|
|
@@ -99,61 +93,3 @@ export const sumBalances = (
|
|
|
99
93
|
return acc + BigInt(curr.balance);
|
|
100
94
|
}, BigInt(0));
|
|
101
95
|
};
|
|
102
|
-
|
|
103
|
-
/***
|
|
104
|
-
* Given an account and quantity of MINTs to use to collect with, queries for MINTs
|
|
105
|
-
* owned by an account, and selects the best MINTs to use to collect with that will satisfy that quantity.
|
|
106
|
-
* @param account Account to query for MINTs
|
|
107
|
-
* @param chainId
|
|
108
|
-
* @param quantityToCollect How many MINTs to use to collect with
|
|
109
|
-
* @returns
|
|
110
|
-
*/
|
|
111
|
-
export const getMINTsToCollectWith = async ({
|
|
112
|
-
account,
|
|
113
|
-
chainId,
|
|
114
|
-
quantityToCollect,
|
|
115
|
-
}: {
|
|
116
|
-
account: Address;
|
|
117
|
-
chainId: number;
|
|
118
|
-
quantityToCollect: bigint;
|
|
119
|
-
}): Promise<CollectQueryResult> => {
|
|
120
|
-
const subgraphUrl = getSubgraphUrl(chainId);
|
|
121
|
-
|
|
122
|
-
const { query, variables } = getMintsAccountBalanceWithPriceQuery(account);
|
|
123
|
-
|
|
124
|
-
const result = await request<MintAccountBalancesQueryResult>(
|
|
125
|
-
subgraphUrl,
|
|
126
|
-
query,
|
|
127
|
-
variables,
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
return selectMintsToCollectWithFromQueryResult(
|
|
131
|
-
result.mintTokenBalances,
|
|
132
|
-
quantityToCollect,
|
|
133
|
-
);
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
/***
|
|
137
|
-
* Given an account, queries for MINTs owned by an account, and sums the balances.
|
|
138
|
-
* @param account Account to query for MINTs
|
|
139
|
-
* @returns Total MINTs balance of account
|
|
140
|
-
*/
|
|
141
|
-
export const getMINTsBalance = async ({
|
|
142
|
-
chainId,
|
|
143
|
-
account,
|
|
144
|
-
}: {
|
|
145
|
-
account: Address;
|
|
146
|
-
chainId: number;
|
|
147
|
-
}) => {
|
|
148
|
-
const subgraphUrl = getSubgraphUrl(chainId);
|
|
149
|
-
|
|
150
|
-
const { query, variables } = getMintsAccountBalanceWithPriceQuery(account);
|
|
151
|
-
|
|
152
|
-
const result = await request<MintAccountBalancesQueryResult>(
|
|
153
|
-
subgraphUrl,
|
|
154
|
-
query,
|
|
155
|
-
variables,
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
return sumBalances(result.mintTokenBalances);
|
|
159
|
-
};
|