@zoralabs/protocol-sdk 0.11.5 → 0.11.6-COMMENTS.0
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 +13 -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 +195 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +201 -43
- 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/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/test-utils.d.ts +3 -1
- package/dist/test-utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/comments/comments.test.ts +342 -0
- package/src/create/1155-create-helper.test.ts +2 -12
- package/src/create/1155-create-helper.ts +2 -0
- package/src/create/mint-from-create.ts +3 -0
- 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 +118 -2
- package/src/secondary/secondary-client.ts +136 -6
- package/src/secondary/types.ts +2 -0
- package/src/sparks/sparks-sponsored-sparks-spender.test.ts +1 -1
- package/src/test-utils.ts +12 -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.6-COMMENTS.0 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 228.29 KB
|
|
14
|
+
CJS dist/index.cjs.map 462.51 KB
|
|
15
|
+
CJS ⚡️ Build success in 392ms
|
|
16
|
+
ESM dist/index.js 222.00 KB
|
|
17
|
+
ESM dist/index.js.map 460.67 KB
|
|
18
|
+
ESM ⚡️ Build success in 399ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @zoralabs/protocol-sdk
|
|
2
2
|
|
|
3
|
+
## 0.11.6-COMMENTS.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9d5d1638: When minting + commenting, and using the timed sale strategy, protocol sdk will call the CallerAndCommenter contract
|
|
8
|
+
- 088ec6fb: When buying on secondary, you can now add a comment, which will call the CallerAndCommenter's buyOnSecondaryAndComment
|
|
9
|
+
- Updated dependencies [4928687d]
|
|
10
|
+
- Updated dependencies [c6e1c1bc]
|
|
11
|
+
- Updated dependencies [7e285fb1]
|
|
12
|
+
- Updated dependencies [17cc9821]
|
|
13
|
+
- Updated dependencies [a141e322]
|
|
14
|
+
- @zoralabs/protocol-deployments@0.3.8-COMMENTS.0
|
|
15
|
+
|
|
3
16
|
## 0.11.5
|
|
4
17
|
|
|
5
18
|
### 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");
|
|
@@ -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,
|
|
@@ -6017,10 +6077,13 @@ var ERROR_INSUFFICIENT_WALLET_FUNDS = "Insufficient wallet funds";
|
|
|
6017
6077
|
var ERROR_INSUFFICIENT_POOL_SUPPLY = "Insufficient pool supply";
|
|
6018
6078
|
var ERROR_SECONDARY_NOT_CONFIGURED = "Secondary not configured for given contract and token";
|
|
6019
6079
|
var ERROR_SECONDARY_NOT_STARTED = "Secondary market has not started";
|
|
6080
|
+
var ERROR_RECIPIENT_MISMATCH = "Recipient must be the same as the caller if there is a comment";
|
|
6020
6081
|
function makeError(errorMessage) {
|
|
6021
6082
|
return { error: errorMessage };
|
|
6022
6083
|
}
|
|
6023
6084
|
async function makeBuy({
|
|
6085
|
+
contract,
|
|
6086
|
+
tokenId,
|
|
6024
6087
|
erc20z,
|
|
6025
6088
|
poolBalance,
|
|
6026
6089
|
amount,
|
|
@@ -6029,20 +6092,106 @@ async function makeBuy({
|
|
|
6029
6092
|
recipient,
|
|
6030
6093
|
chainId,
|
|
6031
6094
|
slippage,
|
|
6032
|
-
publicClient
|
|
6095
|
+
publicClient,
|
|
6096
|
+
comment
|
|
6033
6097
|
}) {
|
|
6034
6098
|
const costWithSlippage = calculateSlippageUp(amount, slippage);
|
|
6035
|
-
const availableToBuy = poolBalance.erc20z / BigInt(1e18) - 1n;
|
|
6036
6099
|
const accountAddress = addressOrAccountAddress(account);
|
|
6100
|
+
const validationResult = await validateBuyConditions({
|
|
6101
|
+
poolBalance,
|
|
6102
|
+
quantity,
|
|
6103
|
+
costWithSlippage,
|
|
6104
|
+
accountAddress,
|
|
6105
|
+
publicClient
|
|
6106
|
+
});
|
|
6107
|
+
if (validationResult.error) {
|
|
6108
|
+
return makeError(validationResult.error);
|
|
6109
|
+
}
|
|
6110
|
+
if (comment && comment !== "") {
|
|
6111
|
+
return handleBuyWithComment({
|
|
6112
|
+
accountAddress,
|
|
6113
|
+
recipient,
|
|
6114
|
+
chainId,
|
|
6115
|
+
quantity,
|
|
6116
|
+
contract,
|
|
6117
|
+
tokenId,
|
|
6118
|
+
costWithSlippage,
|
|
6119
|
+
comment,
|
|
6120
|
+
account
|
|
6121
|
+
});
|
|
6122
|
+
}
|
|
6123
|
+
return handleBuyWithoutComment({
|
|
6124
|
+
erc20z,
|
|
6125
|
+
quantity,
|
|
6126
|
+
recipient,
|
|
6127
|
+
accountAddress,
|
|
6128
|
+
costWithSlippage,
|
|
6129
|
+
chainId,
|
|
6130
|
+
account
|
|
6131
|
+
});
|
|
6132
|
+
}
|
|
6133
|
+
async function validateBuyConditions({
|
|
6134
|
+
poolBalance,
|
|
6135
|
+
quantity,
|
|
6136
|
+
costWithSlippage,
|
|
6137
|
+
accountAddress,
|
|
6138
|
+
publicClient
|
|
6139
|
+
}) {
|
|
6140
|
+
const availableToBuy = poolBalance.erc20z / BigInt(1e18) - 1n;
|
|
6037
6141
|
const availableToSpend = await publicClient.getBalance({
|
|
6038
6142
|
address: accountAddress
|
|
6039
6143
|
});
|
|
6040
6144
|
if (costWithSlippage > availableToSpend) {
|
|
6041
|
-
return
|
|
6145
|
+
return { error: ERROR_INSUFFICIENT_WALLET_FUNDS };
|
|
6042
6146
|
}
|
|
6043
6147
|
if (availableToBuy < BigInt(quantity)) {
|
|
6044
|
-
return
|
|
6148
|
+
return { error: ERROR_INSUFFICIENT_POOL_SUPPLY };
|
|
6149
|
+
}
|
|
6150
|
+
return {};
|
|
6151
|
+
}
|
|
6152
|
+
function handleBuyWithComment({
|
|
6153
|
+
accountAddress,
|
|
6154
|
+
recipient,
|
|
6155
|
+
chainId,
|
|
6156
|
+
quantity,
|
|
6157
|
+
contract,
|
|
6158
|
+
tokenId,
|
|
6159
|
+
costWithSlippage,
|
|
6160
|
+
comment,
|
|
6161
|
+
account
|
|
6162
|
+
}) {
|
|
6163
|
+
if (recipient && recipient !== accountAddress) {
|
|
6164
|
+
return makeError(ERROR_RECIPIENT_MISMATCH);
|
|
6045
6165
|
}
|
|
6166
|
+
return {
|
|
6167
|
+
parameters: makeContractParameters({
|
|
6168
|
+
abi: import_protocol_deployments15.callerAndCommenterABI,
|
|
6169
|
+
address: import_protocol_deployments15.callerAndCommenterAddress[chainId],
|
|
6170
|
+
functionName: "buyOnSecondaryAndComment",
|
|
6171
|
+
args: [
|
|
6172
|
+
accountAddress,
|
|
6173
|
+
quantity,
|
|
6174
|
+
contract,
|
|
6175
|
+
tokenId,
|
|
6176
|
+
accountAddress,
|
|
6177
|
+
costWithSlippage,
|
|
6178
|
+
0n,
|
|
6179
|
+
comment
|
|
6180
|
+
],
|
|
6181
|
+
account,
|
|
6182
|
+
value: costWithSlippage
|
|
6183
|
+
})
|
|
6184
|
+
};
|
|
6185
|
+
}
|
|
6186
|
+
function handleBuyWithoutComment({
|
|
6187
|
+
erc20z,
|
|
6188
|
+
quantity,
|
|
6189
|
+
recipient,
|
|
6190
|
+
accountAddress,
|
|
6191
|
+
costWithSlippage,
|
|
6192
|
+
chainId,
|
|
6193
|
+
account
|
|
6194
|
+
}) {
|
|
6046
6195
|
return {
|
|
6047
6196
|
parameters: makeContractParameters({
|
|
6048
6197
|
abi: import_protocol_deployments15.secondarySwapABI,
|
|
@@ -6069,7 +6218,8 @@ async function buyWithSlippage({
|
|
|
6069
6218
|
chainId,
|
|
6070
6219
|
account,
|
|
6071
6220
|
slippage = UNISWAP_SLIPPAGE,
|
|
6072
|
-
recipient
|
|
6221
|
+
recipient,
|
|
6222
|
+
comment
|
|
6073
6223
|
}) {
|
|
6074
6224
|
const secondaryInfo = await getSecondaryInfo({
|
|
6075
6225
|
contract,
|
|
@@ -6096,6 +6246,8 @@ async function buyWithSlippage({
|
|
|
6096
6246
|
);
|
|
6097
6247
|
const call = await makeBuy({
|
|
6098
6248
|
erc20z,
|
|
6249
|
+
contract,
|
|
6250
|
+
tokenId,
|
|
6099
6251
|
poolBalance,
|
|
6100
6252
|
amount,
|
|
6101
6253
|
quantity,
|
|
@@ -6103,6 +6255,7 @@ async function buyWithSlippage({
|
|
|
6103
6255
|
recipient,
|
|
6104
6256
|
chainId,
|
|
6105
6257
|
slippage,
|
|
6258
|
+
comment,
|
|
6106
6259
|
publicClient
|
|
6107
6260
|
});
|
|
6108
6261
|
return {
|
|
@@ -6292,7 +6445,8 @@ function createCollectorClient(params) {
|
|
|
6292
6445
|
const mintClient = new MintClient({
|
|
6293
6446
|
publicClient: params.publicClient,
|
|
6294
6447
|
premintGetter: premintGetterToUse,
|
|
6295
|
-
mintGetter: mintGetterToUse
|
|
6448
|
+
mintGetter: mintGetterToUse,
|
|
6449
|
+
chainId: params.chainId
|
|
6296
6450
|
});
|
|
6297
6451
|
const secondaryClient = new SecondaryClient({
|
|
6298
6452
|
publicClient: params.publicClient,
|