-
Notifications
You must be signed in to change notification settings - Fork 950
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
Deployment and verification abstraction #781
Deployment and verification abstraction #781
Conversation
This reverts commit e157257.
Hey thanks @Hotmanics, as I assume in general people might use multiple deploy scripts for deploying different contracts with different scripts. For example, two contracts With your changes I copy-pasted script and created
But the problem with this approach is that it ovverrides abi's generated in I think a better approach if people wants to have multiple files of different contract is to maybe do something like this :
Deploy.s.sol//SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "./DeployHelpers.s.sol";
import "./DeployYourContract.sol";
import "./DeployMyContract.s.sol";
contract DeployScript is ScaffoldETHDeploy {
error InvalidPrivateKey(string);
function run() external {
DeployYourContract yourContractScript = new DeployYourContract();
yourContractScript.run();
DeployMyContractScript myContractScript = new DeployMyContractScript();
myContractScript.run();
/**
* 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.
* This function should be called last.
*/
exportDeployments();
}
function test() public {}
} DeployYourContract.s.sol//SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "../contracts/YourContract.sol";
import "./DeployHelpers.s.sol";
contract DeployYourContract is ScaffoldETHDeploy {
error InvalidPrivateKey(string);
function run() external {
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"
);
}
vm.startBroadcast(deployerPrivateKey);
YourContract yourContract = new YourContract(
vm.addr(deployerPrivateKey)
);
console.logString(
string.concat(
"YourContract deployed at: ",
vm.toString(address(yourContract))
)
);
vm.stopBroadcast();
}
} DeployMyContract.s.sol//SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "../contracts/MyContract.sol";
import "./DeployHelpers.s.sol";
contract DeployMyContractScript is ScaffoldETHDeploy {
error InvalidPrivateKey(string);
function run() external {
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"
);
}
vm.startBroadcast(deployerPrivateKey);
MyContract myContract = new MyContract(vm.addr(deployerPrivateKey));
console.logString(
string.concat(
"MyContract deployed at: ",
vm.toString(address(myContract))
)
);
vm.stopBroadcast();
}
} This simplifies the process a lot, you just need to run Also now, if people want to just deploy Also, maybe it's good idea to have this example default in SE-2 foundry repo with Lol I am not very well versed with foundry and not sure if its really good pattern to follow, but we should create an issue / discussion first and discuss their 🙌 Closing this for now, but thanks so much !! for trying tackling it, lets brainstorm a bit and see if we can find a better soution 🙌 |
Thanks for the good comment @technophile-04. This is one way to approach the issue, something that i see more in foundry would be using inheritance and internal functions that you can run from the main The are some other ways to approach this too 🫡. |
Rationale
In a personal project, I faced a challenge and experienced confusion and errors when I needed more than just the
Deploy.s.sol
script, and made aDeployDemo.s.sol
script. However there were a large number of changes to my project that I needed to do.Original Process:
deploy
,deploy:verify
, andverify
yarn commands todeployDemo
,deployDemo:verify
, andverifyDeployDemo
.Deploy.s.sol
toDeployDemo.s.sol
.generateTsAbis.ts
togenerateTsAbis_Demo.ts
.VerifyAll.s.sol
toVerifyAll_Demo.s.sol
.generateTsAbi_Demo.ts
fromDeploy.s.sol
toDeployDemo.s.sol
.VerifyAll_Demo.ts
fromDeploy.s.sol
toDeployDemo.s.sol
.generateTsAbis.ts
togenerateTsAbis_Demo.ts
andVerifyAll.s.sol
toVerifyAll_Demo.s.sol
.New Process
deploy
,deploy:verify
, andverify
yarn commands todeployDemo
,deployDemo:verify
, andverifyDeployDemo
.Deploy.s.sol
toDeployDemo.s.sol
.Description
Simplifies the process of creating and running additional deploy scripts and verifications.
Additional Information
Your ENS/address: JacobHomanics.eth