From b2f29ed40a2589873bdde8c2aa4c1dd7fd087e45 Mon Sep 17 00:00:00 2001 From: J M Rossy Date: Tue, 30 Apr 2024 16:01:10 -0400 Subject: [PATCH] Move fix from test to mainnet igp config --- .../infra/config/environments/mainnet3/igp.ts | 12 +++- .../infra/config/environments/test/igp.ts | 56 +++++++------------ 2 files changed, 29 insertions(+), 39 deletions(-) diff --git a/typescript/infra/config/environments/mainnet3/igp.ts b/typescript/infra/config/environments/mainnet3/igp.ts index cc7fa27ee5..065fd4c6e2 100644 --- a/typescript/infra/config/environments/mainnet3/igp.ts +++ b/typescript/infra/config/environments/mainnet3/igp.ts @@ -4,17 +4,19 @@ import { ChainMap, ChainName, IgpConfig, + OwnableConfig, TOKEN_EXCHANGE_RATE_DECIMALS, defaultMultisigConfigs, multisigIsmVerificationCost, } from '@hyperlane-xyz/sdk'; -import { exclude, objMap } from '@hyperlane-xyz/utils'; +import { ProtocolType, exclude, objFilter, objMap } from '@hyperlane-xyz/utils'; import { AllStorageGasOracleConfigs, getAllStorageGasOracleConfigs, getTokenExchangeRateFromValues, } from '../../../src/config/gas-oracle.js'; +import { getChain } from '../../registry.js'; import { ethereumChainNames } from './chains.js'; import gasPrices from './gasPrices.json'; @@ -57,7 +59,13 @@ const storageGasOracleConfig: AllStorageGasOracleConfigs = (local) => remoteOverhead(local), ); -export const igp: ChainMap = objMap(owners, (local, owner) => ({ +const evmOwners = objFilter( + owners, + (chain, _): _ is OwnableConfig => + getChain(chain).protocol === ProtocolType.Ethereum, +); + +export const igp: ChainMap = objMap(evmOwners, (local, owner) => ({ ...owner, ownerOverrides: { ...owner.ownerOverrides, diff --git a/typescript/infra/config/environments/test/igp.ts b/typescript/infra/config/environments/test/igp.ts index 367a63410f..b47be48e66 100644 --- a/typescript/infra/config/environments/test/igp.ts +++ b/typescript/infra/config/environments/test/igp.ts @@ -3,18 +3,9 @@ import { ChainName, GasOracleContractType, IgpConfig, - OwnableConfig, multisigIsmVerificationCost, } from '@hyperlane-xyz/sdk'; -import { - Address, - ProtocolType, - exclude, - objFilter, - objMap, -} from '@hyperlane-xyz/utils'; - -import { getChain } from '../../registry.js'; +import { Address, exclude, objMap } from '@hyperlane-xyz/utils'; import { testChainNames } from './chains.js'; import { multisigIsm } from './multisigIsm.js'; @@ -29,30 +20,21 @@ function getGasOracles(local: ChainName) { ); } -const evmOwners = objFilter( - owners, - (chain, _): _ is OwnableConfig => - getChain(chain).protocol === ProtocolType.Ethereum, -); - -export const igp: ChainMap = objMap( - evmOwners, - (chain, ownerConfig) => { - const overhead = Object.fromEntries( - exclude(chain, testChainNames).map((remote) => [ - remote, - multisigIsmVerificationCost( - multisigIsm[remote].threshold, - multisigIsm[remote].validators.length, - ), - ]), - ); - return { - oracleKey: ownerConfig.owner as Address, // owner can be AccountConfig - beneficiary: ownerConfig.owner as Address, // same as above - gasOracleType: getGasOracles(chain), - overhead, - ...ownerConfig, - }; - }, -); +export const igp: ChainMap = objMap(owners, (chain, ownerConfig) => { + const overhead = Object.fromEntries( + exclude(chain, testChainNames).map((remote) => [ + remote, + multisigIsmVerificationCost( + multisigIsm[remote].threshold, + multisigIsm[remote].validators.length, + ), + ]), + ); + return { + oracleKey: ownerConfig.owner as Address, // owner can be AccountConfig + beneficiary: ownerConfig.owner as Address, // same as above + gasOracleType: getGasOracles(chain), + overhead, + ...ownerConfig, + }; +});