import { BigNumberish, ethers } from 'ethers'; import { MultiProvider } from '..'; import { xapps, core } from 'optics-ts-interface'; import { BridgeContracts } from './contracts/BridgeContracts'; import { CoreContracts } from './contracts/CoreContracts'; import { ResolvedTokenInfo, TokenIdentifier } from './tokens'; import { OpticsDomain } from './domains'; import { TransferMessage } from './messages'; declare type Address = string; /** * The OpticsContext managers connections to Optics core and Bridge contracts. * It inherits from the {@link MultiProvider}, and ensures that its contracts * always use the latest registered providers and signers. * * For convenience, we've pre-constructed contexts for mainnet and testnet * deployments. These can be imported directly. * * @example * // Set up mainnet and then access contracts as below: * let router = mainnet.mustGetBridge('celo').bridgeRouter; */ export declare class OpticsContext extends MultiProvider { private cores; private bridges; private _governorDomain?; constructor(domains: OpticsDomain[], cores: CoreContracts[], bridges: BridgeContracts[]); /** * Instantiate an OpticsContext from contract info. * * @param domains An array of Domains with attached contract info * @returns A context object */ static fromDomains(domains: OpticsDomain[]): OpticsContext; /** * Ensure that the contracts on a given domain are connected to the * currently-registered signer or provider. * * @param domain the domain to reconnect */ private reconnect; /** * Register an ethers Provider for a specified domain. * * @param nameOrDomain A domain name or number. * @param provider An ethers Provider to be used by requests to that domain. */ registerProvider(nameOrDomain: string | number, provider: ethers.providers.Provider): void; /** * Register an ethers Signer for a specified domain. * * @param nameOrDomain A domain name or number. * @param signer An ethers Signer to be used by requests to that domain. */ registerSigner(nameOrDomain: string | number, signer: ethers.Signer): void; /** * Remove the registered ethers Signer from a domain. This function will * attempt to preserve any Provider that was previously connected to this * domain. * * @param nameOrDomain A domain name or number. */ unregisterSigner(nameOrDomain: string | number): void; /** * Clear all signers from all registered domains. */ clearSigners(): void; /** * Get the {@link CoreContracts} for a given domain (or undefined) * * @param nameOrDomain A domain name or number. * @returns a {@link CoreContracts} object (or undefined) */ getCore(nameOrDomain: string | number): CoreContracts | undefined; /** * Get the {@link CoreContracts} for a given domain (or throw an error) * * @param nameOrDomain A domain name or number. * @returns a {@link CoreContracts} object * @throws if no {@link CoreContracts} object exists on that domain. */ mustGetCore(nameOrDomain: string | number): CoreContracts; /** * 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 replica for the Home domain on the Remote domain (if any). * * WARNING: do not hold references to this contract, as it will not be * reconnected in the event the chain connection changes. * * @param home the sending domain * @param remote the receiving domain * @returns An interface for the Replica (if any) */ getReplicaFor(home: string | number, remote: string | number): core.Replica | undefined; /** * Resolve the replica for the Home domain on the Remote domain (or throws). * * WARNING: do not hold references to this contract, as it will not be * reconnected in the event the chain connection changes. * * @param home the sending domain * @param remote the receiving domain * @returns An interface for the Replica * @throws If no replica is found. */ mustGetReplicaFor(home: string | number, remote: string | number): core.Replica; /** * Discovers the governor domain of this optics deployment and caches it. * * @returns The identifier of the governing domain */ governorDomain(): Promise; /** * Discovers the governor domain of this optics deployment and returns the * associated Core. * * @returns The identifier of the governing domain */ governorCore(): Promise; /** * 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; /** * 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; /** * 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; /** * 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; /** * 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 token to send * @param amount The amount (in smallest unit) to send * @param recipient The identifier to send to on the `to` domain * @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, overrides?: ethers.Overrides): Promise; /** * 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 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, overrides?: ethers.PayableOverrides): Promise; } export declare const mainnet: OpticsContext; export declare const mainnetCommunity: OpticsContext; export declare const devCommunity: OpticsContext; export declare const staging: OpticsContext; export declare const stagingCommunity: OpticsContext; export {}; //# sourceMappingURL=OpticsContext.d.ts.map