Skip to content

Commit

Permalink
refactor: remove unused contract (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
blockgroot committed Jun 24, 2024
1 parent bd7e239 commit 373600e
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 79 deletions.
74 changes: 0 additions & 74 deletions contracts/L2/ETHx.sol

This file was deleted.

11 changes: 8 additions & 3 deletions scripts/safe-scripts/helpers/upgrade.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import hre from "hardhat";
import proposeTransaction from "./proposeTransaction";

async function main(contractAddress: string, contractName: string) {
const { ethers, upgrades } = hre;
const network = await ethers.provider.getNetwork();
Expand All @@ -27,12 +25,19 @@ async function main(contractAddress: string, contractName: string) {
contractAddress,
newImplementationAddress,
]);
await proposeTransaction(await proxyAdminContract.getAddress(), "0", encodedFunctionCall);

console.log(
`Upgrade transaction proposed for ${contractName} at ${contractAddress} to new implementation at ${newImplementationAddress}`,
);
console.log(`When finished run to verify:`);
console.log(`npx hardhat verify ${newImplementationAddress} --network ${network.name}`);
console.log("\n");


const to = await proxyAdminContract.getAddress();
const value ="0"
const data = encodedFunctionCall;

return{to, value, data};
}
export default main;
4 changes: 3 additions & 1 deletion scripts/safe-scripts/upgrade.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import hre from "hardhat";
import upgrade from "./helpers/upgrade";
import proposeTransaction from "./helpers/proposeTransaction";

import addressJson from "./address.json";

Expand All @@ -21,7 +22,8 @@ async function main() {
if (contract === undefined) {
throw new Error(`Contract ${contractName} not found`);
}
await upgrade(contract?.address, contractName);
const {to, value, data} = await upgrade(contract?.address, contractName);
await proposeTransaction(to, data, value);
} catch (error) {
console.error("An error occurred:", error);
}
Expand Down
4 changes: 3 additions & 1 deletion scripts/safe-scripts/upgradeAll.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { ethers, upgrades } = require("hardhat");
import upgradeHelper from "./helpers/upgrade";
import networkAddresses from "./address.json";
import proposeTransaction from "./helpers/proposeTransaction";
import { artifacts } from "hardhat";

async function main(networks: { [networkName: string]: { contracts: { name: string; address: string }[] } }) {
Expand All @@ -26,7 +27,8 @@ async function main(networks: { [networkName: string]: { contracts: { name: stri
if (deployedBytecode !== compiledBytecode) {
console.warn(` Contract "${name}" is out of date!`);
console.log(` Upgrading to latest version...`);
await upgradeHelper(address, name);
const {to, value, data} = await upgradeHelper(address, name);
await proposeTransaction(to, data, value);
} else {
console.log(` "${name}" is already up to date on network "${networkName}".`);
}
Expand Down
48 changes: 48 additions & 0 deletions scripts/safe-scripts/upgradeAllBatch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const { ethers, upgrades } = require("hardhat");
import upgradeHelper from "./helpers/upgrade";
import networkAddresses from "./address.json";
import proposeTransactions from "./helpers/proposeTransactions";
import { MetaTransactionData } from "@safe-global/safe-core-sdk-types";


async function main(networks: { [networkName: string]: { contracts: { name: string; address: string }[] } }) {
const networkName = await hre.network.name;
const networkContracts = networks[networkName].contracts;
let targets = [];
let values = [];
let params = [];

console.log(`Checking contracts on network "${networkName}":`, "\n");

for (let { name, address } of networkContracts) {
const { to, value, data } = await upgradeHelper(address, name);
targets.push(to)
values.push(value)
params.push(data)
}
const multisigData = await buildMultisigTx(targets,values, params);
await proposeTransactions(multisigData);
}



async function buildMultisigTx(targets:string[], values:string[], params: string[]): Promise<MetaTransactionData[]> {
const safeTransactionData: MetaTransactionData[] = [];
for (let i = 0; i < targets.length; ++i) {
const safeTxData: MetaTransactionData = {
to: targets[i],
data: params[i],
value: values[i],
operation: 0,
};
safeTransactionData.push(safeTxData);
}
return safeTransactionData;
}

main(networkAddresses)
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

0 comments on commit 373600e

Please sign in to comment.