@zoralabs/protocol-sdk 0.11.6-COMMENTS.0 → 0.11.7-BUGFIX.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/.env +1 -0
- package/.turbo/turbo-build.log +18 -18
- package/CHANGELOG.md +10 -8
- package/dist/create/mint-from-create.d.ts +1 -2
- package/dist/create/mint-from-create.d.ts.map +1 -1
- package/dist/index.cjs +42 -196
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -202
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-client.d.ts +1 -3
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/mint-queries.d.ts +3 -5
- package/dist/mint/mint-queries.d.ts.map +1 -1
- package/dist/mint/mint-transactions.d.ts +2 -4
- package/dist/mint/mint-transactions.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +8 -0
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/secondary/secondary-client.d.ts +1 -2
- package/dist/secondary/secondary-client.d.ts.map +1 -1
- package/dist/secondary/types.d.ts +0 -1
- package/dist/secondary/types.d.ts.map +1 -1
- package/dist/test-utils.d.ts +1 -3
- package/dist/test-utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/create/1155-create-helper.test.ts +12 -2
- package/src/create/1155-create-helper.ts +0 -2
- package/src/create/mint-from-create.ts +0 -3
- package/src/mint/mint-client.test.ts +30 -67
- package/src/mint/mint-client.ts +1 -10
- package/src/mint/mint-queries.ts +5 -16
- package/src/mint/mint-transactions.ts +16 -80
- package/src/rewards/subgraph-queries.ts +1 -1
- package/src/sdk.ts +0 -1
- package/src/secondary/secondary-client.test.ts +2 -118
- package/src/secondary/secondary-client.ts +6 -136
- package/src/secondary/types.ts +0 -2
- package/src/sparks/sparks-sponsored-sparks-spender.test.ts +1 -1
- package/src/test-utils.ts +0 -12
- package/yarn-error.log +8602 -0
- package/src/comments/comments.test.ts +0 -342
package/.env
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_CONDUIT_KEY=066ae224-b5c3-4086-ac11-a3a44ede9458
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
> @zoralabs/protocol-sdk@0.11.
|
|
3
|
-
> pnpm tsup
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
|
|
2
|
+
> @zoralabs/protocol-sdk@0.11.7-BUGFIX.0 build /Users/danovedzora/source/zora-protocol/packages/protocol-sdk
|
|
3
|
+
> pnpm tsup
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.build.json
|
|
7
|
+
[34mCLI[39m tsup v7.3.0
|
|
8
|
+
[34mCLI[39m Using tsup config: /Users/danovedzora/source/zora-protocol/packages/protocol-sdk/tsup.config.ts
|
|
9
|
+
[34mCLI[39m Target: es2021
|
|
10
|
+
[34mCLI[39m Cleaning output folder
|
|
11
|
+
[34mCJS[39m Build start
|
|
12
|
+
[34mESM[39m Build start
|
|
13
|
+
[32mESM[39m [1mdist/index.js [22m[32m218.90 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m454.14 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 66ms
|
|
16
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m225.23 KB[39m
|
|
17
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m456.14 KB[39m
|
|
18
|
+
[32mCJS[39m ⚡️ Build success in 66ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
# @zoralabs/protocol-sdk
|
|
2
2
|
|
|
3
|
-
## 0.11.
|
|
3
|
+
## 0.11.7-BUGFIX.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
- 6ce69da4: Fix royalties query for secondary tokens to query subgraph for royaltyRecipient instead of user.
|
|
8
|
+
|
|
9
|
+
## 0.11.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [ad707434]
|
|
14
|
+
- Updated dependencies [2e68a87c]
|
|
12
15
|
- Updated dependencies [17cc9821]
|
|
13
|
-
-
|
|
14
|
-
- @zoralabs/protocol-deployments@0.3.8-COMMENTS.0
|
|
16
|
+
- @zoralabs/protocol-deployments@0.3.8
|
|
15
17
|
|
|
16
18
|
## 0.11.5
|
|
17
19
|
|
|
@@ -1,13 +1,12 @@
|
|
|
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, }: {
|
|
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;
|
|
12
11
|
}): AsyncPrepareMint;
|
|
13
12
|
//# 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,GAChB,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;CACzB,GAAG,gBAAgB,CAyBnB"}
|
package/dist/index.cjs
CHANGED
|
@@ -3773,8 +3773,7 @@ var contractSupportsNewMintFunction = (contractVersion) => {
|
|
|
3773
3773
|
// src/mint/mint-transactions.ts
|
|
3774
3774
|
function makeOnchainMintCall({
|
|
3775
3775
|
token,
|
|
3776
|
-
mintParams
|
|
3777
|
-
chainId
|
|
3776
|
+
mintParams
|
|
3778
3777
|
}) {
|
|
3779
3778
|
if (token.mintType === "721") {
|
|
3780
3779
|
return makePrepareMint721TokenParams({
|
|
@@ -3787,55 +3786,9 @@ function makeOnchainMintCall({
|
|
|
3787
3786
|
salesConfigAndTokenInfo: token,
|
|
3788
3787
|
tokenContract: token.contract.address,
|
|
3789
3788
|
tokenId: token.tokenId,
|
|
3790
|
-
chainId,
|
|
3791
3789
|
...mintParams
|
|
3792
3790
|
});
|
|
3793
3791
|
}
|
|
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
|
-
}
|
|
3839
3792
|
function makePrepareMint1155TokenParams({
|
|
3840
3793
|
tokenContract,
|
|
3841
3794
|
tokenId,
|
|
@@ -3845,8 +3798,7 @@ function makePrepareMint1155TokenParams({
|
|
|
3845
3798
|
mintReferral,
|
|
3846
3799
|
mintRecipient,
|
|
3847
3800
|
quantityToMint,
|
|
3848
|
-
allowListEntry
|
|
3849
|
-
chainId
|
|
3801
|
+
allowListEntry
|
|
3850
3802
|
}) {
|
|
3851
3803
|
const mintQuantity = BigInt(quantityToMint || 1);
|
|
3852
3804
|
const mintTo = mintRecipientOrAccount({ mintRecipient, minterAccount });
|
|
@@ -3865,16 +3817,21 @@ function makePrepareMint1155TokenParams({
|
|
|
3865
3817
|
});
|
|
3866
3818
|
}
|
|
3867
3819
|
if (saleType === "timed") {
|
|
3868
|
-
return
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
tokenId,
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3820
|
+
return makeContractParameters({
|
|
3821
|
+
abi: import_protocol_deployments6.zoraTimedSaleStrategyABI,
|
|
3822
|
+
functionName: "mint",
|
|
3823
|
+
account: minterAccount,
|
|
3824
|
+
address: salesConfigAndTokenInfo.salesConfig.address,
|
|
3825
|
+
value: salesConfigAndTokenInfo.salesConfig.mintFeePerQuantity * mintQuantity,
|
|
3826
|
+
/* args: mintTo, quantity, collection, tokenId, mintReferral, comment */
|
|
3827
|
+
args: [
|
|
3828
|
+
mintTo,
|
|
3829
|
+
mintQuantity,
|
|
3830
|
+
tokenContract,
|
|
3831
|
+
BigInt(tokenId),
|
|
3832
|
+
mintReferral || import_viem5.zeroAddress,
|
|
3833
|
+
mintComment || ""
|
|
3834
|
+
]
|
|
3878
3835
|
});
|
|
3879
3836
|
}
|
|
3880
3837
|
if (saleType === "erc20") {
|
|
@@ -4039,8 +3996,7 @@ async function getMint({
|
|
|
4039
3996
|
params,
|
|
4040
3997
|
mintGetter,
|
|
4041
3998
|
premintGetter,
|
|
4042
|
-
publicClient
|
|
4043
|
-
chainId
|
|
3999
|
+
publicClient
|
|
4044
4000
|
}) {
|
|
4045
4001
|
const { tokenContract } = params;
|
|
4046
4002
|
if (isOnChainMint(params)) {
|
|
@@ -4052,7 +4008,7 @@ async function getMint({
|
|
|
4052
4008
|
preferredSaleType: params.preferredSaleType,
|
|
4053
4009
|
blockTime
|
|
4054
4010
|
});
|
|
4055
|
-
return toMintableReturn(result
|
|
4011
|
+
return toMintableReturn(result);
|
|
4056
4012
|
}
|
|
4057
4013
|
const premint = await premintGetter.get({
|
|
4058
4014
|
collectionAddress: tokenContract,
|
|
@@ -4090,12 +4046,11 @@ async function getMintsOfContract({
|
|
|
4090
4046
|
params,
|
|
4091
4047
|
mintGetter,
|
|
4092
4048
|
premintGetter,
|
|
4093
|
-
publicClient
|
|
4094
|
-
chainId
|
|
4049
|
+
publicClient
|
|
4095
4050
|
}) {
|
|
4096
4051
|
const onchainMints = (await mintGetter.getContractMintable({
|
|
4097
4052
|
tokenAddress: params.tokenContract
|
|
4098
|
-
})).map(
|
|
4053
|
+
})).map(toMintableReturn);
|
|
4099
4054
|
const offchainMints = await getPremintsOfContractMintable({
|
|
4100
4055
|
mintGetter,
|
|
4101
4056
|
premintGetter,
|
|
@@ -4212,15 +4167,14 @@ function parsePremint({
|
|
|
4212
4167
|
}
|
|
4213
4168
|
throw new Error("Invalid premint config version");
|
|
4214
4169
|
}
|
|
4215
|
-
var makeOnchainPrepareMint = (result
|
|
4170
|
+
var makeOnchainPrepareMint = (result) => (params) => {
|
|
4216
4171
|
if (!result.salesConfig) {
|
|
4217
4172
|
throw new Error("No valid sales config found for token");
|
|
4218
4173
|
}
|
|
4219
4174
|
return {
|
|
4220
4175
|
parameters: makeOnchainMintCall({
|
|
4221
4176
|
token: result,
|
|
4222
|
-
mintParams: params
|
|
4223
|
-
chainId
|
|
4177
|
+
mintParams: params
|
|
4224
4178
|
}),
|
|
4225
4179
|
erc20Approval: getRequiredErc20Approvals(params, result.salesConfig),
|
|
4226
4180
|
costs: parseMintCosts({
|
|
@@ -4230,7 +4184,7 @@ var makeOnchainPrepareMint = (result, chainId) => (params) => {
|
|
|
4230
4184
|
})
|
|
4231
4185
|
};
|
|
4232
4186
|
};
|
|
4233
|
-
function toMintableReturn(result
|
|
4187
|
+
function toMintableReturn(result) {
|
|
4234
4188
|
const primaryMintActive = result.primaryMintActive;
|
|
4235
4189
|
if (!primaryMintActive) {
|
|
4236
4190
|
return {
|
|
@@ -4246,10 +4200,7 @@ function toMintableReturn(result, chainId) {
|
|
|
4246
4200
|
primaryMintActive,
|
|
4247
4201
|
primaryMintEnd: result.primaryMintEnd,
|
|
4248
4202
|
secondaryMarketActive: result.secondaryMarketActive,
|
|
4249
|
-
prepareMint: makeOnchainPrepareMint(
|
|
4250
|
-
result.salesConfigAndTokenInfo,
|
|
4251
|
-
chainId
|
|
4252
|
-
)
|
|
4203
|
+
prepareMint: makeOnchainPrepareMint(result.salesConfigAndTokenInfo)
|
|
4253
4204
|
};
|
|
4254
4205
|
}
|
|
4255
4206
|
var makePremintPrepareMint = (mintable, mintFee, premint) => {
|
|
@@ -4312,13 +4263,11 @@ var MintClient = class {
|
|
|
4312
4263
|
constructor({
|
|
4313
4264
|
publicClient,
|
|
4314
4265
|
premintGetter,
|
|
4315
|
-
mintGetter
|
|
4316
|
-
chainId
|
|
4266
|
+
mintGetter
|
|
4317
4267
|
}) {
|
|
4318
4268
|
this.publicClient = publicClient;
|
|
4319
4269
|
this.mintGetter = mintGetter;
|
|
4320
4270
|
this.premintGetter = premintGetter;
|
|
4321
|
-
this.chainId = chainId;
|
|
4322
4271
|
}
|
|
4323
4272
|
/**
|
|
4324
4273
|
* Returns the parameters needed to prepare a transaction mint a token.
|
|
@@ -4332,8 +4281,7 @@ var MintClient = class {
|
|
|
4332
4281
|
parameters,
|
|
4333
4282
|
publicClient: this.publicClient,
|
|
4334
4283
|
mintGetter: this.mintGetter,
|
|
4335
|
-
premintGetter: this.premintGetter
|
|
4336
|
-
chainId: this.chainId
|
|
4284
|
+
premintGetter: this.premintGetter
|
|
4337
4285
|
});
|
|
4338
4286
|
}
|
|
4339
4287
|
/**
|
|
@@ -4347,8 +4295,7 @@ var MintClient = class {
|
|
|
4347
4295
|
params: parameters,
|
|
4348
4296
|
mintGetter: this.mintGetter,
|
|
4349
4297
|
premintGetter: this.premintGetter,
|
|
4350
|
-
publicClient: this.publicClient
|
|
4351
|
-
chainId: this.chainId
|
|
4298
|
+
publicClient: this.publicClient
|
|
4352
4299
|
});
|
|
4353
4300
|
}
|
|
4354
4301
|
/**
|
|
@@ -4362,8 +4309,7 @@ var MintClient = class {
|
|
|
4362
4309
|
params,
|
|
4363
4310
|
mintGetter: this.mintGetter,
|
|
4364
4311
|
premintGetter: this.premintGetter,
|
|
4365
|
-
publicClient: this.publicClient
|
|
4366
|
-
chainId: this.chainId
|
|
4312
|
+
publicClient: this.publicClient
|
|
4367
4313
|
});
|
|
4368
4314
|
}
|
|
4369
4315
|
/**
|
|
@@ -4384,15 +4330,13 @@ async function mint({
|
|
|
4384
4330
|
parameters,
|
|
4385
4331
|
publicClient,
|
|
4386
4332
|
mintGetter,
|
|
4387
|
-
premintGetter
|
|
4388
|
-
chainId
|
|
4333
|
+
premintGetter
|
|
4389
4334
|
}) {
|
|
4390
4335
|
const { prepareMint, primaryMintActive } = await getMint({
|
|
4391
4336
|
params: parameters,
|
|
4392
4337
|
mintGetter,
|
|
4393
4338
|
premintGetter,
|
|
4394
|
-
publicClient
|
|
4395
|
-
chainId
|
|
4339
|
+
publicClient
|
|
4396
4340
|
});
|
|
4397
4341
|
if (!primaryMintActive) {
|
|
4398
4342
|
throw new Error("Primary mint is not active");
|
|
@@ -4935,8 +4879,7 @@ function makeOnchainPrepareMintFromCreate({
|
|
|
4935
4879
|
result,
|
|
4936
4880
|
minter,
|
|
4937
4881
|
getContractMintFee,
|
|
4938
|
-
contractVersion
|
|
4939
|
-
chainId
|
|
4882
|
+
contractVersion
|
|
4940
4883
|
}) {
|
|
4941
4884
|
return async (params) => {
|
|
4942
4885
|
const subgraphSalesConfig = await toSalesStrategyFromSubgraph({
|
|
@@ -4952,8 +4895,7 @@ function makeOnchainPrepareMintFromCreate({
|
|
|
4952
4895
|
},
|
|
4953
4896
|
...params,
|
|
4954
4897
|
tokenContract: contractAddress,
|
|
4955
|
-
tokenId
|
|
4956
|
-
chainId
|
|
4898
|
+
tokenId
|
|
4957
4899
|
}),
|
|
4958
4900
|
costs: parseMintCosts({
|
|
4959
4901
|
allowListEntry: params.allowListEntry,
|
|
@@ -5126,8 +5068,7 @@ async function createNew1155ContractAndToken({
|
|
|
5126
5068
|
getContractMintFee: async () => getNewContractMintFee({
|
|
5127
5069
|
publicClient,
|
|
5128
5070
|
chainId
|
|
5129
|
-
})
|
|
5130
|
-
chainId
|
|
5071
|
+
})
|
|
5131
5072
|
});
|
|
5132
5073
|
return {
|
|
5133
5074
|
parameters: request,
|
|
@@ -5173,8 +5114,7 @@ async function createNew1155Token({
|
|
|
5173
5114
|
minter,
|
|
5174
5115
|
result: newToken.salesConfig,
|
|
5175
5116
|
tokenId: nextTokenId,
|
|
5176
|
-
getContractMintFee: async () => mintFee
|
|
5177
|
-
chainId
|
|
5117
|
+
getContractMintFee: async () => mintFee
|
|
5178
5118
|
});
|
|
5179
5119
|
return {
|
|
5180
5120
|
parameters: request,
|
|
@@ -5762,7 +5702,7 @@ function buildCreatorERC20zs({
|
|
|
5762
5702
|
query: `
|
|
5763
5703
|
query ($address: Bytes!) {
|
|
5764
5704
|
zoraCreateTokens(
|
|
5765
|
-
where: { royalties_: {
|
|
5705
|
+
where: { royalties_: { royaltyRecipient: $address }, salesStrategies_: { type: "ZORA_TIMED" } }
|
|
5766
5706
|
) {
|
|
5767
5707
|
royalties {
|
|
5768
5708
|
user
|
|
@@ -6077,13 +6017,10 @@ var ERROR_INSUFFICIENT_WALLET_FUNDS = "Insufficient wallet funds";
|
|
|
6077
6017
|
var ERROR_INSUFFICIENT_POOL_SUPPLY = "Insufficient pool supply";
|
|
6078
6018
|
var ERROR_SECONDARY_NOT_CONFIGURED = "Secondary not configured for given contract and token";
|
|
6079
6019
|
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";
|
|
6081
6020
|
function makeError(errorMessage) {
|
|
6082
6021
|
return { error: errorMessage };
|
|
6083
6022
|
}
|
|
6084
6023
|
async function makeBuy({
|
|
6085
|
-
contract,
|
|
6086
|
-
tokenId,
|
|
6087
6024
|
erc20z,
|
|
6088
6025
|
poolBalance,
|
|
6089
6026
|
amount,
|
|
@@ -6092,106 +6029,20 @@ async function makeBuy({
|
|
|
6092
6029
|
recipient,
|
|
6093
6030
|
chainId,
|
|
6094
6031
|
slippage,
|
|
6095
|
-
publicClient,
|
|
6096
|
-
comment
|
|
6097
|
-
}) {
|
|
6098
|
-
const costWithSlippage = calculateSlippageUp(amount, slippage);
|
|
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
6032
|
publicClient
|
|
6139
6033
|
}) {
|
|
6034
|
+
const costWithSlippage = calculateSlippageUp(amount, slippage);
|
|
6140
6035
|
const availableToBuy = poolBalance.erc20z / BigInt(1e18) - 1n;
|
|
6036
|
+
const accountAddress = addressOrAccountAddress(account);
|
|
6141
6037
|
const availableToSpend = await publicClient.getBalance({
|
|
6142
6038
|
address: accountAddress
|
|
6143
6039
|
});
|
|
6144
6040
|
if (costWithSlippage > availableToSpend) {
|
|
6145
|
-
return
|
|
6041
|
+
return makeError(ERROR_INSUFFICIENT_WALLET_FUNDS);
|
|
6146
6042
|
}
|
|
6147
6043
|
if (availableToBuy < BigInt(quantity)) {
|
|
6148
|
-
return
|
|
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);
|
|
6044
|
+
return makeError(ERROR_INSUFFICIENT_POOL_SUPPLY);
|
|
6165
6045
|
}
|
|
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
|
-
}) {
|
|
6195
6046
|
return {
|
|
6196
6047
|
parameters: makeContractParameters({
|
|
6197
6048
|
abi: import_protocol_deployments15.secondarySwapABI,
|
|
@@ -6218,8 +6069,7 @@ async function buyWithSlippage({
|
|
|
6218
6069
|
chainId,
|
|
6219
6070
|
account,
|
|
6220
6071
|
slippage = UNISWAP_SLIPPAGE,
|
|
6221
|
-
recipient
|
|
6222
|
-
comment
|
|
6072
|
+
recipient
|
|
6223
6073
|
}) {
|
|
6224
6074
|
const secondaryInfo = await getSecondaryInfo({
|
|
6225
6075
|
contract,
|
|
@@ -6246,8 +6096,6 @@ async function buyWithSlippage({
|
|
|
6246
6096
|
);
|
|
6247
6097
|
const call = await makeBuy({
|
|
6248
6098
|
erc20z,
|
|
6249
|
-
contract,
|
|
6250
|
-
tokenId,
|
|
6251
6099
|
poolBalance,
|
|
6252
6100
|
amount,
|
|
6253
6101
|
quantity,
|
|
@@ -6255,7 +6103,6 @@ async function buyWithSlippage({
|
|
|
6255
6103
|
recipient,
|
|
6256
6104
|
chainId,
|
|
6257
6105
|
slippage,
|
|
6258
|
-
comment,
|
|
6259
6106
|
publicClient
|
|
6260
6107
|
});
|
|
6261
6108
|
return {
|
|
@@ -6445,8 +6292,7 @@ function createCollectorClient(params) {
|
|
|
6445
6292
|
const mintClient = new MintClient({
|
|
6446
6293
|
publicClient: params.publicClient,
|
|
6447
6294
|
premintGetter: premintGetterToUse,
|
|
6448
|
-
mintGetter: mintGetterToUse
|
|
6449
|
-
chainId: params.chainId
|
|
6295
|
+
mintGetter: mintGetterToUse
|
|
6450
6296
|
});
|
|
6451
6297
|
const secondaryClient = new SecondaryClient({
|
|
6452
6298
|
publicClient: params.publicClient,
|