@hyperlane-xyz/sdk
Version:
The official SDK for the Hyperlane Network
64 lines • 3.72 kB
JavaScript
import { InterchainGasPaymaster__factory } from '@hyperlane-xyz/core';
import { HyperlaneApp } from '../app/HyperlaneApp.js';
import { appFromAddressesMapHelper } from '../contracts/contracts.js';
import { igpFactories } from './contracts.js';
export class HyperlaneIgp extends HyperlaneApp {
static fromAddressesMap(addressesMap, multiProvider) {
const helper = appFromAddressesMapHelper(addressesMap, igpFactories, multiProvider);
return new HyperlaneIgp(helper.contractsMap, helper.multiProvider);
}
/**
* Calls the default ISM IGP's `quoteGasPayment` function to get the amount of native tokens
* required to pay for interchain gas.
* The default ISM IGP will add any gas overhead amounts related to the Mailbox
* and default ISM on the destination to the provided gasAmount.
* @param origin The name of the origin chain.
* @param destination The name of the destination chain.
* @param gasAmount The amount of gas to use when calling `quoteGasPayment`.
* The default IGP is expected to add any gas overhead related to the Mailbox
* or ISM, so this gas amount is only required to cover the usage of the `handle`
* function.
* @returns The amount of native tokens required to pay for interchain gas.
*/
quoteGasPayment(origin, destination, gasAmount) {
const igp = this.getContracts(origin).interchainGasPaymaster;
return this.quoteGasPaymentForIgp(origin, destination, gasAmount, igp.address);
}
/**
* Calls the default ISM IGP's `quoteGasPayment` function to get the amount of native tokens
* required to pay for interchain gas.
* The default ISM IGP will add any gas overhead amounts related to the Mailbox
* and default ISM on the destination to the provided gasAmount.
* @param origin The name of the origin chain.
* @param destination The name of the destination chain.
* @param gasAmount The amount of gas to use when calling `quoteGasPayment`.
* The default IGP is expected to add any gas overhead related to the Mailbox
* or ISM, so this gas amount is only required to cover the usage of the `handle`
* function.
* @returns The amount of native tokens required to pay for interchain gas.
*/
quoteGasPaymentForDefaultIsmIgp(origin, destination, gasAmount) {
const igp = this.getContracts(origin).interchainGasPaymaster;
return this.quoteGasPaymentForIgp(origin, destination, gasAmount, igp.address);
}
/**
* Calls the origin's default IGP's `quoteGasPayment` function to get the
* amount of native tokens required to pay for interchain gas.
* The default IGP is expected to add any gas overhead related to the Mailbox
* and ISM to the provided gasAmount.
* @param origin The name of the origin chain.
* @param destination The name of the destination chain.
* @param gasAmount The amount of gas to use when calling `quoteGasPayment`.
* The default IGP is expected to add any gas overhead related to the Mailbox
* or ISM, so this gas amount is only required to cover the usage of the `handle`
* function.
* @returns The amount of native tokens required to pay for interchain gas.
*/
quoteGasPaymentForIgp(origin, destination, gasAmount, interchainGasPaymasterAddress) {
const originProvider = this.multiProvider.getProvider(origin);
const igp = InterchainGasPaymaster__factory.connect(interchainGasPaymasterAddress, originProvider);
const domainId = this.multiProvider.getDomainId(destination);
return igp['quoteGasPayment(uint32,uint256)'](domainId, gasAmount);
}
}
//# sourceMappingURL=HyperlaneIgp.js.map