diff --git a/typescript/infra/config/environments/mainnet3/chains.ts b/typescript/infra/config/environments/mainnet3/chains.ts index 9f8cba7f90..29f33e9365 100644 --- a/typescript/infra/config/environments/mainnet3/chains.ts +++ b/typescript/infra/config/environments/mainnet3/chains.ts @@ -1,4 +1,5 @@ -import { ChainMap, ChainMetadata, ChainName } from '@hyperlane-xyz/sdk'; +import { ChainMap, ChainMetadata } from '@hyperlane-xyz/sdk'; +import { objKeys } from '@hyperlane-xyz/utils'; import { getChainMetadatas } from '../../../src/config/chain.js'; import { getChain } from '../../registry.js'; @@ -67,6 +68,4 @@ export const mainnetConfigs: ChainMap = { ...nonEthereumMainnetConfigs, }; -export const ethereumChainNames = Object.keys( - ethereumMainnetConfigs, -) as ChainName[]; +export const ethereumChainNames = objKeys(ethereumMainnetConfigs); diff --git a/typescript/infra/config/environments/mainnet3/igp.ts b/typescript/infra/config/environments/mainnet3/igp.ts index 065fd4c6e2..cc7fa27ee5 100644 --- a/typescript/infra/config/environments/mainnet3/igp.ts +++ b/typescript/infra/config/environments/mainnet3/igp.ts @@ -4,19 +4,17 @@ import { ChainMap, ChainName, IgpConfig, - OwnableConfig, TOKEN_EXCHANGE_RATE_DECIMALS, defaultMultisigConfigs, multisigIsmVerificationCost, } from '@hyperlane-xyz/sdk'; -import { ProtocolType, exclude, objFilter, objMap } from '@hyperlane-xyz/utils'; +import { exclude, 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'; @@ -59,13 +57,7 @@ const storageGasOracleConfig: AllStorageGasOracleConfigs = (local) => remoteOverhead(local), ); -const evmOwners = objFilter( - owners, - (chain, _): _ is OwnableConfig => - getChain(chain).protocol === ProtocolType.Ethereum, -); - -export const igp: ChainMap = objMap(evmOwners, (local, owner) => ({ +export const igp: ChainMap = objMap(owners, (local, owner) => ({ ...owner, ownerOverrides: { ...owner.ownerOverrides, diff --git a/typescript/infra/config/environments/testnet4/chains.ts b/typescript/infra/config/environments/testnet4/chains.ts index 0dc9f9ec00..1476e3076f 100644 --- a/typescript/infra/config/environments/testnet4/chains.ts +++ b/typescript/infra/config/environments/testnet4/chains.ts @@ -1,15 +1,20 @@ import { ChainMap, ChainMetadata } from '@hyperlane-xyz/sdk'; +import { objKeys } from '@hyperlane-xyz/utils'; +import { getChainMetadatas } from '../../../src/config/chain.js'; import { getChain } from '../../registry.js'; import { supportedChainNames } from './supportedChainNames.js'; export const environment = 'testnet4'; +const { + ethereumMetadatas: defaultEthereumMainnetConfigs, + nonEthereumMetadatas: nonEthereumMainnetConfigs, +} = getChainMetadatas(supportedChainNames); + export const testnetConfigs: ChainMap = { - ...Object.fromEntries( - supportedChainNames.map((chain) => [chain, getChain(chain)]), - ), + ...defaultEthereumMainnetConfigs, bsctestnet: { ...getChain('bsctestnet'), transactionOverrides: { @@ -17,3 +22,5 @@ export const testnetConfigs: ChainMap = { }, }, }; + +export const ethereumChainNames = objKeys(defaultEthereumMainnetConfigs); diff --git a/typescript/infra/config/environments/testnet4/igp.ts b/typescript/infra/config/environments/testnet4/igp.ts index 2e94c71668..f0736d46e1 100644 --- a/typescript/infra/config/environments/testnet4/igp.ts +++ b/typescript/infra/config/environments/testnet4/igp.ts @@ -1,48 +1,30 @@ import { ChainMap, IgpConfig, - OwnableConfig, defaultMultisigConfigs, 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 { storageGasOracleConfig } from './gas-oracle.js'; import { owners } from './owners.js'; import { supportedChainNames } from './supportedChainNames.js'; -const evmOwners = objFilter( - owners, - (chain, _): _ is OwnableConfig => - getChain(chain).protocol === ProtocolType.Ethereum, -); - -export const igp: ChainMap = objMap( - evmOwners, - (chain, ownerConfig) => { - return { - ...ownerConfig, - oracleKey: ownerConfig.owner as Address, - beneficiary: ownerConfig.owner as Address, - oracleConfig: storageGasOracleConfig[chain], - overhead: Object.fromEntries( - exclude(chain, supportedChainNames).map((remote) => [ - remote, - multisigIsmVerificationCost( - // TODO: parameterize this - defaultMultisigConfigs[remote].threshold, - defaultMultisigConfigs[remote].validators.length, - ), - ]), - ), - }; - }, -); +export const igp: ChainMap = objMap(owners, (chain, ownerConfig) => { + return { + ...ownerConfig, + oracleKey: ownerConfig.owner as Address, + beneficiary: ownerConfig.owner as Address, + oracleConfig: storageGasOracleConfig[chain], + overhead: Object.fromEntries( + exclude(chain, supportedChainNames).map((remote) => [ + remote, + multisigIsmVerificationCost( + // TODO: parameterize this + defaultMultisigConfigs[remote].threshold, + defaultMultisigConfigs[remote].validators.length, + ), + ]), + ), + }; +}); diff --git a/typescript/infra/config/environments/testnet4/owners.ts b/typescript/infra/config/environments/testnet4/owners.ts index 4ef46cd159..00f3b00f96 100644 --- a/typescript/infra/config/environments/testnet4/owners.ts +++ b/typescript/infra/config/environments/testnet4/owners.ts @@ -1,13 +1,13 @@ import { ChainMap, OwnableConfig } from '@hyperlane-xyz/sdk'; -import { supportedChainNames } from './supportedChainNames.js'; +import { ethereumChainNames } from './chains.js'; const ETHEREUM_DEPLOYER_ADDRESS = '0xfaD1C94469700833717Fa8a3017278BC1cA8031C'; // const SEALEVEL_DEPLOYER_ADDRESS = '6DjHX6Ezjpq3zZMZ8KsqyoFYo1zPSDoiZmLLkxD4xKXS'; export const owners: ChainMap = { ...Object.fromEntries( - supportedChainNames.map((chain) => [ + ethereumChainNames.map((chain) => [ chain, { owner: ETHEREUM_DEPLOYER_ADDRESS }, ]),