Skip to content

Commit

Permalink
change dependency structure
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavBreadless committed Nov 24, 2023
1 parent 1d97fae commit f910a01
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 49 deletions.
48 changes: 48 additions & 0 deletions ethereum/scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,51 @@ export function getTokens(network: string): L1Token[] {
})
);
}

export interface DeployedAddresses {
ZkSync: {
MailboxFacet: string;
AdminFacet: string;
ExecutorFacet: string;
GettersFacet: string;
Verifier: string;
DiamondInit: string;
DiamondUpgradeInit: string;
DefaultUpgrade: string;
DiamondProxy: string;
};
Bridges: {
ERC20BridgeImplementation: string;
ERC20BridgeProxy: string;
WethBridgeImplementation: string;
WethBridgeProxy: string;
};
Governance: string;
ValidatorTimeLock: string;
Create2Factory: string;
}

export function deployedAddressesFromEnv(): DeployedAddresses {
return {
ZkSync: {
MailboxFacet: getAddressFromEnv("CONTRACTS_MAILBOX_FACET_ADDR"),
AdminFacet: getAddressFromEnv("CONTRACTS_ADMIN_FACET_ADDR"),
ExecutorFacet: getAddressFromEnv("CONTRACTS_EXECUTOR_FACET_ADDR"),
GettersFacet: getAddressFromEnv("CONTRACTS_GETTERS_FACET_ADDR"),
DiamondInit: getAddressFromEnv("CONTRACTS_DIAMOND_INIT_ADDR"),
DiamondUpgradeInit: getAddressFromEnv("CONTRACTS_DIAMOND_UPGRADE_INIT_ADDR"),
DefaultUpgrade: getAddressFromEnv("CONTRACTS_DEFAULT_UPGRADE_ADDR"),
DiamondProxy: getAddressFromEnv("CONTRACTS_DIAMOND_PROXY_ADDR"),
Verifier: getAddressFromEnv("CONTRACTS_VERIFIER_ADDR"),
},
Bridges: {
ERC20BridgeImplementation: getAddressFromEnv("CONTRACTS_L1_ERC20_BRIDGE_IMPL_ADDR"),
ERC20BridgeProxy: getAddressFromEnv("CONTRACTS_L1_ERC20_BRIDGE_PROXY_ADDR"),
WethBridgeImplementation: getAddressFromEnv("CONTRACTS_L1_WETH_BRIDGE_IMPL_ADDR"),
WethBridgeProxy: getAddressFromEnv("CONTRACTS_L1_WETH_BRIDGE_PROXY_ADDR"),
},
Create2Factory: getAddressFromEnv("CONTRACTS_CREATE2_FACTORY_ADDR"),
ValidatorTimeLock: getAddressFromEnv("CONTRACTS_VALIDATOR_TIMELOCK_ADDR"),
Governance: getAddressFromEnv("CONTRACTS_GOVERNANCE_ADDR"),
};
}
50 changes: 2 additions & 48 deletions ethereum/src.ts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,67 +19,21 @@ import {
getNumberFromEnv,
readBatchBootloaderBytecode,
getTokens,
DeployedAddresses,
deployedAddressesFromEnv,
} from "../scripts/utils";
import { deployViaCreate2 } from "./deploy-utils";
import { IGovernanceFactory } from "../typechain/IGovernanceFactory";

const L2_BOOTLOADER_BYTECODE_HASH = hexlify(hashL2Bytecode(readBatchBootloaderBytecode()));
const L2_DEFAULT_ACCOUNT_BYTECODE_HASH = hexlify(hashL2Bytecode(readSystemContractsBytecode("DefaultAccount")));

export interface DeployedAddresses {
ZkSync: {
MailboxFacet: string;
AdminFacet: string;
ExecutorFacet: string;
GettersFacet: string;
Verifier: string;
DiamondInit: string;
DiamondUpgradeInit: string;
DefaultUpgrade: string;
DiamondProxy: string;
};
Bridges: {
ERC20BridgeImplementation: string;
ERC20BridgeProxy: string;
WethBridgeImplementation: string;
WethBridgeProxy: string;
};
Governance: string;
ValidatorTimeLock: string;
Create2Factory: string;
}

export interface DeployerConfig {
deployWallet: Wallet;
ownerAddress?: string;
verbose?: boolean;
}

export function deployedAddressesFromEnv(): DeployedAddresses {
return {
ZkSync: {
MailboxFacet: getAddressFromEnv("CONTRACTS_MAILBOX_FACET_ADDR"),
AdminFacet: getAddressFromEnv("CONTRACTS_ADMIN_FACET_ADDR"),
ExecutorFacet: getAddressFromEnv("CONTRACTS_EXECUTOR_FACET_ADDR"),
GettersFacet: getAddressFromEnv("CONTRACTS_GETTERS_FACET_ADDR"),
DiamondInit: getAddressFromEnv("CONTRACTS_DIAMOND_INIT_ADDR"),
DiamondUpgradeInit: getAddressFromEnv("CONTRACTS_DIAMOND_UPGRADE_INIT_ADDR"),
DefaultUpgrade: getAddressFromEnv("CONTRACTS_DEFAULT_UPGRADE_ADDR"),
DiamondProxy: getAddressFromEnv("CONTRACTS_DIAMOND_PROXY_ADDR"),
Verifier: getAddressFromEnv("CONTRACTS_VERIFIER_ADDR"),
},
Bridges: {
ERC20BridgeImplementation: getAddressFromEnv("CONTRACTS_L1_ERC20_BRIDGE_IMPL_ADDR"),
ERC20BridgeProxy: getAddressFromEnv("CONTRACTS_L1_ERC20_BRIDGE_PROXY_ADDR"),
WethBridgeImplementation: getAddressFromEnv("CONTRACTS_L1_WETH_BRIDGE_IMPL_ADDR"),
WethBridgeProxy: getAddressFromEnv("CONTRACTS_L1_WETH_BRIDGE_PROXY_ADDR"),
},
Create2Factory: getAddressFromEnv("CONTRACTS_CREATE2_FACTORY_ADDR"),
ValidatorTimeLock: getAddressFromEnv("CONTRACTS_VALIDATOR_TIMELOCK_ADDR"),
Governance: getAddressFromEnv("CONTRACTS_GOVERNANCE_ADDR"),
};
}

export class Deployer {
public addresses: DeployedAddresses;
private deployWallet: Wallet;
Expand Down
2 changes: 1 addition & 1 deletion zksync/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { artifacts } from "hardhat";

import { Interface } from "ethers/lib/utils";
import { deployedAddressesFromEnv } from "../../ethereum/src.ts/deploy";
import { deployedAddressesFromEnv } from "../../ethereum/scripts/utils";
import { IZkSyncFactory } from "../../ethereum/typechain/IZkSyncFactory";

import type { BytesLike, Wallet } from "ethers";
Expand Down

0 comments on commit f910a01

Please sign in to comment.