UNPKG

@nomad-xyz/sdk-bridge

Version:
191 lines 9.35 kB
import { BigNumberish, ethers } from 'ethers'; import * as bridge from '@nomad-xyz/contracts-bridge'; import { NomadContext } from '@nomad-xyz/sdk'; import { AccountantAsset, BridgeContracts, NftInfo } from './BridgeContracts'; import { ResolvedTokenInfo, TokenIdentifier } from './tokens'; import { TransferMessage } from './BridgeMessage'; import * as config from '@nomad-xyz/configuration'; import BridgeMessageBackend from './backend'; declare type Address = string; /** * The BridgeContext manages connections to Nomad Bridge contracts. * It inherits from the {@link MultiProvider} and {@link NomadContext} and * ensures that its contracts always use the latest registered providers and * signers. */ export declare class BridgeContext extends NomadContext { private bridges; _backend?: BridgeMessageBackend; constructor(environment?: string | config.NomadConfig, backend?: BridgeMessageBackend); /** * Create default backend for the context */ withDefaultBackend(): BridgeContext; static fromNomadContext(context: NomadContext): BridgeContext; /** * Get the {@link BridgeContracts} for a given domain (or undefined) * * @param nameOrDomain A domain name or number. * @returns a {@link BridgeContracts} object (or undefined) */ getBridge(nameOrDomain: string | number): BridgeContracts | undefined; /** * Get the {@link BridgeContracts} for a given domain (or throw an error) * * @param nameOrDomain A domain name or number. * @returns a {@link BridgeContracts} object * @throws if no {@link BridgeContracts} object exists on that domain. */ mustGetBridge(nameOrDomain: string | number): BridgeContracts; /** * Resolve the local representation of a token on some domain. E.g. find the * deployed Celo address of Ethereum's Sushi Token. * * WARNING: do not hold references to this contract, as it will not be * reconnected in the event the chain connection changes. * * @param nameOrDomain the target domain, which hosts the representation * @param token The token to locate on that domain * @returns An interface for that token (if it has been deployed on that * domain) */ resolveRepresentation(nameOrDomain: string | number, token: TokenIdentifier): Promise<bridge.BridgeToken | undefined>; /** * Resolve the local representation of a token on ALL known domain. E.g. * find ALL deployed addresses of Ethereum's Sushi Token, on all registered * domains. * * WARNING: do not hold references to these contracts, as they will not be * reconnected in the event the chain connection changes. * * @param token The token to locate on ALL domains * @returns A {@link ResolvedTokenInfo} object with representation addresses */ resolveRepresentations(token: TokenIdentifier): Promise<ResolvedTokenInfo>; /** * Resolve the canonical domain and identifier for a representation on some * domain. * * @param nameOrDomain The domain hosting the representation * @param representation The address of the representation on that domain * @returns The domain and ID for the canonical token * @throws If the token is unknown to the bridge router on its domain. */ resolveCanonicalIdentifier(nameOrDomain: string | number, representation: Address): Promise<TokenIdentifier>; /** * Resolve an interface for the canonical token corresponding to a * representation on some domain. * * @param nameOrDomain The domain hosting the representation * @param representation The address of the representation on that domain * @returns An interface for that token * @throws If the token is unknown to the bridge router on its domain. */ resolveCanonicalToken(nameOrDomain: string | number, representation: Address): Promise<bridge.BridgeToken>; /** * Send tokens from one domain to another. Approves the bridge if necessary. * * @param from The domain to send from * @param to The domain to send to * @param token The canonical token to send (details from originating chain) * @param amount The amount (in smallest unit) to send * @param recipient The identifier to send to on the `to` domain * @param enableFast TRUE to enable fast liquidity; FALSE to require no fast liquidity * @param overrides Any tx overrides (e.g. gas price) * @returns a {@link TransferMessage} object representing the in-flight * transfer * @throws On missing signers, missing tokens, tx issues, etc. */ prepareSend(from: string | number, to: string | number, token: TokenIdentifier, amount: BigNumberish, recipient: Address, enableFast?: boolean, overrides?: ethers.Overrides): Promise<ethers.PopulatedTransaction>; /** * Send tokens from one domain to another. Approves the bridge if necessary. * * @param from The domain to send from * @param to The domain to send to * @param token The canonical token to send (details from originating chain) * @param amount The amount (in smallest unit) to send * @param recipient The identifier to send to on the `to` domain * @param enableFast TRUE to enable fast liquidity; FALSE to require no fast liquidity * @param overrides Any tx overrides (e.g. gas price) * @returns a {@link TransferMessage} object representing the in-flight * transfer * @throws On missing signers, missing tokens, tx issues, etc. */ send(from: string | number, to: string | number, token: TokenIdentifier, amount: BigNumberish, recipient: Address, enableFast?: boolean, overrides?: ethers.Overrides): Promise<TransferMessage>; /** * Send a chain's native asset from one chain to another using the * `EthHelper` contract. * * @param from The domain to send from * @param to The domain to send to * @param amount The amount (in smallest unit) to send * @param recipient The identifier to send to on the `to` domain * @param enableFast TRUE to enable fast liquidity; FALSE to require no fast liquidity * @param overrides Any tx overrides (e.g. gas price) * @returns a {@link TransferMessage} object representing the in-flight * transfer * @throws On missing signers, tx issues, etc. */ prepareSendNative(from: string | number, to: string | number, amount: BigNumberish, recipient: Address, enableFast?: boolean, overrides?: ethers.PayableOverrides): Promise<ethers.PopulatedTransaction>; /** * Send a chain's native asset from one chain to another using the * `EthHelper` contract. * * @param from The domain to send from * @param to The domain to send to * @param amount The amount (in smallest unit) to send * @param recipient The identifier to send to on the `to` domain * @param enableFast TRUE to enable fast liquidity; FALSE to require no fast liquidity * @param overrides Any tx overrides (e.g. gas price) * @returns a {@link TransferMessage} object representing the in-flight * transfer * @throws On missing signers, tx issues, etc. */ sendNative(from: string | number, to: string | number, amount: BigNumberish, recipient: Address, enableFast?: boolean, overrides?: ethers.PayableOverrides): Promise<TransferMessage>; /** * Get the accountant associated with this environment, if any. Accountants * will be on Goerli for development, Ethereum for production. */ get accountant(): bridge.NFTAccountant | undefined; /** * Get the info associated with the NFT ID, if any. * * @param id The numerical NFT ID * @returns The NFT info, or undefined if no NFT exists, or undefined if * this is not production (i.e. there is no network named "ethereum") * @throws If no signer is available, or if the transaction errors */ nftInfo(id: BigNumberish): Promise<NftInfo | undefined>; /** * Prepare a transaction to recover from the NFT, if possible * * @param id The numerical NFT ID * @returns A populated transaction * @throws If no signer is available, or if the transaction errors */ prepareRecover(id: BigNumberish, overrides?: ethers.PayableOverrides): Promise<ethers.PopulatedTransaction | undefined>; /** * Recover from the NFT, if possible * * @param id The numerical NFT ID * @returns A transaction receipt * @throws If no signer is available, or if the transaction errors */ recover(id: BigNumberish, overrides?: ethers.PayableOverrides): Promise<ethers.ContractReceipt | undefined>; /** * Read the accountant's information on an asset * * @param id The token address on Ethereum * @returns The asset info (_totalAffected, _totalMinted, _totalCollected, _totalRecovered) */ assetInfo(token: string): Promise<AccountantAsset | undefined>; /** * Checks if an address is on the allow list * * @param address A 20-byte Ethereum address * @returns Boolean, whether the address is on the allow list or not */ isAllowed(address: Address): Promise<boolean>; } export {}; //# sourceMappingURL=BridgeContext.d.ts.map