-
Notifications
You must be signed in to change notification settings - Fork 38
[PT1-92] added automation scripts #206
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
Open
Sunnesoft
wants to merge
10
commits into
master
Choose a base branch
from
feature/deployment-automation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
71844db
added automation scripts
Sunnesoft ad3cf26
fixed skip all
Sunnesoft 7d558e9
added suffix to deployment name; fixed Makefile
Sunnesoft ed0c148
fixed suffix parsing
Sunnesoft ba971e3
refactored constants; simplified makefile
Sunnesoft 2c6d4bb
added deployment automation for all contracts
Sunnesoft fa24581
fixed salt parser
Sunnesoft 8827635
updated solidity utils to 6.8.0
Sunnesoft e41a926
updated packages versions
Sunnesoft 1577f11
fixed pacjage.json
Sunnesoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,4 +17,4 @@ coverage.json | |
|
|
||
| .idea | ||
|
|
||
| .env | ||
| .env* | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| # Conditionally include .env or .env.automation based on OPS_LAUNCH_MODE | ||
| ifeq ($(OPS_LAUNCH_MODE),auto) | ||
| -include .env.automation | ||
| else | ||
| -include .env | ||
| endif | ||
|
|
||
| CURRENT_DIR=$(shell pwd) | ||
|
|
||
| OPS_NETWORK_=$(shell echo "$(OPS_NETWORK)" | tr -d '\"') | ||
| OPS_CHAIN_ID_=$(shell echo "$(OPS_CHAIN_ID)" | tr -d '\"') | ||
|
|
||
| FILE_DEPLOY_KYC_NFT=$(CURRENT_DIR)/deploy/deploy-kyc-nft.js | ||
| FILE_CREATE3_DEPLOYER=$(CURRENT_DIR)/deploy/constants/create3-deployer.js | ||
| FILE_ACCESS_TOKEN_OWNER=$(CURRENT_DIR)/deploy/constants/access-token-owner.js | ||
| FILE_ACCESS_TOKEN_SALT=$(CURRENT_DIR)/deploy/constants/access-token-salt.js | ||
|
|
||
| # New access token deployment targets | ||
| deploy-access-token: | ||
| @$(MAKE) OPS_CURRENT_DEP_FILE=$(FILE_DEPLOY_KYC_NFT) validate-access-token deploy-skip-all deploy-noskip deploy-access-token-impl deploy-skip | ||
|
|
||
| deploy-access-token-impl: | ||
| @{ \ | ||
| yarn deploy $(OPS_NETWORK_) || exit 1; \ | ||
| } | ||
|
|
||
| # Validation targets | ||
| validate-access-token: | ||
| @{ \ | ||
| if [ -z "$(OPS_NETWORK_)" ]; then echo "OPS_NETWORK is not set!"; exit 1; fi; \ | ||
| if [ -z "$(OPS_CHAIN_ID_)" ]; then echo "OPS_CHAIN_ID is not set!"; exit 1; fi; \ | ||
| if [ -z "$(OPS_CREATE3_DEPLOYER_ADDRESS)" ] && [ "$(OPS_CHAIN_ID_)" != 324 ]; then echo "OPS_CREATE3_DEPLOYER_ADDRESS is not set!"; exit 1; fi; \ | ||
| if [ -z "$(MAINNET_RPC_URL)" ] && [ "$(OPS_NETWORK_)" = "hardhat" ]; then echo "MAINNET_RPC_URL is not set!"; exit 1; fi; \ | ||
| if [ -z "$(OPS_KYC_TOKEN_OWNER_ADDRESS)" ]; then echo "OPS_KYC_TOKEN_OWNER_ADDRESS is not set!"; exit 1; fi; \ | ||
| if [ -z "$(OPS_KYC_TOKEN_SALT)" ]; then echo "OPS_KYC_TOKEN_SALT is not set!"; exit 1; fi; \ | ||
| $(MAKE) process-access-token-owner process-access-token-salt process-create3-deployer; \ | ||
| } | ||
|
|
||
| # Process constant functions for new addresses | ||
| process-access-token-owner: | ||
| @$(MAKE) OPS_GEN_VAL='$(OPS_KYC_TOKEN_OWNER_ADDRESS)' OPS_GEN_FILE=$(FILE_ACCESS_TOKEN_OWNER) upsert-constant | ||
|
|
||
| process-access-token-salt: | ||
| @$(MAKE) OPS_GEN_VAL='$(OPS_KYC_TOKEN_SALT)' OPS_GEN_FILE=$(FILE_ACCESS_TOKEN_SALT) upsert-constant | ||
|
|
||
| process-create3-deployer: | ||
| @{ \ | ||
| if [ -n "$(OPS_CREATE3_DEPLOYER_ADDRESS)" ]; then \ | ||
| $(MAKE) OPS_GEN_VAL='$(OPS_CREATE3_DEPLOYER_ADDRESS)' OPS_GEN_FILE=$(FILE_CREATE3_DEPLOYER) upsert-constant; \ | ||
| fi \ | ||
| } | ||
|
|
||
| upsert-constant: | ||
| @{ \ | ||
| if [ -z "$(OPS_GEN_VAL)" ]; then \ | ||
| echo "variable for file $(OPS_GEN_FILE) is not set!"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| if grep -q "$(OPS_CHAIN_ID_)" $(OPS_GEN_FILE); then \ | ||
| sed -i '' 's|$(OPS_CHAIN_ID_): .*|$(OPS_CHAIN_ID_): $(OPS_GEN_VAL),|' $(OPS_GEN_FILE); \ | ||
| sed -i '' 's/"/'\''/g' $(OPS_GEN_FILE); \ | ||
| else \ | ||
| tmpfile=$$(mktemp); \ | ||
| awk '1;/module.exports = {/{print " $(OPS_CHAIN_ID_): $(subst ",\",$(OPS_GEN_VAL)),"}' $(OPS_GEN_FILE) > $$tmpfile && sed -i '' 's/"/'\''/g' $$tmpfile && mv $$tmpfile $(OPS_GEN_FILE); \ | ||
Sunnesoft marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fi \ | ||
| } | ||
|
|
||
| deploy-skip-all: | ||
| @{ \ | ||
| for secret in $(FILE_DEPLOY); do \ | ||
| $(MAKE) OPS_CURRENT_DEP_FILE=$$secret deploy-skip; \ | ||
| done \ | ||
| } | ||
|
|
||
| deploy-skip: | ||
| @sed -i '' 's/module.exports.skip.*/module.exports.skip = async () => true;/g' $(OPS_CURRENT_DEP_FILE) | ||
Sunnesoft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| deploy-noskip: | ||
| @sed -i '' 's/module.exports.skip.*/module.exports.skip = async () => false;/g' $(OPS_CURRENT_DEP_FILE) | ||
Sunnesoft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| launch-hh-node: | ||
| @{ \ | ||
| if [ -z "$(NODE_RPC)" ]; then \ | ||
| echo "NODE_RPC is not set!"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| echo "Launching Hardhat node with RPC: $(NODE_RPC)"; \ | ||
| npx hardhat node --fork $(NODE_RPC) --vvvv --full-trace; \ | ||
| } | ||
|
|
||
| install: install-utils install-dependencies | ||
|
|
||
| install-utils: | ||
| brew install yarn wget | ||
Sunnesoft marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| install-dependencies: | ||
| yarn | ||
|
|
||
| clean: | ||
| @rm -Rf $(CURRENT_DIR)/deployments/$(OPS_NETWORK_)/* | ||
|
|
||
|
|
||
| # Get deployed contract addresses from deployment files | ||
| get: | ||
| @{ \ | ||
| if [ -z "$(PARAMETER)" ]; then \ | ||
| echo "Error: PARAMETER is not set. Usage: make get PARAMETER=OPS_AGGREGATION_EXECUTOR_SIMPLE_ADDRESS"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| if [ -z "$(OPS_NETWORK_)" ]; then \ | ||
| echo "Error: OPS_NETWORK_ is not set"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| CONTRACT_FILE=""; \ | ||
| case "$(PARAMETER)" in \ | ||
| "OPS_KYC_TOKEN_ADDRESS") CONTRACT_FILE="KycNFT.json" ;; \ | ||
| *) echo "Error: Unknown parameter $(PARAMETER)"; exit 1 ;; \ | ||
| esac; \ | ||
| DEPLOYMENT_FILE="$(CURRENT_DIR)/deployments/$(OPS_NETWORK_)/$$CONTRACT_FILE"; \ | ||
| if [ ! -f "$$DEPLOYMENT_FILE" ]; then \ | ||
| echo "Error: Deployment file $$DEPLOYMENT_FILE not found"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| ADDRESS=$$(cat "$$DEPLOYMENT_FILE" | grep '"address"' | head -1 | sed 's/.*"address": *"\([^"]*\)".*/\1/'); \ | ||
| echo "$$ADDRESS"; \ | ||
| } | ||
|
|
||
| help: | ||
| @echo "Available targets:" | ||
| @echo " deploy-access-token Deploy access token contracts" | ||
| @echo " deploy-access-token-impl Deploy access token implementation" | ||
| @echo " validate-access-token Validate required environment variables" | ||
| @echo " process-access-token-owner Update access token owner constant" | ||
| @echo " process-access-token-salt Update access token salt constant" | ||
| @echo " process-create3-deployer Update create3 deployer constant" | ||
| @echo " upsert-constant Upsert constant value in JS file" | ||
| @echo " deploy-skip-all Mark all deploy files as skipped" | ||
| @echo " deploy-skip Mark current deploy file as skipped" | ||
| @echo " deploy-noskip Mark current deploy file as not skipped" | ||
| @echo " launch-hh-node Launch Hardhat node with forked RPC" | ||
| @echo " install Install utils and dependencies" | ||
| @echo " install-utils Install required utilities" | ||
| @echo " install-dependencies Install yarn dependencies" | ||
| @echo " clean Remove deployment files" | ||
| @echo " get PARAMETER=... Get deployed contract address" | ||
| @echo " help Show this help message" | ||
|
|
||
|
|
||
| .PHONY: help deploy-access-token deploy-access-token-impl validate-access-token process-access-token-owner process-access-token-salt process-create3-deployer upsert-constant deploy-skip-all deploy-skip deploy-noskip launch-hh-node install install-utils install-dependencies clean get | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| module.exports = { | ||
| 31337: '0x56E44874F624EbDE6efCc783eFD685f0FBDC6dcF', | ||
Sunnesoft marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| module.exports.skip = async () => true; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| module.exports = { | ||
| 31337: '0xfd0450e10366502b67f46a6037db5b90d1cad2d4a744b961f7986bf35f4d35d7', | ||
Sunnesoft marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| module.exports.skip = async () => true; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| module.exports = { | ||
| 31337: '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65', | ||
| 1: '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65', // Mainnet | ||
| 56: '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65', // BSC | ||
| 137: '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65', // Matic | ||
| 42161: '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65', // Arbitrum | ||
| 10: '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65', // Optimistic | ||
| 43114: '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65', // Avalanche | ||
| 100: '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65', // xDAI | ||
| 250: '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65', // FTM | ||
| 1313161554: '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65', // Aurora | ||
| 8217: '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65', // Klaytn | ||
| 8453: '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65', // Base | ||
| 59144: '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65', // Linea | ||
| 146: '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65', // Sonic | ||
| 130: '0xD935a2bb926019E0ed6fb31fbD5b1Bbb7c05bf65', // Unichain | ||
| }; | ||
|
|
||
| module.exports.skip = async () => true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| const ACCESS_TOKEN_SALT = require('./access-token-salt'); | ||
| const ACCESS_TOKEN_OWNER = require('./access-token-owner'); | ||
| const CREATE3_DEPLOYERS = require('./create3-deployer'); | ||
|
|
||
| module.exports = { | ||
| ACCESS_TOKEN_SALT, | ||
| ACCESS_TOKEN_OWNER, | ||
| CREATE3_DEPLOYERS, | ||
| }; | ||
|
|
||
| module.exports.skip = async () => true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.