@signumjs/wallets
Version:
Wallets communication package for DApps in the Signum Network
45 lines • 2.01 kB
JavaScript
;
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");
class ExtensionWalletError {
name = 'ExtensionWalletError';
message = 'An unknown error occured. Please try again or report it';
}
exports.ExtensionWalletError = ExtensionWalletError;
class NotGrantedWalletError extends ExtensionWalletError {
name = 'NotGrantedWalletError';
message = 'Permission Not Granted';
}
exports.NotGrantedWalletError = NotGrantedWalletError;
class NotFoundWalletError extends ExtensionWalletError {
name = 'NotFoundWalletError';
message = 'Could not find a compatible wallet';
}
exports.NotFoundWalletError = NotFoundWalletError;
class InvalidParamsWalletError extends ExtensionWalletError {
name = 'InvalidParamsWalletError';
message = 'Some of the parameters you provided are invalid';
}
exports.InvalidParamsWalletError = InvalidParamsWalletError;
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;
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