Skip to content

Commit 6655d73

Browse files
feat: handle zksync direct deploys in deployContract
1 parent 4f346e6 commit 6655d73

File tree

5 files changed

+21
-24
lines changed

5 files changed

+21
-24
lines changed

.changeset/rich-steaks-guess.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Handle zk sync direct deploys in `deployContract`

packages/thirdweb/src/contract/deployment/deploy-with-abi.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { encodeAbiParameters } from "../../utils/abi/encodeAbiParameters.js";
55
import { normalizeFunctionParams } from "../../utils/abi/normalizeFunctionParams.js";
66
import { computeDeploymentAddress } from "../../utils/any-evm/compute-deployment-address.js";
77
import { computeDeploymentInfoFromBytecode } from "../../utils/any-evm/compute-published-contract-deploy-info.js";
8+
import { isZkSyncChain } from "../../utils/any-evm/zksync/isZkSyncChain.js";
89
import { isContractDeployed } from "../../utils/bytecode/is-contract-deployed.js";
910
import { ensureBytecodePrefix } from "../../utils/bytecode/prefix.js";
1011
import { concatHex } from "../../utils/encoding/helpers/concat-hex.js";
@@ -13,6 +14,7 @@ import type { Prettify } from "../../utils/type-utils.js";
1314
import type { ClientAndChain } from "../../utils/types.js";
1415
import type { Account } from "../../wallets/interfaces/wallet.js";
1516
import { getContract } from "../contract.js";
17+
import { zkDeployContract } from "./zksync/zkDeployContract.js";
1618

1719
/**
1820
* @extension DEPLOY
@@ -121,6 +123,18 @@ export async function deployContract(
121123
salt?: string;
122124
},
123125
) {
126+
if (await isZkSyncChain(options.chain)) {
127+
return zkDeployContract({
128+
account: options.account,
129+
client: options.client,
130+
chain: options.chain,
131+
bytecode: options.bytecode,
132+
abi: options.abi,
133+
params: options.constructorParams,
134+
salt: options.salt,
135+
});
136+
}
137+
124138
if (options.salt !== undefined) {
125139
// Deploy with CREATE2 if salt is provided
126140
const info = await computeDeploymentInfoFromBytecode(options);

packages/thirdweb/src/extensions/ens/resolve-avatar.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { describe, expect, it } from "vitest";
2-
32
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
43
import { resolveAvatar } from "./resolve-avatar.js";
54

@@ -22,9 +21,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("ENS:resolve-avatar", () => {
2221
client: TEST_CLIENT,
2322
name: "vitalik.eth",
2423
});
25-
expect(avatarUri?.split("/ipfs/")[1]).toMatchInlineSnapshot(
26-
`"QmSP4nq9fnN9dAiCj42ug9Wa79rqmQerZXZch82VqpiH7U/image.gif"`,
27-
);
24+
expect(avatarUri).toMatchInlineSnapshot(`"https://euc.li/vitalik.eth"`);
2825
});
2926

3027
it("resolves name without avatar record to null", async () => {

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import type { ThirdwebClient } from "../../client/client.js";
44
import { type ThirdwebContract, getContract } from "../../contract/contract.js";
55
import { fetchPublishedContractMetadata } from "../../contract/deployment/publisher.js";
66
import { getOrDeployInfraContractFromMetadata } from "../../contract/deployment/utils/bootstrap.js";
7-
import {} from "../../contract/deployment/utils/infra.js";
8-
import { zkDeployContract } from "../../contract/deployment/zksync/zkDeployContract.js";
97
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
108
import { simulateTransaction } from "../../transaction/actions/simulate.js";
119
import { prepareContractCall } from "../../transaction/prepare-contract-call.js";
@@ -18,7 +16,6 @@ import {
1816
fetchBytecodeFromCompilerMetadata,
1917
} from "../../utils/any-evm/deploy-metadata.js";
2018
import type { FetchDeployMetadataResult } from "../../utils/any-evm/deploy-metadata.js";
21-
import { isZkSyncChain } from "../../utils/any-evm/zksync/isZkSyncChain.js";
2219
import type { Hex } from "../../utils/encoding/hex.js";
2320
import type { Account } from "../../wallets/interfaces/wallet.js";
2421
import { getAllDefaultConstructorParamsForImplementation } from "./get-required-transactions.js";
@@ -263,22 +260,6 @@ async function directDeploy(options: {
263260
const { account, client, chain, compilerMetadata, contractParams, salt } =
264261
options;
265262

266-
if (await isZkSyncChain(chain)) {
267-
return zkDeployContract({
268-
account,
269-
client,
270-
chain,
271-
bytecode: await fetchBytecodeFromCompilerMetadata({
272-
compilerMetadata,
273-
client,
274-
chain,
275-
}),
276-
abi: compilerMetadata.abi,
277-
params: contractParams,
278-
salt,
279-
});
280-
}
281-
282263
const { deployContract } = await import(
283264
"../../contract/deployment/deploy-with-abi.js"
284265
);

packages/thirdweb/test/vitest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default defineConfig({
3737
setupFiles: [join(__dirname, "./reactSetup.ts")],
3838
globalSetup: [join(__dirname, "./globalSetup.ts")],
3939
testTimeout: 90_000,
40-
retry: 0,
40+
retry: 3,
4141
bail: 1,
4242
// clear any mocks between any tests
4343
clearMocks: true,

0 commit comments

Comments
 (0)