Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Option to not hash the salt #82

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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