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

Auto whitelist periphery2 #775

Merged
merged 12 commits into from
Aug 22, 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
8 changes: 7 additions & 1 deletion config/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,11 @@
"sei": "0x0000000000000000000000000000000000000000",
"taiko": "0x0000000000000000000000000000000000000000",
"zksync": "0x0000000000000000000000000000000000000000"
}
},
"autoWhitelistPeripheryContracts": [
"FeeCollector",
"LiFuelFeeCollector",
"TokenWrapper",
"LiFiDEXAggregator"
]
}
23 changes: 16 additions & 7 deletions script/helperFunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1313,13 +1313,18 @@ function addPeripheryToDexsJson() {
local NETWORK="$1"
local ENVIRONMENT="$2"

local FILEPATH_DEXS="config/dexs.json"
local FILEPATH_GLOBAL_CONFIG="config/global.json"

WHITELIST_PERIPHERY=($(jq -r '.autoWhitelistPeripheryContracts[] | select(length > 0)' "$FILEPATH_GLOBAL_CONFIG"))

# Get all contracts that need to be whitelisted and convert the comma-separated string into an array
IFS=',' read -r -a CONTRACTS <<< "$WHITELIST_PERIPHERY"
# IFS=',' read -r -a CONTRACTS <<< "$WHITELIST_PERIPHERY"
CONTRACTS=("${WHITELIST_PERIPHERY[@]}")

# get number of periphery contracts to be added
local ADD_COUNTER=${#CONTRACTS[@]}

local FILEPATH_DEXS="config/dexs.json"

# get number of existing DEX addresses in the file for the given network
local EXISTING_DEXS=$(jq --arg network "$NETWORK" '.[$network] | length' "$FILEPATH_DEXS")
Expand All @@ -1332,6 +1337,9 @@ function addPeripheryToDexsJson() {
if [[ -z "$CONTRACT_ADDRESS" ]]; then
error "Could not find contract address for contract $CONTRACT on network $NETWORK ($ENVIRONMENT) in deploy log."
error "Please manually whitelist this contract after this task has been completed."
# reduce add counter since we are not adding this contract
((ADD_COUNTER--))
continue
fi

# check if address already exists in dexs.json for the given network
Expand All @@ -1356,8 +1364,10 @@ function addPeripheryToDexsJson() {
# check how many DEX addresses are in the dexs.json now
local ADDRESS_COUNTER=${#CONTRACTS[@]}

EXPECTED_DEXS=$((EXISTING_DEXS + ADD_COUNTER))

# make sure dexs.json has been updated correctly
if [ $ADDRESS_COUNTER -eq $((EXISTING_DEXS + ADD_COUNTER)) ]; then
if [ $EXPECTED_DEXS -eq $((EXISTING_DEXS + ADD_COUNTER)) ]; then
success "$ADD_COUNTER addresses were added to config/dexs.json"
else
error "The array in dexs.json for network $NETWORK does not have the expected number of elements after executing this script (expected: $, got: $ADDRESS_COUNTER)."
Expand Down Expand Up @@ -3814,10 +3824,9 @@ function test_getContractNameFromDeploymentLogs() {

function test_tmp() {

CONTRACT="LiFiDiamond"
NETWORK="taiko"
ADDRESS="0x3A9A5dBa8FE1C4Da98187cE4755701BCA182f63b"
ADDRESS_NEW_OWNER="0xa89a87986e8ee1Ac8fDaCc5Ac91627010Ec9f772"
CONTRACT="LiFiDEXAggregator"
NETWORK="immutablezkevm"
ADDRESS=""
ENVIRONMENT="production"
VERSION="2.0.0"
DIAMOND_CONTRACT_NAME="LiFiDiamondImmutable"
Expand Down
Loading