Skip to content

Commit

Permalink
templatised foundry deploy script (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 authored Jun 12, 2024
1 parent 11de1ee commit 6a3afc7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"networkName": "Anvil"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
//SPDX-License-Identifier: MIT
import { withDefaults } from "../../../../../utils.js";

const content = ({ deploymentsScriptsImports, deploymentsLogic }) => `//SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "../contracts/YourContract.sol";
import "./DeployHelpers.s.sol";
${deploymentsScriptsImports.filter(Boolean).join("\n")}
contract DeployScript is ScaffoldETHDeploy {
error InvalidPrivateKey(string);
Expand All @@ -11,19 +14,25 @@ contract DeployScript is ScaffoldETHDeploy {
uint256 deployerPrivateKey = setupLocalhostEnv();
if (deployerPrivateKey == 0) {
revert InvalidPrivateKey(
"You don't have a deployer account. Make sure you have set DEPLOYER_PRIVATE_KEY in .env or use `yarn generate` to generate a new random account"
"You don't have a deployer account. Make sure you have set DEPLOYER_PRIVATE_KEY in .env or use \`yarn generate\` to generate a new random account"
);
}
vm.startBroadcast(deployerPrivateKey);
YourContract yourContract =
new YourContract(vm.addr(deployerPrivateKey));
YourContract yourContract = new YourContract(
vm.addr(deployerPrivateKey)
);
console.logString(
string.concat(
"YourContract deployed at: ", vm.toString(address(yourContract))
"YourContract deployed at: ",
vm.toString(address(yourContract))
)
);
vm.stopBroadcast();
${deploymentsLogic.filter(Boolean).join("\n")}
/**
* This function generates the file containing the contracts Abi definitions.
* These definitions are used to derive the types needed in the custom scaffold-eth hooks, for example.
Expand All @@ -33,4 +42,9 @@ contract DeployScript is ScaffoldETHDeploy {
}
function test() public {}
}
}`;

export default withDefaults(content, {
deploymentsScriptsImports: "",
deploymentsLogic: "",
});

0 comments on commit 6a3afc7

Please sign in to comment.