Skip to content
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

minor: add deploy.sh and upgrade.sh to avoid error #27

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# <TOKEN> <CHAIN>

DERIVATION_PATH=
DEFAULT_ADMIN_ADDRESS=
PAUSER_ADDRESS=
MINTER_ADDRESS=
UPGRADER_ADDRESS=
RESCUER_ADDRESS=
BLACKLISTER_ADDRESS=
TOKEN_NAME=
TOKEN_SYMBOL=

RPC_URL=
ETHERSCAN_API_KEY=

FIAT_TOKEN_PROXY_ADDRESS=

# <TOKEN> <CHAIN>
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ yarn.lock
# coverage stuff
coverage/
lcov.info
**/*.env
!.env.example
Empty file added config/.gitkeep
Empty file.
Empty file added config/tnsgd/.gitkeep
Empty file.
Empty file added config/tnusd/.gitkeep
Empty file.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"scripts": {
"lint": "solhint 'src/**/*.sol' && solhint --config .solhint.test.json 'test/**/*.t.sol'",
"test": "forge test",
"coverage": "forge coverage --report lcov && lcov --remove ./lcov.info --rc derive_function_end_line=0 -o ./lcov.info 'test/*' 'script/*' && genhtml lcov.info --rc derive_function_end_line=0 --ignore-errors category --output-dir coverage && open coverage/index.html"
"coverage": "forge coverage --report lcov && lcov --remove ./lcov.info --rc derive_function_end_line=0 -o ./lcov.info 'test/*' 'script/*' && genhtml lcov.info --rc derive_function_end_line=0 --ignore-errors category --output-dir coverage && open coverage/index.html",
"deploy": "bash script/deploy.sh",
"upgrade": "bash script/upgrade.sh"
},
"devDependencies": {
"solhint": "^5.0.3"
Expand Down
44 changes: 44 additions & 0 deletions script/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Check for arguments
if [ -z "$1" ] || [ -z "$2" ] ; then
echo "Usage: npm run deploy -- <token> <chain>"
# Example:
# npm run deploy -- tnusd eth-mainnet
# npm run deploy -- tnsgd eth-sepolia
# npm run deploy -- tnusd op-mainnet
# npm run deploy -- tnusd op-sepolia
exit 1
fi

# Assign arguments to variables
TOKEN=$1
CHAIN=$2
ENV_FILE="config/${TOKEN}/${CHAIN}.env"
ROOT_ENV_FILE="./.env"

# Load environment variables from .env file
if [ -f "$ENV_FILE" ]; then
source $ENV_FILE

# Copy the .env file to the current directory
cp "$ENV_FILE" "$ROOT_ENV_FILE"

# Confirm the copy was successful
if [[ -f "$ROOT_ENV_FILE" ]]; then
echo "File '.env' has been successfully copied to the current folder."
else
echo "Error: Failed to copy '.env' to the current folder."
fi
else
echo "$ENV_FILE file not found!"
exit 1
fi

if [[ -n "${ETHERSCAN_API_KEY}" ]]; then
# with verify
forge script script/DeployFiatToken.s.sol:DeployFiatToken --rpc-url $RPC_URL --ledger --hd-paths $DERIVATION_PATH --sender $DEFAULT_ADMIN_ADDRESS --broadcast --verify --ffi -vvvv
else
# no verify
forge script script/DeployFiatToken.s.sol:DeployFiatToken --rpc-url $RPC_URL --ledger --hd-paths $DERIVATION_PATH --sender $DEFAULT_ADMIN_ADDRESS --broadcast --ffi -vvvv
fi
44 changes: 44 additions & 0 deletions script/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Check for arguments
if [ -z "$1" ] || [ -z "$2" ] ; then
echo "Usage: npm run deploy -- <token> <chain>"
# Example:
# npm run deploy -- tnusd eth-mainnet
# npm run deploy -- tnsgd eth-sepolia
# npm run deploy -- tnusd op-mainnet
# npm run deploy -- tnusd op-sepolia
exit 1
fi

# Assign arguments to variables
TOKEN=$1
CHAIN=$2
ENV_FILE="config/${TOKEN}/${CHAIN}.env"
ROOT_ENV_FILE="./.env"

# Load environment variables from .env file
if [ -f "$ENV_FILE" ]; then
source $ENV_FILE

# Copy the .env file to the current directory
cp "$ENV_FILE" "$ROOT_ENV_FILE"

# Confirm the copy was successful
if [[ -f "$ROOT_ENV_FILE" ]]; then
echo "File '.env' has been successfully copied to the current folder."
else
echo "Error: Failed to copy '.env' to the current folder."
fi
else
echo "$ENV_FILE file not found!"
exit 1
fi

if [[ -n "${ETHERSCAN_API_KEY}" ]]; then
# with verify
forge script script/UpgradeFiatToken.s.sol:UpgradeFiatToken --rpc-url $RPC_URL --ledger --hd-paths $DERIVATION_PATH --sender $DEFAULT_ADMIN_ADDRESS --broadcast --verify --ffi -vvvv
else
# no verify
forge script script/UpgradeFiatToken.s.sol:UpgradeFiatToken --rpc-url $RPC_URL --ledger --hd-paths $DERIVATION_PATH --sender $DEFAULT_ADMIN_ADDRESS --broadcast --ffi -vvvv
fi
Loading