Skip to content

Commit

Permalink
feat: filter chains to check depending on Operator chain
Browse files Browse the repository at this point in the history
  • Loading branch information
maximegris committed Dec 14, 2024
1 parent 08cf6ac commit 18ee2b5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
19 changes: 17 additions & 2 deletions typescript/cli/src/avs/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import {
ValidatorAnnounce__factory,
} from '@hyperlane-xyz/core';
import { ChainMap, ChainName, MultiProvider } 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 {
Expand Down Expand Up @@ -81,7 +86,7 @@ export const checkValidatorAvsSetup = async (
);

if (!isObjEmpty(avsOperatorRecord)) {
await setValidatorInfo(context, avsOperatorRecord, topLevelErrors);
await setValidatorInfo(chain, context, avsOperatorRecord, topLevelErrors);
}

logOutput(avsOperatorRecord, topLevelErrors);
Expand Down Expand Up @@ -226,6 +231,7 @@ const setOperatorName = async (
};

const setValidatorInfo = async (
operatorChain: string,
context: CommandContext,
avsOperatorRecord: Record<Address, ValidatorInfo>,
topLevelErrors: string[],
Expand All @@ -242,6 +248,15 @@ const setValidatorInfo = async (
// skip if chain is not an Ethereum chain
if (chainMetadata[chain].protocol !== ProtocolType.Ethereum) continue;

// skip if chain network type 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
Expand Down
2 changes: 2 additions & 0 deletions typescript/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ export {
MerkleProof,
MessageStatus,
Numberish,
OperatorChain,
OperatorChainValue,
ParsedLegacyMultisigIsmMetadata,
ParsedMessage,
ProtocolSmallestUnit,
Expand Down
7 changes: 7 additions & 0 deletions typescript/utils/src/types.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit 18ee2b5

Please sign in to comment.