From 30b8f9dd19901300cd16c00b4652d89991a19ea8 Mon Sep 17 00:00:00 2001 From: Diana Carvalho Date: Thu, 8 May 2025 15:11:07 +0100 Subject: [PATCH] chore: Add script to remove executor addresses from Tycho Router --- don't change below this line --- ENG-4454 Took 1 hour 6 minutes --- foundry/hardhat.config.js | 14 +++++------ foundry/scripts/README.md | 6 +++++ foundry/scripts/remove-executor.js | 38 ++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 foundry/scripts/remove-executor.js diff --git a/foundry/hardhat.config.js b/foundry/hardhat.config.js index 0603641..e0d3d82 100644 --- a/foundry/hardhat.config.js +++ b/foundry/hardhat.config.js @@ -52,14 +52,14 @@ module.exports = { etherscan: { apiKey: process.env.BLOCKCHAIN_EXPLORER_API_KEY, customChains: [ - { - network: "unichain", - chainId: 130, - urls: { - apiURL: "https://api.uniscan.xyz/api", - browserURL: "https://www.uniscan.xyz/" + { + network: "unichain", + chainId: 130, + urls: { + apiURL: "https://api.uniscan.xyz/api", + browserURL: "https://www.uniscan.xyz/" + } } - } ] } }; diff --git a/foundry/scripts/README.md b/foundry/scripts/README.md index 91b85e8..8836138 100644 --- a/foundry/scripts/README.md +++ b/foundry/scripts/README.md @@ -48,3 +48,9 @@ For each of the following, you must select one of `tenderly_ethereum`, `tenderly 1. In `scripts/deploy-executors.js` define the executors to be deployed 2. Deploy executors: `npx hardhat run scripts/deploy-executors.js --network NETWORK` 3. Fill in the executor addresses in `config/executor_addresses.json` + +### Remove executors + +1. If you set a new executor for the same protocol, you need to remove the old one. +2. Run: `npx hardhat run scripts/remove-executor.js --network NETWORK` +3. There will be a prompt for you to insert the executor address you want to remove. \ No newline at end of file diff --git a/foundry/scripts/remove-executor.js b/foundry/scripts/remove-executor.js new file mode 100644 index 0000000..f63ff22 --- /dev/null +++ b/foundry/scripts/remove-executor.js @@ -0,0 +1,38 @@ +require('dotenv').config(); +const {ethers} = require("hardhat"); +const hre = require("hardhat"); +const prompt = require('prompt-sync')(); + +async function main() { + const network = hre.network.name; + const routerAddress = process.env.ROUTER_ADDRESS; + console.log(`Removing executors on TychoRouter at ${routerAddress} on ${network}`); + + const [deployer] = await ethers.getSigners(); + console.log(`Removing executors with account: ${deployer.address}`); + console.log(`Account balance: ${ethers.utils.formatEther(await deployer.getBalance())} ETH`); + + const TychoRouter = await ethers.getContractFactory("TychoRouter"); + const router = TychoRouter.attach(routerAddress); + + const executorAddress = prompt("Enter executor address to remove: "); + + if (!executorAddress) { + console.error("Please provide the executorAddress as an argument."); + process.exit(1); + } + + // Remove executor + const tx = await router.removeExecutor(executorAddress, { + gasLimit: 50000 + }); + await tx.wait(); // Wait for the transaction to be mined + console.log(`Executor removed at transaction: ${tx.hash}`); +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error("Error removing executor:", error); + process.exit(1); + }); \ No newline at end of file