@zoralabs/protocol-sdk 0.9.1 → 0.9.2
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 +6 -0
- package/dist/anvil.d.ts.map +1 -1
- package/dist/apis/http-api-base.d.ts +1 -1
- package/dist/apis/http-api-base.d.ts.map +1 -1
- package/dist/apis/subgraph-querier.d.ts +6 -0
- package/dist/apis/subgraph-querier.d.ts.map +1 -1
- package/dist/create/1155-create-helper.d.ts +4 -1
- package/dist/create/1155-create-helper.d.ts.map +1 -1
- package/dist/create/contract-getter.d.ts +30 -0
- package/dist/create/contract-getter.d.ts.map +1 -0
- package/dist/create/contract-setup.d.ts +4 -8
- package/dist/create/contract-setup.d.ts.map +1 -1
- package/dist/create/mint-from-create.d.ts +3 -3
- package/dist/create/mint-from-create.d.ts.map +1 -1
- package/dist/create/subgraph-queries.d.ts +13 -0
- package/dist/create/subgraph-queries.d.ts.map +1 -0
- package/dist/index.cjs +176 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +155 -76
- package/dist/index.js.map +1 -1
- package/dist/mint/subgraph-mint-getter.d.ts +2 -2
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
- package/dist/mint/subgraph-queries.d.ts +1 -5
- package/dist/mint/subgraph-queries.d.ts.map +1 -1
- package/dist/retries.d.ts +7 -0
- package/dist/retries.d.ts.map +1 -0
- package/dist/sdk.d.ts +2 -0
- package/dist/sdk.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/apis/http-api-base.ts +12 -20
- package/src/apis/subgraph-querier.ts +7 -0
- package/src/create/1155-create-helper.test.ts +22 -1
- package/src/create/1155-create-helper.ts +18 -9
- package/src/create/contract-getter.ts +90 -0
- package/src/create/contract-setup.ts +17 -46
- package/src/create/mint-from-create.ts +7 -15
- package/src/create/subgraph-queries.ts +35 -0
- package/src/mint/subgraph-mint-getter.ts +5 -2
- package/src/mint/subgraph-queries.ts +1 -7
- package/src/retries.ts +49 -0
- package/src/sdk.ts +8 -0
- package/test-integration/create-multiple-tokens-on-contract.ts +104 -0
package/dist/index.cjs
CHANGED
|
@@ -2551,6 +2551,44 @@ var toContractCreationConfigOrAddress = ({
|
|
|
2551
2551
|
// src/premint/premint-client.ts
|
|
2552
2552
|
var import_protocol_deployments4 = require("@zoralabs/protocol-deployments");
|
|
2553
2553
|
|
|
2554
|
+
// src/retries.ts
|
|
2555
|
+
async function wait(delayMs) {
|
|
2556
|
+
return new Promise((resolve) => {
|
|
2557
|
+
setTimeout(resolve, delayMs);
|
|
2558
|
+
});
|
|
2559
|
+
}
|
|
2560
|
+
var retryInternal = async ({
|
|
2561
|
+
tryFn,
|
|
2562
|
+
maxTries = 3,
|
|
2563
|
+
atTry,
|
|
2564
|
+
linearBackoffMS = 200,
|
|
2565
|
+
shouldRetryOnError = () => true
|
|
2566
|
+
}) => {
|
|
2567
|
+
try {
|
|
2568
|
+
return await tryFn();
|
|
2569
|
+
} catch (err) {
|
|
2570
|
+
if (shouldRetryOnError(err)) {
|
|
2571
|
+
if (atTry <= maxTries) {
|
|
2572
|
+
await wait(atTry * linearBackoffMS);
|
|
2573
|
+
return await retryInternal({
|
|
2574
|
+
tryFn,
|
|
2575
|
+
maxTries,
|
|
2576
|
+
atTry: atTry + 1,
|
|
2577
|
+
linearBackoffMS,
|
|
2578
|
+
shouldRetryOnError
|
|
2579
|
+
});
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
throw err;
|
|
2583
|
+
}
|
|
2584
|
+
};
|
|
2585
|
+
var retriesGeneric = async (params) => {
|
|
2586
|
+
return retryInternal({
|
|
2587
|
+
...params,
|
|
2588
|
+
atTry: 1
|
|
2589
|
+
});
|
|
2590
|
+
};
|
|
2591
|
+
|
|
2554
2592
|
// src/apis/http-api-base.ts
|
|
2555
2593
|
var BadResponseError = class extends Error {
|
|
2556
2594
|
constructor(message, status, json) {
|
|
@@ -2560,11 +2598,6 @@ var BadResponseError = class extends Error {
|
|
|
2560
2598
|
this.json = json;
|
|
2561
2599
|
}
|
|
2562
2600
|
};
|
|
2563
|
-
async function wait(delayMs) {
|
|
2564
|
-
return new Promise((resolve) => {
|
|
2565
|
-
setTimeout(resolve, delayMs);
|
|
2566
|
-
});
|
|
2567
|
-
}
|
|
2568
2601
|
var get = async (url) => {
|
|
2569
2602
|
const response = await fetch(url, { method: "GET" });
|
|
2570
2603
|
if (response.status !== 200) {
|
|
@@ -2610,20 +2643,16 @@ var post = async (url, data) => {
|
|
|
2610
2643
|
}
|
|
2611
2644
|
return await response.json();
|
|
2612
2645
|
};
|
|
2613
|
-
var retries = async (tryFn, maxTries = 3,
|
|
2614
|
-
|
|
2615
|
-
return
|
|
2616
|
-
}
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
}
|
|
2624
|
-
}
|
|
2625
|
-
throw err;
|
|
2626
|
-
}
|
|
2646
|
+
var retries = async (tryFn, maxTries = 3, linearBackoffMS = 200) => {
|
|
2647
|
+
const shouldRetry = (err) => {
|
|
2648
|
+
return err instanceof BadResponseError && err.status >= 500;
|
|
2649
|
+
};
|
|
2650
|
+
return retriesGeneric({
|
|
2651
|
+
tryFn,
|
|
2652
|
+
maxTries,
|
|
2653
|
+
linearBackoffMS,
|
|
2654
|
+
shouldRetryOnError: shouldRetry
|
|
2655
|
+
});
|
|
2627
2656
|
};
|
|
2628
2657
|
var httpClient = {
|
|
2629
2658
|
get,
|
|
@@ -4247,7 +4276,7 @@ async function mint({
|
|
|
4247
4276
|
}
|
|
4248
4277
|
|
|
4249
4278
|
// src/create/1155-create-helper.ts
|
|
4250
|
-
var
|
|
4279
|
+
var import_protocol_deployments10 = require("@zoralabs/protocol-deployments");
|
|
4251
4280
|
var import_viem10 = require("viem");
|
|
4252
4281
|
|
|
4253
4282
|
// src/create/contract-setup.ts
|
|
@@ -4259,36 +4288,6 @@ function new1155ContractVersion(chainId) {
|
|
|
4259
4288
|
}
|
|
4260
4289
|
return address.CONTRACT_1155_IMPL_VERSION;
|
|
4261
4290
|
}
|
|
4262
|
-
async function getContractInfoExistingContract({
|
|
4263
|
-
publicClient,
|
|
4264
|
-
contractAddress
|
|
4265
|
-
}) {
|
|
4266
|
-
let contractVersion;
|
|
4267
|
-
try {
|
|
4268
|
-
contractVersion = await publicClient.readContract({
|
|
4269
|
-
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
4270
|
-
address: contractAddress,
|
|
4271
|
-
functionName: "contractVersion"
|
|
4272
|
-
});
|
|
4273
|
-
} catch (e) {
|
|
4274
|
-
throw new Error(`Contract does not exist at ${contractAddress}`);
|
|
4275
|
-
}
|
|
4276
|
-
const nextTokenId = await publicClient.readContract({
|
|
4277
|
-
address: contractAddress,
|
|
4278
|
-
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
4279
|
-
functionName: "nextTokenId"
|
|
4280
|
-
});
|
|
4281
|
-
const contractName = await publicClient.readContract({
|
|
4282
|
-
address: contractAddress,
|
|
4283
|
-
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
4284
|
-
functionName: "name"
|
|
4285
|
-
});
|
|
4286
|
-
return {
|
|
4287
|
-
contractVersion,
|
|
4288
|
-
contractName,
|
|
4289
|
-
nextTokenId
|
|
4290
|
-
};
|
|
4291
|
-
}
|
|
4292
4291
|
async function getDeterministicContractAddress({
|
|
4293
4292
|
publicClient,
|
|
4294
4293
|
account,
|
|
@@ -4310,6 +4309,17 @@ async function getDeterministicContractAddress({
|
|
|
4310
4309
|
});
|
|
4311
4310
|
return contractAddress;
|
|
4312
4311
|
}
|
|
4312
|
+
async function getNewContractMintFee({
|
|
4313
|
+
publicClient,
|
|
4314
|
+
chainId
|
|
4315
|
+
}) {
|
|
4316
|
+
const implAddress = import_protocol_deployments7.contracts1155.addresses[chainId].CONTRACT_1155_IMPL;
|
|
4317
|
+
return await publicClient.readContract({
|
|
4318
|
+
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
4319
|
+
address: implAddress,
|
|
4320
|
+
functionName: "mintFee"
|
|
4321
|
+
});
|
|
4322
|
+
}
|
|
4313
4323
|
|
|
4314
4324
|
// src/create/token-setup.ts
|
|
4315
4325
|
var import_protocol_deployments9 = require("@zoralabs/protocol-deployments");
|
|
@@ -5835,12 +5845,10 @@ var contractSupportsMintRewards = (contractVersion, contractStandard) => {
|
|
|
5835
5845
|
|
|
5836
5846
|
// src/create/mint-from-create.ts
|
|
5837
5847
|
var import_viem9 = require("viem");
|
|
5838
|
-
var import_protocol_deployments10 = require("@zoralabs/protocol-deployments");
|
|
5839
5848
|
async function toSalesStrategyFromSubgraph({
|
|
5840
5849
|
minter,
|
|
5841
5850
|
salesConfig,
|
|
5842
|
-
|
|
5843
|
-
contractAddress
|
|
5851
|
+
getContractMintFee
|
|
5844
5852
|
}) {
|
|
5845
5853
|
if (salesConfig.type === "timed") {
|
|
5846
5854
|
return {
|
|
@@ -5869,11 +5877,7 @@ async function toSalesStrategyFromSubgraph({
|
|
|
5869
5877
|
maxTokensPerAddress: salesConfig.maxTokensPerAddress
|
|
5870
5878
|
};
|
|
5871
5879
|
}
|
|
5872
|
-
const contractMintFee = await
|
|
5873
|
-
abi: import_protocol_deployments10.zoraCreator1155ImplABI,
|
|
5874
|
-
address: contractAddress,
|
|
5875
|
-
functionName: "mintFee"
|
|
5876
|
-
});
|
|
5880
|
+
const contractMintFee = await getContractMintFee();
|
|
5877
5881
|
if (salesConfig.type === "fixedPrice") {
|
|
5878
5882
|
return {
|
|
5879
5883
|
saleType: "fixedPrice",
|
|
@@ -5899,14 +5903,13 @@ function makeOnchainPrepareMintFromCreate({
|
|
|
5899
5903
|
tokenId,
|
|
5900
5904
|
result,
|
|
5901
5905
|
minter,
|
|
5902
|
-
|
|
5906
|
+
getContractMintFee,
|
|
5903
5907
|
contractVersion
|
|
5904
5908
|
}) {
|
|
5905
5909
|
return async (params) => {
|
|
5906
5910
|
const subgraphSalesConfig = await toSalesStrategyFromSubgraph({
|
|
5907
5911
|
minter,
|
|
5908
|
-
|
|
5909
|
-
publicClient,
|
|
5912
|
+
getContractMintFee,
|
|
5910
5913
|
salesConfig: result
|
|
5911
5914
|
});
|
|
5912
5915
|
return {
|
|
@@ -5935,7 +5938,7 @@ var getTokenIdFromCreateReceipt = (receipt) => {
|
|
|
5935
5938
|
for (const data of receipt.logs) {
|
|
5936
5939
|
try {
|
|
5937
5940
|
const decodedLog = (0, import_viem10.decodeEventLog)({
|
|
5938
|
-
abi:
|
|
5941
|
+
abi: import_protocol_deployments10.zoraCreator1155ImplABI,
|
|
5939
5942
|
eventName: "SetupNewToken",
|
|
5940
5943
|
...data
|
|
5941
5944
|
});
|
|
@@ -5953,7 +5956,7 @@ var getContractAddressFromReceipt = (receipt) => {
|
|
|
5953
5956
|
for (const data of receipt.logs) {
|
|
5954
5957
|
try {
|
|
5955
5958
|
const decodedLog = (0, import_viem10.decodeEventLog)({
|
|
5956
|
-
abi:
|
|
5959
|
+
abi: import_protocol_deployments10.zoraCreator1155FactoryImplABI,
|
|
5957
5960
|
eventName: "SetupNewContract",
|
|
5958
5961
|
...data
|
|
5959
5962
|
});
|
|
@@ -5977,10 +5980,10 @@ function makeCreateContractAndTokenCall({
|
|
|
5977
5980
|
}) {
|
|
5978
5981
|
const accountAddress = typeof account === "string" ? account : account.address;
|
|
5979
5982
|
return makeContractParameters({
|
|
5980
|
-
abi:
|
|
5983
|
+
abi: import_protocol_deployments10.zoraCreator1155FactoryImplABI,
|
|
5981
5984
|
functionName: "createContractDeterministic",
|
|
5982
5985
|
account,
|
|
5983
|
-
address:
|
|
5986
|
+
address: import_protocol_deployments10.zoraCreator1155FactoryImplAddress[chainId],
|
|
5984
5987
|
args: [
|
|
5985
5988
|
contract.uri,
|
|
5986
5989
|
contract.name,
|
|
@@ -6001,7 +6004,7 @@ function makeCreateTokenCall({
|
|
|
6001
6004
|
tokenSetupActions
|
|
6002
6005
|
}) {
|
|
6003
6006
|
return makeContractParameters({
|
|
6004
|
-
abi:
|
|
6007
|
+
abi: import_protocol_deployments10.zoraCreator1155ImplABI,
|
|
6005
6008
|
functionName: "multicall",
|
|
6006
6009
|
account,
|
|
6007
6010
|
address: contractAddress,
|
|
@@ -6011,10 +6014,12 @@ function makeCreateTokenCall({
|
|
|
6011
6014
|
var Create1155Client = class {
|
|
6012
6015
|
constructor({
|
|
6013
6016
|
chainId,
|
|
6014
|
-
publicClient
|
|
6017
|
+
publicClient,
|
|
6018
|
+
contractGetter
|
|
6015
6019
|
}) {
|
|
6016
6020
|
this.chainId = chainId;
|
|
6017
6021
|
this.publicClient = publicClient;
|
|
6022
|
+
this.contractGetter = contractGetter;
|
|
6018
6023
|
}
|
|
6019
6024
|
async createNew1155(props) {
|
|
6020
6025
|
return createNew1155ContractAndToken({
|
|
@@ -6035,7 +6040,8 @@ var Create1155Client = class {
|
|
|
6035
6040
|
token,
|
|
6036
6041
|
getAdditionalSetupActions,
|
|
6037
6042
|
publicClient: this.publicClient,
|
|
6038
|
-
chainId: this.chainId
|
|
6043
|
+
chainId: this.chainId,
|
|
6044
|
+
contractGetter: this.contractGetter
|
|
6039
6045
|
});
|
|
6040
6046
|
}
|
|
6041
6047
|
};
|
|
@@ -6080,9 +6086,13 @@ async function createNew1155ContractAndToken({
|
|
|
6080
6086
|
contractAddress,
|
|
6081
6087
|
contractVersion,
|
|
6082
6088
|
minter,
|
|
6083
|
-
publicClient,
|
|
6084
6089
|
result: newToken.salesConfig,
|
|
6085
|
-
tokenId: nextTokenId
|
|
6090
|
+
tokenId: nextTokenId,
|
|
6091
|
+
// to get the contract wide mint fee, we get what it would be for a new contract
|
|
6092
|
+
getContractMintFee: async () => getNewContractMintFee({
|
|
6093
|
+
publicClient,
|
|
6094
|
+
chainId
|
|
6095
|
+
})
|
|
6086
6096
|
});
|
|
6087
6097
|
return {
|
|
6088
6098
|
parameters: request,
|
|
@@ -6100,13 +6110,10 @@ async function createNew1155Token({
|
|
|
6100
6110
|
account,
|
|
6101
6111
|
getAdditionalSetupActions,
|
|
6102
6112
|
token,
|
|
6103
|
-
|
|
6104
|
-
|
|
6113
|
+
chainId,
|
|
6114
|
+
contractGetter
|
|
6105
6115
|
}) {
|
|
6106
|
-
const { nextTokenId, contractVersion } = await
|
|
6107
|
-
publicClient,
|
|
6108
|
-
contractAddress
|
|
6109
|
-
});
|
|
6116
|
+
const { nextTokenId, contractVersion, mintFee } = await contractGetter.getContractInfo({ contractAddress, retries: 5 });
|
|
6110
6117
|
const {
|
|
6111
6118
|
minter,
|
|
6112
6119
|
newToken,
|
|
@@ -6128,9 +6135,9 @@ async function createNew1155Token({
|
|
|
6128
6135
|
contractAddress,
|
|
6129
6136
|
contractVersion,
|
|
6130
6137
|
minter,
|
|
6131
|
-
publicClient,
|
|
6132
6138
|
result: newToken.salesConfig,
|
|
6133
|
-
tokenId: nextTokenId
|
|
6139
|
+
tokenId: nextTokenId,
|
|
6140
|
+
getContractMintFee: async () => mintFee
|
|
6134
6141
|
});
|
|
6135
6142
|
return {
|
|
6136
6143
|
parameters: request,
|
|
@@ -6227,7 +6234,7 @@ var sumBalances = (mintAccountBalances) => {
|
|
|
6227
6234
|
};
|
|
6228
6235
|
|
|
6229
6236
|
// src/sparks/sparks-contracts.ts
|
|
6230
|
-
var
|
|
6237
|
+
var import_protocol_deployments11 = require("@zoralabs/protocol-deployments");
|
|
6231
6238
|
var import_viem11 = require("viem");
|
|
6232
6239
|
var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
|
|
6233
6240
|
var mintWithEthParams = ({
|
|
@@ -6238,8 +6245,8 @@ var mintWithEthParams = ({
|
|
|
6238
6245
|
pricePerMint,
|
|
6239
6246
|
account
|
|
6240
6247
|
}) => makeContractParameters({
|
|
6241
|
-
abi:
|
|
6242
|
-
address:
|
|
6248
|
+
abi: import_protocol_deployments11.zoraSparksManagerImplABI,
|
|
6249
|
+
address: import_protocol_deployments11.zoraSparksManagerImplAddress[chainId],
|
|
6243
6250
|
functionName: "mintWithEth",
|
|
6244
6251
|
args: [tokenId, quantity, recipient || addressOrAccountAddress(account)],
|
|
6245
6252
|
value: pricePerMint * quantity,
|
|
@@ -6254,8 +6261,8 @@ var mintsBalanceOfAccountParams = ({
|
|
|
6254
6261
|
account,
|
|
6255
6262
|
chainId
|
|
6256
6263
|
}) => ({
|
|
6257
|
-
abi:
|
|
6258
|
-
address:
|
|
6264
|
+
abi: import_protocol_deployments11.zoraMints1155Config.abi,
|
|
6265
|
+
address: import_protocol_deployments11.zoraMints1155Config.address[chainId],
|
|
6259
6266
|
functionName: "balanceOfAccount",
|
|
6260
6267
|
args: [account]
|
|
6261
6268
|
});
|
|
@@ -6265,7 +6272,7 @@ var encodeCollectOnManager = ({
|
|
|
6265
6272
|
zoraCreator1155TokenId,
|
|
6266
6273
|
mintArguments
|
|
6267
6274
|
}) => (0, import_viem11.encodeFunctionData)({
|
|
6268
|
-
abi:
|
|
6275
|
+
abi: import_protocol_deployments11.zoraMintsManagerImplConfig.abi,
|
|
6269
6276
|
functionName: "collect",
|
|
6270
6277
|
args: [
|
|
6271
6278
|
zoraCreator1155Contract,
|
|
@@ -6294,8 +6301,8 @@ function collectWithMintsParams({
|
|
|
6294
6301
|
mintArguments
|
|
6295
6302
|
});
|
|
6296
6303
|
return makeContractParameters({
|
|
6297
|
-
abi:
|
|
6298
|
-
address:
|
|
6304
|
+
abi: import_protocol_deployments11.zoraMints1155Config.abi,
|
|
6305
|
+
address: import_protocol_deployments11.zoraMints1155Config.address[chainId],
|
|
6299
6306
|
functionName: "transferBatchToManagerAndCall",
|
|
6300
6307
|
args: [tokenIds, quantities, call],
|
|
6301
6308
|
// if it is a paid mint, the aadditional value will be sent to the manager contract and forwarded to the creator 1155 contract
|
|
@@ -6308,12 +6315,12 @@ function getMintsEthPrice({
|
|
|
6308
6315
|
publicClient
|
|
6309
6316
|
}) {
|
|
6310
6317
|
const chainId = publicClient.chain?.id;
|
|
6311
|
-
if (!chainId || !
|
|
6318
|
+
if (!chainId || !import_protocol_deployments11.zoraMintsManagerImplAddress[chainId]) {
|
|
6312
6319
|
throw new Error(`Chain id ${chainId} not supported`);
|
|
6313
6320
|
}
|
|
6314
6321
|
return publicClient.readContract({
|
|
6315
|
-
abi:
|
|
6316
|
-
address:
|
|
6322
|
+
abi: import_protocol_deployments11.zoraMintsManagerImplABI,
|
|
6323
|
+
address: import_protocol_deployments11.zoraMintsManagerImplAddress[chainId],
|
|
6317
6324
|
functionName: "getEthPrice"
|
|
6318
6325
|
});
|
|
6319
6326
|
}
|
|
@@ -6337,7 +6344,7 @@ function makePermitTransferBatchAndTypeData({
|
|
|
6337
6344
|
safeTransferData
|
|
6338
6345
|
};
|
|
6339
6346
|
const typedData = {
|
|
6340
|
-
...(0,
|
|
6347
|
+
...(0, import_protocol_deployments11.mintsSafeTransferBatchTypedDataDefinition)({
|
|
6341
6348
|
chainId,
|
|
6342
6349
|
message: permit
|
|
6343
6350
|
}),
|
|
@@ -6368,7 +6375,7 @@ function makePermitTransferTypeData({
|
|
|
6368
6375
|
safeTransferData
|
|
6369
6376
|
};
|
|
6370
6377
|
const typedData = {
|
|
6371
|
-
...(0,
|
|
6378
|
+
...(0, import_protocol_deployments11.mintsSafeTransferTypedDataDefinition)({
|
|
6372
6379
|
chainId,
|
|
6373
6380
|
message: permit
|
|
6374
6381
|
}),
|
|
@@ -6386,7 +6393,7 @@ var encodePremintOnManager = ({
|
|
|
6386
6393
|
mintArguments,
|
|
6387
6394
|
signerContract = import_viem11.zeroAddress
|
|
6388
6395
|
}) => (0, import_viem11.encodeFunctionData)({
|
|
6389
|
-
abi:
|
|
6396
|
+
abi: import_protocol_deployments11.zoraMintsManagerImplConfig.abi,
|
|
6390
6397
|
functionName: "collectPremintV2",
|
|
6391
6398
|
args: [
|
|
6392
6399
|
contractCreationConfig,
|
|
@@ -6425,7 +6432,7 @@ var makePermitToCollectPremintOrNonPremint = ({
|
|
|
6425
6432
|
nonce,
|
|
6426
6433
|
deadline,
|
|
6427
6434
|
safeTransferData,
|
|
6428
|
-
to:
|
|
6435
|
+
to: import_protocol_deployments11.zoraMintsManagerImplConfig.address[chainId]
|
|
6429
6436
|
});
|
|
6430
6437
|
};
|
|
6431
6438
|
function collectPremintV2WithMintsParams({
|
|
@@ -6440,8 +6447,8 @@ function collectPremintV2WithMintsParams({
|
|
|
6440
6447
|
...rest
|
|
6441
6448
|
});
|
|
6442
6449
|
return makeContractParameters({
|
|
6443
|
-
abi:
|
|
6444
|
-
address:
|
|
6450
|
+
abi: import_protocol_deployments11.zoraMints1155Config.abi,
|
|
6451
|
+
address: import_protocol_deployments11.zoraMints1155Config.address[chainId],
|
|
6445
6452
|
functionName: "transferBatchToManagerAndCall",
|
|
6446
6453
|
args: [tokenIds, quantities, call],
|
|
6447
6454
|
value: getPaidMintValue(quantities, paidMintPricePerToken),
|
|
@@ -6453,11 +6460,82 @@ function decodeCallFailedError(error) {
|
|
|
6453
6460
|
throw new Error("Not a CallFailed error");
|
|
6454
6461
|
const internalErrorData = error.data?.args?.[0];
|
|
6455
6462
|
return (0, import_viem11.decodeErrorResult)({
|
|
6456
|
-
abi:
|
|
6463
|
+
abi: import_protocol_deployments11.zoraMintsManagerImplABI,
|
|
6457
6464
|
data: internalErrorData
|
|
6458
6465
|
});
|
|
6459
6466
|
}
|
|
6460
6467
|
|
|
6468
|
+
// src/create/subgraph-queries.ts
|
|
6469
|
+
function buildContractInfoQuery({
|
|
6470
|
+
contractAddress
|
|
6471
|
+
}) {
|
|
6472
|
+
return {
|
|
6473
|
+
query: `
|
|
6474
|
+
query ($contractAddress: Bytes!) {
|
|
6475
|
+
zoraCreateContract(id: $contractAddress) {
|
|
6476
|
+
contractVersion
|
|
6477
|
+
name
|
|
6478
|
+
mintFeePerQuantity
|
|
6479
|
+
tokens(first: 1, orderBy: tokenId, orderDirection: desc) {
|
|
6480
|
+
tokenId
|
|
6481
|
+
}
|
|
6482
|
+
}
|
|
6483
|
+
}
|
|
6484
|
+
`,
|
|
6485
|
+
variables: {
|
|
6486
|
+
contractAddress: contractAddress.toLowerCase()
|
|
6487
|
+
},
|
|
6488
|
+
parseResponseData: (responseData) => responseData.zoraCreateContract
|
|
6489
|
+
};
|
|
6490
|
+
}
|
|
6491
|
+
|
|
6492
|
+
// src/create/contract-getter.ts
|
|
6493
|
+
var SubgraphContractGetter = class {
|
|
6494
|
+
constructor(chainId, subgraphQuerier) {
|
|
6495
|
+
this.subgraphQuerier = subgraphQuerier || new SubgraphQuerier(httpClient);
|
|
6496
|
+
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
6497
|
+
}
|
|
6498
|
+
async querySubgraphWithRetries({
|
|
6499
|
+
query,
|
|
6500
|
+
variables,
|
|
6501
|
+
parseResponseData
|
|
6502
|
+
}) {
|
|
6503
|
+
const responseData = await this.subgraphQuerier.query({
|
|
6504
|
+
subgraphUrl: this.networkConfig.subgraphUrl,
|
|
6505
|
+
query,
|
|
6506
|
+
variables
|
|
6507
|
+
});
|
|
6508
|
+
return parseResponseData(responseData);
|
|
6509
|
+
}
|
|
6510
|
+
async getContractInfo({
|
|
6511
|
+
contractAddress,
|
|
6512
|
+
retries: retries2 = 1
|
|
6513
|
+
}) {
|
|
6514
|
+
const tryFn = async () => {
|
|
6515
|
+
const responseData2 = await this.querySubgraphWithRetries(
|
|
6516
|
+
buildContractInfoQuery({ contractAddress })
|
|
6517
|
+
);
|
|
6518
|
+
if (!responseData2) {
|
|
6519
|
+
console.log("could not find contract");
|
|
6520
|
+
throw new Error("Cannot find contract");
|
|
6521
|
+
}
|
|
6522
|
+
return responseData2;
|
|
6523
|
+
};
|
|
6524
|
+
const responseData = await retriesGeneric({
|
|
6525
|
+
tryFn,
|
|
6526
|
+
maxTries: retries2,
|
|
6527
|
+
linearBackoffMS: 1e3
|
|
6528
|
+
});
|
|
6529
|
+
const nextTokenId = responseData.tokens.length === 0 ? 1n : BigInt(responseData.tokens[0].tokenId) + 1n;
|
|
6530
|
+
return {
|
|
6531
|
+
name: responseData.name,
|
|
6532
|
+
contractVersion: responseData.contractVersion,
|
|
6533
|
+
mintFee: BigInt(responseData.mintFeePerQuantity),
|
|
6534
|
+
nextTokenId
|
|
6535
|
+
};
|
|
6536
|
+
}
|
|
6537
|
+
};
|
|
6538
|
+
|
|
6461
6539
|
// src/sdk.ts
|
|
6462
6540
|
function createCreatorClient(clientConfig) {
|
|
6463
6541
|
const premintClient = new PremintClient({
|
|
@@ -6467,7 +6545,8 @@ function createCreatorClient(clientConfig) {
|
|
|
6467
6545
|
});
|
|
6468
6546
|
const create1155CreatorClient = new Create1155Client({
|
|
6469
6547
|
chainId: clientConfig.chainId,
|
|
6470
|
-
publicClient: clientConfig.publicClient
|
|
6548
|
+
publicClient: clientConfig.publicClient,
|
|
6549
|
+
contractGetter: clientConfig.contractGetter || new SubgraphContractGetter(clientConfig.chainId)
|
|
6471
6550
|
});
|
|
6472
6551
|
return {
|
|
6473
6552
|
createPremint: (p) => premintClient.createPremint(p),
|