@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
|
@@ -15,10 +15,12 @@ export declare class MintClient {
|
|
|
15
15
|
private readonly publicClient;
|
|
16
16
|
private readonly mintGetter;
|
|
17
17
|
private readonly premintGetter;
|
|
18
|
-
|
|
18
|
+
private readonly chainId;
|
|
19
|
+
constructor({ publicClient, premintGetter, mintGetter, chainId, }: {
|
|
19
20
|
publicClient: IPublicClient;
|
|
20
21
|
premintGetter: IPremintGetter;
|
|
21
22
|
mintGetter: IOnchainMintGetter;
|
|
23
|
+
chainId: number;
|
|
22
24
|
});
|
|
23
25
|
/**
|
|
24
26
|
* Returns the parameters needed to prepare a transaction mint a token.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mint-client.d.ts","sourceRoot":"","sources":["../../src/mint/mint-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAIhE,cAAM,SAAU,SAAQ,KAAK;CAAG;AAChC,cAAM,iBAAkB,SAAQ,KAAK;CAAG;AAExC,eAAO,MAAM,MAAM;;;CAGlB,CAAC;AAEF,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAgB;IAC7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;IAChD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;
|
|
1
|
+
{"version":3,"file":"mint-client.d.ts","sourceRoot":"","sources":["../../src/mint/mint-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAIhE,cAAM,SAAU,SAAQ,KAAK;CAAG;AAChC,cAAM,iBAAkB,SAAQ,KAAK;CAAG;AAExC,eAAO,MAAM,MAAM;;;CAGlB,CAAC;AAEF,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAgB;IAC7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;IAChD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBACrB,EACV,YAAY,EACZ,aAAa,EACb,UAAU,EACV,OAAO,GACR,EAAE;QACD,YAAY,EAAE,aAAa,CAAC;QAC5B,aAAa,EAAE,cAAc,CAAC;QAC9B,UAAU,EAAE,kBAAkB,CAAC;QAC/B,OAAO,EAAE,MAAM,CAAC;KACjB;IAOD;;;;;;OAMG;IACG,IAAI,CACR,UAAU,EAAE,2BAA2B,GACtC,OAAO,CAAC,iBAAiB,CAAC;IAU7B;;;;;OAKG;IACG,GAAG,CAAC,UAAU,EAAE,iBAAiB;IAUvC;;;;;OAKG;IACG,aAAa,CAAC,MAAM,EAAE;QAC1B,aAAa,EAAE,OAAO,CAAC;QACvB,iBAAiB,CAAC,EAAE,QAAQ,CAAC;KAC9B;;;;IAUD;;;;OAIG;IACG,YAAY,CAAC,UAAU,EAAE,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC;CAQ3E"}
|
|
@@ -4,11 +4,12 @@ import { Address } from "viem";
|
|
|
4
4
|
import { PremintFromApi } from "src/premint/conversions";
|
|
5
5
|
import { IPublicClient } from "src/types";
|
|
6
6
|
import { AllowListEntry } from "src/allow-list/types";
|
|
7
|
-
export declare function getMint({ params, mintGetter, premintGetter, publicClient, }: {
|
|
7
|
+
export declare function getMint({ params, mintGetter, premintGetter, publicClient, chainId, }: {
|
|
8
8
|
params: GetMintParameters;
|
|
9
9
|
mintGetter: IOnchainMintGetter;
|
|
10
10
|
premintGetter: IPremintGetter;
|
|
11
11
|
publicClient: IPublicClient;
|
|
12
|
+
chainId: number;
|
|
12
13
|
}): Promise<MintableReturn>;
|
|
13
14
|
export declare function getPremintsOfCollectionWithTokenIds({ premintGetter, mintGetter, tokenContract, }: {
|
|
14
15
|
premintGetter: IPremintGetter;
|
|
@@ -22,11 +23,12 @@ export declare function getPremintsOfCollectionWithTokenIds({ premintGetter, min
|
|
|
22
23
|
signature: import("viem").Hex;
|
|
23
24
|
}[];
|
|
24
25
|
}>;
|
|
25
|
-
export declare function getMintsOfContract({ params, mintGetter, premintGetter, publicClient, }: {
|
|
26
|
+
export declare function getMintsOfContract({ params, mintGetter, premintGetter, publicClient, chainId, }: {
|
|
26
27
|
params: GetMintsOfContractParameters;
|
|
27
28
|
mintGetter: IOnchainMintGetter;
|
|
28
29
|
premintGetter: IPremintGetter;
|
|
29
30
|
publicClient: IPublicClient;
|
|
31
|
+
chainId: number;
|
|
30
32
|
}): Promise<{
|
|
31
33
|
contract?: ContractInfo;
|
|
32
34
|
tokens: MintableReturn[];
|
|
@@ -39,6 +41,6 @@ export declare function getMintCosts({ params, allowListEntry, mintGetter, premi
|
|
|
39
41
|
publicClient: IPublicClient;
|
|
40
42
|
}): Promise<import("./types").MintCosts>;
|
|
41
43
|
export declare function isPrimaryMintActive(premint: Pick<PremintFromApi, "premint">["premint"]): boolean;
|
|
42
|
-
export declare const makeOnchainPrepareMint: (result: OnchainSalesConfigAndTokenInfo) => PrepareMint;
|
|
44
|
+
export declare const makeOnchainPrepareMint: (result: OnchainSalesConfigAndTokenInfo, chainId: number) => PrepareMint;
|
|
43
45
|
export declare function getRequiredErc20Approvals(params: MintParametersBase, salesConfig: OnchainSalesConfigAndTokenInfo["salesConfig"]): Erc20Approval | undefined;
|
|
44
46
|
//# sourceMappingURL=mint-queries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mint-queries.d.ts","sourceRoot":"","sources":["../../src/mint/mint-queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EACL,YAAY,EACZ,aAAa,EACb,sBAAsB,EACtB,iBAAiB,EACjB,4BAA4B,EAC5B,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,8BAA8B,EAE9B,WAAW,EAIZ,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAe,MAAM,MAAM,CAAC;AAK5C,OAAO,EACL,cAAc,EAGf,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,wBAAsB,OAAO,CAAC,EAC5B,MAAM,EACN,UAAU,EACV,aAAa,EACb,YAAY,
|
|
1
|
+
{"version":3,"file":"mint-queries.d.ts","sourceRoot":"","sources":["../../src/mint/mint-queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EACL,YAAY,EACZ,aAAa,EACb,sBAAsB,EACtB,iBAAiB,EACjB,4BAA4B,EAC5B,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,8BAA8B,EAE9B,WAAW,EAIZ,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAe,MAAM,MAAM,CAAC;AAK5C,OAAO,EACL,cAAc,EAGf,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,wBAAsB,OAAO,CAAC,EAC5B,MAAM,EACN,UAAU,EACV,aAAa,EACb,YAAY,EACZ,OAAO,GACR,EAAE;IACD,MAAM,EAAE,iBAAiB,CAAC;IAC1B,UA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AAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,8BAA8B,CAAC,aAAa,CAAC,GACzD,aAAa,GAAG,SAAS,CAQ3B"}
|
|
@@ -5,14 +5,16 @@ import { MintCosts, SaleStrategies } from "./types";
|
|
|
5
5
|
import { MakeMintParametersArgumentsBase } from "./types";
|
|
6
6
|
import { OnchainSalesConfigAndTokenInfo } from "./types";
|
|
7
7
|
import { AllowListEntry } from "src/allow-list/types";
|
|
8
|
-
export declare function makeOnchainMintCall({ token, mintParams, }: {
|
|
8
|
+
export declare function makeOnchainMintCall({ token, mintParams, chainId, }: {
|
|
9
9
|
token: Concrete<OnchainSalesConfigAndTokenInfo>;
|
|
10
10
|
mintParams: Omit<MakeMintParametersArgumentsBase, "tokenContract">;
|
|
11
|
+
chainId: number;
|
|
11
12
|
}): SimulateContractParametersWithAccount;
|
|
12
13
|
export type MintableParameters = Pick<OnchainSalesConfigAndTokenInfo, "contractVersion" | "salesConfig">;
|
|
13
|
-
export declare function makePrepareMint1155TokenParams({ tokenContract: tokenContract, tokenId, salesConfigAndTokenInfo, minterAccount, mintComment, mintReferral, mintRecipient, quantityToMint, allowListEntry, }: {
|
|
14
|
+
export declare function makePrepareMint1155TokenParams({ tokenContract: tokenContract, tokenId, salesConfigAndTokenInfo, minterAccount, mintComment, mintReferral, mintRecipient, quantityToMint, allowListEntry, chainId, }: {
|
|
14
15
|
salesConfigAndTokenInfo: Concrete<MintableParameters>;
|
|
15
16
|
tokenId: GenericTokenIdTypes;
|
|
17
|
+
chainId: number;
|
|
16
18
|
} & Pick<MakeMintParametersArgumentsBase, "minterAccount" | "tokenContract" | "mintComment" | "mintReferral" | "quantityToMint" | "mintRecipient" | "allowListEntry">): SimulateContractParameters<any, any, any, any, any, Address | Account>;
|
|
17
19
|
export declare function parseMintCosts({ salesConfig, quantityToMint, allowListEntry, }: {
|
|
18
20
|
salesConfig: SaleStrategies;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mint-transactions.d.ts","sourceRoot":"","sources":["../../src/mint/mint-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAIP,OAAO,EACP,0BAA0B,EAE3B,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"mint-transactions.d.ts","sourceRoot":"","sources":["../../src/mint/mint-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAIP,OAAO,EACP,0BAA0B,EAE3B,MAAM,MAAM,CAAC;AASd,OAAO,EACL,mBAAmB,EACnB,qCAAqC,EACtC,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,QAAQ,EAGT,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAuB,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAG1D,OAAO,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,UAAU,EACV,OAAO,GACR,EAAE;IACD,KAAK,EAAE,QAAQ,CAAC,8BAA8B,CAAC,CAAC;IAChD,UAAU,EAAE,IAAI,CAAC,+BAA+B,EAAE,eAAe,CAAC,CAAC;IACnE,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,qCAAqC,CAgBxC;AAED,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,8BAA8B,EAC9B,iBAAiB,GAAG,aAAa,CAClC,CAAC;AAiEF,wBAAgB,8BAA8B,CAAC,EAC7C,aAAa,EAAE,aAAa,EAC5B,OAAO,EACP,uBAAuB,EACvB,aAAa,EACb,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,cAAc,EACd,OAAO,GACR,EAAE;IACD,uBAAuB,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IACtD,OAAO,EAAE,mBAAmB,CAAC;IAC7B,OAAO,EAAE,MA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ACzB,YAAY,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;IACzC,QAAQ,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IAC5B,mBAAmB,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;IACjD,kBAAkB,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC;IAC1D,mBAAmB,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;IAC5D,gBAAgB,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CACvD,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG;IAC/C,iFAAiF;IACjF,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,aAAa,CAAC,EAAE,cAAc,CAAC;CAChC,CAAC;AAEF;;;;;KAKK;AACL,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,mBAAmB,GAChC,aAAa,CAkCf;AAED,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG;IACjD,kEAAkE;IAClE,aAAa,CAAC,EAAE,WAAW,CAAC;IAC5B,4EAA4E;IAC5E,UAAU,CAAC,EAAE,kBAAkB,CAAC;CACjC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,qBAAqB,GAC5B,eAAe,CAgCjB"}
|
|
@@ -3,6 +3,7 @@ import { PublicClient } from "src/utils";
|
|
|
3
3
|
import { SimulateContractParametersWithAccount } from "src/types";
|
|
4
4
|
import { QuotePrice, BuyWithSlippageInput, SellWithSlippageInput, SecondaryInfo } from "./types";
|
|
5
5
|
export declare const ERROR_SECONDARY_NOT_STARTED = "Secondary market has not started";
|
|
6
|
+
export declare const ERROR_RECIPIENT_MISMATCH = "Recipient must be the same as the caller if there is a comment";
|
|
6
7
|
type Call = {
|
|
7
8
|
parameters: SimulateContractParametersWithAccount;
|
|
8
9
|
error?: undefined;
|
|
@@ -17,7 +18,7 @@ type BuyOrSellWithSlippageResult = ({
|
|
|
17
18
|
price?: undefined;
|
|
18
19
|
parameters?: undefined;
|
|
19
20
|
};
|
|
20
|
-
export declare function buyWithSlippage({ contract, tokenId, publicClient, quantity, chainId, account, slippage, recipient, }: BuyWithSlippageInput & {
|
|
21
|
+
export declare function buyWithSlippage({ contract, tokenId, publicClient, quantity, chainId, account, slippage, recipient, comment, }: BuyWithSlippageInput & {
|
|
21
22
|
chainId: number;
|
|
22
23
|
publicClient: PublicClient;
|
|
23
24
|
}): Promise<BuyOrSellWithSlippageResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secondary-client.d.ts","sourceRoot":"","sources":["../../src/secondary/secondary-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,OAAO,EAAuB,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"secondary-client.d.ts","sourceRoot":"","sources":["../../src/secondary/secondary-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,OAAO,EAAuB,MAAM,MAAM,CAAC;AAS7D,OAAO,EAA0B,YAAY,EAAE,MAAM,WAAW,CAAC;AAKjE,OAAO,EAAE,qCAAqC,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,EACd,MAAM,SAAS,CAAC;AAUjB,eAAO,MAAM,2BAA2B,qCAAqC,CAAC;AAC9E,eAAO,MAAM,wBAAwB,mEAC6B,CAAC;AAOnE,KAAK,IAAI,GACL;IAEE,UAAU,EAAE,qCAAqC,CAAC;IAClD,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,GACD;IACE,UAAU,CAAC,EAAE,SAAS,CAAC;IAEvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAwLN,KAAK,2BAA2B,GAC5B,CAAC;IAEC,KAAK,EAAE,UAAU,CAAC;CACnB,GAAG,IAAI,CAAC,GACT;IACE,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,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Q,EAAE,MAAM,CAAC;QAEjB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;CACJ,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAE3B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE;QAEX,MAAM,EAAE,MAAM,CAAC;QAEf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IAEF,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAEjC,QAAQ,EAAE,OAAO,CAAC;IAElB,OAAO,EAAE,MAAM,CAAC;IAEhB,QAAQ,EAAE,MAAM,CAAC;IAEjB,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IAE3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAGF,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAGzD,MAAM,MAAM,aAAa,GAAG;IAE1B,kBAAkB,EAAE,OAAO,CAAC;IAE5B,IAAI,EAAE,OAAO,CAAC;IAEd,MAAM,EAAE,OAAO,CAAC;IAEhB,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,EAAE,MAAM,CAAC;IAEf,SAAS,EAAE,MAAM,CAAC;IAElB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
package/dist/test-utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { zoraCreator1155FactoryImplAddress } from "@zoralabs/protocol-deployments";
|
|
2
2
|
import { Address, Hex, PublicClient } from "viem";
|
|
3
|
-
|
|
3
|
+
import { NewContractParams } from "./create/types";
|
|
4
|
+
export declare const waitForSuccess: (hash: Hex, publicClient: PublicClient) => Promise<import("viem").TransactionReceipt>;
|
|
4
5
|
export declare const getFixedPricedMinter: ({ publicClient, chainId, }: {
|
|
5
6
|
publicClient: PublicClient;
|
|
6
7
|
chainId: keyof typeof zoraCreator1155FactoryImplAddress;
|
|
@@ -8,4 +9,5 @@ export declare const getFixedPricedMinter: ({ publicClient, chainId, }: {
|
|
|
8
9
|
export declare const fixedPriceMinterMinterArguments: ({ mintRecipient, }: {
|
|
9
10
|
mintRecipient: Address;
|
|
10
11
|
}) => `0x${string}`;
|
|
12
|
+
export declare function randomNewContract(): NewContractParams;
|
|
11
13
|
//# sourceMappingURL=test-utils.d.ts.map
|
package/dist/test-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iCAAiC,EAClC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,OAAO,EACP,GAAG,EACH,YAAY,EAGb,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iCAAiC,EAClC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,OAAO,EACP,GAAG,EACH,YAAY,EAGb,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD,eAAO,MAAM,cAAc,SAAgB,GAAG,gBAAgB,YAAY,+CAQzE,CAAC;AAEF,eAAO,MAAM,oBAAoB,+BAG9B;IACD,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,MAAM,OAAO,iCAAiC,CAAC;CACzD,2BAKG,CAAC;AAEL,eAAO,MAAM,+BAA+B,uBAEzC;IACD,aAAa,EAAE,OAAO,CAAC;CACxB,kBAAwE,CAAC;AAI1E,wBAAgB,iBAAiB,IAAI,iBAAiB,CAKrD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zoralabs/protocol-sdk",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.6-COMMENTS.0",
|
|
4
4
|
"repository": "https://github.com/ourzora/zora-protocol",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"abitype": "^1.0.2",
|
|
20
|
-
"@zoralabs/protocol-deployments": "^0.3.
|
|
20
|
+
"@zoralabs/protocol-deployments": "^0.3.8-COMMENTS.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"viem": "^2.21.21"
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { describe, expect } from "vitest";
|
|
2
|
+
import { forkUrls, makeAnvilTest, writeContractWithRetries } from "src/anvil";
|
|
3
|
+
import { base, zora } from "viem/chains";
|
|
4
|
+
import {
|
|
5
|
+
commentsABI,
|
|
6
|
+
commentsAddress,
|
|
7
|
+
emptyCommentIdentifier,
|
|
8
|
+
PermitComment,
|
|
9
|
+
PermitSparkComment,
|
|
10
|
+
sparkValue,
|
|
11
|
+
CommentIdentifier,
|
|
12
|
+
permitSparkCommentTypedDataDefinition,
|
|
13
|
+
permitMintAndCommentTypedDataDefinition,
|
|
14
|
+
PermitMintAndComment,
|
|
15
|
+
callerAndCommenterAddress as callerAndCommenterAddresses,
|
|
16
|
+
callerAndCommenterABI,
|
|
17
|
+
zoraCreator1155ImplABI,
|
|
18
|
+
} from "@zoralabs/protocol-deployments";
|
|
19
|
+
import {
|
|
20
|
+
Address,
|
|
21
|
+
keccak256,
|
|
22
|
+
toBytes,
|
|
23
|
+
zeroAddress,
|
|
24
|
+
parseEther,
|
|
25
|
+
TransactionReceipt,
|
|
26
|
+
parseEventLogs,
|
|
27
|
+
hashTypedData,
|
|
28
|
+
} from "viem";
|
|
29
|
+
import { createCreatorClient } from "src/sdk";
|
|
30
|
+
import { randomNewContract, waitForSuccess } from "src/test-utils";
|
|
31
|
+
import { permitCommentTypedDataDefinition } from "@zoralabs/protocol-deployments";
|
|
32
|
+
import { demoTokenMetadataURI } from "src/fixtures/contract-setup";
|
|
33
|
+
|
|
34
|
+
const getCommentIdentifierFromReceipt = (
|
|
35
|
+
receipt: TransactionReceipt,
|
|
36
|
+
): CommentIdentifier => {
|
|
37
|
+
const logs = parseEventLogs({
|
|
38
|
+
abi: commentsABI,
|
|
39
|
+
logs: receipt.logs,
|
|
40
|
+
eventName: "Commented",
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (logs.length === 0) {
|
|
44
|
+
throw new Error("No Commented event found in receipt");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return logs[0]!.args.commentIdentifier;
|
|
48
|
+
};
|
|
49
|
+
const randomNonce = () => keccak256(toBytes(Math.round(Math.random() * 1000)));
|
|
50
|
+
const thirtySecondsFromNow =
|
|
51
|
+
BigInt(Math.round(new Date().getTime() / 1000)) + 30n;
|
|
52
|
+
// todo: move this to protocol-deployments
|
|
53
|
+
describe("comments", () => {
|
|
54
|
+
makeAnvilTest({
|
|
55
|
+
forkUrl: forkUrls.zoraMainnet,
|
|
56
|
+
forkBlockNumber: 21297211,
|
|
57
|
+
anvilChainId: zora.id,
|
|
58
|
+
})(
|
|
59
|
+
"can sign and execute a cross-chain comment, and sign and execute a cross-chain spark comment",
|
|
60
|
+
async ({
|
|
61
|
+
viemClients: { publicClient, walletClient, chain, testClient },
|
|
62
|
+
}) => {
|
|
63
|
+
// Get the chain ID and set up addresses for different roles
|
|
64
|
+
const chainId = chain.id;
|
|
65
|
+
const [
|
|
66
|
+
collectorAddress,
|
|
67
|
+
creatorAddress,
|
|
68
|
+
executorAddress,
|
|
69
|
+
sparkerAddress,
|
|
70
|
+
] = (await walletClient.getAddresses()!) as [
|
|
71
|
+
Address,
|
|
72
|
+
Address,
|
|
73
|
+
Address,
|
|
74
|
+
Address,
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
// Create a creator client for interacting with the protocol
|
|
78
|
+
const creatorClient = createCreatorClient({
|
|
79
|
+
chainId,
|
|
80
|
+
publicClient,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Step 1: Create a new 1155 contract and token
|
|
84
|
+
const { contractAddress, newTokenId, parameters, prepareMint } =
|
|
85
|
+
await creatorClient.create1155({
|
|
86
|
+
contract: randomNewContract(),
|
|
87
|
+
token: {
|
|
88
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
89
|
+
},
|
|
90
|
+
account: creatorAddress,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Deploy the new contract
|
|
94
|
+
const { request } = await publicClient.simulateContract(parameters);
|
|
95
|
+
await writeContractWithRetries({
|
|
96
|
+
request,
|
|
97
|
+
walletClient,
|
|
98
|
+
publicClient,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Prepare to mint a token
|
|
102
|
+
const { parameters: collectParameters } = await prepareMint({
|
|
103
|
+
quantityToMint: 1n,
|
|
104
|
+
minterAccount: collectorAddress,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Step 2: Mint an 1155 token on the new contract
|
|
108
|
+
const { request: mintRequest } =
|
|
109
|
+
await publicClient.simulateContract(collectParameters);
|
|
110
|
+
await writeContractWithRetries({
|
|
111
|
+
request: mintRequest,
|
|
112
|
+
walletClient,
|
|
113
|
+
publicClient,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Set up cross-chain comment parameters
|
|
117
|
+
const sourceChainId = base.id; // The chain ID where the comment originates
|
|
118
|
+
|
|
119
|
+
const commentsAddressForChainId =
|
|
120
|
+
commentsAddress[chainId as keyof typeof commentsAddress];
|
|
121
|
+
|
|
122
|
+
// Step 3: Prepare a cross-chain comment
|
|
123
|
+
const permitComment: PermitComment = {
|
|
124
|
+
sourceChainId,
|
|
125
|
+
contractAddress,
|
|
126
|
+
destinationChainId: chainId,
|
|
127
|
+
tokenId: newTokenId,
|
|
128
|
+
commenter: collectorAddress,
|
|
129
|
+
text: "hello world",
|
|
130
|
+
deadline: thirtySecondsFromNow,
|
|
131
|
+
nonce: randomNonce(),
|
|
132
|
+
referrer: zeroAddress,
|
|
133
|
+
commenterSmartWallet: zeroAddress,
|
|
134
|
+
replyTo: emptyCommentIdentifier(),
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// Generate typed data for signing
|
|
138
|
+
const typedData = permitCommentTypedDataDefinition(permitComment);
|
|
139
|
+
|
|
140
|
+
expect(typedData.domain!.chainId).toEqual(sourceChainId);
|
|
141
|
+
expect(typedData.account).toEqual(collectorAddress);
|
|
142
|
+
expect(typedData.domain!.verifyingContract).toEqual(
|
|
143
|
+
commentsAddressForChainId,
|
|
144
|
+
);
|
|
145
|
+
expect(typedData.domain!.verifyingContract).toEqual(
|
|
146
|
+
commentsAddressForChainId,
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
const hashed = await publicClient.readContract({
|
|
150
|
+
abi: commentsABI,
|
|
151
|
+
address: commentsAddressForChainId,
|
|
152
|
+
functionName: "hashPermitComment",
|
|
153
|
+
args: [permitComment],
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
expect(hashed).toEqual(hashTypedData(typedData));
|
|
157
|
+
|
|
158
|
+
// Ensure the commenter has enough balance for the spark value
|
|
159
|
+
await testClient.setBalance({
|
|
160
|
+
address: collectorAddress,
|
|
161
|
+
value: sparkValue(),
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Step 4: Sign the cross-chain comment
|
|
165
|
+
const signature = await walletClient.signTypedData(typedData);
|
|
166
|
+
|
|
167
|
+
// Ensure the executor has enough balance to execute the transaction
|
|
168
|
+
await testClient.setBalance({
|
|
169
|
+
address: executorAddress,
|
|
170
|
+
value: parseEther("1"),
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// Step 5: Simulate and execute the cross-chain comment
|
|
174
|
+
const { request: commentRequest } = await publicClient.simulateContract({
|
|
175
|
+
abi: commentsABI,
|
|
176
|
+
address: commentsAddressForChainId,
|
|
177
|
+
functionName: "permitComment",
|
|
178
|
+
args: [permitComment, signature],
|
|
179
|
+
account: executorAddress,
|
|
180
|
+
value: sparkValue(),
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const commentHash = await walletClient.writeContract(commentRequest);
|
|
184
|
+
const receipt = await publicClient.waitForTransactionReceipt({
|
|
185
|
+
hash: commentHash,
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
expect(receipt.status).toBe("success");
|
|
189
|
+
|
|
190
|
+
// Extract the comment identifier from the transaction receipt
|
|
191
|
+
const commentIdentifier = getCommentIdentifierFromReceipt(receipt);
|
|
192
|
+
|
|
193
|
+
// Step 6: Prepare a spark (like) for the comment
|
|
194
|
+
const sparkComment: PermitSparkComment = {
|
|
195
|
+
sparksQuantity: 3n,
|
|
196
|
+
sparker: sparkerAddress,
|
|
197
|
+
deadline: thirtySecondsFromNow,
|
|
198
|
+
nonce: randomNonce(),
|
|
199
|
+
referrer: zeroAddress,
|
|
200
|
+
sourceChainId,
|
|
201
|
+
destinationChainId: chainId,
|
|
202
|
+
comment: commentIdentifier,
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const sparkTypedData =
|
|
206
|
+
permitSparkCommentTypedDataDefinition(sparkComment);
|
|
207
|
+
|
|
208
|
+
// Step 7: Sign the spark comment
|
|
209
|
+
const sparkSignature = await walletClient.signTypedData(sparkTypedData);
|
|
210
|
+
|
|
211
|
+
// Step 8: Simulate and execute the spark comment
|
|
212
|
+
const { request: sparkRequest } = await publicClient.simulateContract({
|
|
213
|
+
abi: commentsABI,
|
|
214
|
+
address: commentsAddressForChainId,
|
|
215
|
+
functionName: "permitSparkComment",
|
|
216
|
+
args: [sparkComment, sparkSignature],
|
|
217
|
+
account: executorAddress,
|
|
218
|
+
value: sparkValue() * sparkComment.sparksQuantity,
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
const sparkHash = await walletClient.writeContract(sparkRequest);
|
|
222
|
+
|
|
223
|
+
await waitForSuccess(sparkHash, publicClient);
|
|
224
|
+
|
|
225
|
+
// Step 9: Verify the spark count
|
|
226
|
+
const sparkCount = await publicClient.readContract({
|
|
227
|
+
abi: commentsABI,
|
|
228
|
+
address: commentsAddressForChainId,
|
|
229
|
+
functionName: "commentSparksQuantity",
|
|
230
|
+
args: [commentIdentifier],
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
expect(sparkCount).toEqual(sparkComment.sparksQuantity);
|
|
234
|
+
},
|
|
235
|
+
40_000,
|
|
236
|
+
);
|
|
237
|
+
makeAnvilTest({
|
|
238
|
+
forkUrl: forkUrls.zoraMainnet,
|
|
239
|
+
forkBlockNumber: 21297211,
|
|
240
|
+
anvilChainId: zora.id,
|
|
241
|
+
})(
|
|
242
|
+
"can sign and execute a cross-chain timed sale mint and comment",
|
|
243
|
+
async ({
|
|
244
|
+
viemClients: { publicClient, walletClient, chain, testClient },
|
|
245
|
+
}) => {
|
|
246
|
+
// Get the chain ID and set up addresses for different roles
|
|
247
|
+
const chainId = chain.id;
|
|
248
|
+
const [commenterAddress, executorAddress] =
|
|
249
|
+
(await walletClient.getAddresses()!) as [Address, Address, Address];
|
|
250
|
+
|
|
251
|
+
// Create a creator client for interacting with the protocol
|
|
252
|
+
const creatorClient = createCreatorClient({
|
|
253
|
+
chainId,
|
|
254
|
+
publicClient,
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// Step 1: Create a new 1155 contract and token
|
|
258
|
+
const { contractAddress, newTokenId, parameters } =
|
|
259
|
+
await creatorClient.create1155({
|
|
260
|
+
contract: randomNewContract(),
|
|
261
|
+
token: {
|
|
262
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
263
|
+
},
|
|
264
|
+
account: commenterAddress,
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// Deploy the new contract
|
|
268
|
+
const { request } = await publicClient.simulateContract(parameters);
|
|
269
|
+
await writeContractWithRetries({
|
|
270
|
+
request,
|
|
271
|
+
walletClient,
|
|
272
|
+
publicClient,
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
// Step 2: Prepare the permit data for timed sale mint and comment
|
|
276
|
+
const thirtySecondsFromNow = BigInt(Math.floor(Date.now() / 1000) + 30);
|
|
277
|
+
const quantity = 3n;
|
|
278
|
+
const mintReferral = zeroAddress;
|
|
279
|
+
const comment = "This is a test comment for timed sale mint";
|
|
280
|
+
|
|
281
|
+
const permitMintAndComment: PermitMintAndComment = {
|
|
282
|
+
commenter: commenterAddress,
|
|
283
|
+
quantity,
|
|
284
|
+
collection: contractAddress,
|
|
285
|
+
tokenId: newTokenId,
|
|
286
|
+
mintReferral,
|
|
287
|
+
comment,
|
|
288
|
+
deadline: thirtySecondsFromNow,
|
|
289
|
+
nonce: randomNonce(),
|
|
290
|
+
sourceChainId: chainId,
|
|
291
|
+
destinationChainId: chainId,
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
// Step 3: Generate the typed data for signing
|
|
295
|
+
const typedData =
|
|
296
|
+
permitMintAndCommentTypedDataDefinition(permitMintAndComment);
|
|
297
|
+
|
|
298
|
+
// Step 4: Sign the typed data
|
|
299
|
+
const signature = await walletClient.signTypedData(typedData);
|
|
300
|
+
|
|
301
|
+
await testClient.setBalance({
|
|
302
|
+
address: executorAddress,
|
|
303
|
+
value: parseEther("1"),
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// Step 5: Simulate and execute the permitTimedSaleMintAndComment function
|
|
307
|
+
const callerAndCommenterAddress =
|
|
308
|
+
callerAndCommenterAddresses[
|
|
309
|
+
chainId as keyof typeof callerAndCommenterAddresses
|
|
310
|
+
];
|
|
311
|
+
const { request: permitRequest } = await publicClient.simulateContract({
|
|
312
|
+
abi: callerAndCommenterABI,
|
|
313
|
+
address: callerAndCommenterAddress,
|
|
314
|
+
functionName: "permitTimedSaleMintAndComment",
|
|
315
|
+
args: [permitMintAndComment, signature],
|
|
316
|
+
account: executorAddress,
|
|
317
|
+
value: quantity * parseEther("0.000111"),
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
const receipt = await writeContractWithRetries({
|
|
321
|
+
publicClient,
|
|
322
|
+
walletClient,
|
|
323
|
+
request: permitRequest,
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
// Step 6: Verify the comment was created
|
|
327
|
+
const commentIdentifier = getCommentIdentifierFromReceipt(receipt);
|
|
328
|
+
expect(commentIdentifier).toBeDefined();
|
|
329
|
+
|
|
330
|
+
// Step 7: Verify the token was minted
|
|
331
|
+
const balance = await publicClient.readContract({
|
|
332
|
+
abi: zoraCreator1155ImplABI,
|
|
333
|
+
address: contractAddress,
|
|
334
|
+
functionName: "balanceOf",
|
|
335
|
+
args: [commenterAddress, newTokenId],
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
expect(balance).toEqual(quantity);
|
|
339
|
+
},
|
|
340
|
+
40_000, // Increased timeout to 30 seconds
|
|
341
|
+
);
|
|
342
|
+
});
|
|
@@ -21,16 +21,13 @@ import {
|
|
|
21
21
|
import { zora } from "viem/chains";
|
|
22
22
|
import { AllowList } from "src/allow-list/types";
|
|
23
23
|
import { createAllowList } from "src/allow-list/allow-list-client";
|
|
24
|
-
import { NewContractParams } from "./types";
|
|
25
24
|
import { SubgraphContractGetter } from "./contract-getter";
|
|
26
25
|
import {
|
|
27
26
|
DEFAULT_MINIMUM_MARKET_ETH,
|
|
28
27
|
DEFAULT_MARKET_COUNTDOWN,
|
|
29
28
|
} from "./minter-defaults";
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
demoTokenMetadataURI,
|
|
33
|
-
} from "src/fixtures/contract-setup";
|
|
29
|
+
import { randomNewContract } from "src/test-utils";
|
|
30
|
+
import { demoTokenMetadataURI } from "src/fixtures/contract-setup";
|
|
34
31
|
|
|
35
32
|
const anvilTest = makeAnvilTest({
|
|
36
33
|
forkUrl: forkUrls.zoraMainnet,
|
|
@@ -61,13 +58,6 @@ const minterIsMinterOnToken = async ({
|
|
|
61
58
|
});
|
|
62
59
|
};
|
|
63
60
|
|
|
64
|
-
function randomNewContract(): NewContractParams {
|
|
65
|
-
return {
|
|
66
|
-
name: `testContract-${Math.round(Math.random() * 1_000_000)}`,
|
|
67
|
-
uri: demoContractMetadataURI,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
61
|
describe("create-helper", () => {
|
|
72
62
|
anvilTest(
|
|
73
63
|
"when no sales config is provided, it creates a new 1155 contract and token using the timed sale strategy",
|
|
@@ -238,6 +238,7 @@ async function createNew1155ContractAndToken({
|
|
|
238
238
|
publicClient,
|
|
239
239
|
chainId,
|
|
240
240
|
}),
|
|
241
|
+
chainId,
|
|
241
242
|
});
|
|
242
243
|
|
|
243
244
|
return {
|
|
@@ -294,6 +295,7 @@ async function createNew1155Token({
|
|
|
294
295
|
result: newToken.salesConfig,
|
|
295
296
|
tokenId: nextTokenId,
|
|
296
297
|
getContractMintFee: async () => mintFee,
|
|
298
|
+
chainId,
|
|
297
299
|
});
|
|
298
300
|
|
|
299
301
|
return {
|
|
@@ -75,6 +75,7 @@ export function makeOnchainPrepareMintFromCreate({
|
|
|
75
75
|
minter,
|
|
76
76
|
getContractMintFee,
|
|
77
77
|
contractVersion,
|
|
78
|
+
chainId,
|
|
78
79
|
}: {
|
|
79
80
|
contractAddress: Address;
|
|
80
81
|
tokenId: bigint;
|
|
@@ -82,6 +83,7 @@ export function makeOnchainPrepareMintFromCreate({
|
|
|
82
83
|
minter: Address;
|
|
83
84
|
getContractMintFee: () => Promise<bigint>;
|
|
84
85
|
contractVersion: string;
|
|
86
|
+
chainId: number;
|
|
85
87
|
}): AsyncPrepareMint {
|
|
86
88
|
return async (params: MintParametersBase): Promise<PrepareMintReturn> => {
|
|
87
89
|
const subgraphSalesConfig = await toSalesStrategyFromSubgraph({
|
|
@@ -98,6 +100,7 @@ export function makeOnchainPrepareMintFromCreate({
|
|
|
98
100
|
...params,
|
|
99
101
|
tokenContract: contractAddress,
|
|
100
102
|
tokenId,
|
|
103
|
+
chainId,
|
|
101
104
|
}),
|
|
102
105
|
costs: parseMintCosts({
|
|
103
106
|
allowListEntry: params.allowListEntry,
|