@aeternity/aepp-sdk
Version:
SDK for the æternity blockchain
202 lines (186 loc) • 5.53 kB
JavaScript
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
// eslint-disable-next-line max-classes-per-file
import { BaseError, InternalError } from '../utils/errors.js';
/**
* @category aepp wallet communication
*/
export let MESSAGE_DIRECTION = /*#__PURE__*/function (MESSAGE_DIRECTION) {
MESSAGE_DIRECTION["to_waellet"] = "to_waellet";
MESSAGE_DIRECTION["to_aepp"] = "to_aepp";
return MESSAGE_DIRECTION;
}({});
/**
* @category aepp wallet communication
*/
export let WALLET_TYPE = /*#__PURE__*/function (WALLET_TYPE) {
WALLET_TYPE["window"] = "window";
WALLET_TYPE["extension"] = "extension";
return WALLET_TYPE;
}({});
/**
* @category aepp wallet communication
*/
export let SUBSCRIPTION_TYPES = /*#__PURE__*/function (SUBSCRIPTION_TYPES) {
SUBSCRIPTION_TYPES["subscribe"] = "subscribe";
SUBSCRIPTION_TYPES["unsubscribe"] = "unsubscribe";
return SUBSCRIPTION_TYPES;
}({});
/**
* @category aepp wallet communication
*/
export let METHODS = /*#__PURE__*/function (METHODS) {
METHODS["readyToConnect"] = "connection.announcePresence";
METHODS["updateAddress"] = "address.update";
METHODS["address"] = "address.get";
METHODS["connect"] = "connection.open";
METHODS["unsafeSign"] = "data.unsafeSign";
METHODS["sign"] = "transaction.sign";
METHODS["signMessage"] = "message.sign";
METHODS["signTypedData"] = "typedData.sign";
METHODS["signDelegation"] = "delegation.sign";
METHODS["subscribeAddress"] = "address.subscribe";
METHODS["updateNetwork"] = "networkId.update";
METHODS["closeConnection"] = "connection.close";
return METHODS;
}({});
/**
* @category aepp wallet communication
*/
export let RPC_STATUS = /*#__PURE__*/function (RPC_STATUS) {
RPC_STATUS["CONNECTED"] = "CONNECTED";
RPC_STATUS["DISCONNECTED"] = "DISCONNECTED";
RPC_STATUS["WAITING_FOR_CONNECTION_REQUEST"] = "WAITING_FOR_CONNECTION_REQUEST";
return RPC_STATUS;
}({});
const rpcErrors = [];
/**
* @category exception
*/
export class RpcError extends BaseError {
toJSON() {
return {
code: this.code,
message: this.message,
data: this.data
};
}
static deserialize(json) {
const RpcErr = rpcErrors.find(cl => cl.code === json.code);
if (RpcErr == null) throw new InternalError(`Can't find RpcError with code: ${json.code}`);
return new RpcErr(json.data);
}
}
/**
* @category exception
*/
export class RpcInvalidTransactionError extends RpcError {
constructor(data) {
super('Invalid transaction');
_defineProperty(this, "code", 2);
this.data = data;
this.name = 'RpcInvalidTransactionError';
}
}
_defineProperty(RpcInvalidTransactionError, "code", 2);
rpcErrors.push(RpcInvalidTransactionError);
/**
* @category exception
*/
export class RpcRejectedByUserError extends RpcError {
constructor(data) {
super('Operation rejected by user');
_defineProperty(this, "code", 4);
this.data = data;
this.name = 'RpcRejectedByUserError';
}
}
_defineProperty(RpcRejectedByUserError, "code", 4);
rpcErrors.push(RpcRejectedByUserError);
/**
* @category exception
*/
export class RpcUnsupportedProtocolError extends RpcError {
constructor() {
super('Unsupported Protocol Version');
_defineProperty(this, "code", 5);
this.name = 'RpcUnsupportedProtocolError';
}
}
_defineProperty(RpcUnsupportedProtocolError, "code", 5);
rpcErrors.push(RpcUnsupportedProtocolError);
/**
* @category exception
*/
export class RpcConnectionDenyError extends RpcError {
constructor(data) {
super('Wallet deny your connection request');
_defineProperty(this, "code", 9);
this.data = data;
this.name = 'RpcConnectionDenyError';
}
}
_defineProperty(RpcConnectionDenyError, "code", 9);
rpcErrors.push(RpcConnectionDenyError);
/**
* @category exception
*/
export class RpcNotAuthorizeError extends RpcError {
constructor() {
super('You are not connected to the wallet');
_defineProperty(this, "code", 10);
this.name = 'RpcNotAuthorizeError';
}
}
_defineProperty(RpcNotAuthorizeError, "code", 10);
rpcErrors.push(RpcNotAuthorizeError);
/**
* @category exception
*/
export class RpcPermissionDenyError extends RpcError {
constructor(address) {
super(`You are not subscribed for account ${address}`);
_defineProperty(this, "code", 11);
this.data = address;
this.name = 'RpcPermissionDenyError';
}
}
_defineProperty(RpcPermissionDenyError, "code", 11);
rpcErrors.push(RpcPermissionDenyError);
/**
* @category exception
*/
export class RpcInternalError extends RpcError {
constructor() {
super('The peer failed to execute your request due to unknown error');
_defineProperty(this, "code", 12);
this.name = 'RpcInternalError';
}
}
_defineProperty(RpcInternalError, "code", 12);
rpcErrors.push(RpcInternalError);
/**
* @category exception
*/
export class RpcNoNetworkById extends RpcError {
constructor(networkId) {
super(`Wallet can't find a network by id "${networkId}"`);
_defineProperty(this, "code", 13);
this.data = networkId;
this.name = 'RpcNoNetworkById';
}
}
_defineProperty(RpcNoNetworkById, "code", 13);
rpcErrors.push(RpcNoNetworkById);
/**
* @category exception
*/
export class RpcMethodNotFoundError extends RpcError {
constructor() {
super('Method not found');
_defineProperty(this, "code", -32601);
this.name = 'RpcMethodNotFoundError';
}
}
_defineProperty(RpcMethodNotFoundError, "code", -32601);
rpcErrors.push(RpcMethodNotFoundError);
//# sourceMappingURL=schema.js.map