Skip to content

Commit

Permalink
feat: script to check roles on all contracts
Browse files Browse the repository at this point in the history
* ground work to check roles on all Angle contracts

* first draft log roles

* draft log roles

* v1 Check roles working

* almost complete full script testing access control

* fix minor sidechains bugs

* script final version and all chain in one call

* feat: create test layerzero cross chain setup

* chore: doublon contract name

* fix: compilation

* fix: @sogipec comment
  • Loading branch information
GuillaumeNervoXS authored Jan 24, 2024
1 parent 4412f16 commit 33b69f7
Show file tree
Hide file tree
Showing 20 changed files with 1,068 additions and 246 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
[submodule "lib/borrow-contracts"]
path = lib/borrow-contracts
url = https://github.com/AngleProtocol/borrow-contracts
[submodule "lib/angle-router"]
path = lib/angle-router
url = https://github.com/AngleProtocol/angle-router
[submodule "lib/new-oz"]
path = lib/new-oz
url = https://github.com/OpenZeppelin/openzeppelin-contracts
Expand Down
83 changes: 83 additions & 0 deletions helpers/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
function chain_to_uri {
chain=$1

case $chain in
"1")
echo $ETH_NODE_URI_MAINNET
;;
"2")
echo $ETH_NODE_URI_ARBITRUM
;;
"3")
echo $ETH_NODE_URI_POLYGON
;;
"4")
echo $ETH_NODE_URI_GNOSIS
;;
"5")
echo $ETH_NODE_URI_AVALANCHE
;;
"6")
echo $ETH_NODE_URI_BASE
;;
"7")
echo $ETH_NODE_URI_BSC
;;
"8")
echo $ETH_NODE_URI_CELO
;;
"9")
echo $ETH_NODE_URI_POLYGON_ZKEVM
;;
"10")
echo $ETH_NODE_URI_OPTIMISM
;;
"11")
echo $ETH_NODE_URI_LINEA
;;
*)
;;
esac
}

function chain_to_chainId {
chain=$1

case $chain in
"1")
echo "1"
;;
"2")
echo "42161"
;;
"3")
echo "137"
;;
"4")
echo "100"
;;
"5")
echo "43114"
;;
"6")
echo "8453"
;;
"7")
echo "56"
;;
"8")
echo "42220"
;;
"9")
echo "1101"
;;
"10")
echo "10"
;;
"11")
echo "59144"
;;
*)
;;
esac
}
90 changes: 7 additions & 83 deletions helpers/createProposal.sh
Original file line number Diff line number Diff line change
@@ -1,88 +1,6 @@
#! /bin/bash

function chain_to_uri {
chain=$1

case $chain in
"1")
echo $ETH_NODE_URI_MAINNET
;;
"2")
echo $ETH_NODE_URI_ARBITRUM
;;
"3")
echo $ETH_NODE_URI_POLYGON
;;
"4")
echo $ETH_NODE_URI_GNOSIS
;;
"5")
echo $ETH_NODE_URI_AVALANCHE
;;
"6")
echo $ETH_NODE_URI_BASE
;;
"7")
echo $ETH_NODE_URI_BSC
;;
"8")
echo $ETH_NODE_URI_CELO
;;
"9")
echo $ETH_NODE_URI_POLYGON_ZKEVM
;;
"10")
echo $ETH_NODE_URI_OPTIMISM
;;
"11")
echo $ETH_NODE_URI_LINEA
;;
*)
;;
esac
}

function chain_to_chainId {
chain=$1

case $chain in
"1")
echo "1"
;;
"2")
echo "42161"
;;
"3")
echo "137"
;;
"4")
echo "100"
;;
"5")
echo "43114"
;;
"6")
echo "8453"
;;
"7")
echo "56"
;;
"8")
echo "42220"
;;
"9")
echo "1101"
;;
"10")
echo "10"
;;
"11")
echo "59144"
;;
*)
;;
esac
}
source helpers/common.sh

function usage {
echo "bash createProposal.sh <script> <chain>"
Expand Down Expand Up @@ -146,6 +64,7 @@ function main {
echo "- 9: Polygon ZkEvm"
echo "- 10: Optimism"
echo "- 11: Linea"
echo "- 100: All"

read chains

Expand All @@ -157,6 +76,11 @@ function main {

mainnet_uri=$(chain_to_uri 1)

if [[ "$chains" == "100" ]]; then
# If user entered 100 (All), loop from 1 to 11 and add all chains
chains="1,2,3,4,5,6,7,8,9,10,11"
fi

chainIds=""
for chain in $(echo $chains | sed "s/,/ /g")
do
Expand Down
44 changes: 2 additions & 42 deletions helpers/fork.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,6 @@
#! /bin/bash

function option_to_uri {
option=$1

case $option in
"1")
echo $ETH_NODE_URI_MAINNET
;;
"2")
echo $ETH_NODE_URI_ARBITRUM
;;
"3")
echo $ETH_NODE_URI_POLYGON
;;
"4")
echo $ETH_NODE_URI_GNOSIS
;;
"5")
echo $ETH_NODE_URI_AVALANCHE
;;
"6")
echo $ETH_NODE_URI_BASE
;;
"7")
echo $ETH_NODE_URI_BSC
;;
"8")
echo $ETH_NODE_URI_CELO
;;
"9")
echo $ETH_NODE_URI_POLYGON_ZKEVM
;;
"10")
echo $ETH_NODE_URI_OPTIMISM
;;
"11")
echo $ETH_NODE_URI_LINEA
;;
*)
;;
esac
}
source helpers/common.sh

function main {
if [ ! -f .env ]; then
Expand All @@ -64,7 +24,7 @@ function main {

read option

uri=$(option_to_uri $option)
uri=$(chain_to_uri $option)
if [ -z "$uri" ]; then
echo "Unknown network"
exit 1
Expand Down
108 changes: 108 additions & 0 deletions helpers/runScript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#! /bin/bash

source helpers/common.sh


function usage {
echo "bash runScript.sh <script> <chain>"
echo ""
echo -e "script: path to the script to run"
echo -e "chain: chain(s) to run the script on (separate with commas)"
echo -e "\t1: Ethereum Mainnet"
echo -e "\t2: Arbitrum"
echo -e "\t3: Polygon"
echo -e "\t4: Gnosis"
echo -e "\t5: Avalanche"
echo -e "\t6: Base"
echo -e "\t7: Binance Smart Chain"
echo -e "\t8: Celo"
echo -e "\t9: Polygon ZkEvm"
echo -e "\t10: Optimism"
echo -e "\t11: Linea"
echo -e "\t12: All"
echo ""
}

function main {
command=false
if [[ $# -ne 2 && $# -ne 0 ]]; then
usage
exit 1
fi
if [ $# -eq 2 ]; then
script=$1
chains=$2
command=true
fi

if [ ! -f .env ]; then
echo ".env not found!"
exit 1
fi
source .env

if [ $command != true ]; then
echo ""
echo "What script would you like to run ?"

read script

if [ -z "$script" ]; then
echo "No script provided"
exit 1
fi

echo ""

echo "Which chain(s) would you like to run the script on ? (separate with commas)"
echo "- 1: Ethereum Mainnet"
echo "- 2: Arbitrum"
echo "- 3: Polygon"
echo "- 4: Gnosis"
echo "- 5: Avalanche"
echo "- 6: Base"
echo "- 7: Binance Smart Chain"
echo "- 8: Celo"
echo "- 9: Polygon ZkEvm"
echo "- 10: Optimism"
echo "- 11: Linea"
echo "- 12: All"

read chains

if [ -z "$chains" ]; then
echo "No chain provided"
exit 1
fi
fi

mainnet_uri=$(chain_to_uri 1)

if [[ "$chains" == "12" ]]; then
# If user entered 12 (All), loop from 1 to 11 and add all chains
chains="1,2,3,4,5,6,7,8,9,10,11"
fi

chainIds=""
for chain in $(echo $chains | sed "s/,/ /g")
do
if [[ -z $chainIds ]]; then
chainIds="$(chain_to_chainId $chain)"
else
chainIds="$chainIds,$(chain_to_chainId $chain)"
fi
done

echo ""
echo "Running on chains $chainIds"

export CHAIN_IDS=$chainIds
FOUNDRY_PROFILE=dev forge script $script

if [ $? -ne 0 ]; then
echo ""
echo "Script failed"
fi
}

main $@
1 change: 1 addition & 0 deletions lib/angle-router
Submodule angle-router added at 0cccd2
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
"gas": "yarn test --gas-report",
"fork": "bash helpers/fork.sh",
"run": "docker run -it --rm -v $(pwd):/app -w /app ghcr.io/foundry-rs/foundry sh",
"script:fork": "source .env && forge script --skip test --fork-url fork --broadcast -vvvv",
"script:fork": "FOUNDRY_PROFILE=dev forge script --skip test --fork-url fork --broadcast -vvvv",
"test:unit": "forge test -vvv --gas-report --match-path \"test/unit/**/*.sol\"",
"test:invariant": "forge test -vvv --gas-report --match-path \"test/invariant/**/*.sol\"",
"test:fuzz": "forge test -vvv --gas-report --match-path \"test/fuzz/**/*.sol\"",
"test": "FOUNDRY_PROFILE=dev forge test -vvvv",
"slither": "slither .",
"lcov:clean": "lcov --remove lcov.info -o lcov.info 'test/**' 'scripts/**' 'contracts/transmuter/configs/**' 'contracts/utils/**'",
"lcov:generate-html": "genhtml lcov.info --output=coverage",
"run:script": "bash helpers/runScript.sh",
"size": "forge build --skip test --sizes",
"size:dev": "FOUNDRY_PROFILE=dev forge build --skip test --sizes",
"prettier": "prettier --write '**/*.sol'",
Expand Down
1 change: 1 addition & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ lz/=lib/solidity-examples/contracts
stringutils/=lib/solidity-stringutils
borrow/=lib/borrow-contracts/contracts
transmuter/=lib/angle-transmuter/contracts
router/=lib/angle-router/contracts
contracts/=contracts
test/=test
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts
Expand Down
Loading

0 comments on commit 33b69f7

Please sign in to comment.