Skip to content

Commit 9b0a3df

Browse files
fix: deploy WETH9 infra contract for marketplace deploys (#2775)
1 parent 0c9376f commit 9b0a3df

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

packages/thirdweb/src/extensions/prebuilts/deploy-marketplace.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ import type {
44
AbiParametersToPrimitiveTypes,
55
Address,
66
} from "abitype";
7-
import { toFunctionSelector, toFunctionSignature, zeroAddress } from "viem";
7+
import { toFunctionSelector, toFunctionSignature } from "viem";
88
import type { ThirdwebClient } from "../../client/client.js";
99
import { resolveContractAbi } from "../../contract/actions/resolve-abi.js";
1010
import type { ThirdwebContract } from "../../contract/contract.js";
1111
import { deployViaAutoFactory } from "../../contract/deployment/deploy-via-autofactory.js";
12-
import { getOrDeployInfraForPublishedContract } from "../../contract/deployment/utils/bootstrap.js";
12+
import {
13+
getOrDeployInfraContract,
14+
getOrDeployInfraForPublishedContract,
15+
} from "../../contract/deployment/utils/bootstrap.js";
1316
import { upload } from "../../storage/upload.js";
1417
import type { FileOrBufferOrString } from "../../storage/upload/types.js";
18+
import { getRoyaltyEngineV1ByChainId } from "../../utils/royalty-engine.js";
1519
import type { Prettify } from "../../utils/type-utils.js";
1620
import type { ClientAndChainAndAccount } from "../../utils/types.js";
1721
import { initialize as initMarketplace } from "./__generated__/Marketplace/write/initialize.js";
@@ -42,26 +46,27 @@ export async function deployMarketplaceContract(
4246
options: DeployMarketplaceContractOptions,
4347
) {
4448
const { chain, client, account, params } = options;
49+
const WETH = await getOrDeployInfraContract({
50+
chain,
51+
client,
52+
account,
53+
contractId: "WETH9",
54+
constructorParams: [],
55+
});
4556
const direct = await getOrDeployInfraForPublishedContract({
4657
chain,
4758
client,
4859
account,
4960
contractId: "DirectListingsLogic",
50-
constructorParams: [
51-
// TODO - actually determine ... "weth"?
52-
zeroAddress, // _weth
53-
],
61+
constructorParams: [WETH.address],
5462
});
5563

5664
const english = await getOrDeployInfraForPublishedContract({
5765
chain,
5866
client,
5967
account,
6068
contractId: "EnglishAuctionsLogic",
61-
constructorParams: [
62-
// TODO - actually determine ... "weth"?
63-
zeroAddress, // _weth
64-
],
69+
constructorParams: [WETH.address],
6570
});
6671

6772
const offers = await getOrDeployInfraForPublishedContract({
@@ -119,10 +124,8 @@ export async function deployMarketplaceContract(
119124
functions: offersFunctions,
120125
},
121126
],
122-
// TODO - actually determine ... "royaltyEngineAddress"?
123-
royaltyEngineAddress: zeroAddress,
124-
// TODO - actually determine ... "weth"?
125-
nativeTokenWrapper: zeroAddress,
127+
royaltyEngineAddress: getRoyaltyEngineV1ByChainId(chain.id),
128+
nativeTokenWrapper: WETH.address,
126129
},
127130
] as MarketplaceConstructorParams,
128131
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { ADDRESS_ZERO } from "../constants/addresses.js";
2+
3+
/**
4+
* Returns the RoyaltyEngineV1 address for a given chain
5+
* @param chainId - the chain id
6+
* @public
7+
*/
8+
export function getRoyaltyEngineV1ByChainId(chainId: number): string {
9+
return ROYALTY_ENGINE_V1_ADDRESS[chainId] || ADDRESS_ZERO;
10+
}
11+
12+
export const ROYALTY_ENGINE_V1_ADDRESS: Record<number, string> =
13+
/* @__PURE__ */ {
14+
1: "0x0385603ab55642cb4dd5de3ae9e306809991804f",
15+
56: "0xEF770dFb6D5620977213f55f99bfd781D04BBE15",
16+
137: "0x28EdFcF0Be7E86b07493466e7631a213bDe8eEF2",
17+
8453: "0xEF770dFb6D5620977213f55f99bfd781D04BBE15",
18+
43114: "0xEF770dFb6D5620977213f55f99bfd781D04BBE15",
19+
10: "0xEF770dFb6D5620977213f55f99bfd781D04BBE15",
20+
42161: "0xEF770dFb6D5620977213f55f99bfd781D04BBE15",
21+
};

0 commit comments

Comments
 (0)