@aeternity/aepp-sdk
Version:
SDK for the æternity blockchain
103 lines (100 loc) • 4 kB
JavaScript
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
import _zipObj from "ramda/src/zipObj";
var _wallet, _aepp, _METHODS;
var asEnum = function asEnum(array) {
return _zipObj(array, array);
};
export var VERSION = 1;
export var MESSAGE_DIRECTION = asEnum(['to_waellet', 'to_aepp']);
export var WALLET_TYPE = asEnum(['window', 'extension']);
export var NOTIFICATIONS = asEnum(['readyToConnect', 'closeConnection', 'updateNetwork', 'updateAddress']);
export var REQUESTS = asEnum(['connect', 'subscribeAddress', 'sign', 'address', 'signMessage']);
export var SUBSCRIPTION_VALUES = asEnum(['current', 'connected']);
export var SUBSCRIPTION_TYPES = asEnum(['subscribe', 'unsubscribe']);
export var METHODS = (_METHODS = {
wallet: (_wallet = {}, _defineProperty(_wallet, NOTIFICATIONS.readyToConnect, 'connection.announcePresence'), _defineProperty(_wallet, NOTIFICATIONS.updateAddress, 'address.update'), _wallet),
aepp: (_aepp = {}, _defineProperty(_aepp, REQUESTS.address, 'address.get'), _defineProperty(_aepp, REQUESTS.connect, 'connection.open'), _defineProperty(_aepp, REQUESTS.sign, 'transaction.sign'), _defineProperty(_aepp, REQUESTS.signMessage, 'message.sign'), _defineProperty(_aepp, REQUESTS.subscribeAddress, 'address.subscribe'), _aepp)
}, _defineProperty(_METHODS, NOTIFICATIONS.updateNetwork, 'networkId.update'), _defineProperty(_METHODS, NOTIFICATIONS.closeConnection, 'connection.close'), _METHODS);
export var RPC_STATUS = {
CONNECTED: 'CONNECTED',
DISCONNECTED: 'DISCONNECTED',
CONNECTION_REJECTED: 'CONNECTION_REJECTED',
WAITING_FOR_CONNECTION_APPROVE: 'WAITING_FOR_CONNECTION_APPROVE',
WAITING_FOR_CONNECTION_REQUEST: 'WAITING_FOR_CONNECTION_REQUEST',
WAITING_FOR_SUBSCRIPTION: 'WAITING_FOR_SUBSCRIPTION'
};
export var ERRORS = {
broadcastFailde: function broadcastFailde() {
var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return {
code: 3,
data: error,
message: 'Broadcast failed'
};
},
invalidTransaction: function invalidTransaction() {
var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return {
code: 2,
data: error,
message: 'Invalid transaction'
};
},
rejectedByUser: function rejectedByUser() {
var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return {
code: 4,
data: error,
message: 'Operation rejected by user'
};
},
connectionDeny: function connectionDeny() {
var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return {
code: 9,
data: error,
message: 'Wallet deny your connection request'
};
},
permissionDeny: function permissionDeny() {
var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return {
code: 11,
data: error,
message: "You are not subscribed for account ".concat(error.account)
};
},
internalError: function internalError() {
var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return {
code: 12,
data: error,
message: error.msg
};
},
notAuthorize: function notAuthorize() {
var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return {
code: 10,
data: error,
message: 'You are not connected to the wallet'
};
},
unsupportedProtocol: function unsupportedProtocol() {
var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return {
code: 5,
data: error,
message: 'Unsupported Protocol Version'
};
},
unsupportedNetwork: function unsupportedNetwork() {
var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return {
code: 8,
data: error,
message: 'Unsupported Network'
};
}
};
//# sourceMappingURL=schema.js.map