Skip to content

Commit

Permalink
feat: Option to not hash the salt
Browse files Browse the repository at this point in the history
  • Loading branch information
0xkowloon committed Oct 28, 2022
1 parent 576b48e commit 9859751
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ module.exports = {
contract: "YOUR_CONTRACT_NAME_TO_BE_DEPLOYED",
constructorArgsPath: "PATH_TO_CONSTRUCTOR_ARGS",
salt: "YOUR_SALT_MESSAGE",
// The default option is to hash the salt, even if this is undefined.
// Should the salt not be hashed, make this "false".
hashSalt: "true",
signer: "SIGNER_PRIVATE_KEY",
networks: ["LIST_OF_NETWORKS"],
rpcUrls: ["LIST_OF_RPCURLS"],
Expand All @@ -85,6 +88,9 @@ const config: HardhatUserConfig = {
contract: "YOUR_CONTRACT_NAME_TO_BE_DEPLOYED",
constructorArgsPath: "PATH_TO_CONSTRUCTOR_ARGS",
salt: "YOUR_SALT_MESSAGE",
// The default option is to hash the salt, even if this is undefined.
// Should the salt not be hashed, make this "false".
hashSalt: "true",
signer: "SIGNER_PRIVATE_KEY",
networks: ["LIST_OF_NETWORKS"],
rpcUrls: ["LIST_OF_RPCURLS"],
Expand Down
11 changes: 8 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,16 @@ task(
signers[i]
);

if (hre.config.xdeploy.salt) {
let salt = hre.config.xdeploy.salt;
if (salt) {
if (hre.config.xdeploy.hashSalt !== "false") {
salt = hre.ethers.utils.id(salt);
}

try {
let counter = 0;
computedContractAddress = await create2Deployer[i].computeAddress(
hre.ethers.utils.id(hre.config.xdeploy.salt),
salt,
hre.ethers.utils.keccak256(initcode.data)
);
if (counter === 0) {
Expand Down Expand Up @@ -143,7 +148,7 @@ task(
try {
createReceipt[i] = await create2Deployer[i].deploy(
AMOUNT,
hre.ethers.utils.id(hre.config.xdeploy.salt),
salt,
initcode.data,
{ gasLimit: hre.config.xdeploy.gasLimit }
);
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface XdeployConfig {
contract?: string;
constructorArgsPath?: string;
salt?: string;
hashSalt?: "true" | "false";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
signer?: any;
networks?: Array<string>;
Expand Down

0 comments on commit 9859751

Please sign in to comment.