Skip to content

Commit

Permalink
Move fix from test to mainnet igp config
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrossy committed Apr 30, 2024
1 parent ea283dc commit b2f29ed
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 39 deletions.
12 changes: 10 additions & 2 deletions typescript/infra/config/environments/mainnet3/igp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -57,7 +59,13 @@ const storageGasOracleConfig: AllStorageGasOracleConfigs =
(local) => remoteOverhead(local),
);

export const igp: ChainMap<IgpConfig> = objMap(owners, (local, owner) => ({
const evmOwners = objFilter(
owners,
(chain, _): _ is OwnableConfig =>
getChain(chain).protocol === ProtocolType.Ethereum,
);

export const igp: ChainMap<IgpConfig> = objMap(evmOwners, (local, owner) => ({
...owner,
ownerOverrides: {
...owner.ownerOverrides,
Expand Down
56 changes: 19 additions & 37 deletions typescript/infra/config/environments/test/igp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -29,30 +20,21 @@ function getGasOracles(local: ChainName) {
);
}

const evmOwners = objFilter(
owners,
(chain, _): _ is OwnableConfig =>
getChain(chain).protocol === ProtocolType.Ethereum,
);

export const igp: ChainMap<IgpConfig> = 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<IgpConfig> = 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,
};
});

0 comments on commit b2f29ed

Please sign in to comment.