wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.19k stars 292 forks source link

Save deployments from alternate deployment methods #452

Open AlbertSu123 opened 1 year ago

AlbertSu123 commented 1 year ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

When deploying contracts through contract calls like create3.sol, I pass in salt and bytecode to deploy a contract. However, this bypasses the 'deploy' function and instead uses the 'execute' function. I still want this deployment saved to the deployments/ folder, so the solution right now is writing it to a file manually using fs.writefilesync

Describe the solution you'd like A clear and concise description of what you want to happen.

The creation of a saveDeployment function that allows you to pass in a contract address, abi, transaction data, and anything else that is saved to the deployments folder when using deploy()

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered. The alternative method is just creating these files manually with fs.writefile, but this doesn't work half the time(it creates the file but nothing is written to the file), and is annoying to manage for multi chain deployments

Additional context Add any other context or screenshots about the feature request here.

wighawag commented 1 year ago

Thanks @AlbertSu123 for the report

You can use the save function for that:

https://github.com/wighawag/hardhat-deploy/blob/192d6119c7e594c4e4c5e96eeb41de1fdaa71afc/types.ts#L237

n00b21337 commented 11 months ago

Would something like this work for Saving the deployment from already deployed contracts with other methods?

await save(name, { ...artifact, address });

wighawag commented 11 months ago

yes more or less, it really depens on what is artifact, see type:https://github.com/wighawag/hardhat-deploy/blob/192d6119c7e594c4e4c5e96eeb41de1fdaa71afc/types.ts#L327-L353

n00b21337 commented 11 months ago

ohh that makes sense. Thnx It is very similar with the deployment type https://github.com/wighawag/hardhat-deploy#migrating-existing-deployment-to-hardhat-deploy

and that is what I am basically trying to do. Import already deployed contract either through SAVE or just with migration process. So basically in both all I need is ABI and address, rest is optional.
This wasnt really obvious from docs at first, so writing it here, if someone else will need this, really useful to know.