@zoralabs/protocol-sdk 0.11.7 → 0.11.9
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 +15 -0
- package/dist/anvil.d.ts +1 -0
- package/dist/anvil.d.ts.map +1 -1
- package/dist/create/mint-from-create.d.ts +2 -1
- package/dist/create/mint-from-create.d.ts.map +1 -1
- package/dist/fixtures/rewards-query-results.d.ts +4 -1
- package/dist/fixtures/rewards-query-results.d.ts.map +1 -1
- package/dist/index.cjs +219 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +225 -54
- 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/rewards/rewards-queries.d.ts.map +1 -1
- package/dist/rewards/subgraph-queries.d.ts +2 -1
- package/dist/rewards/subgraph-queries.d.ts.map +1 -1
- package/dist/rewards/subgraph-rewards-getter.d.ts +9 -3
- package/dist/rewards/subgraph-rewards-getter.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 +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 +2 -12
- package/src/create/1155-create-helper.ts +2 -0
- package/src/create/mint-from-create.ts +3 -0
- package/src/fixtures/rewards-query-results.ts +9 -2
- 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/rewards/rewards-client.test.ts +41 -9
- package/src/rewards/rewards-queries.ts +15 -5
- package/src/rewards/subgraph-queries.ts +3 -1
- package/src/rewards/subgraph-rewards-getter.ts +24 -10
- 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-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.9 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
|
-
CJS dist/index.cjs
|
|
14
|
-
CJS dist/index.cjs.map
|
|
15
|
-
CJS ⚡️ Build success in
|
|
16
|
-
ESM dist/index.js
|
|
17
|
-
ESM dist/index.js.map
|
|
18
|
-
ESM ⚡️ Build success in
|
|
13
|
+
CJS dist/index.cjs 228.92 KB
|
|
14
|
+
CJS dist/index.cjs.map 463.70 KB
|
|
15
|
+
CJS ⚡️ Build success in 407ms
|
|
16
|
+
ESM dist/index.js 222.63 KB
|
|
17
|
+
ESM dist/index.js.map 461.86 KB
|
|
18
|
+
ESM ⚡️ Build success in 407ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @zoralabs/protocol-sdk
|
|
2
2
|
|
|
3
|
+
## 0.11.9
|
|
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 function.
|
|
9
|
+
- Updated dependencies [4928687d]
|
|
10
|
+
- @zoralabs/protocol-deployments@0.3.9
|
|
11
|
+
|
|
12
|
+
## 0.11.8
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 330f1131: Fix royalties queries to filter by erc20z that have secondary activated
|
|
17
|
+
|
|
3
18
|
## 0.11.7
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/anvil.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare const makeAnvilTest: ({ forkUrl, forkBlockNumber, anvilChainId, }
|
|
|
24
24
|
export declare const forkUrls: {
|
|
25
25
|
zoraMainnet: string;
|
|
26
26
|
zoraSepolia: string;
|
|
27
|
+
baseMainnet: string;
|
|
27
28
|
};
|
|
28
29
|
export declare const anvilTest: import("vitest").TestAPI<{
|
|
29
30
|
viemClients: {
|
package/dist/anvil.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anvil.d.ts","sourceRoot":"","sources":["../src/anvil.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,OAAO,EACP,KAAK,EACL,YAAY,EACZ,0BAA0B,EAC1B,UAAU,EACV,SAAS,EACT,YAAY,EAKb,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,qCAAqC,EAAE,MAAM,SAAS,CAAC;AAEhE,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE;QACX,YAAY,EAAE,YAAY,CAAC;QAE3B,YAAY,EAAE,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC7C,UAAU,EAAE,UAAU,CAAC;QACvB,KAAK,EAAE,KAAK,CAAC;KACd,CAAC;CACH;AAaD,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,aAAa,gDAIvB,qBAAqB;;sBA7BN,YAAY;sBAEZ,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC;oBAChC,UAAU;eACf,KAAK;;EAoFZ,CAAC;AAEL,eAAO,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"anvil.d.ts","sourceRoot":"","sources":["../src/anvil.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,OAAO,EACP,KAAK,EACL,YAAY,EACZ,0BAA0B,EAC1B,UAAU,EACV,SAAS,EACT,YAAY,EAKb,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,qCAAqC,EAAE,MAAM,SAAS,CAAC;AAEhE,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE;QACX,YAAY,EAAE,YAAY,CAAC;QAE3B,YAAY,EAAE,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC7C,UAAU,EAAE,UAAU,CAAC;QACvB,KAAK,EAAE,KAAK,CAAC;KACd,CAAC;CACH;AAaD,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,aAAa,gDAIvB,qBAAqB;;sBA7BN,YAAY;sBAEZ,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC;oBAChC,UAAU;eACf,KAAK;;EAoFZ,CAAC;AAEL,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC;AAEF,eAAO,MAAM,SAAS;;sBAhGJ,YAAY;sBAEZ,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC;oBAChC,UAAU;eACf,KAAK;;EAgGd,CAAC;AAEH,wBAAsB,mCAAmC,CAAC,EACxD,UAAU,EACV,YAAY,EACZ,YAAY,GACb,EAAE;IACD,UAAU,EAAE,qCAAqC,CAAC;IAClD,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;CAC5B,8CAOA;AAED,wBAAsB,wBAAwB,CAAC,EAC7C,OAAO,EACP,YAAY,EACZ,YAAY,GACb,EAAE;IACD,OAAO,EAAE,0BAA0B,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC;IAC9E,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;CAC5B,8CAuBA"}
|
|
@@ -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"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Address } from "viem";
|
|
2
2
|
import { CreatorERC20zQueryResult } from "../rewards/subgraph-queries";
|
|
3
3
|
export declare const mockRewardsQueryResults: ({ erc20z, }: {
|
|
4
|
-
erc20z:
|
|
4
|
+
erc20z: {
|
|
5
|
+
secondaryActivated: boolean;
|
|
6
|
+
erz20z: Address;
|
|
7
|
+
}[];
|
|
5
8
|
}) => CreatorERC20zQueryResult;
|
|
6
9
|
//# sourceMappingURL=rewards-query-results.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewards-query-results.d.ts","sourceRoot":"","sources":["../../src/fixtures/rewards-query-results.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAEL,wBAAwB,EACzB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"rewards-query-results.d.ts","sourceRoot":"","sources":["../../src/fixtures/rewards-query-results.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAEL,wBAAwB,EACzB,MAAM,6BAA6B,CAAC;AAqBrC,eAAO,MAAM,uBAAuB,gBAEjC;IACD,MAAM,EAAE;QAAE,kBAAkB,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CAC5D,KAAG,wBAEF,CAAC"}
|
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,
|
|
@@ -5554,7 +5614,10 @@ var getRewardsBalance = async ({
|
|
|
5554
5614
|
// Interface for getting ERC20Z tokens for a creator
|
|
5555
5615
|
}) => {
|
|
5556
5616
|
const address = typeof account === "string" ? account : account.address;
|
|
5557
|
-
const
|
|
5617
|
+
const erc20ZsAndSecondaryActivated = await rewardsGetter.getErc20ZzForCreator(
|
|
5618
|
+
{ address }
|
|
5619
|
+
);
|
|
5620
|
+
const validErc20Zs = erc20ZsAndSecondaryActivated.filter(({ secondaryActivated }) => secondaryActivated).map(({ erc20z }) => erc20z);
|
|
5558
5621
|
const result = await publicClient.multicall({
|
|
5559
5622
|
contracts: [
|
|
5560
5623
|
{
|
|
@@ -5567,7 +5630,7 @@ var getRewardsBalance = async ({
|
|
|
5567
5630
|
address: import_protocol_deployments12.erc20ZRoyaltiesAddress[chainId],
|
|
5568
5631
|
abi: import_protocol_deployments12.erc20ZRoyaltiesABI,
|
|
5569
5632
|
functionName: "getUnclaimedFeesBatch",
|
|
5570
|
-
args: [
|
|
5633
|
+
args: [validErc20Zs]
|
|
5571
5634
|
}
|
|
5572
5635
|
],
|
|
5573
5636
|
multicallAddress: multicall3Address,
|
|
@@ -5600,9 +5663,10 @@ var makeClaimSecondaryRoyaltiesCalls = async ({
|
|
|
5600
5663
|
chainId,
|
|
5601
5664
|
rewardsGetter
|
|
5602
5665
|
}) => {
|
|
5603
|
-
const
|
|
5604
|
-
address: claimFor
|
|
5605
|
-
|
|
5666
|
+
const erc20ZsAndSecondaryActivated = await rewardsGetter.getErc20ZzForCreator(
|
|
5667
|
+
{ address: claimFor }
|
|
5668
|
+
);
|
|
5669
|
+
const erc20z = erc20ZsAndSecondaryActivated.filter(({ secondaryActivated }) => secondaryActivated).map(({ erc20z: erc20z2 }) => erc20z2);
|
|
5606
5670
|
const royaltiesAddress = import_protocol_deployments12.erc20ZRoyaltiesAddress[chainId];
|
|
5607
5671
|
if (erc20z.length === 0) {
|
|
5608
5672
|
return [];
|
|
@@ -5709,6 +5773,7 @@ function buildCreatorERC20zs({
|
|
|
5709
5773
|
}
|
|
5710
5774
|
salesStrategies {
|
|
5711
5775
|
zoraTimedMinter {
|
|
5776
|
+
secondaryActivated
|
|
5712
5777
|
erc20Z {
|
|
5713
5778
|
id
|
|
5714
5779
|
}
|
|
@@ -5729,15 +5794,23 @@ var SubgraphRewardsGetter = class extends SubgraphGetter {
|
|
|
5729
5794
|
constructor(chainId, subgraphQuerier) {
|
|
5730
5795
|
super(chainId, subgraphQuerier);
|
|
5731
5796
|
}
|
|
5732
|
-
async getErc20ZzForCreator({
|
|
5733
|
-
address
|
|
5734
|
-
}) {
|
|
5797
|
+
async getErc20ZzForCreator({ address }) {
|
|
5735
5798
|
const queryResults = await this.querySubgraphWithRetries(
|
|
5736
5799
|
buildCreatorERC20zs({ address })
|
|
5737
5800
|
);
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5801
|
+
const results = (queryResults?.map((result) => {
|
|
5802
|
+
const timedMinter = result.salesStrategies[0].zoraTimedMinter;
|
|
5803
|
+
if (!timedMinter) {
|
|
5804
|
+
return null;
|
|
5805
|
+
}
|
|
5806
|
+
return {
|
|
5807
|
+
secondaryActivated: timedMinter.secondaryActivated,
|
|
5808
|
+
erc20z: timedMinter.erc20Z.id
|
|
5809
|
+
};
|
|
5810
|
+
}) || []).filter(
|
|
5811
|
+
(idAndActivated) => !!idAndActivated
|
|
5812
|
+
);
|
|
5813
|
+
return results;
|
|
5741
5814
|
}
|
|
5742
5815
|
};
|
|
5743
5816
|
|
|
@@ -6017,10 +6090,13 @@ var ERROR_INSUFFICIENT_WALLET_FUNDS = "Insufficient wallet funds";
|
|
|
6017
6090
|
var ERROR_INSUFFICIENT_POOL_SUPPLY = "Insufficient pool supply";
|
|
6018
6091
|
var ERROR_SECONDARY_NOT_CONFIGURED = "Secondary not configured for given contract and token";
|
|
6019
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";
|
|
6020
6094
|
function makeError(errorMessage) {
|
|
6021
6095
|
return { error: errorMessage };
|
|
6022
6096
|
}
|
|
6023
6097
|
async function makeBuy({
|
|
6098
|
+
contract,
|
|
6099
|
+
tokenId,
|
|
6024
6100
|
erc20z,
|
|
6025
6101
|
poolBalance,
|
|
6026
6102
|
amount,
|
|
@@ -6029,20 +6105,106 @@ async function makeBuy({
|
|
|
6029
6105
|
recipient,
|
|
6030
6106
|
chainId,
|
|
6031
6107
|
slippage,
|
|
6032
|
-
publicClient
|
|
6108
|
+
publicClient,
|
|
6109
|
+
comment
|
|
6033
6110
|
}) {
|
|
6034
6111
|
const costWithSlippage = calculateSlippageUp(amount, slippage);
|
|
6035
|
-
const availableToBuy = poolBalance.erc20z / BigInt(1e18) - 1n;
|
|
6036
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;
|
|
6037
6154
|
const availableToSpend = await publicClient.getBalance({
|
|
6038
6155
|
address: accountAddress
|
|
6039
6156
|
});
|
|
6040
6157
|
if (costWithSlippage > availableToSpend) {
|
|
6041
|
-
return
|
|
6158
|
+
return { error: ERROR_INSUFFICIENT_WALLET_FUNDS };
|
|
6042
6159
|
}
|
|
6043
6160
|
if (availableToBuy < BigInt(quantity)) {
|
|
6044
|
-
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);
|
|
6045
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
|
+
}) {
|
|
6046
6208
|
return {
|
|
6047
6209
|
parameters: makeContractParameters({
|
|
6048
6210
|
abi: import_protocol_deployments15.secondarySwapABI,
|
|
@@ -6069,7 +6231,8 @@ async function buyWithSlippage({
|
|
|
6069
6231
|
chainId,
|
|
6070
6232
|
account,
|
|
6071
6233
|
slippage = UNISWAP_SLIPPAGE,
|
|
6072
|
-
recipient
|
|
6234
|
+
recipient,
|
|
6235
|
+
comment
|
|
6073
6236
|
}) {
|
|
6074
6237
|
const secondaryInfo = await getSecondaryInfo({
|
|
6075
6238
|
contract,
|
|
@@ -6096,6 +6259,8 @@ async function buyWithSlippage({
|
|
|
6096
6259
|
);
|
|
6097
6260
|
const call = await makeBuy({
|
|
6098
6261
|
erc20z,
|
|
6262
|
+
contract,
|
|
6263
|
+
tokenId,
|
|
6099
6264
|
poolBalance,
|
|
6100
6265
|
amount,
|
|
6101
6266
|
quantity,
|
|
@@ -6103,6 +6268,7 @@ async function buyWithSlippage({
|
|
|
6103
6268
|
recipient,
|
|
6104
6269
|
chainId,
|
|
6105
6270
|
slippage,
|
|
6271
|
+
comment,
|
|
6106
6272
|
publicClient
|
|
6107
6273
|
});
|
|
6108
6274
|
return {
|
|
@@ -6292,7 +6458,8 @@ function createCollectorClient(params) {
|
|
|
6292
6458
|
const mintClient = new MintClient({
|
|
6293
6459
|
publicClient: params.publicClient,
|
|
6294
6460
|
premintGetter: premintGetterToUse,
|
|
6295
|
-
mintGetter: mintGetterToUse
|
|
6461
|
+
mintGetter: mintGetterToUse,
|
|
6462
|
+
chainId: params.chainId
|
|
6296
6463
|
});
|
|
6297
6464
|
const secondaryClient = new SecondaryClient({
|
|
6298
6465
|
publicClient: params.publicClient,
|