@hyperlane-xyz/sdk
Version:
The official SDK for the Hyperlane Network
32 lines • 1.36 kB
JavaScript
import { InterchainAccountRouter__factory } from '@hyperlane-xyz/core';
import { rootLogger } from '@hyperlane-xyz/utils';
import { EvmRouterReader } from '../router/EvmRouterReader.js';
import { throwIfNotMissingSelector } from '../utils/contract.js';
import { IcaRouterType } from './types.js';
export class EvmIcaRouterReader extends EvmRouterReader {
async deriveConfig(address) {
const icaRouterInstance = InterchainAccountRouter__factory.connect(address, this.provider);
let commitmentIsmAddress;
let routerType;
try {
commitmentIsmAddress = await icaRouterInstance.CCIP_READ_ISM();
routerType = IcaRouterType.REGULAR;
}
catch (error) {
throwIfNotMissingSelector(error);
rootLogger.debug(`No CCIP_READ_ISM on ${address} — MinimalInterchainAccountRouter`);
routerType = IcaRouterType.MINIMAL;
}
const routerConfig = await this.readRouterConfig(address);
const commitmentIsm = commitmentIsmAddress
? await this.evmIsmReader.deriveOffchainLookupConfig(commitmentIsmAddress)
: undefined;
return {
address,
...routerConfig,
routerType,
...(commitmentIsm ? { commitmentIsm } : {}),
};
}
}
//# sourceMappingURL=EvmIcaReader.js.map