import { WalletTransport, ConnectOptions } from "../WalletTransport"; import { PeraNetwork, PeraProvider } from "./peraProviderTypes"; import PeraWalletConnectError from "../../util/PeraWalletConnectError"; import { PeraWalletArbitraryData, PeraWalletArc60SignData, PeraWalletArc60SignDataResponse, SignMetadata, PeraWalletTransaction } from "../../util/model/peraWalletModels"; import { AlgorandChainIDs } from "../../util/peraWalletTypes"; type ErrorContext = "connect" | "reconnect" | "sign-txn" | "sign-data"; /** * Maps a `window.pera` rejection onto the SDK's error classes. Anything that * is not a `PeraProviderError` is wrapped as the context's generic failure with * the original error attached as `detail`. */ declare function mapProviderError(error: unknown, context: ErrorContext): PeraWalletConnectError; /** * The `network` option for `window.pera.connect()`: set when the session is * pinned to one network, omitted for the all-networks `4160` (or unset) so the * wallet connects on whatever network it is on. */ declare function getPeraNetworkFromChainId(chainId?: AlgorandChainIDs): PeraNetwork | undefined; export interface ExtensionTransportDeps { chainId?: AlgorandChainIDs; /** The wallet revoked this origin from its Connections screen. */ onDisconnect?: () => void; onNetworkChanged?: (params: { network: PeraNetwork; }) => void; } /** * Routes connect / reconnect / sign / disconnect through the provider the Pera * browser extension injects at `window.pera`. The wallet keys the connection * on the page origin, so the only state kept here is the stored wallet details * that mark the extension as the last successful transport. */ export declare class ExtensionTransport implements WalletTransport { readonly platform: "extension"; private provider; private deps; private unsubscribers; private _network; constructor(provider: PeraProvider, deps?: ExtensionTransportDeps); /** The wallet's active network as of the last connect or `networkChanged`. */ get network(): PeraNetwork | null; /** Stops listening to the provider's notifications. */ dispose(): void; /** * Must run synchronously inside the user's click: a first-time connect needs * transient user activation, which the extension checks on the page's behalf. * There is deliberately no `await` before `provider.connect()`. */ connect(_opts?: ConnectOptions): Promise; /** * A plain `connect()` without a gesture: resolves at once when the origin is * already approved, and fails with UNAUTHORIZED when it is not, which is * "no session" rather than an error. */ reconnect(): Promise; disconnect(): Promise; signTransaction(txns: PeraWalletTransaction[]): Promise; signData(data: PeraWalletArbitraryData[], signer: string, _chainId: AlgorandChainIDs): Promise; /** * The wallet's empty signatures for this origin, unfiltered, or `{}` from an * extension that predates the method. Without `network` the wallet answers * for the network it is on. */ getEmptySignatures(network: PeraNetwork | undefined): Promise; signArc60Data(payload: PeraWalletArc60SignData, metadata: SignMetadata): Promise; private storeConnection; private handleProviderDisconnect; private handleProviderNetworkChanged; } export { getPeraNetworkFromChainId, mapProviderError };