Skip to content

Commit

Permalink
default prepareDeploy param
Browse files Browse the repository at this point in the history
  • Loading branch information
alvrs committed Sep 19, 2024
1 parent 50d4b9c commit 0bce659
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/deploy/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export type LibraryPlaceholder = {
export type DeterministicContract = {
readonly prepareDeploy: (
deployer: Address,
libraryMap: LibraryMap,
libraryMap?: LibraryMap,
) => {
readonly address: Address;
readonly bytecode: Hex;
Expand Down
11 changes: 10 additions & 1 deletion packages/cli/src/deploy/createPrepareDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@ export function createPrepareDeploy(
bytecodeWithPlaceholders: Hex,
placeholders: readonly LibraryPlaceholder[],
): DeterministicContract["prepareDeploy"] {
return function prepareDeploy(deployer: Address, libraryMap: LibraryMap) {
return function prepareDeploy(deployer: Address, libraryMap?: LibraryMap) {
let bytecode = bytecodeWithPlaceholders;

if (placeholders.length === 0) {
return { bytecode, address: getCreate2Address({ from: deployer, bytecode, salt }) };
}

if (!libraryMap) {
throw new Error("Libraries must be provided if there are placeholders");
}

for (const placeholder of placeholders) {
const address = libraryMap.getAddress({ name: placeholder.name, path: placeholder.path, deployer });
bytecode = spliceHex(bytecode, placeholder.start, placeholder.length, address);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export async function verify({
);

modules.map(({ name, prepareDeploy }) => {
const { address } = prepareDeploy(deployerAddress, {});
const { address } = prepareDeploy(deployerAddress);
return verifyQueue.add(() =>
verifyContract({
// TODO: figure out dir from artifactPath via import.meta.resolve?
Expand Down

0 comments on commit 0bce659

Please sign in to comment.