Bladeren bron

chore(contract_manager): cleanup (#2811)

- Purge some entropy contracts
- Remove EvmExpressRelayContract type
- Fix shell script
Amin Moghaddam 4 maanden geleden
bovenliggende
commit
e130743166

+ 1 - 1
contract_manager/package.json

@@ -31,7 +31,7 @@
   ],
   "scripts": {
     "build": "tsc",
-    "shell": "ts-node ./src/shell.ts",
+    "shell": "ts-node ./src/node/utils/shell.ts",
     "fix:lint": "eslint src/ scripts/ --fix --max-warnings 0",
     "fix:format": "prettier --write \"src/**/*.ts\" \"scripts/**/*.ts\"",
     "test:lint": "eslint src/ scripts/ --max-warnings 0",

+ 0 - 88
contract_manager/src/core/contracts/evm.ts

@@ -7,7 +7,6 @@ import { WormholeContract } from "./wormhole";
 import { TokenQty } from "../token";
 import {
   EXECUTOR_ABI,
-  EXPRESS_RELAY_ABI,
   EXTENDED_ENTROPY_ABI,
   EXTENDED_PYTH_ABI,
   WORMHOLE_ABI,
@@ -413,93 +412,6 @@ export class EvmEntropyContract extends Storable {
   }
 }
 
-export class EvmExpressRelayContract extends Storable {
-  static type = "EvmExpressRelayContract";
-
-  constructor(
-    public chain: EvmChain,
-    public address: string,
-  ) {
-    super();
-  }
-
-  getId(): string {
-    return `${this.chain.getId()}_${this.address}`;
-  }
-
-  getChain(): EvmChain {
-    return this.chain;
-  }
-
-  getType(): string {
-    return EvmExpressRelayContract.type;
-  }
-
-  async getVersion(): Promise<string> {
-    const contract = this.getContract();
-    return contract.methods.version().call();
-  }
-
-  static fromJson(
-    chain: Chain,
-    parsed: { type: string; address: string },
-  ): EvmExpressRelayContract {
-    if (parsed.type !== EvmExpressRelayContract.type)
-      throw new Error("Invalid type");
-    if (!(chain instanceof EvmChain))
-      throw new Error(`Wrong chain type ${chain}`);
-    return new EvmExpressRelayContract(chain, parsed.address);
-  }
-
-  async generateSetRelayerPayload(relayer: string): Promise<Buffer> {
-    const contract = this.getContract();
-    const data = contract.methods.setRelayer(relayer).encodeABI();
-    return this.chain.generateExecutorPayload(
-      await this.getOwner(),
-      this.address,
-      data,
-    );
-  }
-
-  async getOwner(): Promise<string> {
-    const contract = this.getContract();
-    return contract.methods.owner().call();
-  }
-
-  async getExecutorContract(): Promise<EvmExecutorContract> {
-    const owner = await this.getOwner();
-    return new EvmExecutorContract(this.chain, owner);
-  }
-
-  async getPendingOwner(): Promise<string> {
-    const contract = this.getContract();
-    return contract.methods.pendingOwner().call();
-  }
-
-  async getRelayer(): Promise<string> {
-    const contract = this.getContract();
-    return contract.methods.getRelayer().call();
-  }
-
-  async getRelayerSubwallets(): Promise<string[]> {
-    const contract = this.getContract();
-    return contract.methods.getRelayerSubwallets().call();
-  }
-
-  toJson() {
-    return {
-      chain: this.chain.getId(),
-      address: this.address,
-      type: EvmExpressRelayContract.type,
-    };
-  }
-
-  getContract() {
-    const web3 = this.chain.getWeb3();
-    return new web3.eth.Contract(EXPRESS_RELAY_ABI, this.address);
-  }
-}
-
 export class EvmExecutorContract {
   constructor(
     public chain: EvmChain,

+ 0 - 158
contract_manager/src/core/contracts/evm_abis.ts

@@ -63,164 +63,6 @@ export const OWNABLE_ABI = [
   },
 ] as any; // eslint-disable-line  @typescript-eslint/no-explicit-any
 
-export const EXPRESS_RELAY_ABI = [
-  {
-    type: "function",
-    name: "getAdmin",
-    inputs: [],
-    outputs: [
-      {
-        name: "",
-        type: "address",
-        internalType: "address",
-      },
-    ],
-    stateMutability: "view",
-  },
-  {
-    type: "function",
-    name: "getFeeProtocol",
-    inputs: [
-      {
-        name: "feeRecipient",
-        type: "address",
-        internalType: "address",
-      },
-    ],
-    outputs: [
-      {
-        name: "",
-        type: "uint256",
-        internalType: "uint256",
-      },
-    ],
-    stateMutability: "view",
-  },
-  {
-    type: "function",
-    name: "getFeeProtocolDefault",
-    inputs: [],
-    outputs: [
-      {
-        name: "",
-        type: "uint256",
-        internalType: "uint256",
-      },
-    ],
-    stateMutability: "view",
-  },
-  {
-    type: "function",
-    name: "getFeeRelayer",
-    inputs: [],
-    outputs: [
-      {
-        name: "",
-        type: "uint256",
-        internalType: "uint256",
-      },
-    ],
-    stateMutability: "view",
-  },
-  {
-    type: "function",
-    name: "getFeeSplitPrecision",
-    inputs: [],
-    outputs: [
-      {
-        name: "",
-        type: "uint256",
-        internalType: "uint256",
-      },
-    ],
-    stateMutability: "view",
-  },
-  {
-    type: "function",
-    name: "getRelayer",
-    inputs: [],
-    outputs: [
-      {
-        name: "",
-        type: "address",
-        internalType: "address",
-      },
-    ],
-    stateMutability: "view",
-  },
-  {
-    type: "function",
-    name: "getRelayerSubwallets",
-    inputs: [],
-    outputs: [
-      {
-        name: "",
-        type: "address[]",
-        internalType: "address[]",
-      },
-    ],
-    stateMutability: "view",
-  },
-  {
-    type: "function",
-    name: "setFeeProtocol",
-    inputs: [
-      {
-        name: "feeRecipient",
-        type: "address",
-        internalType: "address",
-      },
-      {
-        name: "feeSplit",
-        type: "uint256",
-        internalType: "uint256",
-      },
-    ],
-    outputs: [],
-    stateMutability: "nonpayable",
-  },
-  {
-    type: "function",
-    name: "setFeeProtocolDefault",
-    inputs: [
-      {
-        name: "feeSplit",
-        type: "uint256",
-        internalType: "uint256",
-      },
-    ],
-    outputs: [],
-    stateMutability: "nonpayable",
-  },
-  {
-    type: "function",
-    name: "setFeeRelayer",
-    inputs: [
-      {
-        name: "feeSplit",
-        type: "uint256",
-        internalType: "uint256",
-      },
-    ],
-    outputs: [],
-    stateMutability: "nonpayable",
-  },
-  {
-    type: "function",
-    name: "setRelayer",
-    inputs: [
-      {
-        name: "relayer",
-        type: "address",
-        internalType: "address",
-      },
-    ],
-    outputs: [],
-    stateMutability: "nonpayable",
-  },
-  ...OWNABLE_ABI,
-] as any; // eslint-disable-line  @typescript-eslint/no-explicit-any
-
 export const EXTENDED_ENTROPY_ABI = [
   {
     inputs: [],

+ 9 - 9
contract_manager/src/node/utils/shell.ts

@@ -5,14 +5,14 @@ const service = tsNode.create({ ...repl.evalAwarePartialHost });
 repl.setService(service);
 repl.start();
 repl.evalCode(
-  "import { loadHotWallet, Vault } from './src/governance';" +
-    "import { SuiChain, CosmWasmChain, AptosChain, EvmChain, StarknetChain } from './src/chains';" +
-    "import { SuiPriceFeedContract } from './src/contracts/sui';" +
-    "import { CosmWasmWormholeContract, CosmWasmPriceFeedContract } from './src/contracts/cosmwasm';" +
-    "import { EvmWormholeContract, EvmPriceFeedContract, EvmEntropyContract, EvmExpressRelayContract } from './src/contracts/evm';" +
-    "import { AptosWormholeContract, AptosPriceFeedContract } from './src/contracts/aptos';" +
-    "import { StarknetPriceFeedContract } from './src/contracts/starknet';" +
-    "import { DefaultStore } from './src/store';" +
-    "import { toPrivateKey } from './src/base';" +
+  "import { loadHotWallet, Vault } from './src/node/utils/governance';" +
+    "import { SuiChain, CosmWasmChain, AptosChain, EvmChain, StarknetChain } from './src/core/chains';" +
+    "import { SuiPriceFeedContract } from './src/core/contracts/sui';" +
+    "import { CosmWasmWormholeContract, CosmWasmPriceFeedContract } from './src/core/contracts/cosmwasm';" +
+    "import { EvmWormholeContract, EvmPriceFeedContract, EvmEntropyContract } from './src/core/contracts/evm';" +
+    "import { AptosWormholeContract, AptosPriceFeedContract } from './src/core/contracts/aptos';" +
+    "import { StarknetPriceFeedContract } from './src/core/contracts/starknet';" +
+    "import { DefaultStore } from './src/node/utils/store';" +
+    "import { toPrivateKey } from './src/core/base';" +
     "DefaultStore",
 );

+ 0 - 5
contract_manager/src/node/utils/store.ts

@@ -24,7 +24,6 @@ import {
   FuelWormholeContract,
   WormholeContract,
   FuelPriceFeedContract,
-  EvmExpressRelayContract,
   TonPriceFeedContract,
   TonWormholeContract,
   IotaWormholeContract,
@@ -50,7 +49,6 @@ export class Store {
   public entropy_contracts: Record<string, EvmEntropyContract> = {};
   public pulse_contracts: Record<string, EvmPulseContract> = {};
   public wormhole_contracts: Record<string, WormholeContract> = {};
-  public express_relay_contracts: Record<string, EvmExpressRelayContract> = {};
   public tokens: Record<string, Token> = {};
   public vaults: Record<string, Vault> = {};
 
@@ -168,7 +166,6 @@ export class Store {
       [AptosPriceFeedContract.type]: AptosPriceFeedContract,
       [AptosWormholeContract.type]: AptosWormholeContract,
       [EvmEntropyContract.type]: EvmEntropyContract,
-      [EvmExpressRelayContract.type]: EvmExpressRelayContract,
       [EvmWormholeContract.type]: EvmWormholeContract,
       [FuelPriceFeedContract.type]: FuelPriceFeedContract,
       [FuelWormholeContract.type]: FuelWormholeContract,
@@ -202,8 +199,6 @@ export class Store {
           );
         if (chainContract instanceof EvmEntropyContract) {
           this.entropy_contracts[chainContract.getId()] = chainContract;
-        } else if (chainContract instanceof EvmExpressRelayContract) {
-          this.express_relay_contracts[chainContract.getId()] = chainContract;
         } else if (chainContract instanceof WormholeContract) {
           this.wormhole_contracts[chainContract.getId()] = chainContract;
         } else {

+ 1 - 61
contract_manager/store/contracts/EvmEntropyContracts.json

@@ -1,19 +1,4 @@
 [
-  {
-    "chain": "lightlink_pegasus_testnet",
-    "address": "0x8250f4aF4B972684F7b336503E2D6dFeDeB1487a",
-    "type": "EvmEntropyContract"
-  },
-  {
-    "chain": "chiliz_spicy",
-    "address": "0xD458261E832415CFd3BAE5E416FdF3230ce6F134",
-    "type": "EvmEntropyContract"
-  },
-  {
-    "chain": "mode_testnet",
-    "address": "0x98046Bd286715D3B0BC227Dd7a956b83D8978603",
-    "type": "EvmEntropyContract"
-  },
   {
     "chain": "arbitrum_sepolia",
     "address": "0x549Ebba8036Ab746611B4fFA1423eb0A4Df61440",
@@ -24,16 +9,6 @@
     "address": "0x98046Bd286715D3B0BC227Dd7a956b83D8978603",
     "type": "EvmEntropyContract"
   },
-  {
-    "chain": "lightlink_phoenix",
-    "address": "0x98046Bd286715D3B0BC227Dd7a956b83D8978603",
-    "type": "EvmEntropyContract"
-  },
-  {
-    "chain": "chiliz",
-    "address": "0x0708325268dF9F66270F1401206434524814508b",
-    "type": "EvmEntropyContract"
-  },
   {
     "chain": "arbitrum",
     "address": "0x7698E925FfC29655576D0b361D75Af579e20AdAc",
@@ -54,56 +29,21 @@
     "address": "0x4821932D0CDd71225A6d914706A621e0389D7061",
     "type": "EvmEntropyContract"
   },
-  {
-    "chain": "mode",
-    "address": "0x8D254a21b3C86D32F7179855531CE99164721933",
-    "type": "EvmEntropyContract"
-  },
   {
     "chain": "blast",
     "address": "0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb",
     "type": "EvmEntropyContract"
   },
-  {
-    "chain": "zetachain_testnet",
-    "address": "0x4374e5a8b9C22271E9EB878A2AA31DE97DF15DAF",
-    "type": "EvmEntropyContract"
-  },
-  {
-    "chain": "zetachain",
-    "address": "0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320",
-    "type": "EvmEntropyContract"
-  },
   {
     "chain": "base",
     "address": "0x6E7D74FA7d5c90FEF9F0512987605a6d546181Bb",
     "type": "EvmEntropyContract"
   },
-  {
-    "chain": "taiko_hekla",
-    "address": "0x98046Bd286715D3B0BC227Dd7a956b83D8978603",
-    "type": "EvmEntropyContract"
-  },
   {
     "chain": "sei_evm_mainnet",
     "address": "0x98046Bd286715D3B0BC227Dd7a956b83D8978603",
     "type": "EvmEntropyContract"
   },
-  {
-    "chain": "merlin",
-    "address": "0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320",
-    "type": "EvmEntropyContract"
-  },
-  {
-    "chain": "taiko_mainnet",
-    "address": "0x26DD80569a8B23768A1d80869Ed7339e07595E85",
-    "type": "EvmEntropyContract"
-  },
-  {
-    "chain": "merlin_testnet",
-    "address": "0x5744Cbf430D99456a0A8771208b674F27f8EF0Fb",
-    "type": "EvmEntropyContract"
-  },
   {
     "chain": "etherlink_testnet",
     "address": "0x23f0e8FAeE7bbb405E7A7C3d60138FCfd43d7509",
@@ -239,4 +179,4 @@
     "address": "0x23f0e8FAeE7bbb405E7A7C3d60138FCfd43d7509",
     "type": "EvmEntropyContract"
   }
-]
+]

+ 0 - 7
contract_manager/store/contracts/EvmExpressRelayContracts.json

@@ -1,7 +0,0 @@
-[
-  {
-    "chain": "mode",
-    "address": "0x5Cc070844E98F4ceC5f2fBE1592fB1ed73aB7b48",
-    "type": "EvmExpressRelayContract"
-  }
-]