thirdweb 5.55.0 → 5.55.1-nightly-b2a2c9784a33394dffbcd32bbd28b2c612a4e603-20240915000420

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.
Files changed (129) hide show
  1. package/dist/cjs/contract/deployment/deploy-with-abi.js +17 -6
  2. package/dist/cjs/contract/deployment/deploy-with-abi.js.map +1 -1
  3. package/dist/cjs/exports/deploys.js +2 -2
  4. package/dist/cjs/exports/deploys.js.map +1 -1
  5. package/dist/cjs/exports/extensions/marketplace.js +14 -3
  6. package/dist/cjs/exports/extensions/marketplace.js.map +1 -1
  7. package/dist/cjs/extensions/marketplace/direct-listings/read/getListing.js +18 -2
  8. package/dist/cjs/extensions/marketplace/direct-listings/read/getListing.js.map +1 -1
  9. package/dist/cjs/extensions/marketplace/direct-listings/write/buyFromListing.js +21 -4
  10. package/dist/cjs/extensions/marketplace/direct-listings/write/buyFromListing.js.map +1 -1
  11. package/dist/cjs/extensions/marketplace/direct-listings/write/createListing.js +18 -2
  12. package/dist/cjs/extensions/marketplace/direct-listings/write/createListing.js.map +1 -1
  13. package/dist/cjs/extensions/marketplace/english-auctions/read/getAuction.js +18 -2
  14. package/dist/cjs/extensions/marketplace/english-auctions/read/getAuction.js.map +1 -1
  15. package/dist/cjs/extensions/marketplace/english-auctions/read/getWinningBid.js +19 -3
  16. package/dist/cjs/extensions/marketplace/english-auctions/read/getWinningBid.js.map +1 -1
  17. package/dist/cjs/extensions/marketplace/english-auctions/write/bidInAuction.js +27 -8
  18. package/dist/cjs/extensions/marketplace/english-auctions/write/bidInAuction.js.map +1 -1
  19. package/dist/cjs/extensions/marketplace/english-auctions/write/cancelAuction.js +19 -2
  20. package/dist/cjs/extensions/marketplace/english-auctions/write/cancelAuction.js.map +1 -1
  21. package/dist/cjs/extensions/marketplace/english-auctions/write/createAuction.js +18 -2
  22. package/dist/cjs/extensions/marketplace/english-auctions/write/createAuction.js.map +1 -1
  23. package/dist/cjs/extensions/prebuilts/deploy-published.js +6 -1
  24. package/dist/cjs/extensions/prebuilts/deploy-published.js.map +1 -1
  25. package/dist/cjs/extensions/prebuilts/get-required-transactions.js +110 -23
  26. package/dist/cjs/extensions/prebuilts/get-required-transactions.js.map +1 -1
  27. package/dist/cjs/gas/fee-data.js +2 -2
  28. package/dist/cjs/gas/fee-data.js.map +1 -1
  29. package/dist/cjs/utils/abi/normalizeFunctionParams.js +6 -6
  30. package/dist/cjs/utils/abi/normalizeFunctionParams.js.map +1 -1
  31. package/dist/cjs/utils/any-evm/deploy-metadata.js +2 -1
  32. package/dist/cjs/utils/any-evm/deploy-metadata.js.map +1 -1
  33. package/dist/cjs/utils/any-evm/get-init-bytecode-with-salt.js +2 -2
  34. package/dist/cjs/utils/any-evm/get-init-bytecode-with-salt.js.map +1 -1
  35. package/dist/cjs/utils/contract/parse-abi-params.js +3 -0
  36. package/dist/cjs/utils/contract/parse-abi-params.js.map +1 -1
  37. package/dist/cjs/version.js +1 -1
  38. package/dist/cjs/version.js.map +1 -1
  39. package/dist/esm/contract/deployment/deploy-with-abi.js +17 -6
  40. package/dist/esm/contract/deployment/deploy-with-abi.js.map +1 -1
  41. package/dist/esm/exports/deploys.js +1 -1
  42. package/dist/esm/exports/deploys.js.map +1 -1
  43. package/dist/esm/exports/extensions/marketplace.js +9 -8
  44. package/dist/esm/exports/extensions/marketplace.js.map +1 -1
  45. package/dist/esm/extensions/marketplace/direct-listings/read/getListing.js +17 -2
  46. package/dist/esm/extensions/marketplace/direct-listings/read/getListing.js.map +1 -1
  47. package/dist/esm/extensions/marketplace/direct-listings/write/buyFromListing.js +20 -4
  48. package/dist/esm/extensions/marketplace/direct-listings/write/buyFromListing.js.map +1 -1
  49. package/dist/esm/extensions/marketplace/direct-listings/write/createListing.js +17 -2
  50. package/dist/esm/extensions/marketplace/direct-listings/write/createListing.js.map +1 -1
  51. package/dist/esm/extensions/marketplace/english-auctions/read/getAuction.js +17 -2
  52. package/dist/esm/extensions/marketplace/english-auctions/read/getAuction.js.map +1 -1
  53. package/dist/esm/extensions/marketplace/english-auctions/read/getWinningBid.js +19 -4
  54. package/dist/esm/extensions/marketplace/english-auctions/read/getWinningBid.js.map +1 -1
  55. package/dist/esm/extensions/marketplace/english-auctions/write/bidInAuction.js +26 -8
  56. package/dist/esm/extensions/marketplace/english-auctions/write/bidInAuction.js.map +1 -1
  57. package/dist/esm/extensions/marketplace/english-auctions/write/cancelAuction.js +19 -3
  58. package/dist/esm/extensions/marketplace/english-auctions/write/cancelAuction.js.map +1 -1
  59. package/dist/esm/extensions/marketplace/english-auctions/write/createAuction.js +17 -2
  60. package/dist/esm/extensions/marketplace/english-auctions/write/createAuction.js.map +1 -1
  61. package/dist/esm/extensions/prebuilts/deploy-published.js +6 -1
  62. package/dist/esm/extensions/prebuilts/deploy-published.js.map +1 -1
  63. package/dist/esm/extensions/prebuilts/get-required-transactions.js +108 -22
  64. package/dist/esm/extensions/prebuilts/get-required-transactions.js.map +1 -1
  65. package/dist/esm/gas/fee-data.js +2 -2
  66. package/dist/esm/gas/fee-data.js.map +1 -1
  67. package/dist/esm/utils/abi/normalizeFunctionParams.js +6 -6
  68. package/dist/esm/utils/abi/normalizeFunctionParams.js.map +1 -1
  69. package/dist/esm/utils/any-evm/deploy-metadata.js +2 -1
  70. package/dist/esm/utils/any-evm/deploy-metadata.js.map +1 -1
  71. package/dist/esm/utils/any-evm/get-init-bytecode-with-salt.js +1 -1
  72. package/dist/esm/utils/any-evm/get-init-bytecode-with-salt.js.map +1 -1
  73. package/dist/esm/utils/contract/parse-abi-params.js +3 -0
  74. package/dist/esm/utils/contract/parse-abi-params.js.map +1 -1
  75. package/dist/esm/version.js +1 -1
  76. package/dist/esm/version.js.map +1 -1
  77. package/dist/types/contract/deployment/deploy-with-abi.d.ts.map +1 -1
  78. package/dist/types/exports/deploys.d.ts +1 -1
  79. package/dist/types/exports/deploys.d.ts.map +1 -1
  80. package/dist/types/exports/extensions/marketplace.d.ts +9 -8
  81. package/dist/types/exports/extensions/marketplace.d.ts.map +1 -1
  82. package/dist/types/extensions/marketplace/direct-listings/read/getListing.d.ts +15 -2
  83. package/dist/types/extensions/marketplace/direct-listings/read/getListing.d.ts.map +1 -1
  84. package/dist/types/extensions/marketplace/direct-listings/write/buyFromListing.d.ts +13 -0
  85. package/dist/types/extensions/marketplace/direct-listings/write/buyFromListing.d.ts.map +1 -1
  86. package/dist/types/extensions/marketplace/direct-listings/write/createListing.d.ts +13 -0
  87. package/dist/types/extensions/marketplace/direct-listings/write/createListing.d.ts.map +1 -1
  88. package/dist/types/extensions/marketplace/english-auctions/read/getAuction.d.ts +15 -2
  89. package/dist/types/extensions/marketplace/english-auctions/read/getAuction.d.ts.map +1 -1
  90. package/dist/types/extensions/marketplace/english-auctions/read/getWinningBid.d.ts +15 -2
  91. package/dist/types/extensions/marketplace/english-auctions/read/getWinningBid.d.ts.map +1 -1
  92. package/dist/types/extensions/marketplace/english-auctions/write/bidInAuction.d.ts +13 -0
  93. package/dist/types/extensions/marketplace/english-auctions/write/bidInAuction.d.ts.map +1 -1
  94. package/dist/types/extensions/marketplace/english-auctions/write/cancelAuction.d.ts +13 -0
  95. package/dist/types/extensions/marketplace/english-auctions/write/cancelAuction.d.ts.map +1 -1
  96. package/dist/types/extensions/marketplace/english-auctions/write/createAuction.d.ts +13 -0
  97. package/dist/types/extensions/marketplace/english-auctions/write/createAuction.d.ts.map +1 -1
  98. package/dist/types/extensions/prebuilts/deploy-published.d.ts.map +1 -1
  99. package/dist/types/extensions/prebuilts/get-required-transactions.d.ts +8 -8
  100. package/dist/types/extensions/prebuilts/get-required-transactions.d.ts.map +1 -1
  101. package/dist/types/utils/abi/normalizeFunctionParams.d.ts.map +1 -1
  102. package/dist/types/utils/any-evm/deploy-metadata.d.ts +27 -1
  103. package/dist/types/utils/any-evm/deploy-metadata.d.ts.map +1 -1
  104. package/dist/types/utils/any-evm/get-init-bytecode-with-salt.d.ts +1 -1
  105. package/dist/types/utils/any-evm/get-init-bytecode-with-salt.d.ts.map +1 -1
  106. package/dist/types/utils/contract/parse-abi-params.d.ts.map +1 -1
  107. package/dist/types/version.d.ts +1 -1
  108. package/dist/types/version.d.ts.map +1 -1
  109. package/package.json +2 -2
  110. package/src/contract/deployment/deploy-with-abi.ts +19 -6
  111. package/src/exports/deploys.ts +1 -1
  112. package/src/exports/extensions/marketplace.ts +10 -0
  113. package/src/extensions/marketplace/direct-listings/read/getListing.ts +19 -7
  114. package/src/extensions/marketplace/direct-listings/write/buyFromListing.ts +23 -4
  115. package/src/extensions/marketplace/direct-listings/write/createListing.ts +18 -2
  116. package/src/extensions/marketplace/english-auctions/read/getAuction.ts +19 -7
  117. package/src/extensions/marketplace/english-auctions/read/getWinningBid.ts +21 -8
  118. package/src/extensions/marketplace/english-auctions/write/bidInAuction.ts +29 -8
  119. package/src/extensions/marketplace/english-auctions/write/cancelAuction.ts +25 -3
  120. package/src/extensions/marketplace/english-auctions/write/createAuction.ts +18 -2
  121. package/src/extensions/prebuilts/deploy-published.ts +7 -1
  122. package/src/extensions/prebuilts/get-required-transactions.test.ts +13 -11
  123. package/src/extensions/prebuilts/get-required-transactions.ts +149 -32
  124. package/src/gas/fee-data.ts +5 -1
  125. package/src/utils/abi/normalizeFunctionParams.ts +24 -19
  126. package/src/utils/any-evm/deploy-metadata.ts +33 -2
  127. package/src/utils/any-evm/get-init-bytecode-with-salt.ts +2 -2
  128. package/src/utils/contract/parse-abi-params.ts +3 -0
  129. package/src/version.ts +1 -1
@@ -1,9 +1,9 @@
1
1
  import { isNativeTokenAddress } from "../../../../constants/addresses.js";
2
2
  import type { BaseTransactionOptions } from "../../../../transaction/types.js";
3
- import { isNewWinningBid } from "../../__generated__/IEnglishAuctions/read/isNewWinningBid.js";
4
- import { bidInAuction as generatedBidInAuction } from "../../__generated__/IEnglishAuctions/write/bidInAuction.js";
5
- import { getAuction } from "../read/getAuction.js";
6
- import { getWinningBid } from "../read/getWinningBid.js";
3
+ import * as IsNewWinningBid from "../../__generated__/IEnglishAuctions/read/isNewWinningBid.js";
4
+ import * as BidInAuction from "../../__generated__/IEnglishAuctions/write/bidInAuction.js";
5
+ import * as GetAuction from "../read/getAuction.js";
6
+ import * as GetWinningBid from "../read/getWinningBid.js";
7
7
 
8
8
  /**
9
9
  * @extension MARKETPLACE
@@ -39,10 +39,10 @@ export type BidInAuctionParams = {
39
39
  export function bidInAuction(
40
40
  options: BaseTransactionOptions<BidInAuctionParams>,
41
41
  ) {
42
- return generatedBidInAuction({
42
+ return BidInAuction.bidInAuction({
43
43
  contract: options.contract,
44
44
  asyncParams: async () => {
45
- const auction = await getAuction({
45
+ const auction = await GetAuction.getAuction({
46
46
  contract: options.contract,
47
47
  auctionId: options.auctionId,
48
48
  });
@@ -70,13 +70,13 @@ export function bidInAuction(
70
70
  if (resolvedBidAmountWei > auction.buyoutCurrencyValue.value) {
71
71
  throw new Error("Bid amount is above the buyout amount");
72
72
  }
73
- const existingWinningBid = await getWinningBid({
73
+ const existingWinningBid = await GetWinningBid.getWinningBid({
74
74
  auctionId: options.auctionId,
75
75
  contract: options.contract,
76
76
  });
77
77
  if (existingWinningBid) {
78
78
  // check if the bid amount is sufficient to outbid the existing winning bid
79
- const isNewWinner = await isNewWinningBid({
79
+ const isNewWinner = await IsNewWinningBid.isNewWinningBid({
80
80
  contract: options.contract,
81
81
  auctionId: options.auctionId,
82
82
  bidAmount: resolvedBidAmountWei,
@@ -106,3 +106,24 @@ export function bidInAuction(
106
106
  },
107
107
  });
108
108
  }
109
+
110
+ /**
111
+ * Checks if the `bidInAuction` method is supported by the given contract.
112
+ * @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
113
+ * @returns A boolean indicating if the `bidInAuction` method is supported.
114
+ * @extension MARKETPLACE
115
+ * @example
116
+ * ```ts
117
+ * import { isBidInAuctionSupported } from "thirdweb/extensions/marketplace";
118
+ *
119
+ * const supported = isBidInAuctionSupported(["0x..."]);
120
+ * ```
121
+ */
122
+ export function isBidInAuctionSupported(availableSelectors: string[]) {
123
+ return (
124
+ BidInAuction.isBidInAuctionSupported(availableSelectors) &&
125
+ GetWinningBid.isGetWinningBidSupported(availableSelectors) &&
126
+ GetAuction.isGetAuctionSupported(availableSelectors) &&
127
+ IsNewWinningBid.isIsNewWinningBidSupported(availableSelectors)
128
+ );
129
+ }
@@ -1,6 +1,9 @@
1
1
  import type { BaseTransactionOptions } from "../../../../transaction/types.js";
2
- import { cancelAuction as generatedCancelAuction } from "../../__generated__/IEnglishAuctions/write/cancelAuction.js";
3
- import { getWinningBid } from "../read/getWinningBid.js";
2
+ import * as CancelAuction from "../../__generated__/IEnglishAuctions/write/cancelAuction.js";
3
+ import {
4
+ getWinningBid,
5
+ isGetWinningBidSupported,
6
+ } from "../read/getWinningBid.js";
4
7
 
5
8
  /**
6
9
  * @extension MARKETPLACE
@@ -32,7 +35,7 @@ export type CancelAuctionParams = {
32
35
  export function cancelAuction(
33
36
  options: BaseTransactionOptions<CancelAuctionParams>,
34
37
  ) {
35
- return generatedCancelAuction({
38
+ return CancelAuction.cancelAuction({
36
39
  contract: options.contract,
37
40
  asyncParams: async () => {
38
41
  const winningBid = await getWinningBid({
@@ -51,3 +54,22 @@ export function cancelAuction(
51
54
  },
52
55
  });
53
56
  }
57
+
58
+ /**
59
+ * Checks if the `cancelAuction` method is supported by the given contract.
60
+ * @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
61
+ * @returns A boolean indicating if the `cancelAuction` method is supported.
62
+ * @extension MARKETPLACE
63
+ * @example
64
+ * ```ts
65
+ * import { isCancelAuctionSupported } from "thirdweb/extensions/marketplace";
66
+ *
67
+ * const supported = isCancelAuctionSupported(["0x..."]);
68
+ * ```
69
+ */
70
+ export function isCancelAuctionSupported(availableSelectors: string[]) {
71
+ return (
72
+ CancelAuction.isCancelAuctionSupported(availableSelectors) &&
73
+ isGetWinningBidSupported(availableSelectors)
74
+ );
75
+ }
@@ -10,7 +10,7 @@ import type { BaseTransactionOptions } from "../../../../transaction/types.js";
10
10
  import { toUnits } from "../../../../utils/units.js";
11
11
  import { isERC721 } from "../../../erc721/read/isERC721.js";
12
12
  import { isERC1155 } from "../../../erc1155/read/isERC1155.js";
13
- import { createAuction as generatedCreateAuction } from "../../__generated__/IEnglishAuctions/write/createAuction.js";
13
+ import * as CreateAuction from "../../__generated__/IEnglishAuctions/write/createAuction.js";
14
14
 
15
15
  /**
16
16
  * @extension MARKETPLACE
@@ -119,7 +119,7 @@ export type CreateAuctionParams = {
119
119
  export function createAuction(
120
120
  options: BaseTransactionOptions<CreateAuctionParams>,
121
121
  ) {
122
- return generatedCreateAuction({
122
+ return CreateAuction.createAuction({
123
123
  ...options,
124
124
  asyncParams: async () => {
125
125
  const assetContract = getContract({
@@ -245,3 +245,19 @@ export function createAuction(
245
245
  },
246
246
  });
247
247
  }
248
+
249
+ /**
250
+ * Checks if the `createAuction` method is supported by the given contract.
251
+ * @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
252
+ * @returns A boolean indicating if the `createAuction` method is supported.
253
+ * @extension MARKETPLACE
254
+ * @example
255
+ * ```ts
256
+ * import { isCreateAuctionSupported } from "thirdweb/extensions/marketplace";
257
+ *
258
+ * const supported = isCreateAuctionSupported(["0x..."]);
259
+ * ```
260
+ */
261
+ export function isCreateAuctionSupported(availableSelectors: string[]) {
262
+ return CreateAuction.isCreateAuctionSupported(availableSelectors);
263
+ }
@@ -18,6 +18,7 @@ import type { FetchDeployMetadataResult } from "../../utils/any-evm/deploy-metad
18
18
  import { isZkSyncChain } from "../../utils/any-evm/zksync/isZkSyncChain.js";
19
19
  import type { Hex } from "../../utils/encoding/hex.js";
20
20
  import type { Account } from "../../wallets/interfaces/wallet.js";
21
+ import { getAllDefaultConstructorParamsForImplementation } from "./get-required-transactions.js";
21
22
 
22
23
  /**
23
24
  * @extension DEPLOY
@@ -168,7 +169,12 @@ export async function deployContractfromDeployMetadata(
168
169
  client,
169
170
  account,
170
171
  contractId: deployMetadata.name,
171
- constructorParams: implementationConstructorParams,
172
+ constructorParams:
173
+ implementationConstructorParams ||
174
+ (await getAllDefaultConstructorParamsForImplementation({
175
+ chain,
176
+ client,
177
+ })),
172
178
  publisher: deployMetadata.publisher,
173
179
  });
174
180
 
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
2
2
  import { CLEAN_ANVIL_CHAIN } from "../../../test/src/chains.js";
3
3
  import { TEST_CLIENT } from "../../../test/src/test-clients.js";
4
4
  import { fetchPublishedContractMetadata } from "../../contract/deployment/publisher.js";
5
- import { getRequiredTransactionCount } from "./get-required-transactions.js";
5
+ import { getRequiredTransactions } from "./get-required-transactions.js";
6
6
 
7
7
  describe.runIf(process.env.TW_SECRET_KEY)(
8
8
  "getRequiredTransactions",
@@ -11,47 +11,49 @@ describe.runIf(process.env.TW_SECRET_KEY)(
11
11
  },
12
12
  () => {
13
13
  it("should count transactions for a published direct deploy contract", async () => {
14
- const metadata = await fetchPublishedContractMetadata({
14
+ const deployMetadata = await fetchPublishedContractMetadata({
15
15
  client: TEST_CLIENT,
16
16
  contractId: "AccountFactory",
17
17
  });
18
- const results = await getRequiredTransactionCount({
18
+ const results = await getRequiredTransactions({
19
19
  client: TEST_CLIENT,
20
20
  chain: CLEAN_ANVIL_CHAIN,
21
- metadata,
21
+ deployMetadata,
22
22
  });
23
23
  expect(results.length).toBe(1);
24
24
  });
25
25
 
26
26
  it("should count transactions for a published autofactory contract", async () => {
27
- const metadata = await fetchPublishedContractMetadata({
27
+ const deployMetadata = await fetchPublishedContractMetadata({
28
28
  client: TEST_CLIENT,
29
29
  contractId: "Airdrop",
30
30
  });
31
- const results = await getRequiredTransactionCount({
31
+ const results = await getRequiredTransactions({
32
32
  client: TEST_CLIENT,
33
33
  chain: CLEAN_ANVIL_CHAIN,
34
- metadata,
34
+ deployMetadata,
35
35
  });
36
36
  expect(results.length).toBe(4);
37
37
  });
38
38
 
39
39
  it("should count transactions for a modular contract with modules", async () => {
40
- const metadata = await fetchPublishedContractMetadata({
40
+ const deployMetadata = await fetchPublishedContractMetadata({
41
41
  client: TEST_CLIENT,
42
42
  contractId: "ERC721CoreInitializable",
43
43
  });
44
- const results = await getRequiredTransactionCount({
44
+ const results = await getRequiredTransactions({
45
45
  client: TEST_CLIENT,
46
46
  chain: CLEAN_ANVIL_CHAIN,
47
- metadata,
47
+ deployMetadata,
48
48
  modules: await Promise.all(
49
49
  ["ClaimableERC721", "BatchMetadataERC721", "RoyaltyERC721"].map(
50
50
  (contractId) =>
51
51
  fetchPublishedContractMetadata({
52
52
  client: TEST_CLIENT,
53
53
  contractId,
54
- }),
54
+ }).then((m) => ({
55
+ deployMetadata: m,
56
+ })),
55
57
  ),
56
58
  ),
57
59
  });
@@ -5,6 +5,8 @@ import { getDeployedInfraContract } from "../../contract/deployment/utils/infra.
5
5
  import { getDeployedInfraContractFromMetadata } from "../../contract/deployment/utils/infra.js";
6
6
  import { computePublishedContractAddress } from "../../utils/any-evm/compute-published-contract-address.js";
7
7
  import type { FetchDeployMetadataResult } from "../../utils/any-evm/deploy-metadata.js";
8
+ import { isZkSyncChain } from "../../utils/any-evm/zksync/isZkSyncChain.js";
9
+ import type { DeployContractfromDeployMetadataOptions } from "./deploy-published.js";
8
10
 
9
11
  /**
10
12
  * @internal
@@ -13,6 +15,7 @@ export type DeployTransactionType =
13
15
  | "infra"
14
16
  | "implementation"
15
17
  | "module"
18
+ | "extension"
16
19
  | "proxy";
17
20
 
18
21
  /**
@@ -26,36 +29,42 @@ export type DeployTransactionResult = {
26
29
  /**
27
30
  * @internal
28
31
  */
29
- export async function getRequiredTransactionCount(options: {
30
- chain: Chain;
31
- client: ThirdwebClient;
32
- metadata: FetchDeployMetadataResult;
33
- constructorParams?: Record<string, unknown>;
34
- implementationConstructorParams?: Record<string, unknown>;
35
- modules?: FetchDeployMetadataResult[];
36
- }): Promise<DeployTransactionResult[]> {
32
+ export async function getRequiredTransactions(
33
+ options: Omit<
34
+ DeployContractfromDeployMetadataOptions,
35
+ "account" | "initializeParams"
36
+ >,
37
+ ): Promise<DeployTransactionResult[]> {
37
38
  const {
38
39
  chain,
39
40
  client,
40
- metadata,
41
+ deployMetadata,
41
42
  implementationConstructorParams,
42
43
  modules = [],
43
44
  } = options;
44
45
 
45
- if (metadata?.deployType === "autoFactory") {
46
- const results: (DeployTransactionResult | null)[] = await Promise.all([
46
+ if (deployMetadata?.deployType === "autoFactory") {
47
+ const results: (
48
+ | DeployTransactionResult
49
+ | DeployTransactionResult[]
50
+ | null
51
+ )[] = await Promise.all([
47
52
  getDeployedCreate2Factory({
48
53
  chain,
49
54
  client,
50
55
  }).then((c) =>
51
- c ? null : ({ type: "infra", contractId: "Create2Factory" } as const),
56
+ c || isZkSyncChain(chain)
57
+ ? null
58
+ : ({ type: "infra", contractId: "Create2Factory" } as const),
52
59
  ),
53
60
  getDeployedInfraContract({
54
61
  chain,
55
62
  client,
56
63
  contractId: "Forwarder",
57
64
  }).then((c) =>
58
- c ? null : ({ type: "infra", contractId: "Forwarder" } as const),
65
+ c || isZkSyncChain(chain)
66
+ ? null
67
+ : ({ type: "infra", contractId: "Forwarder" } as const),
59
68
  ),
60
69
  getDeployedInfraContract({
61
70
  chain,
@@ -69,42 +78,150 @@ export async function getRequiredTransactionCount(options: {
69
78
  }),
70
79
  },
71
80
  }).then((c) =>
72
- c ? null : ({ type: "infra", contractId: "TWCloneFactory" } as const),
81
+ c || isZkSyncChain(chain)
82
+ ? null
83
+ : ({ type: "infra", contractId: "TWCloneFactory" } as const),
73
84
  ),
74
85
  // TODO (deploy): add WETH contract check for implementations that need it (check implementation constructor params)
75
- getDeployedInfraContract({
86
+ getTransactionsForImplementation({
76
87
  chain,
77
88
  client,
78
- contractId: metadata.name,
79
- constructorParams: implementationConstructorParams,
80
- publisher: metadata.publisher,
81
- version: metadata.version,
82
- }).then((c) =>
83
- c
84
- ? null
85
- : ({
86
- type: "implementation",
87
- contractId: metadata.name,
88
- } as const),
89
- ),
89
+ deployMetadata,
90
+ implementationConstructorParams,
91
+ }),
90
92
  ...modules.map((m) =>
91
93
  getDeployedInfraContractFromMetadata({
92
94
  chain,
93
95
  client,
94
- contractMetadata: m,
96
+ contractMetadata: m.deployMetadata,
95
97
  }).then((c) =>
96
98
  c
97
99
  ? null
98
100
  : ({
99
101
  type: "module",
100
- contractId: m.name,
102
+ contractId: m.deployMetadata.name,
101
103
  } as const),
102
104
  ),
103
105
  ),
104
106
  ]);
105
- results.push({ type: "proxy", contractId: metadata.name });
106
- return results.filter((r) => r !== null);
107
+ results.push({ type: "proxy", contractId: deployMetadata.name });
108
+ return results.flat().filter((r) => r !== null);
107
109
  }
108
110
 
109
- return [{ type: "implementation", contractId: metadata.name }];
111
+ return [{ type: "implementation", contractId: deployMetadata.name }];
112
+ }
113
+
114
+ async function getTransactionsForImplementation(options: {
115
+ chain: Chain;
116
+ client: ThirdwebClient;
117
+ deployMetadata: FetchDeployMetadataResult;
118
+ implementationConstructorParams?: Record<string, unknown>;
119
+ }): Promise<DeployTransactionResult[]> {
120
+ const { chain, client, deployMetadata, implementationConstructorParams } =
121
+ options;
122
+
123
+ if (deployMetadata.name === "MarketplaceV3") {
124
+ return getTransactionsForMaketplaceV3(options);
125
+ }
126
+
127
+ const constructorParams =
128
+ implementationConstructorParams ??
129
+ (await getAllDefaultConstructorParamsForImplementation({
130
+ chain,
131
+ client,
132
+ }));
133
+
134
+ const result = await getDeployedInfraContract({
135
+ chain,
136
+ client,
137
+ contractId: deployMetadata.name,
138
+ constructorParams,
139
+ publisher: deployMetadata.publisher,
140
+ version: deployMetadata.version,
141
+ }).then((c) =>
142
+ c
143
+ ? null
144
+ : ({
145
+ type: "implementation",
146
+ contractId: deployMetadata.name,
147
+ } as const),
148
+ );
149
+ return result ? [result] : [];
150
+ }
151
+
152
+ async function getTransactionsForMaketplaceV3(options: {
153
+ chain: Chain;
154
+ client: ThirdwebClient;
155
+ }): Promise<DeployTransactionResult[]> {
156
+ const { chain, client } = options;
157
+ const WETHAdress = await computePublishedContractAddress({
158
+ chain,
159
+ client,
160
+ contractId: "WETH9",
161
+ });
162
+ const extensions: (DeployTransactionResult | null)[] = await Promise.all([
163
+ getDeployedInfraContract({
164
+ chain,
165
+ client,
166
+ contractId: "WETH9",
167
+ }).then((c) =>
168
+ c ? null : ({ type: "infra", contractId: "WETH9" } as const),
169
+ ),
170
+ getDeployedInfraContract({
171
+ chain,
172
+ client,
173
+ contractId: "DirectListingsLogic",
174
+ constructorParams: { _nativeTokenWrapper: WETHAdress },
175
+ }).then((c) =>
176
+ c
177
+ ? null
178
+ : ({ type: "extension", contractId: "DirectListingsLogic" } as const),
179
+ ),
180
+ getDeployedInfraContract({
181
+ chain,
182
+ client,
183
+ contractId: "EnglishAuctionsLogic",
184
+ constructorParams: { _nativeTokenWrapper: WETHAdress },
185
+ }).then((c) =>
186
+ c
187
+ ? null
188
+ : ({ type: "extension", contractId: "EnglishAuctionsLogic" } as const),
189
+ ),
190
+ getDeployedInfraContract({
191
+ chain,
192
+ client,
193
+ contractId: "OffersLogic",
194
+ }).then((c) =>
195
+ c ? null : ({ type: "extension", contractId: "OffersLogic" } as const),
196
+ ),
197
+ ]);
198
+ // hacky assumption: if we need to deploy any of the extensions, we also need to deploy the implementation
199
+ const transactions = extensions.filter((e) => e !== null);
200
+ if (transactions.length) {
201
+ transactions.push({ type: "implementation", contractId: "MarketplaceV3" });
202
+ }
203
+ return transactions;
204
+ }
205
+
206
+ export async function getAllDefaultConstructorParamsForImplementation(args: {
207
+ chain: Chain;
208
+ client: ThirdwebClient;
209
+ }) {
210
+ const { chain, client } = args;
211
+ const [forwarder, weth] = await Promise.all([
212
+ computePublishedContractAddress({
213
+ chain,
214
+ client,
215
+ contractId: "Forwarder",
216
+ }),
217
+ computePublishedContractAddress({
218
+ chain,
219
+ client,
220
+ contractId: "WETH9",
221
+ }),
222
+ ]);
223
+ return {
224
+ trustedForwarder: forwarder,
225
+ nativeTokenWrapper: weth,
226
+ };
110
227
  }
@@ -138,6 +138,7 @@ export async function getDefaultGasOverrides(
138
138
  async function getDynamicFeeData(
139
139
  client: ThirdwebClient,
140
140
  chain: Chain,
141
+ percentMultiplier = 10,
141
142
  ): Promise<FeeData> {
142
143
  let maxFeePerGas: null | bigint = null;
143
144
  let maxPriorityFeePerGas_: null | bigint = null;
@@ -173,7 +174,10 @@ async function getDynamicFeeData(
173
174
  }
174
175
 
175
176
  // add 10% tip to maxPriorityFeePerGas for faster processing
176
- maxPriorityFeePerGas_ = getPreferredPriorityFee(maxPriorityFeePerGas_);
177
+ maxPriorityFeePerGas_ = getPreferredPriorityFee(
178
+ maxPriorityFeePerGas_,
179
+ percentMultiplier,
180
+ );
177
181
  // eip-1559 formula, doubling the base fee ensures that the tx can be included in the next 6 blocks no matter how busy the network is
178
182
  // good article on the subject: https://www.blocknative.com/blog/eip-1559-fees
179
183
  maxFeePerGas = baseBlockFee * 2n + maxPriorityFeePerGas_;
@@ -1,4 +1,5 @@
1
1
  import type { AbiConstructor, AbiFunction } from "abitype";
2
+ import { parseAbiParams } from "../contract/parse-abi-params.js";
2
3
 
3
4
  export function normalizeFunctionParams(
4
5
  abiFunction: AbiFunction | AbiConstructor | undefined,
@@ -7,23 +8,27 @@ export function normalizeFunctionParams(
7
8
  if (!abiFunction) {
8
9
  return [];
9
10
  }
10
- if (abiFunction.inputs?.length !== Object.keys(params).length) {
11
- throw new Error(
12
- `Expected ${abiFunction.inputs?.length || 0} parameters, but got ${Object.keys(params).length}`,
13
- );
14
- }
15
- return abiFunction.inputs.map((input, index) => {
16
- const value = input.name;
17
- if (value === undefined) {
18
- throw new Error(
19
- `Missing named parameter for ${"name" in abiFunction ? abiFunction.name : "constructor"} at index ${index}`,
20
- );
21
- }
22
- const valueWithoutUnderscore = value.replace(/^_+/, "");
23
- const normalizedValue = params[value] ?? params[valueWithoutUnderscore]; // handle _name, _symbol, etc passed without underscore in the keys
24
- if (normalizedValue === undefined) {
25
- throw new Error(`Missing value for parameter ${value} at index ${index}`);
26
- }
27
- return normalizedValue;
28
- });
11
+
12
+ return parseAbiParams(
13
+ abiFunction.inputs.map((i) => i.type),
14
+ abiFunction.inputs.map((input, index) => {
15
+ const value = input.name;
16
+ if (value === undefined) {
17
+ throw new Error(
18
+ `Missing named parameter for ${"name" in abiFunction ? abiFunction.name : "constructor"} at index ${index}`,
19
+ );
20
+ }
21
+ const valueWithoutUnderscore = value.replace(/^_+/, "");
22
+ const normalizedValue =
23
+ valueWithoutUnderscore in params
24
+ ? params[valueWithoutUnderscore]
25
+ : params[value]; // handle _name, _symbol, etc passed without underscore in the keys
26
+ if (normalizedValue === undefined) {
27
+ throw new Error(
28
+ `Missing value for parameter ${value} at index ${index}`,
29
+ );
30
+ }
31
+ return normalizedValue;
32
+ }),
33
+ );
29
34
  }
@@ -48,6 +48,7 @@ export async function fetchDeployMetadata(
48
48
  return {
49
49
  ...rawMeta,
50
50
  ...parsedMeta,
51
+ version: rawMeta.version,
51
52
  bytecode: deployBytecode,
52
53
  };
53
54
  }
@@ -69,7 +70,7 @@ async function fetchAndParseCompilerMetadata(
69
70
  `Could not resolve metadata for contract at ${options.uri}`,
70
71
  );
71
72
  }
72
- return formatCompilerMetadata(metadata);
73
+ return { ...metadata, ...formatCompilerMetadata(metadata) };
73
74
  }
74
75
 
75
76
  // types
@@ -87,7 +88,37 @@ type RawCompilerMetadata = {
87
88
  type ParsedCompilerMetadata = {
88
89
  name: string;
89
90
  abi: Abi;
90
- metadata: Record<string, unknown>;
91
+ metadata: {
92
+ compiler: {
93
+ version: string;
94
+ };
95
+ language: string;
96
+ output: {
97
+ abi: Abi;
98
+ devdoc: Record<string, unknown>;
99
+ userdoc: Record<string, unknown>;
100
+ };
101
+ settings: {
102
+ compilationTarget: Record<string, unknown>;
103
+ evmVersion: string;
104
+ libraries: Record<string, string>;
105
+ optimizer: Record<string, unknown>;
106
+ remappings: string[];
107
+ };
108
+ sources: Record<
109
+ string,
110
+ { keccak256: string } & (
111
+ | {
112
+ content: string;
113
+ }
114
+ | {
115
+ urls: string[];
116
+ license?: string;
117
+ }
118
+ )
119
+ >;
120
+ [key: string]: unknown;
121
+ };
91
122
  info: {
92
123
  title?: string;
93
124
  author?: string;
@@ -1,6 +1,6 @@
1
- import { type Hex, encodePacked } from "viem";
1
+ import { encodePacked } from "viem/utils";
2
2
  import { ensureBytecodePrefix } from "../bytecode/prefix.js";
3
- import { uint8ArrayToHex } from "../encoding/hex.js";
3
+ import { type Hex, uint8ArrayToHex } from "../encoding/hex.js";
4
4
  import { getSaltHash } from "./get-salt-hash.js";
5
5
  import { keccakId } from "./keccak-id.js";
6
6
 
@@ -79,6 +79,9 @@ export function parseAbiParams(
79
79
  return value;
80
80
  }
81
81
  if (type.startsWith("uint") || type.startsWith("int")) {
82
+ if (typeof value === "bigint") {
83
+ return value;
84
+ }
82
85
  if (typeof value !== "string" && typeof value !== "number") {
83
86
  throw new Error(`Cannot convert type ${typeof value} to BigInt`);
84
87
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.55.0";
1
+ export const version = "5.55.1-nightly-b2a2c9784a33394dffbcd32bbd28b2c612a4e603-20240915000420";