Skip to content

Commit

Permalink
Merge pull request #27 from trillion-network/minor/add-deploy-upgrade…
Browse files Browse the repository at this point in the history
…-scripts

minor: add deploy.sh and upgrade.sh to avoid error
  • Loading branch information
stanleygtrillion authored Dec 16, 2024
2 parents fc0e83d + b064a6b commit bfe4246
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 1 deletion.
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

0 comments on commit bfe4246

Please sign in to comment.