@zoralabs/protocol-sdk 0.9.4-PRE.0 → 0.9.5
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 +18 -18
- package/CHANGELOG.md +13 -4
- package/LICENSE +21 -0
- package/dist/anvil.d.ts +2 -2
- 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/create/mint-from-create.d.ts.map +1 -1
- package/dist/create/minter-defaults.d.ts +3 -1
- package/dist/create/minter-defaults.d.ts.map +1 -1
- package/dist/create/minter-setup.d.ts.map +1 -1
- package/dist/create/token-setup.d.ts +2 -2
- package/dist/create/token-setup.d.ts.map +1 -1
- package/dist/create/types.d.ts +4 -1
- package/dist/create/types.d.ts.map +1 -1
- package/dist/index.cjs +36 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -28
- package/dist/index.js.map +1 -1
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
- package/dist/mint/subgraph-queries.d.ts +2 -0
- package/dist/mint/subgraph-queries.d.ts.map +1 -1
- package/dist/mint/types.d.ts +5 -1
- package/dist/mint/types.d.ts.map +1 -1
- package/package.json +14 -15
- package/src/apis/http-api-base.ts +5 -4
- package/src/create/1155-create-helper.test.ts +40 -58
- package/src/create/1155-create-helper.ts +4 -4
- package/src/create/mint-from-create.ts +0 -1
- package/src/create/minter-defaults.ts +16 -6
- package/src/create/minter-setup.ts +7 -5
- package/src/create/token-setup.ts +7 -10
- package/src/create/types.ts +7 -1
- package/src/mint/mint-client.test.ts +4 -9
- package/src/mint/subgraph-mint-getter.ts +10 -1
- package/src/mint/subgraph-queries.ts +4 -0
- package/src/mint/types.ts +5 -1
- package/.env +0 -1
- package/yarn-error.log +0 -8602
package/dist/index.js
CHANGED
|
@@ -2595,10 +2595,10 @@ var post = async (url, data) => {
|
|
|
2595
2595
|
}
|
|
2596
2596
|
return await response.json();
|
|
2597
2597
|
};
|
|
2598
|
-
var
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2598
|
+
var defaultShouldRetry = (err) => {
|
|
2599
|
+
return err instanceof BadResponseError && err.status >= 500;
|
|
2600
|
+
};
|
|
2601
|
+
var retries = async (tryFn, maxTries = 3, linearBackoffMS = 200, shouldRetry = defaultShouldRetry) => {
|
|
2602
2602
|
return retriesGeneric({
|
|
2603
2603
|
tryFn,
|
|
2604
2604
|
maxTries,
|
|
@@ -2668,6 +2668,8 @@ fragment SaleStrategy on SalesStrategyConfig {
|
|
|
2668
2668
|
pool
|
|
2669
2669
|
}
|
|
2670
2670
|
secondaryActivated
|
|
2671
|
+
marketCountdown
|
|
2672
|
+
minimumMarketEth
|
|
2671
2673
|
}
|
|
2672
2674
|
}`;
|
|
2673
2675
|
var TOKEN_FRAGMENT = `
|
|
@@ -2806,7 +2808,9 @@ function parseSalesConfig(targetStrategy, contractMintFee) {
|
|
|
2806
2808
|
erc20Z: targetStrategy.zoraTimedMinter.erc20Z.id,
|
|
2807
2809
|
pool: targetStrategy.zoraTimedMinter.erc20Z.pool,
|
|
2808
2810
|
secondaryActivated: targetStrategy.zoraTimedMinter.secondaryActivated,
|
|
2809
|
-
mintFeePerQuantity: BigInt(targetStrategy.zoraTimedMinter.mintFee)
|
|
2811
|
+
mintFeePerQuantity: BigInt(targetStrategy.zoraTimedMinter.mintFee),
|
|
2812
|
+
marketCountdown: targetStrategy.zoraTimedMinter.marketCountdown ? BigInt(targetStrategy.zoraTimedMinter.marketCountdown) : void 0,
|
|
2813
|
+
minimumMarketEth: targetStrategy.zoraTimedMinter.minimumMarketEth ? BigInt(targetStrategy.zoraTimedMinter.minimumMarketEth) : void 0
|
|
2810
2814
|
};
|
|
2811
2815
|
}
|
|
2812
2816
|
throw new Error("Unknown saleType");
|
|
@@ -2828,7 +2832,7 @@ function strategyIsStillValid(strategy, blockTime) {
|
|
|
2828
2832
|
return BigInt(strategy.erc20Minter.saleEnd) > blockTime;
|
|
2829
2833
|
}
|
|
2830
2834
|
if (strategy.type === "ZORA_TIMED") {
|
|
2831
|
-
return BigInt(strategy.zoraTimedMinter.saleEnd) > blockTime;
|
|
2835
|
+
return BigInt(strategy.zoraTimedMinter.saleEnd) === 0n || BigInt(strategy.zoraTimedMinter.saleEnd) > blockTime;
|
|
2832
2836
|
}
|
|
2833
2837
|
return BigInt(strategy.presale.presaleEnd) > blockTime;
|
|
2834
2838
|
}
|
|
@@ -4298,6 +4302,8 @@ import { zoraCreator1155ImplABI as zoraCreator1155ImplABI5 } from "@zoralabs/pro
|
|
|
4298
4302
|
import { encodeFunctionData as encodeFunctionData2, zeroAddress as zeroAddress5 } from "viem";
|
|
4299
4303
|
|
|
4300
4304
|
// src/create/minter-defaults.ts
|
|
4305
|
+
var DEFAULT_MINIMUM_MARKET_ETH = 2220000000000000n;
|
|
4306
|
+
var DEFAULT_MARKET_COUNTDOWN = BigInt(24 * 60 * 60);
|
|
4301
4307
|
var SALE_END_FOREVER = 18446744073709551615n;
|
|
4302
4308
|
var DEFAULT_SALE_START_AND_END = {
|
|
4303
4309
|
// Sale start time – defaults to beginning of unix time
|
|
@@ -4335,15 +4341,19 @@ var parseNameIntoSymbol = (name) => {
|
|
|
4335
4341
|
}
|
|
4336
4342
|
return result;
|
|
4337
4343
|
};
|
|
4338
|
-
var timedSaleSettingsWithDefaults =
|
|
4344
|
+
var timedSaleSettingsWithDefaults = (params, contractName) => {
|
|
4339
4345
|
const erc20Name = params.erc20Name || contractName;
|
|
4340
4346
|
const symbol = params.erc20Symbol || parseNameIntoSymbol(erc20Name);
|
|
4347
|
+
const start = params.saleStart || 0n;
|
|
4348
|
+
const countdown = params.marketCountdown || DEFAULT_MARKET_COUNTDOWN;
|
|
4349
|
+
const minimumEth = params.minimumMarketEth || DEFAULT_MINIMUM_MARKET_ETH;
|
|
4341
4350
|
return {
|
|
4342
4351
|
type: "timed",
|
|
4343
|
-
...DEFAULT_SALE_START_AND_END,
|
|
4344
|
-
...params,
|
|
4345
4352
|
erc20Name,
|
|
4346
|
-
erc20Symbol: symbol
|
|
4353
|
+
erc20Symbol: symbol,
|
|
4354
|
+
saleStart: start,
|
|
4355
|
+
marketCountdown: countdown,
|
|
4356
|
+
minimumMarketEth: minimumEth
|
|
4347
4357
|
};
|
|
4348
4358
|
};
|
|
4349
4359
|
var isAllowList = (salesConfig) => salesConfig.type === "allowlistMint";
|
|
@@ -4351,7 +4361,7 @@ var isErc20 = (salesConfig) => salesConfig.type === "erc20Mint";
|
|
|
4351
4361
|
var isFixedPrice = (salesConfig) => {
|
|
4352
4362
|
return salesConfig.type === "fixedPrice" || salesConfig.pricePerToken > 0n;
|
|
4353
4363
|
};
|
|
4354
|
-
var getSalesConfigWithDefaults =
|
|
4364
|
+
var getSalesConfigWithDefaults = (salesConfig, contractName) => {
|
|
4355
4365
|
if (!salesConfig)
|
|
4356
4366
|
return timedSaleSettingsWithDefaults({}, contractName);
|
|
4357
4367
|
if (isAllowList(salesConfig)) {
|
|
@@ -4474,22 +4484,24 @@ function setupTimedSaleMinter({
|
|
|
4474
4484
|
erc20Name: erc20zName,
|
|
4475
4485
|
erc20Symbol: erc20zSymbol,
|
|
4476
4486
|
saleStart,
|
|
4477
|
-
|
|
4487
|
+
marketCountdown,
|
|
4488
|
+
minimumMarketEth
|
|
4478
4489
|
}) {
|
|
4479
4490
|
const minterAddress = zoraTimedSaleStrategyAddress[chainId];
|
|
4480
|
-
const
|
|
4491
|
+
const minterApproval = encodeFunctionData({
|
|
4481
4492
|
abi: zoraCreator1155ImplABI4,
|
|
4482
4493
|
functionName: "addPermission",
|
|
4483
4494
|
args: [BigInt(tokenId), minterAddress, PERMISSION_BITS.MINTER]
|
|
4484
4495
|
});
|
|
4485
4496
|
const saleData = encodeFunctionData({
|
|
4486
4497
|
abi: zoraTimedSaleStrategyABI2,
|
|
4487
|
-
functionName: "
|
|
4498
|
+
functionName: "setSaleV2",
|
|
4488
4499
|
args: [
|
|
4489
4500
|
BigInt(tokenId),
|
|
4490
4501
|
{
|
|
4491
4502
|
saleStart,
|
|
4492
|
-
|
|
4503
|
+
marketCountdown,
|
|
4504
|
+
minimumMarketEth,
|
|
4493
4505
|
name: erc20zName,
|
|
4494
4506
|
symbol: erc20zSymbol
|
|
4495
4507
|
}
|
|
@@ -4502,7 +4514,7 @@ function setupTimedSaleMinter({
|
|
|
4502
4514
|
});
|
|
4503
4515
|
return {
|
|
4504
4516
|
minter: minterAddress,
|
|
4505
|
-
setupActions: [
|
|
4517
|
+
setupActions: [minterApproval, callSale]
|
|
4506
4518
|
};
|
|
4507
4519
|
}
|
|
4508
4520
|
function setupAllowListMinter({
|
|
@@ -4569,7 +4581,7 @@ function setupMinters({ salesConfig, ...rest }) {
|
|
|
4569
4581
|
}
|
|
4570
4582
|
|
|
4571
4583
|
// src/create/token-setup.ts
|
|
4572
|
-
|
|
4584
|
+
function applyNew1155Defaults(props, ownerAddress, contractName) {
|
|
4573
4585
|
const { payoutRecipient: fundsRecipient } = props;
|
|
4574
4586
|
const fundsRecipientOrOwner = fundsRecipient && fundsRecipient !== zeroAddress5 ? fundsRecipient : ownerAddress;
|
|
4575
4587
|
return {
|
|
@@ -4578,10 +4590,7 @@ async function applyNew1155Defaults(props, ownerAddress, contractName) {
|
|
|
4578
4590
|
maxSupply: typeof props.maxSupply === "undefined" ? OPEN_EDITION_MINT_SIZE : BigInt(props.maxSupply),
|
|
4579
4591
|
royaltyBPS: props.royaltyBPS || 1e3,
|
|
4580
4592
|
tokenMetadataURI: props.tokenMetadataURI,
|
|
4581
|
-
salesConfig:
|
|
4582
|
-
props.salesConfig,
|
|
4583
|
-
contractName
|
|
4584
|
-
)
|
|
4593
|
+
salesConfig: getSalesConfigWithDefaults(props.salesConfig, contractName)
|
|
4585
4594
|
};
|
|
4586
4595
|
}
|
|
4587
4596
|
function buildSetupNewToken({
|
|
@@ -4643,7 +4652,7 @@ function makeAdminMintCall({
|
|
|
4643
4652
|
args: [ownerAddress, nextTokenId, BigInt(mintQuantity), zeroAddress5]
|
|
4644
4653
|
});
|
|
4645
4654
|
}
|
|
4646
|
-
|
|
4655
|
+
function constructCreate1155TokenCalls(props) {
|
|
4647
4656
|
const {
|
|
4648
4657
|
chainId,
|
|
4649
4658
|
nextTokenId,
|
|
@@ -4651,7 +4660,7 @@ async function constructCreate1155TokenCalls(props) {
|
|
|
4651
4660
|
ownerAddress,
|
|
4652
4661
|
contractVersion
|
|
4653
4662
|
} = props;
|
|
4654
|
-
const new1155TokenPropsWithDefaults =
|
|
4663
|
+
const new1155TokenPropsWithDefaults = applyNew1155Defaults(
|
|
4655
4664
|
props,
|
|
4656
4665
|
ownerAddress,
|
|
4657
4666
|
props.contractName
|
|
@@ -4724,7 +4733,6 @@ async function toSalesStrategyFromSubgraph({
|
|
|
4724
4733
|
// for now we hardcode this
|
|
4725
4734
|
mintFeePerQuantity: parseEther3("0.000111"),
|
|
4726
4735
|
saleStart: salesConfig.saleStart.toString(),
|
|
4727
|
-
saleEnd: salesConfig.saleEnd.toString(),
|
|
4728
4736
|
// the following are not needed for now but we wanna satisfy concrete
|
|
4729
4737
|
erc20Z: zeroAddress6,
|
|
4730
4738
|
mintFee: 0n,
|
|
@@ -4926,7 +4934,7 @@ async function createNew1155ContractAndToken({
|
|
|
4926
4934
|
minter,
|
|
4927
4935
|
newToken,
|
|
4928
4936
|
setupActions: tokenSetupActions
|
|
4929
|
-
} =
|
|
4937
|
+
} = prepareSetupActions({
|
|
4930
4938
|
chainId,
|
|
4931
4939
|
account,
|
|
4932
4940
|
contractVersion,
|
|
@@ -4986,7 +4994,7 @@ async function createNew1155Token({
|
|
|
4986
4994
|
minter,
|
|
4987
4995
|
newToken,
|
|
4988
4996
|
setupActions: tokenSetupActions
|
|
4989
|
-
} =
|
|
4997
|
+
} = prepareSetupActions({
|
|
4990
4998
|
chainId,
|
|
4991
4999
|
account,
|
|
4992
5000
|
contractVersion,
|
|
@@ -5018,7 +5026,7 @@ async function createNew1155Token({
|
|
|
5018
5026
|
prepareMint
|
|
5019
5027
|
};
|
|
5020
5028
|
}
|
|
5021
|
-
|
|
5029
|
+
function prepareSetupActions({
|
|
5022
5030
|
chainId,
|
|
5023
5031
|
account,
|
|
5024
5032
|
contractVersion,
|
|
@@ -5031,7 +5039,7 @@ async function prepareSetupActions({
|
|
|
5031
5039
|
minter,
|
|
5032
5040
|
newToken,
|
|
5033
5041
|
setupActions: tokenSetupActions
|
|
5034
|
-
} =
|
|
5042
|
+
} = constructCreate1155TokenCalls({
|
|
5035
5043
|
chainId,
|
|
5036
5044
|
ownerAddress: account,
|
|
5037
5045
|
contractVersion,
|