UNPKG

@signumjs/wallets

Version:

Wallets communication package for DApps in the Signum Network

65 lines 2.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InvalidNetworkError = exports.InvalidParamsWalletError = exports.NotFoundWalletError = exports.NotGrantedWalletError = exports.ExtensionWalletError = void 0; exports.createError = createError; const messaging_1 = require("./messaging"); /** * A generic and unknown/unexpected error with the extension */ class ExtensionWalletError { name = 'ExtensionWalletError'; message = 'An unknown error occured. Please try again or report it'; } exports.ExtensionWalletError = ExtensionWalletError; /** * Error for rejected permissions, or similar permission errors */ class NotGrantedWalletError extends ExtensionWalletError { name = 'NotGrantedWalletError'; message = 'Permission Not Granted'; } exports.NotGrantedWalletError = NotGrantedWalletError; /** * Error if no compatible extension wallet was found */ class NotFoundWalletError extends ExtensionWalletError { name = 'NotFoundWalletError'; message = 'Could not find a compatible wallet'; } exports.NotFoundWalletError = NotFoundWalletError; /** * Error if request parameters do not match expectation of the wallet */ class InvalidParamsWalletError extends ExtensionWalletError { name = 'InvalidParamsWalletError'; message = 'Some of the parameters you provided are invalid'; } exports.InvalidParamsWalletError = InvalidParamsWalletError; /** * Error if the network is not allowed for the requesting application, i.e. requested network does not exist, or the currently selected node is not * of requested network. */ class InvalidNetworkError extends ExtensionWalletError { name = 'InvalidNetworkError'; message = 'The selected network/node of the wallet does not match the applications required network. Please select another network/node in your wallet'; } exports.InvalidNetworkError = InvalidNetworkError; /** * @internal * @ignore */ function createError(payload) { switch (payload) { case messaging_1.ExtensionErrorType.NotGranted: return new NotGrantedWalletError(); case messaging_1.ExtensionErrorType.NotFound: return new NotFoundWalletError(); case messaging_1.ExtensionErrorType.InvalidParams: return new InvalidParamsWalletError(); case messaging_1.ExtensionErrorType.InvalidNetwork: return new InvalidNetworkError(); default: return new ExtensionWalletError(); } } //# sourceMappingURL=errors.js.map