@zoralabs/protocol-sdk 0.9.0 → 0.9.1
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/create/1155-create-helper.d.ts.map +1 -1
- package/dist/create/mint-from-create.d.ts +12 -0
- package/dist/create/mint-from-create.d.ts.map +1 -0
- package/dist/create/types.d.ts +2 -0
- package/dist/create/types.d.ts.map +1 -1
- package/dist/index.cjs +154 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +127 -13
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-queries.d.ts +3 -1
- package/dist/mint/mint-queries.d.ts.map +1 -1
- package/dist/mint/types.d.ts +1 -0
- package/dist/mint/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/create/1155-create-helper.test.ts +36 -58
- package/src/create/1155-create-helper.ts +21 -0
- package/src/create/mint-from-create.ts +119 -0
- package/src/create/types.ts +2 -0
- package/src/mint/mint-queries.ts +8 -8
- package/src/mint/types.ts +3 -0
package/dist/index.js
CHANGED
|
@@ -4067,7 +4067,7 @@ var makeOnchainPrepareMint = (result) => (params) => {
|
|
|
4067
4067
|
token: result,
|
|
4068
4068
|
mintParams: params
|
|
4069
4069
|
}),
|
|
4070
|
-
erc20Approval: getRequiredErc20Approvals(params, result),
|
|
4070
|
+
erc20Approval: getRequiredErc20Approvals(params, result.salesConfig),
|
|
4071
4071
|
costs: parseMintCosts({
|
|
4072
4072
|
salesConfig: result.salesConfig,
|
|
4073
4073
|
quantityToMint: BigInt(params.quantityToMint),
|
|
@@ -4100,13 +4100,13 @@ function toPremintMintReturn({
|
|
|
4100
4100
|
prepareMint: makePremintPrepareMint(mintable, mintFee, premint)
|
|
4101
4101
|
};
|
|
4102
4102
|
}
|
|
4103
|
-
function getRequiredErc20Approvals(params,
|
|
4104
|
-
if (
|
|
4103
|
+
function getRequiredErc20Approvals(params, salesConfig) {
|
|
4104
|
+
if (salesConfig?.saleType !== "erc20")
|
|
4105
4105
|
return void 0;
|
|
4106
4106
|
return {
|
|
4107
|
-
quantity:
|
|
4108
|
-
approveTo:
|
|
4109
|
-
erc20:
|
|
4107
|
+
quantity: salesConfig.pricePerToken * BigInt(params.quantityToMint),
|
|
4108
|
+
approveTo: salesConfig.address,
|
|
4109
|
+
erc20: salesConfig.currency
|
|
4110
4110
|
};
|
|
4111
4111
|
}
|
|
4112
4112
|
|
|
@@ -4212,7 +4212,7 @@ async function mint({
|
|
|
4212
4212
|
import {
|
|
4213
4213
|
zoraCreator1155FactoryImplABI as zoraCreator1155FactoryImplABI2,
|
|
4214
4214
|
zoraCreator1155FactoryImplAddress as zoraCreator1155FactoryImplAddress2,
|
|
4215
|
-
zoraCreator1155ImplABI as
|
|
4215
|
+
zoraCreator1155ImplABI as zoraCreator1155ImplABI7
|
|
4216
4216
|
} from "@zoralabs/protocol-deployments";
|
|
4217
4217
|
import { decodeEventLog as decodeEventLog2 } from "viem";
|
|
4218
4218
|
|
|
@@ -5814,13 +5814,109 @@ var contractSupportsMintRewards = (contractVersion, contractStandard) => {
|
|
|
5814
5814
|
}
|
|
5815
5815
|
};
|
|
5816
5816
|
|
|
5817
|
+
// src/create/mint-from-create.ts
|
|
5818
|
+
import { parseEther as parseEther3, zeroAddress as zeroAddress6 } from "viem";
|
|
5819
|
+
import { zoraCreator1155ImplABI as zoraCreator1155ImplABI6 } from "@zoralabs/protocol-deployments";
|
|
5820
|
+
async function toSalesStrategyFromSubgraph({
|
|
5821
|
+
minter,
|
|
5822
|
+
salesConfig,
|
|
5823
|
+
publicClient,
|
|
5824
|
+
contractAddress
|
|
5825
|
+
}) {
|
|
5826
|
+
if (salesConfig.type === "timed") {
|
|
5827
|
+
return {
|
|
5828
|
+
saleType: "timed",
|
|
5829
|
+
address: minter,
|
|
5830
|
+
// for now we hardcode this
|
|
5831
|
+
mintFeePerQuantity: parseEther3("0.000111"),
|
|
5832
|
+
saleStart: salesConfig.saleStart.toString(),
|
|
5833
|
+
saleEnd: salesConfig.saleEnd.toString(),
|
|
5834
|
+
// the following are not needed for now but we wanna satisfy concrete
|
|
5835
|
+
erc20Z: zeroAddress6,
|
|
5836
|
+
mintFee: 0n,
|
|
5837
|
+
pool: zeroAddress6,
|
|
5838
|
+
secondaryActivated: false
|
|
5839
|
+
};
|
|
5840
|
+
}
|
|
5841
|
+
if (salesConfig.type === "erc20Mint") {
|
|
5842
|
+
return {
|
|
5843
|
+
saleType: "erc20",
|
|
5844
|
+
address: minter,
|
|
5845
|
+
mintFeePerQuantity: 0n,
|
|
5846
|
+
saleStart: salesConfig.saleStart.toString(),
|
|
5847
|
+
saleEnd: salesConfig.saleEnd.toString(),
|
|
5848
|
+
currency: salesConfig.currency,
|
|
5849
|
+
pricePerToken: salesConfig.pricePerToken,
|
|
5850
|
+
maxTokensPerAddress: salesConfig.maxTokensPerAddress
|
|
5851
|
+
};
|
|
5852
|
+
}
|
|
5853
|
+
const contractMintFee = await publicClient.readContract({
|
|
5854
|
+
abi: zoraCreator1155ImplABI6,
|
|
5855
|
+
address: contractAddress,
|
|
5856
|
+
functionName: "mintFee"
|
|
5857
|
+
});
|
|
5858
|
+
if (salesConfig.type === "fixedPrice") {
|
|
5859
|
+
return {
|
|
5860
|
+
saleType: "fixedPrice",
|
|
5861
|
+
address: minter,
|
|
5862
|
+
maxTokensPerAddress: salesConfig.maxTokensPerAddress,
|
|
5863
|
+
mintFeePerQuantity: contractMintFee,
|
|
5864
|
+
pricePerToken: salesConfig.pricePerToken,
|
|
5865
|
+
saleStart: salesConfig.saleStart.toString(),
|
|
5866
|
+
saleEnd: salesConfig.saleEnd.toString()
|
|
5867
|
+
};
|
|
5868
|
+
}
|
|
5869
|
+
return {
|
|
5870
|
+
saleType: "allowlist",
|
|
5871
|
+
address: minter,
|
|
5872
|
+
saleStart: salesConfig.saleStart.toString(),
|
|
5873
|
+
saleEnd: salesConfig.saleEnd.toString(),
|
|
5874
|
+
merkleRoot: salesConfig.presaleMerkleRoot,
|
|
5875
|
+
mintFeePerQuantity: contractMintFee
|
|
5876
|
+
};
|
|
5877
|
+
}
|
|
5878
|
+
function makeOnchainPrepareMintFromCreate({
|
|
5879
|
+
contractAddress,
|
|
5880
|
+
tokenId,
|
|
5881
|
+
result,
|
|
5882
|
+
minter,
|
|
5883
|
+
publicClient,
|
|
5884
|
+
contractVersion
|
|
5885
|
+
}) {
|
|
5886
|
+
return async (params) => {
|
|
5887
|
+
const subgraphSalesConfig = await toSalesStrategyFromSubgraph({
|
|
5888
|
+
minter,
|
|
5889
|
+
contractAddress,
|
|
5890
|
+
publicClient,
|
|
5891
|
+
salesConfig: result
|
|
5892
|
+
});
|
|
5893
|
+
return {
|
|
5894
|
+
parameters: makePrepareMint1155TokenParams({
|
|
5895
|
+
salesConfigAndTokenInfo: {
|
|
5896
|
+
salesConfig: subgraphSalesConfig,
|
|
5897
|
+
contractVersion
|
|
5898
|
+
},
|
|
5899
|
+
...params,
|
|
5900
|
+
tokenContract: contractAddress,
|
|
5901
|
+
tokenId
|
|
5902
|
+
}),
|
|
5903
|
+
costs: parseMintCosts({
|
|
5904
|
+
allowListEntry: params.allowListEntry,
|
|
5905
|
+
quantityToMint: BigInt(params.quantityToMint),
|
|
5906
|
+
salesConfig: subgraphSalesConfig
|
|
5907
|
+
}),
|
|
5908
|
+
erc20Approval: getRequiredErc20Approvals(params, subgraphSalesConfig)
|
|
5909
|
+
};
|
|
5910
|
+
};
|
|
5911
|
+
}
|
|
5912
|
+
|
|
5817
5913
|
// src/create/1155-create-helper.ts
|
|
5818
5914
|
var ROYALTY_BPS_DEFAULT = 1e3;
|
|
5819
5915
|
var getTokenIdFromCreateReceipt = (receipt) => {
|
|
5820
5916
|
for (const data of receipt.logs) {
|
|
5821
5917
|
try {
|
|
5822
5918
|
const decodedLog = decodeEventLog2({
|
|
5823
|
-
abi:
|
|
5919
|
+
abi: zoraCreator1155ImplABI7,
|
|
5824
5920
|
eventName: "SetupNewToken",
|
|
5825
5921
|
...data
|
|
5826
5922
|
});
|
|
@@ -5886,7 +5982,7 @@ function makeCreateTokenCall({
|
|
|
5886
5982
|
tokenSetupActions
|
|
5887
5983
|
}) {
|
|
5888
5984
|
return makeContractParameters({
|
|
5889
|
-
abi:
|
|
5985
|
+
abi: zoraCreator1155ImplABI7,
|
|
5890
5986
|
functionName: "multicall",
|
|
5891
5987
|
account,
|
|
5892
5988
|
address: contractAddress,
|
|
@@ -5961,6 +6057,14 @@ async function createNew1155ContractAndToken({
|
|
|
5961
6057
|
chainId,
|
|
5962
6058
|
contract
|
|
5963
6059
|
});
|
|
6060
|
+
const prepareMint = makeOnchainPrepareMintFromCreate({
|
|
6061
|
+
contractAddress,
|
|
6062
|
+
contractVersion,
|
|
6063
|
+
minter,
|
|
6064
|
+
publicClient,
|
|
6065
|
+
result: newToken.salesConfig,
|
|
6066
|
+
tokenId: nextTokenId
|
|
6067
|
+
});
|
|
5964
6068
|
return {
|
|
5965
6069
|
parameters: request,
|
|
5966
6070
|
tokenSetupActions,
|
|
@@ -5968,7 +6072,8 @@ async function createNew1155ContractAndToken({
|
|
|
5968
6072
|
newToken,
|
|
5969
6073
|
contractAddress,
|
|
5970
6074
|
contractVersion,
|
|
5971
|
-
minter
|
|
6075
|
+
minter,
|
|
6076
|
+
prepareMint
|
|
5972
6077
|
};
|
|
5973
6078
|
}
|
|
5974
6079
|
async function createNew1155Token({
|
|
@@ -6000,13 +6105,22 @@ async function createNew1155Token({
|
|
|
6000
6105
|
account,
|
|
6001
6106
|
tokenSetupActions
|
|
6002
6107
|
});
|
|
6108
|
+
const prepareMint = makeOnchainPrepareMintFromCreate({
|
|
6109
|
+
contractAddress,
|
|
6110
|
+
contractVersion,
|
|
6111
|
+
minter,
|
|
6112
|
+
publicClient,
|
|
6113
|
+
result: newToken.salesConfig,
|
|
6114
|
+
tokenId: nextTokenId
|
|
6115
|
+
});
|
|
6003
6116
|
return {
|
|
6004
6117
|
parameters: request,
|
|
6005
6118
|
tokenSetupActions,
|
|
6006
6119
|
newTokenId: nextTokenId,
|
|
6007
6120
|
newToken,
|
|
6008
6121
|
contractVersion,
|
|
6009
|
-
minter
|
|
6122
|
+
minter,
|
|
6123
|
+
prepareMint
|
|
6010
6124
|
};
|
|
6011
6125
|
}
|
|
6012
6126
|
async function prepareSetupActions({
|
|
@@ -6107,7 +6221,7 @@ import {
|
|
|
6107
6221
|
import {
|
|
6108
6222
|
decodeErrorResult,
|
|
6109
6223
|
encodeFunctionData as encodeFunctionData3,
|
|
6110
|
-
zeroAddress as
|
|
6224
|
+
zeroAddress as zeroAddress7
|
|
6111
6225
|
} from "viem";
|
|
6112
6226
|
var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
|
|
6113
6227
|
var mintWithEthParams = ({
|
|
@@ -6264,7 +6378,7 @@ var encodePremintOnManager = ({
|
|
|
6264
6378
|
premintConfig,
|
|
6265
6379
|
premintSignature,
|
|
6266
6380
|
mintArguments,
|
|
6267
|
-
signerContract =
|
|
6381
|
+
signerContract = zeroAddress7
|
|
6268
6382
|
}) => encodeFunctionData3({
|
|
6269
6383
|
abi: zoraMintsManagerImplConfig.abi,
|
|
6270
6384
|
functionName: "collectPremintV2",
|