Skip to content

Commit

Permalink
[SDK] Check bytecode prefix (#6196)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaryash90 authored Feb 7, 2025
1 parent c5dfad8 commit 0781da9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
coverage:
ignore:
- "**/__generated__/**"
- "**/contract/deployment/zksync/**"
- "*/thirdweb/src/contract/deployment/zksync/zkDeployContract.ts"
status:
project:
default:
Expand All @@ -10,6 +14,8 @@ coverage:
- packages
ignore:
- "**/__generated__/**"
- "**/contract/deployment/zksync/**"
- "*/thirdweb/src/contract/deployment/zksync/zkDeployContract.ts"


github_checks:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { sendAndConfirmTransaction } from "../../../transaction/actions/send-and
import { prepareTransaction } from "../../../transaction/prepare-transaction.js";
import { normalizeFunctionParams } from "../../../utils/abi/normalizeFunctionParams.js";
import { CONTRACT_DEPLOYER_ADDRESS } from "../../../utils/any-evm/zksync/constants.js";
import { ensureBytecodePrefix } from "../../../utils/bytecode/prefix.js";
import type { Hex } from "../../../utils/encoding/hex.js";
import type { ClientAndChainAndAccount } from "../../../utils/types.js";
import { zkDeployContractDeterministic } from "./zkDeployDeterministic.js";
Expand All @@ -22,14 +23,16 @@ export async function zkDeployContract(
deploymentType?: "create" | "create2";
},
) {
const bytecode = ensureBytecodePrefix(options.bytecode);

if (options.salt !== undefined) {
// if a salt is provided, use the deterministic deployer
return zkDeployContractDeterministic(options);
}

const data = encodeDeployData({
abi: options.abi,
bytecode: options.bytecode,
bytecode,
deploymentType: options.deploymentType ?? "create",
args: normalizeFunctionParams(
options.abi.find((abi) => abi.type === "constructor"),
Expand All @@ -45,7 +48,7 @@ export async function zkDeployContract(
to: CONTRACT_DEPLOYER_ADDRESS,
data,
eip712: {
factoryDeps: [options.bytecode],
factoryDeps: [bytecode],
// TODO (zksync): allow passing in a paymaster
},
}),
Expand Down

0 comments on commit 0781da9

Please sign in to comment.