import { Keplr } from '@keplr-wallet/types'; import { OfflineAminoSigner, StdSignDoc, AminoSignResponse } from '@cosmjs/amino'; import { OfflineDirectSigner, AccountData, DirectSignResponse } from '@cosmjs/proto-signing'; import { Origin, RequestMethodCallMessage, CalledParentMethodResult, ParentMetadata, ListenOptions } from './types.js'; declare class CosmiframeDirectSigner implements OfflineDirectSigner { #private; chainId: string; constructor(chainId: string, allowedParentOrigins: Origin[]); getAccounts(): Promise; signDirect(signerAddress: string, signDoc: DirectSignResponse['signed']): Promise; } declare class CosmiframeAminoSigner implements OfflineAminoSigner { #private; chainId: string; constructor(chainId: string, allowedParentOrigins: Origin[]); getAccounts(): Promise; signAmino(signerAddress: string, signDoc: StdSignDoc): Promise; } declare class CosmiframeEitherSigner implements OfflineDirectSigner, OfflineAminoSigner { #private; chainId: string; constructor(chainId: string, allowedParentOrigins: Origin[]); getAccounts(): Promise; signDirect(signerAddress: string, signDoc: DirectSignResponse['signed']): Promise; signAmino(signerAddress: string, signDoc: StdSignDoc): Promise; } declare class Cosmiframe { #private; /** * Proxy object that can be used to call methods on the parent frame. This * serves as a passthrough and is a convenient alternative to using * `callParentMethod`. This should be used by the iframe. * * For example: * * const cosmiframe = new Cosmiframe() * const accounts = await cosmiframe.p.getAccounts() */ p: { [key: string]: (...params: any[]) => Promise; }; constructor( /** * List of allowed parent origins. * * In order to allow all origins, you must explicitly pass in the string * `UNSAFE_ALLOW_ANY_ORIGIN`. Do not do this. It is very unsafe. */ allowedParentOrigins: Origin[]); /** * Call a method on the parent frame, returning the result with metadata, such * as the response message origin, which should be the parent frame origin. * This should be used by the iframe. */ callParentMethod(options: Pick, /** * The timeout in milliseconds after which to reject the promise and stop * listening if the parent has not responded. If undefined, no timeout. * * Defaults to no timeout. */ timeout?: number): Promise>; /** * Returns whether or not Cosmiframe is ready to use, meaning all of these are * true: * - The current app is being used in an iframe. * - The parent window is running Cosmiframe. * - The parent window is one of the allowed origins. * * If ready to use, this returns the origin of the parent frame that * acknowledged the request. If no origin is set for some reason, this returns * true. Otherwise, this returns false. * * This should be used by the iframe. */ isReady(): Promise; /** * Returns the metadata set by the parent when it started listening. This * should be used by the iframe to display information about the parent. */ getMetadata(): Promise; /** * Get client that conforms to Keplr's interface. */ getKeplrClient(): Keplr; /** * Get an offline signer with both direct and amino sign functions that * forwards requests to the parent frame. The parent frame must be listening * (using the `listen` function). This should be used by the iframe. */ getOfflineSigner(chainId: string): CosmiframeEitherSigner; /** * Get an offline amino signer that forwards requests to the parent frame. The * parent frame must be listening (using the `listen` function). This should * be used by the iframe. */ getOfflineSignerAmino(chainId: string): CosmiframeAminoSigner; /** * Get an offline direct signer that forwards requests to the parent frame. * The parent frame must be listening (using the `listen` function). This * should be used by the iframe. */ getOfflineSignerDirect(chainId: string): CosmiframeDirectSigner; /** * Listen for requests from the provided iframe. This should be used by the * parent. Returns a function that can be called to stop listening. */ static listen(options: ListenOptions): () => void; } export { Cosmiframe as C, CosmiframeDirectSigner as a, CosmiframeAminoSigner as b, CosmiframeEitherSigner as c };