@signumjs/wallets
Version:
Wallets communication package for DApps in the Signum Network
51 lines (50 loc) • 2.61 kB
TypeScript
/**
* Original work Copyright (c) 2020 Madfish Solutions
* Modified work Copyright (c) 2022 Signum Network
*/
import { ExtensionAdapter } from './extensionAdapter';
import { ExtensionNotification, ExtensionPermission, ExtensionRequestArgs, ExtensionResponse, ExtensionSentEncryptedMessage, ExtensionSigned } from './messaging';
import { ExtensionListener } from './extensionListener';
import { RequestPermissionArgs, RequestSignArgs } from './args';
import { RequestSendEncryptedMessageArgs } from './args/requestSendEncryptedMessageArgs';
/**
* Extension Adapter for Browser based wallet access, to use with {@link GenericExtensionWallet}
*
* This adapter is automatically chosen in browser environments - Usually, you won't use this adapter directly.
*/
export declare class BrowserExtensionAdapter implements ExtensionAdapter {
private static send;
private static assertResponse;
/**
* Asserts that a compatible extension wallet is available
* @throws Exception if no wallet was found
*/
assertWalletAvailable(): Promise<void>;
/**
* Informs about extension wallet events, like network/node changes, permission and/or account removals
* @param callback The callback object with the event handler
* @return The listener object, that can/should be used to unsubscribe if not needed anymore
*/
onNotification(callback: (message: ExtensionNotification) => void): ExtensionListener;
/**
* Gets the current permission
* @return The extensions permission object
*/
getCurrentPermission(): Promise<ExtensionPermission>;
/**
* Generic request method, to request various operations
* @param payload The payload object for the respective operation
* @return The response from the wallet in case of success
* @throws An error object in case of failures, see also {@link ExtensionWalletError}
*/
request(payload: ExtensionRequestArgs): Promise<ExtensionResponse>;
/**
* Requests the permission of a compatible wallet.
* A permission is based on _one_ network, e.g. Signum, Signum-TESTNET, etc. and the url of the requesting application.
* The wallet should have selected a node of the required network, otherwise permission request fails with {@link InvalidNetworkError}
* @param args The argument object
*/
requestPermission(args: RequestPermissionArgs): Promise<ExtensionPermission>;
requestSign(args: RequestSignArgs): Promise<ExtensionSigned>;
requestSendEncryptedMessage(args: RequestSendEncryptedMessageArgs): Promise<ExtensionSentEncryptedMessage>;
}