diff --git a/typescript/sdk/src/ism/multisig.ts b/typescript/sdk/src/ism/multisig.ts new file mode 100644 index 0000000000..2846f006ce --- /dev/null +++ b/typescript/sdk/src/ism/multisig.ts @@ -0,0 +1,27 @@ +import { objFilter, objMap } from '@hyperlane-xyz/utils'; + +import { ChainMap, ChainName } from '../types'; + +import { MultisigConfig, MultisigIsmConfig } from './types'; + +// build multisigIsmConfig from multisigConfig +// eg. for { sepolia (local), arbitrumsepolia, scrollsepolia } +// arbitrumsepolia => Ism, scrollsepolia => Ism +export const buildMultisigIsmConfigs = ( + type: MultisigIsmConfig['type'], + local: ChainName, + chains: ChainName[], + multisigConfigs: ChainMap, +): ChainMap => { + return objMap( + objFilter( + multisigConfigs, + (chain, config): config is MultisigConfig => + chain !== local && chains.includes(chain), + ), + (_, config) => ({ + ...config, + type, + }), + ); +};