Skip to content

Commit

Permalink
update salt generators
Browse files Browse the repository at this point in the history
  • Loading branch information
andresaiello committed Jan 18, 2024
1 parent 742221c commit bfb137c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 30 deletions.
8 changes: 5 additions & 3 deletions lib/deterministic-deploy.helpers.ts
Original file line number Diff line number Diff line change
@@ -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 = "";
Expand Down
23 changes: 14 additions & 9 deletions scripts/deployments/tools/deterministic-get-salt-erc20-custody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
23 changes: 14 additions & 9 deletions scripts/deployments/tools/deterministic-get-salt-zeta-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
23 changes: 14 additions & 9 deletions scripts/deployments/tools/deterministic-get-salt-zeta-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit bfb137c

Please sign in to comment.