diff --git a/.env.example b/.env.example index 660e7d4..a5a44d1 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,6 @@ -# NETWORK AND DEPLOYMENT WALLET -DEPLOYMENT_PRIVATE_KEY="..." +# NETWORK AND ACCOUNT(s) +DEPLOYMENT_PRIVATE_KEY="0x..." +REFUND_ADDRESS="0x..." # The name of the networks to use for test/production TESTNET_NETWORK="holesky" diff --git a/Makefile b/Makefile index 4bdcc16..581bc3a 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,8 @@ E2E_TEST_NAME=TestE2EV2 DEPLOY_SCRIPT=script/DeployGauges.s.sol:DeployGauges VERBOSITY=-vvv DEPLOYMENT_LOG_FILE=$(shell echo "./deployment-$(shell date +"%y-%m-%d-%H-%M").log") +DEPLOYMENT_ADDRESS=$(shell cast wallet address --private-key $(DEPLOYMENT_PRIVATE_KEY)) +SHELL:=/bin/bash # TARGETS @@ -143,3 +145,31 @@ deploy: test $(VERIFIER_URL_PARAM) \ $(ETHERSCAN_API_KEY_PARAM) \ $(VERBOSITY) | tee $(DEPLOYMENT_LOG_FILE) + +: ## + +.PHONY: refund +refund: ## Refund the remaining balance left on the deployment account + @echo "Refunding the remaining balance on $(DEPLOYMENT_ADDRESS)" + @if [ -z $(REFUND_ADDRESS) -o $(REFUND_ADDRESS) = "0x0000000000000000000000000000000000000000" ]; then \ + echo "- The refund address is empty" ; \ + exit 1; \ + fi + @BALANCE=$(shell cast balance $(DEPLOYMENT_ADDRESS) --rpc-url $(PRODNET_RPC_URL)) && \ + GAS_PRICE=$(shell cast gas-price --rpc-url $(PRODNET_RPC_URL)) && \ + REMAINING=$$(echo "$$BALANCE - $$GAS_PRICE * 21000" | bc) && \ + \ + ENOUGH_BALANCE=$$(echo "$$REMAINING > 0" | bc) && \ + if [ "$$ENOUGH_BALANCE" = "0" ]; then \ + echo -e "- No balance can be refunded: $$BALANCE wei\n- Minimum balance: $${REMAINING:1} wei" ; \ + exit 1; \ + fi ; \ + echo -n -e "Summary:\n- Refunding: $$REMAINING (wei)\n- Recipient: $(REFUND_ADDRESS)\n\nContinue? (y/N) " && \ + \ + read CONFIRM && \ + if [ "$$CONFIRM" != "y" ]; then echo "Aborting" ; exit 1; fi ; \ + \ + cast send --private-key $(DEPLOYMENT_PRIVATE_KEY) \ + --rpc-url $(PRODNET_RPC_URL) \ + --value $$REMAINING \ + $(REFUND_ADDRESS) diff --git a/README.md b/README.md index caeb653..bf1550d 100644 --- a/README.md +++ b/README.md @@ -99,14 +99,16 @@ Check the available make targets to simulate and deploy the smart contracts: ### Deployment Checklist -- [ ] I am running on a docker container running Alpine Linux +- [ ] I have cloned the official repository on my computer and I have checked out the corresponding branch +- [ ] I am running on a docker container running Debian Linux (stable) - [ ] I have run `docker run --rm -it -v .:/deployment debian:bookworm-slim` - - [ ] I have run `apt update && apt install make curl git` + - [ ] I have run `apt update && apt install -y make curl git vim neovim bc` - [ ] I have run `curl -L https://foundry.paradigm.xyz | bash` - [ ] I have run `source /root/.bashrc && foundryup` - [ ] I have run `cd /deployment` - [ ] I have run `make init` - [ ] I have printed the contents of `.env` and `.env.test` on the screen +- [ ] I am opening an editor on the `/deployment` folder, within Docker - [ ] The `.env` file contains the correct parameters for the deployment - [ ] I have created a brand new burner wallet and copied the private key to `DEPLOYMENT_PRIVATE_KEY` - [ ] I have reviewed the target network and RPC URL