From ebc5e8c20fb515e13989c492172ccdf5bd7b1522 Mon Sep 17 00:00:00 2001 From: Maxime GRIS Date: Sat, 14 Dec 2024 11:47:18 +0100 Subject: [PATCH] feat: filter chains to check depending on Operator chain --- typescript/cli/src/avs/check.ts | 19 +++++++++++++++++-- typescript/utils/src/index.ts | 2 ++ typescript/utils/src/types.ts | 7 +++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/typescript/cli/src/avs/check.ts b/typescript/cli/src/avs/check.ts index b2af3f7b73..6eec38f16d 100644 --- a/typescript/cli/src/avs/check.ts +++ b/typescript/cli/src/avs/check.ts @@ -12,7 +12,12 @@ import { MultiProvider, isValidValidatorStorageLocation, } from '@hyperlane-xyz/sdk'; -import { Address, ProtocolType, isObjEmpty } from '@hyperlane-xyz/utils'; +import { + Address, + OperatorChain, + ProtocolType, + isObjEmpty, +} from '@hyperlane-xyz/utils'; import { CommandContext } from '../context/types.js'; import { @@ -86,7 +91,7 @@ export const checkValidatorAvsSetup = async ( ); if (!isObjEmpty(avsOperatorRecord)) { - await setValidatorInfo(context, avsOperatorRecord, topLevelErrors); + await setValidatorInfo(chain, context, avsOperatorRecord, topLevelErrors); } logOutput(avsOperatorRecord, topLevelErrors); @@ -231,6 +236,7 @@ const setOperatorName = async ( }; const setValidatorInfo = async ( + operatorChain: string, context: CommandContext, avsOperatorRecord: Record, topLevelErrors: string[], @@ -247,6 +253,15 @@ const setValidatorInfo = async ( // skip if chain is not an Ethereum chain if (chainMetadata[chain].protocol !== ProtocolType.Ethereum) continue; + // skip if chain network type does not match the operator chain + if ( + (operatorChain === OperatorChain.Ethereum && + chainMetadata[chain].isTestnet) || + (operatorChain === OperatorChain.Holesky && + !chainMetadata[chain].isTestnet) + ) + continue; + const chainAddresses = addresses[chain]; // skip if no contract addresses are found for this chain diff --git a/typescript/utils/src/index.ts b/typescript/utils/src/index.ts index f4bd9779cb..ed84680172 100644 --- a/typescript/utils/src/index.ts +++ b/typescript/utils/src/index.ts @@ -161,6 +161,8 @@ export { MerkleProof, MessageStatus, Numberish, + OperatorChain, + OperatorChainValue, ParsedLegacyMultisigIsmMetadata, ParsedMessage, ProtocolSmallestUnit, diff --git a/typescript/utils/src/types.ts b/typescript/utils/src/types.ts index c0b7ddee66..1b80624b19 100644 --- a/typescript/utils/src/types.ts +++ b/typescript/utils/src/types.ts @@ -1,6 +1,13 @@ import type { SignatureLike } from '@ethersproject/bytes'; import type { BigNumber, ethers } from 'ethers'; +export enum OperatorChain { + Ethereum = 'ethereum', + Holesky = 'holesky', +} +// A type that also allows for literal values of the enum +export type OperatorChainValue = `${OperatorChain}`; + export enum ProtocolType { Ethereum = 'ethereum', Sealevel = 'sealevel',