UNPKG

@hyperlane-xyz/sdk

Version:

The official SDK for the Hyperlane Network

56 lines 2.46 kB
import { BaseSealevelAdapter } from '../../app/MultiProtocolApp.js'; export class SealevelRouterAdapter extends BaseSealevelAdapter { chainName; multiProvider; addresses; constructor(chainName, multiProvider, addresses) { super(chainName, multiProvider, addresses); this.chainName = chainName; this.multiProvider = multiProvider; this.addresses = addresses; } async interchainSecurityModule() { const routerAccountInfo = await this.getRouterAccountInfo(); if (!routerAccountInfo.interchain_security_module_pubkey) throw new Error(`No ism found for router on ${this.chainName}`); return routerAccountInfo.interchain_security_module_pubkey.toBase58(); } async owner() { const routerAccountInfo = await this.getRouterAccountInfo(); if (!routerAccountInfo.owner_pub_key) throw new Error(`No owner found for router on ${this.chainName}`); return routerAccountInfo.owner_pub_key.toBase58(); } async remoteDomains() { const routers = await this.remoteRouters(); return routers.map((router) => router.domain); } async remoteRouter(remoteDomain) { const routers = await this.remoteRouters(); const addr = routers.find((router) => router.domain === remoteDomain)?.address; if (!addr) throw new Error(`No router found for ${remoteDomain}`); return addr; } async remoteRouters() { const routerAccountInfo = await this.getRouterAccountInfo(); const domainToPubKey = routerAccountInfo.remote_router_pubkeys; return Array.from(domainToPubKey.entries()).map(([domain, pubKey]) => ({ domain, address: pubKey.toBase58(), })); } getRouterAccountInfo() { throw new Error('TODO getRouterAccountInfo not yet implemented'); } // Should match https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/main/rust/sealevel/libraries/hyperlane-sealevel-token/src/processor.rs deriveMessageRecipientPda(routerAddress) { return super.derivePda(['hyperlane_message_recipient', '-', 'handle', '-', 'account_metas'], routerAddress); } } export class SealevelGasRouterAdapter extends SealevelRouterAdapter { async quoteGasPayment(_destination) { throw new Error('Gas payments not yet supported for sealevel'); } } //# sourceMappingURL=SealevelRouterAdapter.js.map