From bfb137ce2010a42929003494394e44f72f985922 Mon Sep 17 00:00:00 2001 From: Andres Aiello Date: Thu, 18 Jan 2024 14:09:47 -0500 Subject: [PATCH] update salt generators --- lib/deterministic-deploy.helpers.ts | 8 ++++--- .../deterministic-get-salt-erc20-custody.ts | 23 +++++++++++-------- .../deterministic-get-salt-zeta-connector.ts | 23 +++++++++++-------- .../deterministic-get-salt-zeta-token.ts | 23 +++++++++++-------- 4 files changed, 47 insertions(+), 30 deletions(-) diff --git a/lib/deterministic-deploy.helpers.ts b/lib/deterministic-deploy.helpers.ts index 7527b5e9..b2d3ce96 100644 --- a/lib/deterministic-deploy.helpers.ts +++ b/lib/deterministic-deploy.helpers.ts @@ -1,21 +1,23 @@ import { BigNumber } from "ethers"; +import { getAddress } from "lib"; -import { getAddress } from "../lib/address.helpers"; import { MAX_ETH_ADDRESS } from "../lib/contracts.constants"; import { buildBytecode, buildCreate2Address, saltToHex, } from "../lib/ImmutableCreate2Factory/ImmutableCreate2Factory.helpers"; +import { ZetaProtocolNetwork } from "./address.tools"; export const calculateBestSalt = async ( maxIterations: BigNumber, deployerAddress: string, constructorTypes: string[], constructorArgs: string[], - contractBytecode: string + contractBytecode: string, + network: ZetaProtocolNetwork ) => { - const immutableCreate2Factory = getAddress("immutableCreate2Factory"); + const immutableCreate2Factory = getAddress("immutableCreate2Factory", network); let minAddress = MAX_ETH_ADDRESS; let minAddressSalt = ""; diff --git a/scripts/deployments/tools/deterministic-get-salt-erc20-custody.ts b/scripts/deployments/tools/deterministic-get-salt-erc20-custody.ts index d22a602a..195f2a6f 100644 --- a/scripts/deployments/tools/deterministic-get-salt-erc20-custody.ts +++ b/scripts/deployments/tools/deterministic-get-salt-erc20-custody.ts @@ -29,14 +29,19 @@ export const deterministicDeployGetSaltERC20Custody = async () => { const constructorArgs = [tssAddress, tssUpdaterAddress, zetaFee.toString(), zetaMaxFee.toString(), zetaTokenAddress]; const contractBytecode = ERC20Custody__factory.bytecode; - calculateBestSalt(MAX_ITERATIONS, DEPLOYER_ADDRESS, constructorTypes, constructorArgs, contractBytecode); + await calculateBestSalt( + MAX_ITERATIONS, + DEPLOYER_ADDRESS, + constructorTypes, + constructorArgs, + contractBytecode, + network.name + ); }; -if (!process.env.EXECUTE_PROGRAMMATICALLY) { - deterministicDeployGetSaltERC20Custody() - .then(() => process.exit(0)) - .catch((error) => { - console.error(error); - process.exit(1); - }); -} +deterministicDeployGetSaltERC20Custody() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/scripts/deployments/tools/deterministic-get-salt-zeta-connector.ts b/scripts/deployments/tools/deterministic-get-salt-zeta-connector.ts index 73252f6f..dfbb3105 100644 --- a/scripts/deployments/tools/deterministic-get-salt-zeta-connector.ts +++ b/scripts/deployments/tools/deterministic-get-salt-zeta-connector.ts @@ -34,14 +34,19 @@ export async function deterministicDeployGetSaltZetaConnector() { contractBytecode = ZetaConnectorNonEth__factory.bytecode; } - calculateBestSalt(MAX_ITERATIONS, DEPLOYER_ADDRESS, constructorTypes, constructorArgs, contractBytecode); + await calculateBestSalt( + MAX_ITERATIONS, + DEPLOYER_ADDRESS, + constructorTypes, + constructorArgs, + contractBytecode, + network.name + ); } -if (!process.env.EXECUTE_PROGRAMMATICALLY) { - deterministicDeployGetSaltZetaConnector() - .then(() => process.exit(0)) - .catch((error) => { - console.error(error); - process.exit(1); - }); -} +deterministicDeployGetSaltZetaConnector() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/scripts/deployments/tools/deterministic-get-salt-zeta-token.ts b/scripts/deployments/tools/deterministic-get-salt-zeta-token.ts index e988ee2c..b627d2fa 100644 --- a/scripts/deployments/tools/deterministic-get-salt-zeta-token.ts +++ b/scripts/deployments/tools/deterministic-get-salt-zeta-token.ts @@ -34,14 +34,19 @@ export async function deterministicDeployGetSaltZetaToken() { constructorArgs = [tssAddress, tssUpdaterAddress]; contractBytecode = ZetaNonEth__factory.bytecode; } - calculateBestSalt(MAX_ITERATIONS, DEPLOYER_ADDRESS, constructorTypes, constructorArgs, contractBytecode); + await calculateBestSalt( + MAX_ITERATIONS, + DEPLOYER_ADDRESS, + constructorTypes, + constructorArgs, + contractBytecode, + network.name + ); } -if (!process.env.EXECUTE_PROGRAMMATICALLY) { - deterministicDeployGetSaltZetaToken() - .then(() => process.exit(0)) - .catch((error) => { - console.error(error); - process.exit(1); - }); -} +deterministicDeployGetSaltZetaToken() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + });