Skip to content

Commit

Permalink
Auto whitelist DEX-like periphery (#753)
Browse files Browse the repository at this point in the history
* add contract reminders for DEX-like periphery

* adds automatic whitelisting for DEX-like periphery when deploying all contracts

* moves list of autoWhitelistPeriphery contracts into global config
  • Loading branch information
0xDEnYO authored Aug 21, 2024
1 parent 25eb3f7 commit 233fcbc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
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"
]
}
3 changes: 3 additions & 0 deletions deployments/_deployments_log_file.json
Original file line number Diff line number Diff line change
Expand Up @@ -22438,6 +22438,8 @@
}
]
}
<<<<<<< HEAD
=======
},
"taiko": {
"production": {
Expand All @@ -22452,6 +22454,7 @@
}
]
}
>>>>>>> 6d61c88163e0de474a3a424cb74488b09abdd8ef
}
}
}
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

0 comments on commit 233fcbc

Please sign in to comment.