holic / web3-scaffold

Quickly get up and running on web3
148 stars 19 forks source link

Add example deploy script #50

Open TheRightChoyce opened 2 years ago

TheRightChoyce commented 2 years ago

This adds a working deploy script and also has an example of deploying a renderer along side the contract. In addition, it updates the following:

holic commented 2 years ago

Thank you!

Update .gitignore file to exclude .s.sol outputs and the broadcast logs

Is the .s.sol pattern common or recommended by Foundry? Haven't seen that yet and I think the .t.sol was following their patterns.

Adds a note about using Solenv but does not actually add it as a requirement

I wouldn't mind adding solenv as a requirement! Seems useful and a good practice to avoid manually juggling credentials.

Any thoughts on how we might extract some of the deploy script output into the deploy JSON files? e.g. contract addresses, etc.

TheRightChoyce commented 2 years ago

Is the .s.sol pattern common or recommended by Foundry? Haven't seen that yet and I think the .t.sol was following their patterns.

I saw it from the example in the scripting docs and found it useful. I didn't see a need for any of the outputs/ABIs in the front-end Dapp.

https://book.getfoundry.sh/tutorials/solidity-scripting?highlight=Scr#solidity-scripting

I wouldn't mind adding solenv as a requirement! Seems useful and a good practice to avoid manually juggling credentials.

I can add!

Any thoughts on how we might extract some of the deploy script output into the deploy JSON files? e.g. contract addresses, etc.

The broadcast outputs chunky json files, but they include all the correct information in a deterministic output file. Could just switch the path to those. Or could write a small script to parse the required output and write to the deploy files. Happy to hack on something and add to this PR : )

holic commented 2 years ago

The broadcast outputs chunky json files, but they include all the correct information in a deterministic output file. Could just switch the path to those. Or could write a small script to parse the required output and write to the deploy files. Happy to hack on something and add to this PR : )

We could probably use the same jq technique that current deploy script uses, just specify the keys we want to extract from the output JSON: https://github.com/holic/web3-scaffold/blob/50551e0f60463b579a79897bfa08ee7d8eb44e3e/packages/contracts/deploy.sh#L17

It'd be so great if this could be encapsulated in Solidity somehow so we don't have to run/maintain a separate script, but I'm happy with some of both if it means using Solidity scripting sooner than later!

jamiew commented 2 years ago

fwiw building a contract address book file from the foundry outputs was also my best solution so far.

I also dislike checking in the full broadcasts because they're so noisy, but that feels like the right pattern for history and being able to rebuild the address book

checkingate continues

TheRightChoyce commented 2 years ago

@holic Added a jq line to the Deploy.sh script that will copy the relevant broadcast output to the existing "deploys" folder to remove the need for some manual copy/paste.