diff --git a/script/tasks/diamondSyncDEXs.sh b/script/tasks/diamondSyncDEXs.sh index 55cca535..de0fc38e 100755 --- a/script/tasks/diamondSyncDEXs.sh +++ b/script/tasks/diamondSyncDEXs.sh @@ -49,6 +49,16 @@ function diamondSyncDEXs { # go through all networks and execute the script for NETWORK in "${NETWORKS[@]}"; do + + # Skip for localanvil or any testnet + if [[ "$NETWORK" == "localanvil" || \ + "$NETWORK" == "bsc-testnet" || \ + "$NETWORK" == "lineatest" || \ + "$NETWORK" == "mumbai" || \ + "$NETWORK" == "sepolia" ]]; then + continue + fi + # get diamond address from deployments script DIAMOND_ADDRESS=$(getContractAddressFromDeploymentLogs "$NETWORK" "$ENVIRONMENT" "$DIAMOND_CONTRACT_NAME") diff --git a/script/tasks/diamondSyncSigs.sh b/script/tasks/diamondSyncSigs.sh index 71fbdd44..a5810d38 100755 --- a/script/tasks/diamondSyncSigs.sh +++ b/script/tasks/diamondSyncSigs.sh @@ -63,19 +63,29 @@ function diamondSyncSigs { # go through all networks and execute the script for NETWORK in "${NETWORKS[@]}"; do + # Skip for localanvil or any testnet + if [[ "$NETWORK" == "localanvil" || \ + "$NETWORK" == "bsc-testnet" || \ + "$NETWORK" == "lineatest" || \ + "$NETWORK" == "mumbai" || \ + "$NETWORK" == "sepolia" ]]; then + continue + fi + # get RPC URL for given network RPC_URL=$(getRPCUrl "$NETWORK") # call batchSetFunctionApprovalBySignature function in diamond to add function selectors local ATTEMPTS=1 while [ $ATTEMPTS -le "$MAX_ATTEMPTS_PER_SCRIPT_EXECUTION" ]; do + echo "----------------------------------------------------------------------------------------" echo "[info] trying to add function selectors now - attempt ${ATTEMPTS} (max attempts: $MAX_ATTEMPTS_PER_SCRIPT_EXECUTION) " # ensure that gas price is below maximum threshold (for mainnet only) doNotContinueUnlessGasIsBelowThreshold "$NETWORK" # try to run the typescript script (will fail if the network is not yet supported by viem) - ts-node ./script/tasks/diamondSyncSigs.ts --network "$NETWORK" --rpcUrl "$RPC_URL" --privateKey "$PRIVATE_KEY" --environment "$ENVIRONMENT" + ts-node ./script/tasks/diamondSyncSigs.ts --network "$NETWORK" --rpcUrl "$RPC_URL" --privateKey "$(getPrivateKey "$NETWORK" "$ENVIRONMENT")" --environment "$ENVIRONMENT" RETURN_CODE=$? # check the typescript script failed diff --git a/script/tasks/diamondSyncSigs.ts b/script/tasks/diamondSyncSigs.ts index b055cd7e..9374b91b 100644 --- a/script/tasks/diamondSyncSigs.ts +++ b/script/tasks/diamondSyncSigs.ts @@ -12,6 +12,7 @@ import { ethers } from 'ethers6' import * as chains from 'viem/chains' import { privateKeyToAccount } from 'viem/accounts' import { getViemChainForNetworkName } from '../utils/viemScriptHelpers' +import consola from 'consola' export const chainNameMappings: Record = { zksync: 'zkSync', @@ -113,19 +114,29 @@ const main = defineCommand({ if (sigsToApprove.length > 0) { // Approve function signatures console.log('Approving function signatures...') - const tx = await walletClient.writeContract({ - address: deployedContracts['LiFiDiamond'], - abi: parseAbi([ - 'function batchSetFunctionApprovalBySignature(bytes4[],bool) external', - ]), - functionName: 'batchSetFunctionApprovalBySignature', - args: [sigsToApprove, true], - account, - }) + let tx + try { + tx = await walletClient.writeContract({ + address: deployedContracts['LiFiDiamond'], + abi: parseAbi([ + 'function batchSetFunctionApprovalBySignature(bytes4[],bool) external', + ]), + functionName: 'batchSetFunctionApprovalBySignature', + args: [sigsToApprove, true], + account, + }) + + await publicClient.waitForTransactionReceipt({ hash: tx }) + } catch (err) { + consola.error(JSON.stringify(err, null, 2)) + process.exit(1) + } console.log('Transaction:', tx) + process.exit(0) } else { console.log('All Signatures are already approved.') + process.exit(0) } }, })