@zoralabs/protocol-sdk 0.11.8 → 0.11.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 +7 -7
- package/CHANGELOG.md +17 -0
- package/dist/create/mint-from-create.d.ts +2 -1
- package/dist/create/mint-from-create.d.ts.map +1 -1
- package/dist/index.cjs +202 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +208 -50
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-client.d.ts +3 -1
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/mint-queries.d.ts +5 -3
- package/dist/mint/mint-queries.d.ts.map +1 -1
- package/dist/mint/mint-transactions.d.ts +4 -2
- package/dist/mint/mint-transactions.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +27 -27
- package/dist/sdk.d.ts.map +1 -1
- package/dist/secondary/secondary-client.d.ts +2 -1
- package/dist/secondary/secondary-client.d.ts.map +1 -1
- package/dist/secondary/types.d.ts +1 -0
- package/dist/secondary/types.d.ts.map +1 -1
- package/dist/sparks/sparks-contracts.d.ts +1 -1
- package/dist/test-utils.d.ts +5 -1
- package/dist/test-utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/comments/comments.test.ts +338 -0
- package/src/create/1155-create-helper.test.ts +6 -12
- package/src/create/1155-create-helper.ts +2 -0
- package/src/create/mint-from-create.ts +3 -0
- package/src/create/minter-defaults.ts +7 -7
- package/src/mint/mint-client.test.ts +67 -30
- package/src/mint/mint-client.ts +10 -1
- package/src/mint/mint-queries.ts +16 -5
- package/src/mint/mint-transactions.ts +80 -16
- package/src/sdk.ts +1 -0
- package/src/secondary/secondary-client.test.ts +248 -2
- package/src/secondary/secondary-client.ts +136 -6
- package/src/secondary/types.ts +2 -0
- package/src/sparks/sparks-contracts.ts +1 -1
- package/src/sparks/sparks-sponsored-sparks-spender.test.ts +1 -0
- package/src/test-utils.ts +19 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @zoralabs/protocol-sdk@0.11.
|
|
2
|
+
> @zoralabs/protocol-sdk@0.11.10 build /home/runner/work/zora-protocol-private/zora-protocol-private/packages/protocol-sdk
|
|
3
3
|
> pnpm tsup
|
|
4
4
|
|
|
5
5
|
CLI Building entry: src/index.ts
|
|
@@ -10,9 +10,9 @@ CLI Target: es2021
|
|
|
10
10
|
CLI Cleaning output folder
|
|
11
11
|
CJS Build start
|
|
12
12
|
ESM Build start
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
CJS dist/index.cjs 229.00 KB
|
|
14
|
+
CJS dist/index.cjs.map 463.84 KB
|
|
15
|
+
CJS ⚡️ Build success in 457ms
|
|
16
|
+
ESM dist/index.js 222.71 KB
|
|
17
|
+
ESM dist/index.js.map 462.00 KB
|
|
18
|
+
ESM ⚡️ Build success in 463ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @zoralabs/protocol-sdk
|
|
2
2
|
|
|
3
|
+
## 0.11.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a1137e35: saleStart defaults to current timestamp in seconds
|
|
8
|
+
- Updated dependencies [abbd6333]
|
|
9
|
+
- @zoralabs/protocol-deployments@0.3.10
|
|
10
|
+
|
|
11
|
+
## 0.11.9
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 9d5d1638: When minting + commenting, and using the timed sale strategy, protocol sdk will call the CallerAndCommenter contract
|
|
16
|
+
- 088ec6fb: When buying on secondary, you can now add a comment, which will call the CallerAndCommenter's buyOnSecondaryAndComment function.
|
|
17
|
+
- Updated dependencies [4928687d]
|
|
18
|
+
- @zoralabs/protocol-deployments@0.3.9
|
|
19
|
+
|
|
3
20
|
## 0.11.8
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Address } from "viem";
|
|
2
2
|
import { ConcreteSalesConfig } from "./types";
|
|
3
3
|
import { AsyncPrepareMint } from "src/mint/types";
|
|
4
|
-
export declare function makeOnchainPrepareMintFromCreate({ contractAddress, tokenId, result, minter, getContractMintFee, contractVersion, }: {
|
|
4
|
+
export declare function makeOnchainPrepareMintFromCreate({ contractAddress, tokenId, result, minter, getContractMintFee, contractVersion, chainId, }: {
|
|
5
5
|
contractAddress: Address;
|
|
6
6
|
tokenId: bigint;
|
|
7
7
|
result: ConcreteSalesConfig;
|
|
8
8
|
minter: Address;
|
|
9
9
|
getContractMintFee: () => Promise<bigint>;
|
|
10
10
|
contractVersion: string;
|
|
11
|
+
chainId: number;
|
|
11
12
|
}): AsyncPrepareMint;
|
|
12
13
|
//# sourceMappingURL=mint-from-create.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mint-from-create.d.ts","sourceRoot":"","sources":["../../src/create/mint-from-create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2B,MAAM,MAAM,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAIjB,MAAM,gBAAgB,CAAC;AA+DxB,wBAAgB,gCAAgC,CAAC,EAC/C,eAAe,EACf,OAAO,EACP,MAAM,EACN,MAAM,EACN,kBAAkB,EAClB,eAAe,
|
|
1
|
+
{"version":3,"file":"mint-from-create.d.ts","sourceRoot":"","sources":["../../src/create/mint-from-create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2B,MAAM,MAAM,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAIjB,MAAM,gBAAgB,CAAC;AA+DxB,wBAAgB,gCAAgC,CAAC,EAC/C,eAAe,EACf,OAAO,EACP,MAAM,EACN,MAAM,EACN,kBAAkB,EAClB,eAAe,EACf,OAAO,GACR,EAAE;IACD,eAAe,EAAE,OAAO,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,MAAM,EAAE,OAAO,CAAC;IAChB,kBAAkB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,gBAAgB,CA0BnB"}
|
package/dist/index.cjs
CHANGED
|
@@ -3773,7 +3773,8 @@ var contractSupportsNewMintFunction = (contractVersion) => {
|
|
|
3773
3773
|
// src/mint/mint-transactions.ts
|
|
3774
3774
|
function makeOnchainMintCall({
|
|
3775
3775
|
token,
|
|
3776
|
-
mintParams
|
|
3776
|
+
mintParams,
|
|
3777
|
+
chainId
|
|
3777
3778
|
}) {
|
|
3778
3779
|
if (token.mintType === "721") {
|
|
3779
3780
|
return makePrepareMint721TokenParams({
|
|
@@ -3786,9 +3787,55 @@ function makeOnchainMintCall({
|
|
|
3786
3787
|
salesConfigAndTokenInfo: token,
|
|
3787
3788
|
tokenContract: token.contract.address,
|
|
3788
3789
|
tokenId: token.tokenId,
|
|
3790
|
+
chainId,
|
|
3789
3791
|
...mintParams
|
|
3790
3792
|
});
|
|
3791
3793
|
}
|
|
3794
|
+
function makeZoraTimedSaleStrategyMintCall({
|
|
3795
|
+
minterAccount,
|
|
3796
|
+
salesConfigAndTokenInfo,
|
|
3797
|
+
mintQuantity,
|
|
3798
|
+
mintTo,
|
|
3799
|
+
tokenContract,
|
|
3800
|
+
tokenId,
|
|
3801
|
+
mintReferral,
|
|
3802
|
+
mintComment,
|
|
3803
|
+
chainId
|
|
3804
|
+
}) {
|
|
3805
|
+
if (mintComment && mintComment !== "") {
|
|
3806
|
+
return makeContractParameters({
|
|
3807
|
+
abi: import_protocol_deployments6.callerAndCommenterABI,
|
|
3808
|
+
address: import_protocol_deployments6.callerAndCommenterAddress[chainId],
|
|
3809
|
+
functionName: "timedSaleMintAndComment",
|
|
3810
|
+
account: minterAccount,
|
|
3811
|
+
value: salesConfigAndTokenInfo.salesConfig.mintFeePerQuantity * mintQuantity,
|
|
3812
|
+
args: [
|
|
3813
|
+
mintTo,
|
|
3814
|
+
mintQuantity,
|
|
3815
|
+
tokenContract,
|
|
3816
|
+
tokenId,
|
|
3817
|
+
mintReferral || import_viem5.zeroAddress,
|
|
3818
|
+
mintComment
|
|
3819
|
+
]
|
|
3820
|
+
});
|
|
3821
|
+
}
|
|
3822
|
+
return makeContractParameters({
|
|
3823
|
+
abi: import_protocol_deployments6.zoraTimedSaleStrategyABI,
|
|
3824
|
+
functionName: "mint",
|
|
3825
|
+
account: minterAccount,
|
|
3826
|
+
address: salesConfigAndTokenInfo.salesConfig.address,
|
|
3827
|
+
value: salesConfigAndTokenInfo.salesConfig.mintFeePerQuantity * mintQuantity,
|
|
3828
|
+
/* args: mintTo, quantity, collection, tokenId, mintReferral, comment */
|
|
3829
|
+
args: [
|
|
3830
|
+
mintTo,
|
|
3831
|
+
mintQuantity,
|
|
3832
|
+
tokenContract,
|
|
3833
|
+
BigInt(tokenId),
|
|
3834
|
+
mintReferral || import_viem5.zeroAddress,
|
|
3835
|
+
""
|
|
3836
|
+
]
|
|
3837
|
+
});
|
|
3838
|
+
}
|
|
3792
3839
|
function makePrepareMint1155TokenParams({
|
|
3793
3840
|
tokenContract,
|
|
3794
3841
|
tokenId,
|
|
@@ -3798,7 +3845,8 @@ function makePrepareMint1155TokenParams({
|
|
|
3798
3845
|
mintReferral,
|
|
3799
3846
|
mintRecipient,
|
|
3800
3847
|
quantityToMint,
|
|
3801
|
-
allowListEntry
|
|
3848
|
+
allowListEntry,
|
|
3849
|
+
chainId
|
|
3802
3850
|
}) {
|
|
3803
3851
|
const mintQuantity = BigInt(quantityToMint || 1);
|
|
3804
3852
|
const mintTo = mintRecipientOrAccount({ mintRecipient, minterAccount });
|
|
@@ -3817,21 +3865,16 @@ function makePrepareMint1155TokenParams({
|
|
|
3817
3865
|
});
|
|
3818
3866
|
}
|
|
3819
3867
|
if (saleType === "timed") {
|
|
3820
|
-
return
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
tokenContract,
|
|
3831
|
-
BigInt(tokenId),
|
|
3832
|
-
mintReferral || import_viem5.zeroAddress,
|
|
3833
|
-
mintComment || ""
|
|
3834
|
-
]
|
|
3868
|
+
return makeZoraTimedSaleStrategyMintCall({
|
|
3869
|
+
minterAccount,
|
|
3870
|
+
salesConfigAndTokenInfo,
|
|
3871
|
+
mintQuantity,
|
|
3872
|
+
mintTo,
|
|
3873
|
+
tokenContract,
|
|
3874
|
+
tokenId,
|
|
3875
|
+
mintReferral,
|
|
3876
|
+
mintComment,
|
|
3877
|
+
chainId
|
|
3835
3878
|
});
|
|
3836
3879
|
}
|
|
3837
3880
|
if (saleType === "erc20") {
|
|
@@ -3996,7 +4039,8 @@ async function getMint({
|
|
|
3996
4039
|
params,
|
|
3997
4040
|
mintGetter,
|
|
3998
4041
|
premintGetter,
|
|
3999
|
-
publicClient
|
|
4042
|
+
publicClient,
|
|
4043
|
+
chainId
|
|
4000
4044
|
}) {
|
|
4001
4045
|
const { tokenContract } = params;
|
|
4002
4046
|
if (isOnChainMint(params)) {
|
|
@@ -4008,7 +4052,7 @@ async function getMint({
|
|
|
4008
4052
|
preferredSaleType: params.preferredSaleType,
|
|
4009
4053
|
blockTime
|
|
4010
4054
|
});
|
|
4011
|
-
return toMintableReturn(result);
|
|
4055
|
+
return toMintableReturn(result, chainId);
|
|
4012
4056
|
}
|
|
4013
4057
|
const premint = await premintGetter.get({
|
|
4014
4058
|
collectionAddress: tokenContract,
|
|
@@ -4046,11 +4090,12 @@ async function getMintsOfContract({
|
|
|
4046
4090
|
params,
|
|
4047
4091
|
mintGetter,
|
|
4048
4092
|
premintGetter,
|
|
4049
|
-
publicClient
|
|
4093
|
+
publicClient,
|
|
4094
|
+
chainId
|
|
4050
4095
|
}) {
|
|
4051
4096
|
const onchainMints = (await mintGetter.getContractMintable({
|
|
4052
4097
|
tokenAddress: params.tokenContract
|
|
4053
|
-
})).map(toMintableReturn);
|
|
4098
|
+
})).map((result) => toMintableReturn(result, chainId));
|
|
4054
4099
|
const offchainMints = await getPremintsOfContractMintable({
|
|
4055
4100
|
mintGetter,
|
|
4056
4101
|
premintGetter,
|
|
@@ -4167,14 +4212,15 @@ function parsePremint({
|
|
|
4167
4212
|
}
|
|
4168
4213
|
throw new Error("Invalid premint config version");
|
|
4169
4214
|
}
|
|
4170
|
-
var makeOnchainPrepareMint = (result) => (params) => {
|
|
4215
|
+
var makeOnchainPrepareMint = (result, chainId) => (params) => {
|
|
4171
4216
|
if (!result.salesConfig) {
|
|
4172
4217
|
throw new Error("No valid sales config found for token");
|
|
4173
4218
|
}
|
|
4174
4219
|
return {
|
|
4175
4220
|
parameters: makeOnchainMintCall({
|
|
4176
4221
|
token: result,
|
|
4177
|
-
mintParams: params
|
|
4222
|
+
mintParams: params,
|
|
4223
|
+
chainId
|
|
4178
4224
|
}),
|
|
4179
4225
|
erc20Approval: getRequiredErc20Approvals(params, result.salesConfig),
|
|
4180
4226
|
costs: parseMintCosts({
|
|
@@ -4184,7 +4230,7 @@ var makeOnchainPrepareMint = (result) => (params) => {
|
|
|
4184
4230
|
})
|
|
4185
4231
|
};
|
|
4186
4232
|
};
|
|
4187
|
-
function toMintableReturn(result) {
|
|
4233
|
+
function toMintableReturn(result, chainId) {
|
|
4188
4234
|
const primaryMintActive = result.primaryMintActive;
|
|
4189
4235
|
if (!primaryMintActive) {
|
|
4190
4236
|
return {
|
|
@@ -4200,7 +4246,10 @@ function toMintableReturn(result) {
|
|
|
4200
4246
|
primaryMintActive,
|
|
4201
4247
|
primaryMintEnd: result.primaryMintEnd,
|
|
4202
4248
|
secondaryMarketActive: result.secondaryMarketActive,
|
|
4203
|
-
prepareMint: makeOnchainPrepareMint(
|
|
4249
|
+
prepareMint: makeOnchainPrepareMint(
|
|
4250
|
+
result.salesConfigAndTokenInfo,
|
|
4251
|
+
chainId
|
|
4252
|
+
)
|
|
4204
4253
|
};
|
|
4205
4254
|
}
|
|
4206
4255
|
var makePremintPrepareMint = (mintable, mintFee, premint) => {
|
|
@@ -4263,11 +4312,13 @@ var MintClient = class {
|
|
|
4263
4312
|
constructor({
|
|
4264
4313
|
publicClient,
|
|
4265
4314
|
premintGetter,
|
|
4266
|
-
mintGetter
|
|
4315
|
+
mintGetter,
|
|
4316
|
+
chainId
|
|
4267
4317
|
}) {
|
|
4268
4318
|
this.publicClient = publicClient;
|
|
4269
4319
|
this.mintGetter = mintGetter;
|
|
4270
4320
|
this.premintGetter = premintGetter;
|
|
4321
|
+
this.chainId = chainId;
|
|
4271
4322
|
}
|
|
4272
4323
|
/**
|
|
4273
4324
|
* Returns the parameters needed to prepare a transaction mint a token.
|
|
@@ -4281,7 +4332,8 @@ var MintClient = class {
|
|
|
4281
4332
|
parameters,
|
|
4282
4333
|
publicClient: this.publicClient,
|
|
4283
4334
|
mintGetter: this.mintGetter,
|
|
4284
|
-
premintGetter: this.premintGetter
|
|
4335
|
+
premintGetter: this.premintGetter,
|
|
4336
|
+
chainId: this.chainId
|
|
4285
4337
|
});
|
|
4286
4338
|
}
|
|
4287
4339
|
/**
|
|
@@ -4295,7 +4347,8 @@ var MintClient = class {
|
|
|
4295
4347
|
params: parameters,
|
|
4296
4348
|
mintGetter: this.mintGetter,
|
|
4297
4349
|
premintGetter: this.premintGetter,
|
|
4298
|
-
publicClient: this.publicClient
|
|
4350
|
+
publicClient: this.publicClient,
|
|
4351
|
+
chainId: this.chainId
|
|
4299
4352
|
});
|
|
4300
4353
|
}
|
|
4301
4354
|
/**
|
|
@@ -4309,7 +4362,8 @@ var MintClient = class {
|
|
|
4309
4362
|
params,
|
|
4310
4363
|
mintGetter: this.mintGetter,
|
|
4311
4364
|
premintGetter: this.premintGetter,
|
|
4312
|
-
publicClient: this.publicClient
|
|
4365
|
+
publicClient: this.publicClient,
|
|
4366
|
+
chainId: this.chainId
|
|
4313
4367
|
});
|
|
4314
4368
|
}
|
|
4315
4369
|
/**
|
|
@@ -4330,13 +4384,15 @@ async function mint({
|
|
|
4330
4384
|
parameters,
|
|
4331
4385
|
publicClient,
|
|
4332
4386
|
mintGetter,
|
|
4333
|
-
premintGetter
|
|
4387
|
+
premintGetter,
|
|
4388
|
+
chainId
|
|
4334
4389
|
}) {
|
|
4335
4390
|
const { prepareMint, primaryMintActive } = await getMint({
|
|
4336
4391
|
params: parameters,
|
|
4337
4392
|
mintGetter,
|
|
4338
4393
|
premintGetter,
|
|
4339
|
-
publicClient
|
|
4394
|
+
publicClient,
|
|
4395
|
+
chainId
|
|
4340
4396
|
});
|
|
4341
4397
|
if (!primaryMintActive) {
|
|
4342
4398
|
throw new Error("Primary mint is not active");
|
|
@@ -4407,28 +4463,28 @@ var import_viem7 = require("viem");
|
|
|
4407
4463
|
var DEFAULT_MINIMUM_MARKET_ETH = (0, import_viem7.parseEther)("0.0123321");
|
|
4408
4464
|
var DEFAULT_MARKET_COUNTDOWN = BigInt(24 * 60 * 60);
|
|
4409
4465
|
var SALE_END_FOREVER = 18446744073709551615n;
|
|
4410
|
-
var DEFAULT_SALE_START_AND_END = {
|
|
4411
|
-
// Sale start time –
|
|
4412
|
-
saleStart:
|
|
4466
|
+
var DEFAULT_SALE_START_AND_END = () => ({
|
|
4467
|
+
// Sale start time – defaults to current time in seconds
|
|
4468
|
+
saleStart: BigInt(Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3)),
|
|
4413
4469
|
// This is the end of uint64, plenty of time
|
|
4414
4470
|
saleEnd: SALE_END_FOREVER
|
|
4415
|
-
};
|
|
4471
|
+
});
|
|
4416
4472
|
var DEFAULT_MAX_TOKENS_PER_ADDRESS = {
|
|
4417
4473
|
maxTokensPerAddress: 0n
|
|
4418
4474
|
};
|
|
4419
4475
|
var erc20SaleSettingsWithDefaults = (params) => ({
|
|
4420
|
-
...DEFAULT_SALE_START_AND_END,
|
|
4476
|
+
...DEFAULT_SALE_START_AND_END(),
|
|
4421
4477
|
...DEFAULT_MAX_TOKENS_PER_ADDRESS,
|
|
4422
4478
|
...params
|
|
4423
4479
|
});
|
|
4424
4480
|
var allowListWithDefaults = (allowlist) => {
|
|
4425
4481
|
return {
|
|
4426
|
-
...DEFAULT_SALE_START_AND_END,
|
|
4482
|
+
...DEFAULT_SALE_START_AND_END(),
|
|
4427
4483
|
...allowlist
|
|
4428
4484
|
};
|
|
4429
4485
|
};
|
|
4430
4486
|
var fixedPriceSettingsWithDefaults = (params) => ({
|
|
4431
|
-
...DEFAULT_SALE_START_AND_END,
|
|
4487
|
+
...DEFAULT_SALE_START_AND_END(),
|
|
4432
4488
|
...DEFAULT_MAX_TOKENS_PER_ADDRESS,
|
|
4433
4489
|
type: "fixedPrice",
|
|
4434
4490
|
...params
|
|
@@ -4879,7 +4935,8 @@ function makeOnchainPrepareMintFromCreate({
|
|
|
4879
4935
|
result,
|
|
4880
4936
|
minter,
|
|
4881
4937
|
getContractMintFee,
|
|
4882
|
-
contractVersion
|
|
4938
|
+
contractVersion,
|
|
4939
|
+
chainId
|
|
4883
4940
|
}) {
|
|
4884
4941
|
return async (params) => {
|
|
4885
4942
|
const subgraphSalesConfig = await toSalesStrategyFromSubgraph({
|
|
@@ -4895,7 +4952,8 @@ function makeOnchainPrepareMintFromCreate({
|
|
|
4895
4952
|
},
|
|
4896
4953
|
...params,
|
|
4897
4954
|
tokenContract: contractAddress,
|
|
4898
|
-
tokenId
|
|
4955
|
+
tokenId,
|
|
4956
|
+
chainId
|
|
4899
4957
|
}),
|
|
4900
4958
|
costs: parseMintCosts({
|
|
4901
4959
|
allowListEntry: params.allowListEntry,
|
|
@@ -5068,7 +5126,8 @@ async function createNew1155ContractAndToken({
|
|
|
5068
5126
|
getContractMintFee: async () => getNewContractMintFee({
|
|
5069
5127
|
publicClient,
|
|
5070
5128
|
chainId
|
|
5071
|
-
})
|
|
5129
|
+
}),
|
|
5130
|
+
chainId
|
|
5072
5131
|
});
|
|
5073
5132
|
return {
|
|
5074
5133
|
parameters: request,
|
|
@@ -5114,7 +5173,8 @@ async function createNew1155Token({
|
|
|
5114
5173
|
minter,
|
|
5115
5174
|
result: newToken.salesConfig,
|
|
5116
5175
|
tokenId: nextTokenId,
|
|
5117
|
-
getContractMintFee: async () => mintFee
|
|
5176
|
+
getContractMintFee: async () => mintFee,
|
|
5177
|
+
chainId
|
|
5118
5178
|
});
|
|
5119
5179
|
return {
|
|
5120
5180
|
parameters: request,
|
|
@@ -6030,10 +6090,13 @@ var ERROR_INSUFFICIENT_WALLET_FUNDS = "Insufficient wallet funds";
|
|
|
6030
6090
|
var ERROR_INSUFFICIENT_POOL_SUPPLY = "Insufficient pool supply";
|
|
6031
6091
|
var ERROR_SECONDARY_NOT_CONFIGURED = "Secondary not configured for given contract and token";
|
|
6032
6092
|
var ERROR_SECONDARY_NOT_STARTED = "Secondary market has not started";
|
|
6093
|
+
var ERROR_RECIPIENT_MISMATCH = "Recipient must be the same as the caller if there is a comment";
|
|
6033
6094
|
function makeError(errorMessage) {
|
|
6034
6095
|
return { error: errorMessage };
|
|
6035
6096
|
}
|
|
6036
6097
|
async function makeBuy({
|
|
6098
|
+
contract,
|
|
6099
|
+
tokenId,
|
|
6037
6100
|
erc20z,
|
|
6038
6101
|
poolBalance,
|
|
6039
6102
|
amount,
|
|
@@ -6042,20 +6105,106 @@ async function makeBuy({
|
|
|
6042
6105
|
recipient,
|
|
6043
6106
|
chainId,
|
|
6044
6107
|
slippage,
|
|
6045
|
-
publicClient
|
|
6108
|
+
publicClient,
|
|
6109
|
+
comment
|
|
6046
6110
|
}) {
|
|
6047
6111
|
const costWithSlippage = calculateSlippageUp(amount, slippage);
|
|
6048
|
-
const availableToBuy = poolBalance.erc20z / BigInt(1e18) - 1n;
|
|
6049
6112
|
const accountAddress = addressOrAccountAddress(account);
|
|
6113
|
+
const validationResult = await validateBuyConditions({
|
|
6114
|
+
poolBalance,
|
|
6115
|
+
quantity,
|
|
6116
|
+
costWithSlippage,
|
|
6117
|
+
accountAddress,
|
|
6118
|
+
publicClient
|
|
6119
|
+
});
|
|
6120
|
+
if (validationResult.error) {
|
|
6121
|
+
return makeError(validationResult.error);
|
|
6122
|
+
}
|
|
6123
|
+
if (comment && comment !== "") {
|
|
6124
|
+
return handleBuyWithComment({
|
|
6125
|
+
accountAddress,
|
|
6126
|
+
recipient,
|
|
6127
|
+
chainId,
|
|
6128
|
+
quantity,
|
|
6129
|
+
contract,
|
|
6130
|
+
tokenId,
|
|
6131
|
+
costWithSlippage,
|
|
6132
|
+
comment,
|
|
6133
|
+
account
|
|
6134
|
+
});
|
|
6135
|
+
}
|
|
6136
|
+
return handleBuyWithoutComment({
|
|
6137
|
+
erc20z,
|
|
6138
|
+
quantity,
|
|
6139
|
+
recipient,
|
|
6140
|
+
accountAddress,
|
|
6141
|
+
costWithSlippage,
|
|
6142
|
+
chainId,
|
|
6143
|
+
account
|
|
6144
|
+
});
|
|
6145
|
+
}
|
|
6146
|
+
async function validateBuyConditions({
|
|
6147
|
+
poolBalance,
|
|
6148
|
+
quantity,
|
|
6149
|
+
costWithSlippage,
|
|
6150
|
+
accountAddress,
|
|
6151
|
+
publicClient
|
|
6152
|
+
}) {
|
|
6153
|
+
const availableToBuy = poolBalance.erc20z / BigInt(1e18) - 1n;
|
|
6050
6154
|
const availableToSpend = await publicClient.getBalance({
|
|
6051
6155
|
address: accountAddress
|
|
6052
6156
|
});
|
|
6053
6157
|
if (costWithSlippage > availableToSpend) {
|
|
6054
|
-
return
|
|
6158
|
+
return { error: ERROR_INSUFFICIENT_WALLET_FUNDS };
|
|
6055
6159
|
}
|
|
6056
6160
|
if (availableToBuy < BigInt(quantity)) {
|
|
6057
|
-
return
|
|
6161
|
+
return { error: ERROR_INSUFFICIENT_POOL_SUPPLY };
|
|
6162
|
+
}
|
|
6163
|
+
return {};
|
|
6164
|
+
}
|
|
6165
|
+
function handleBuyWithComment({
|
|
6166
|
+
accountAddress,
|
|
6167
|
+
recipient,
|
|
6168
|
+
chainId,
|
|
6169
|
+
quantity,
|
|
6170
|
+
contract,
|
|
6171
|
+
tokenId,
|
|
6172
|
+
costWithSlippage,
|
|
6173
|
+
comment,
|
|
6174
|
+
account
|
|
6175
|
+
}) {
|
|
6176
|
+
if (recipient && recipient !== accountAddress) {
|
|
6177
|
+
return makeError(ERROR_RECIPIENT_MISMATCH);
|
|
6058
6178
|
}
|
|
6179
|
+
return {
|
|
6180
|
+
parameters: makeContractParameters({
|
|
6181
|
+
abi: import_protocol_deployments15.callerAndCommenterABI,
|
|
6182
|
+
address: import_protocol_deployments15.callerAndCommenterAddress[chainId],
|
|
6183
|
+
functionName: "buyOnSecondaryAndComment",
|
|
6184
|
+
args: [
|
|
6185
|
+
accountAddress,
|
|
6186
|
+
quantity,
|
|
6187
|
+
contract,
|
|
6188
|
+
tokenId,
|
|
6189
|
+
accountAddress,
|
|
6190
|
+
costWithSlippage,
|
|
6191
|
+
0n,
|
|
6192
|
+
comment
|
|
6193
|
+
],
|
|
6194
|
+
account,
|
|
6195
|
+
value: costWithSlippage
|
|
6196
|
+
})
|
|
6197
|
+
};
|
|
6198
|
+
}
|
|
6199
|
+
function handleBuyWithoutComment({
|
|
6200
|
+
erc20z,
|
|
6201
|
+
quantity,
|
|
6202
|
+
recipient,
|
|
6203
|
+
accountAddress,
|
|
6204
|
+
costWithSlippage,
|
|
6205
|
+
chainId,
|
|
6206
|
+
account
|
|
6207
|
+
}) {
|
|
6059
6208
|
return {
|
|
6060
6209
|
parameters: makeContractParameters({
|
|
6061
6210
|
abi: import_protocol_deployments15.secondarySwapABI,
|
|
@@ -6082,7 +6231,8 @@ async function buyWithSlippage({
|
|
|
6082
6231
|
chainId,
|
|
6083
6232
|
account,
|
|
6084
6233
|
slippage = UNISWAP_SLIPPAGE,
|
|
6085
|
-
recipient
|
|
6234
|
+
recipient,
|
|
6235
|
+
comment
|
|
6086
6236
|
}) {
|
|
6087
6237
|
const secondaryInfo = await getSecondaryInfo({
|
|
6088
6238
|
contract,
|
|
@@ -6109,6 +6259,8 @@ async function buyWithSlippage({
|
|
|
6109
6259
|
);
|
|
6110
6260
|
const call = await makeBuy({
|
|
6111
6261
|
erc20z,
|
|
6262
|
+
contract,
|
|
6263
|
+
tokenId,
|
|
6112
6264
|
poolBalance,
|
|
6113
6265
|
amount,
|
|
6114
6266
|
quantity,
|
|
@@ -6116,6 +6268,7 @@ async function buyWithSlippage({
|
|
|
6116
6268
|
recipient,
|
|
6117
6269
|
chainId,
|
|
6118
6270
|
slippage,
|
|
6271
|
+
comment,
|
|
6119
6272
|
publicClient
|
|
6120
6273
|
});
|
|
6121
6274
|
return {
|
|
@@ -6305,7 +6458,8 @@ function createCollectorClient(params) {
|
|
|
6305
6458
|
const mintClient = new MintClient({
|
|
6306
6459
|
publicClient: params.publicClient,
|
|
6307
6460
|
premintGetter: premintGetterToUse,
|
|
6308
|
-
mintGetter: mintGetterToUse
|
|
6461
|
+
mintGetter: mintGetterToUse,
|
|
6462
|
+
chainId: params.chainId
|
|
6309
6463
|
});
|
|
6310
6464
|
const secondaryClient = new SecondaryClient({
|
|
6311
6465
|
publicClient: params.publicClient,
|