@aeternity/aepp-sdk 9.0.1 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -14
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +7 -36
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +1 -1
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +1 -1
- package/dist/aepp-sdk.js.map +1 -1
- package/es/account/base.mjs +179 -0
- package/es/account/base.mjs.map +1 -0
- package/es/account/memory.mjs +99 -0
- package/es/account/memory.mjs.map +1 -0
- package/es/account/multiple.mjs +179 -0
- package/es/account/multiple.mjs.map +1 -0
- package/es/ae/aens.mjs +404 -0
- package/es/ae/aens.mjs.map +1 -0
- package/es/ae/{aepp.js → aepp.mjs} +9 -9
- package/es/ae/aepp.mjs.map +1 -0
- package/es/ae/contract.mjs +159 -0
- package/es/ae/contract.mjs.map +1 -0
- package/es/ae/index.mjs +207 -0
- package/es/ae/index.mjs.map +1 -0
- package/es/ae/oracle.mjs +339 -0
- package/es/ae/oracle.mjs.map +1 -0
- package/es/ae/{universal.js → universal.mjs} +10 -10
- package/es/ae/universal.mjs.map +1 -0
- package/es/ae/{wallet.js → wallet.mjs} +10 -10
- package/es/ae/wallet.mjs.map +1 -0
- package/es/aepp-wallet-communication/schema.d.ts +74 -0
- package/es/bignumber.d.ts +1 -7
- package/es/chain/{index.js → index.mjs} +29 -9
- package/es/chain/index.mjs.map +1 -0
- package/es/chain/node.mjs +442 -0
- package/es/chain/node.mjs.map +1 -0
- package/es/channel/handlers.mjs +1110 -0
- package/es/channel/handlers.mjs.map +1 -0
- package/es/channel/{index.js → index.mjs} +245 -472
- package/es/channel/index.mjs.map +1 -0
- package/es/channel/internal.mjs +283 -0
- package/es/channel/internal.mjs.map +1 -0
- package/es/contract/aci.mjs +477 -0
- package/es/contract/aci.mjs.map +1 -0
- package/es/contract/compiler.mjs +115 -0
- package/es/contract/compiler.mjs.map +1 -0
- package/es/contract/ga/helpers.mjs +30 -0
- package/es/contract/ga/helpers.mjs.map +1 -0
- package/es/contract/ga/index.mjs +178 -0
- package/es/contract/ga/index.mjs.map +1 -0
- package/es/errors.d.ts +284 -0
- package/es/index.mjs +57 -0
- package/es/index.mjs.map +1 -0
- package/es/node-pool/index.mjs +188 -0
- package/es/node-pool/index.mjs.map +1 -0
- package/es/node.mjs +133 -0
- package/es/node.mjs.map +1 -0
- package/es/other.d.ts +1 -1
- package/es/tx/builder/field-types.mjs +74 -0
- package/es/tx/builder/field-types.mjs.map +1 -0
- package/es/tx/builder/helpers.mjs +363 -0
- package/es/tx/builder/helpers.mjs.map +1 -0
- package/es/tx/builder/index.mjs +606 -0
- package/es/tx/builder/index.mjs.map +1 -0
- package/es/tx/builder/schema.mjs +760 -0
- package/es/tx/builder/schema.mjs.map +1 -0
- package/es/tx/{index.js → index.mjs} +107 -15
- package/es/tx/index.mjs.map +1 -0
- package/es/tx/tx-object.mjs +283 -0
- package/es/tx/tx-object.mjs.map +1 -0
- package/es/tx/tx.mjs +938 -0
- package/es/tx/tx.mjs.map +1 -0
- package/es/tx/validator.mjs +247 -0
- package/es/tx/validator.mjs.map +1 -0
- package/es/typings/blakejs/index.d.mjs +2 -0
- package/es/typings/blakejs/{index.d.js.map → index.d.mjs.map} +1 -1
- package/es/utils/aepp-wallet-communication/connection/{browser-runtime.js → browser-runtime.mjs} +27 -29
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +183 -0
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/connection/{index.js → index.mjs} +7 -3
- package/es/utils/aepp-wallet-communication/connection/index.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/{content-script-bridge.js → content-script-bridge.mjs} +29 -23
- package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/helpers.mjs +92 -0
- package/es/utils/aepp-wallet-communication/helpers.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +375 -0
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +275 -0
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +541 -0
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/schema.mjs +102 -0
- package/es/utils/aepp-wallet-communication/schema.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs +110 -0
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
- package/es/utils/amount-formatter.mjs +139 -0
- package/es/utils/amount-formatter.mjs.map +1 -0
- package/es/utils/async-init.mjs +64 -0
- package/es/utils/async-init.mjs.map +1 -0
- package/es/utils/bignumber.mjs +21 -0
- package/es/utils/bignumber.mjs.map +1 -0
- package/es/utils/{bytes.js → bytes.mjs} +16 -12
- package/es/utils/bytes.mjs.map +1 -0
- package/es/utils/{crypto-ts.js → crypto-ts.mjs} +11 -3
- package/es/utils/crypto-ts.mjs.map +1 -0
- package/es/utils/crypto.mjs +239 -0
- package/es/utils/crypto.mjs.map +1 -0
- package/es/utils/errors.mjs +689 -0
- package/es/utils/errors.mjs.map +1 -0
- package/es/utils/hd-wallet.mjs +111 -0
- package/es/utils/hd-wallet.mjs.map +1 -0
- package/es/utils/json-big.mjs +45 -0
- package/es/utils/json-big.mjs.map +1 -0
- package/es/utils/keystore.mjs +240 -0
- package/es/utils/keystore.mjs.map +1 -0
- package/es/utils/mptree.mjs +161 -0
- package/es/utils/mptree.mjs.map +1 -0
- package/es/utils/other.mjs +43 -0
- package/es/utils/other.mjs.map +1 -0
- package/es/utils/semver-satisfies.mjs +16 -0
- package/es/utils/semver-satisfies.mjs.map +1 -0
- package/es/utils/{string.js → string.mjs} +5 -14
- package/es/utils/string.mjs.map +1 -0
- package/es/utils/swagger.mjs +164 -0
- package/es/utils/swagger.mjs.map +1 -0
- package/package.json +55 -62
- package/src/account/base.js +3 -1
- package/src/account/memory.js +13 -8
- package/src/account/multiple.js +31 -22
- package/src/ae/aens.js +75 -77
- package/src/ae/aepp.js +2 -2
- package/src/ae/contract.js +27 -291
- package/src/ae/index.js +9 -7
- package/src/ae/oracle.js +51 -28
- package/src/ae/universal.js +4 -2
- package/src/ae/wallet.js +2 -2
- package/src/chain/index.js +29 -6
- package/src/chain/node.js +95 -67
- package/src/channel/handlers.js +30 -21
- package/src/channel/index.js +44 -20
- package/src/channel/internal.js +30 -24
- package/src/contract/aci.js +376 -0
- package/src/contract/compiler.js +41 -91
- package/src/contract/ga/helpers.js +10 -13
- package/src/contract/ga/index.js +42 -33
- package/src/index.js +9 -10
- package/src/node-pool/index.js +29 -17
- package/src/node.js +33 -36
- package/src/tx/builder/field-types.js +61 -0
- package/src/tx/builder/helpers.js +126 -84
- package/src/tx/builder/index.js +83 -41
- package/src/tx/builder/schema.js +50 -40
- package/src/tx/index.js +101 -12
- package/src/tx/tx-object.js +35 -15
- package/src/tx/tx.js +232 -153
- package/src/tx/validator.js +34 -12
- package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +11 -5
- package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +35 -13
- package/src/utils/aepp-wallet-communication/connection/index.js +2 -1
- package/src/utils/aepp-wallet-communication/content-script-bridge.js +14 -7
- package/src/utils/aepp-wallet-communication/helpers.js +6 -14
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +107 -60
- package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +24 -11
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +98 -56
- package/src/utils/aepp-wallet-communication/schema.ts +80 -0
- package/src/utils/aepp-wallet-communication/wallet-detector.js +6 -2
- package/src/utils/amount-formatter.ts +4 -3
- package/src/utils/async-init.js +10 -6
- package/src/utils/bignumber.ts +3 -10
- package/src/utils/bytes.ts +3 -2
- package/src/utils/crypto-ts.ts +2 -2
- package/src/utils/crypto.js +10 -144
- package/src/utils/errors.ts +683 -0
- package/src/utils/hd-wallet.js +11 -26
- package/src/utils/keystore.js +57 -53
- package/src/utils/mptree.ts +12 -6
- package/src/utils/other.ts +1 -1
- package/src/utils/semver-satisfies.ts +1 -1
- package/src/utils/swagger.js +75 -45
- package/es/account/base.js +0 -259
- package/es/account/base.js.map +0 -1
- package/es/account/memory.js +0 -86
- package/es/account/memory.js.map +0 -1
- package/es/account/multiple.js +0 -267
- package/es/account/multiple.js.map +0 -1
- package/es/ae/aens.js +0 -829
- package/es/ae/aens.js.map +0 -1
- package/es/ae/aepp.js.map +0 -1
- package/es/ae/contract.js +0 -985
- package/es/ae/contract.js.map +0 -1
- package/es/ae/index.js +0 -442
- package/es/ae/index.js.map +0 -1
- package/es/ae/oracle.js +0 -690
- package/es/ae/oracle.js.map +0 -1
- package/es/ae/universal.js.map +0 -1
- package/es/ae/wallet.js.map +0 -1
- package/es/chain/index.js.map +0 -1
- package/es/chain/node.js +0 -1119
- package/es/chain/node.js.map +0 -1
- package/es/channel/handlers.js +0 -1601
- package/es/channel/handlers.js.map +0 -1
- package/es/channel/index.js.map +0 -1
- package/es/channel/internal.js +0 -438
- package/es/channel/internal.js.map +0 -1
- package/es/contract/aci/helpers.js +0 -298
- package/es/contract/aci/helpers.js.map +0 -1
- package/es/contract/aci/index.js +0 -517
- package/es/contract/aci/index.js.map +0 -1
- package/es/contract/aci/transformation.js +0 -742
- package/es/contract/aci/transformation.js.map +0 -1
- package/es/contract/compiler.js +0 -316
- package/es/contract/compiler.js.map +0 -1
- package/es/contract/ga/helpers.js +0 -120
- package/es/contract/ga/helpers.js.map +0 -1
- package/es/contract/ga/index.js +0 -307
- package/es/contract/ga/index.js.map +0 -1
- package/es/contract/index.js +0 -158
- package/es/contract/index.js.map +0 -1
- package/es/index.js +0 -57
- package/es/index.js.map +0 -1
- package/es/node-pool/index.js +0 -204
- package/es/node-pool/index.js.map +0 -1
- package/es/node.js +0 -228
- package/es/node.js.map +0 -1
- package/es/tx/builder/helpers.js +0 -355
- package/es/tx/builder/helpers.js.map +0 -1
- package/es/tx/builder/index.js +0 -686
- package/es/tx/builder/index.js.map +0 -1
- package/es/tx/builder/schema.js +0 -695
- package/es/tx/builder/schema.js.map +0 -1
- package/es/tx/index.js.map +0 -1
- package/es/tx/tx-object.js +0 -297
- package/es/tx/tx-object.js.map +0 -1
- package/es/tx/tx.js +0 -1757
- package/es/tx/tx.js.map +0 -1
- package/es/tx/validator.js +0 -344
- package/es/tx/validator.js.map +0 -1
- package/es/typings/blakejs/index.d.js +0 -2
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -211
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/index.js.map +0 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +0 -1
- package/es/utils/aepp-wallet-communication/helpers.js +0 -148
- package/es/utils/aepp-wallet-communication/helpers.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -652
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -285
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -763
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +0 -1
- package/es/utils/aepp-wallet-communication/schema.js +0 -103
- package/es/utils/aepp-wallet-communication/schema.js.map +0 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.js +0 -135
- package/es/utils/aepp-wallet-communication/wallet-detector.js.map +0 -1
- package/es/utils/amount-formatter.js +0 -152
- package/es/utils/amount-formatter.js.map +0 -1
- package/es/utils/async-init.js +0 -103
- package/es/utils/async-init.js.map +0 -1
- package/es/utils/bignumber.js +0 -36
- package/es/utils/bignumber.js.map +0 -1
- package/es/utils/bytes.js.map +0 -1
- package/es/utils/crypto-ts.js.map +0 -1
- package/es/utils/crypto.js +0 -358
- package/es/utils/crypto.js.map +0 -1
- package/es/utils/hd-wallet.js +0 -148
- package/es/utils/hd-wallet.js.map +0 -1
- package/es/utils/json-big.js +0 -78
- package/es/utils/json-big.js.map +0 -1
- package/es/utils/keystore.js +0 -393
- package/es/utils/keystore.js.map +0 -1
- package/es/utils/mptree.js +0 -198
- package/es/utils/mptree.js.map +0 -1
- package/es/utils/other.js +0 -93
- package/es/utils/other.js.map +0 -1
- package/es/utils/semver-satisfies.js +0 -35
- package/es/utils/semver-satisfies.js.map +0 -1
- package/es/utils/string.js.map +0 -1
- package/es/utils/swagger.js +0 -269
- package/es/utils/swagger.js.map +0 -1
- package/src/contract/aci/helpers.js +0 -140
- package/src/contract/aci/index.js +0 -191
- package/src/contract/aci/transformation.js +0 -464
- package/src/contract/index.js +0 -159
- package/src/utils/aepp-wallet-communication/schema.js +0 -110
|
@@ -1,763 +0,0 @@
|
|
|
1
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
2
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
3
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
4
|
-
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
|
5
|
-
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
|
6
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
7
|
-
import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
|
|
8
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
9
|
-
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
10
|
-
|
|
11
|
-
var _REQUESTS;
|
|
12
|
-
|
|
13
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
-
|
|
15
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context21; _forEachInstanceProperty(_context21 = ownKeys(Object(source), true)).call(_context21, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context22; _forEachInstanceProperty(_context22 = ownKeys(Object(source))).call(_context22, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
16
|
-
|
|
17
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
18
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
19
|
-
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
20
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
21
|
-
import _bindInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/bind";
|
|
22
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
23
|
-
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
|
24
|
-
import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
|
|
25
|
-
import _Object$entries from "@babel/runtime-corejs3/core-js-stable/object/entries";
|
|
26
|
-
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* RPC handler for WAELLET side
|
|
30
|
-
*
|
|
31
|
-
* @module @aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/wallet-rpc
|
|
32
|
-
* @export WalletRpc
|
|
33
|
-
* @example import WalletRpc from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/wallet-rpc'
|
|
34
|
-
*/
|
|
35
|
-
import { v4 as uuid } from 'uuid';
|
|
36
|
-
import Ae from '../../../ae';
|
|
37
|
-
import verifyTransaction from '../../../tx/validator';
|
|
38
|
-
import AccountMultiple from '../../../account/multiple';
|
|
39
|
-
import TxObject from '../../../tx/tx-object';
|
|
40
|
-
import RpcClient from './rpc-client';
|
|
41
|
-
import { getBrowserAPI, getHandler, isValidAccounts, message, resolveOnAccount, sendResponseMessage } from '../helpers';
|
|
42
|
-
import { ERRORS, METHODS, RPC_STATUS, VERSION, WALLET_TYPE } from '../schema';
|
|
43
|
-
|
|
44
|
-
var NOTIFICATIONS = _defineProperty({}, METHODS.closeConnection, function (instance, _ref) {
|
|
45
|
-
var client = _ref.client;
|
|
46
|
-
return /*#__PURE__*/function () {
|
|
47
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(msg) {
|
|
48
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
49
|
-
while (1) {
|
|
50
|
-
switch (_context.prev = _context.next) {
|
|
51
|
-
case 0:
|
|
52
|
-
client.disconnect(true);
|
|
53
|
-
instance.onDisconnect(msg.params, client);
|
|
54
|
-
|
|
55
|
-
case 2:
|
|
56
|
-
case "end":
|
|
57
|
-
return _context.stop();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}, _callee);
|
|
61
|
-
}));
|
|
62
|
-
|
|
63
|
-
return function (_x) {
|
|
64
|
-
return _ref2.apply(this, arguments);
|
|
65
|
-
};
|
|
66
|
-
}();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
var RESPONSES = {};
|
|
70
|
-
var REQUESTS = (_REQUESTS = {}, _defineProperty(_REQUESTS, METHODS.aepp.connect, function (callInstance, instance, client, _ref3) {
|
|
71
|
-
var name = _ref3.name,
|
|
72
|
-
networkId = _ref3.networkId,
|
|
73
|
-
version = _ref3.version,
|
|
74
|
-
icons = _ref3.icons;
|
|
75
|
-
// Check if protocol and network is compatible with wallet
|
|
76
|
-
if (version !== VERSION) return {
|
|
77
|
-
error: ERRORS.unsupportedProtocol()
|
|
78
|
-
}; // Store new AEPP and wait for connection approve
|
|
79
|
-
|
|
80
|
-
client.updateInfo({
|
|
81
|
-
status: RPC_STATUS.WAITING_FOR_CONNECTION_APPROVE,
|
|
82
|
-
name: name,
|
|
83
|
-
networkId: networkId,
|
|
84
|
-
icons: icons,
|
|
85
|
-
version: version
|
|
86
|
-
}); // Call onConnection callBack to notice Wallet about new AEPP
|
|
87
|
-
|
|
88
|
-
return callInstance('onConnection', {
|
|
89
|
-
name: name,
|
|
90
|
-
networkId: networkId,
|
|
91
|
-
version: version
|
|
92
|
-
}, function () {
|
|
93
|
-
client.updateInfo({
|
|
94
|
-
status: RPC_STATUS.CONNECTED
|
|
95
|
-
});
|
|
96
|
-
return {
|
|
97
|
-
result: instance.getWalletInfo()
|
|
98
|
-
};
|
|
99
|
-
}, function (error) {
|
|
100
|
-
client.updateInfo({
|
|
101
|
-
status: RPC_STATUS.CONNECTION_REJECTED
|
|
102
|
-
});
|
|
103
|
-
return {
|
|
104
|
-
error: ERRORS.connectionDeny(error)
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
}), _defineProperty(_REQUESTS, METHODS.aepp.subscribeAddress, function (callInstance, instance, client, _ref4) {
|
|
108
|
-
var type = _ref4.type,
|
|
109
|
-
value = _ref4.value;
|
|
110
|
-
// Authorization check
|
|
111
|
-
if (!client.isConnected()) return {
|
|
112
|
-
error: ERRORS.notAuthorize()
|
|
113
|
-
};
|
|
114
|
-
return callInstance('onSubscription', {
|
|
115
|
-
type: type,
|
|
116
|
-
value: value
|
|
117
|
-
}, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
118
|
-
var _ref6,
|
|
119
|
-
accounts,
|
|
120
|
-
clientAccounts,
|
|
121
|
-
subscription,
|
|
122
|
-
_args2 = arguments;
|
|
123
|
-
|
|
124
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
125
|
-
while (1) {
|
|
126
|
-
switch (_context2.prev = _context2.next) {
|
|
127
|
-
case 0:
|
|
128
|
-
_ref6 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, accounts = _ref6.accounts;
|
|
129
|
-
_context2.prev = 1;
|
|
130
|
-
clientAccounts = accounts || instance.getAccounts();
|
|
131
|
-
|
|
132
|
-
if (isValidAccounts(clientAccounts)) {
|
|
133
|
-
_context2.next = 5;
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
throw new Error('Invalid provided accounts object');
|
|
138
|
-
|
|
139
|
-
case 5:
|
|
140
|
-
subscription = client.updateSubscription(type, value);
|
|
141
|
-
client.setAccounts(clientAccounts, {
|
|
142
|
-
forceNotification: true
|
|
143
|
-
});
|
|
144
|
-
return _context2.abrupt("return", {
|
|
145
|
-
result: {
|
|
146
|
-
subscription: subscription,
|
|
147
|
-
address: clientAccounts
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
case 10:
|
|
152
|
-
_context2.prev = 10;
|
|
153
|
-
_context2.t0 = _context2["catch"](1);
|
|
154
|
-
console.error(_context2.t0);
|
|
155
|
-
return _context2.abrupt("return", {
|
|
156
|
-
error: ERRORS.internalError({
|
|
157
|
-
msg: _context2.t0.message
|
|
158
|
-
})
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
case 14:
|
|
162
|
-
case "end":
|
|
163
|
-
return _context2.stop();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}, _callee2, null, [[1, 10]]);
|
|
167
|
-
})), function (error) {
|
|
168
|
-
return {
|
|
169
|
-
error: ERRORS.rejectedByUser(error)
|
|
170
|
-
};
|
|
171
|
-
});
|
|
172
|
-
}), _defineProperty(_REQUESTS, METHODS.aepp.address, function (callInstance, instance, client) {
|
|
173
|
-
// Authorization check
|
|
174
|
-
if (!client.isConnected()) return {
|
|
175
|
-
error: ERRORS.notAuthorize()
|
|
176
|
-
};
|
|
177
|
-
if (!client.isSubscribed()) return {
|
|
178
|
-
error: ERRORS.notAuthorize()
|
|
179
|
-
};
|
|
180
|
-
return callInstance('onAskAccounts', {}, function () {
|
|
181
|
-
var _context3;
|
|
182
|
-
|
|
183
|
-
var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
184
|
-
accounts = _ref7.accounts;
|
|
185
|
-
|
|
186
|
-
return {
|
|
187
|
-
result: accounts || _concatInstanceProperty(_context3 = []).call(_context3, _toConsumableArray(_Object$keys(client.accounts.current)), _toConsumableArray(_Object$keys(client.accounts.connected)))
|
|
188
|
-
};
|
|
189
|
-
}, function (error) {
|
|
190
|
-
return {
|
|
191
|
-
error: ERRORS.rejectedByUser(error)
|
|
192
|
-
};
|
|
193
|
-
});
|
|
194
|
-
}), _defineProperty(_REQUESTS, METHODS.aepp.sign, function (callInstance, instance, client, _ref8) {
|
|
195
|
-
var tx = _ref8.tx,
|
|
196
|
-
onAccount = _ref8.onAccount,
|
|
197
|
-
networkId = _ref8.networkId,
|
|
198
|
-
_ref8$returnSigned = _ref8.returnSigned,
|
|
199
|
-
returnSigned = _ref8$returnSigned === void 0 ? false : _ref8$returnSigned;
|
|
200
|
-
var address = onAccount || client.currentAccount; // Update client with new networkId
|
|
201
|
-
|
|
202
|
-
networkId && client.updateInfo({
|
|
203
|
-
networkId: networkId
|
|
204
|
-
}); // Authorization check
|
|
205
|
-
|
|
206
|
-
if (!client.isConnected()) return {
|
|
207
|
-
error: ERRORS.notAuthorize()
|
|
208
|
-
}; // Account permission check
|
|
209
|
-
|
|
210
|
-
if (!client.hasAccessToAccount(address)) return {
|
|
211
|
-
error: ERRORS.permissionDeny({
|
|
212
|
-
account: address
|
|
213
|
-
})
|
|
214
|
-
}; // NetworkId check
|
|
215
|
-
|
|
216
|
-
if (!networkId || networkId !== instance.getNetworkId()) return {
|
|
217
|
-
error: ERRORS.unsupportedNetwork()
|
|
218
|
-
};
|
|
219
|
-
return callInstance('onSign', {
|
|
220
|
-
tx: tx,
|
|
221
|
-
returnSigned: returnSigned,
|
|
222
|
-
onAccount: address,
|
|
223
|
-
txObject: TxObject.fromString(tx)
|
|
224
|
-
}, /*#__PURE__*/function () {
|
|
225
|
-
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(rawTx) {
|
|
226
|
-
var opt,
|
|
227
|
-
onAcc,
|
|
228
|
-
validation,
|
|
229
|
-
_args3 = arguments;
|
|
230
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context4) {
|
|
231
|
-
while (1) {
|
|
232
|
-
switch (_context4.prev = _context4.next) {
|
|
233
|
-
case 0:
|
|
234
|
-
opt = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
235
|
-
_context4.prev = 1;
|
|
236
|
-
onAcc = resolveOnAccount(instance.addresses(), address, opt);
|
|
237
|
-
_context4.next = 9;
|
|
238
|
-
break;
|
|
239
|
-
|
|
240
|
-
case 5:
|
|
241
|
-
_context4.prev = 5;
|
|
242
|
-
_context4.t0 = _context4["catch"](1);
|
|
243
|
-
console.error(_context4.t0);
|
|
244
|
-
return _context4.abrupt("return", {
|
|
245
|
-
error: ERRORS.internalError({
|
|
246
|
-
msg: _context4.t0.message
|
|
247
|
-
})
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
case 9:
|
|
251
|
-
_context4.prev = 9;
|
|
252
|
-
|
|
253
|
-
if (!returnSigned) {
|
|
254
|
-
_context4.next = 17;
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
_context4.next = 13;
|
|
259
|
-
return instance.signTransaction(rawTx || tx, {
|
|
260
|
-
onAccount: onAcc
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
case 13:
|
|
264
|
-
_context4.t2 = _context4.sent;
|
|
265
|
-
_context4.t1 = {
|
|
266
|
-
signedTransaction: _context4.t2
|
|
267
|
-
};
|
|
268
|
-
_context4.next = 21;
|
|
269
|
-
break;
|
|
270
|
-
|
|
271
|
-
case 17:
|
|
272
|
-
_context4.next = 19;
|
|
273
|
-
return instance.send(rawTx || tx, {
|
|
274
|
-
onAccount: onAcc,
|
|
275
|
-
verify: false
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
case 19:
|
|
279
|
-
_context4.t3 = _context4.sent;
|
|
280
|
-
_context4.t1 = {
|
|
281
|
-
transactionHash: _context4.t3
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
case 21:
|
|
285
|
-
_context4.t4 = _context4.t1;
|
|
286
|
-
return _context4.abrupt("return", {
|
|
287
|
-
result: _context4.t4
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
case 25:
|
|
291
|
-
_context4.prev = 25;
|
|
292
|
-
_context4.t5 = _context4["catch"](9);
|
|
293
|
-
|
|
294
|
-
if (returnSigned) {
|
|
295
|
-
_context4.next = 34;
|
|
296
|
-
break;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
_context4.next = 30;
|
|
300
|
-
return verifyTransaction(rawTx || tx, instance.selectedNode.instance);
|
|
301
|
-
|
|
302
|
-
case 30:
|
|
303
|
-
validation = _context4.sent;
|
|
304
|
-
|
|
305
|
-
if (!validation.length) {
|
|
306
|
-
_context4.next = 33;
|
|
307
|
-
break;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return _context4.abrupt("return", {
|
|
311
|
-
error: ERRORS.invalidTransaction(validation)
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
case 33:
|
|
315
|
-
return _context4.abrupt("return", {
|
|
316
|
-
error: ERRORS.broadcastFailed(_context4.t5.message)
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
case 34:
|
|
320
|
-
throw _context4.t5;
|
|
321
|
-
|
|
322
|
-
case 35:
|
|
323
|
-
case "end":
|
|
324
|
-
return _context4.stop();
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}, _callee3, null, [[1, 5], [9, 25]]);
|
|
328
|
-
}));
|
|
329
|
-
|
|
330
|
-
return function (_x2) {
|
|
331
|
-
return _ref9.apply(this, arguments);
|
|
332
|
-
};
|
|
333
|
-
}(), function (error) {
|
|
334
|
-
return {
|
|
335
|
-
error: ERRORS.rejectedByUser(error)
|
|
336
|
-
};
|
|
337
|
-
});
|
|
338
|
-
}), _defineProperty(_REQUESTS, METHODS.aepp.signMessage, function (callInstance, instance, client, _ref10) {
|
|
339
|
-
var message = _ref10.message,
|
|
340
|
-
onAccount = _ref10.onAccount;
|
|
341
|
-
// Authorization check
|
|
342
|
-
if (!client.isConnected()) return {
|
|
343
|
-
error: ERRORS.notAuthorize()
|
|
344
|
-
};
|
|
345
|
-
var address = onAccount || client.currentAccount;
|
|
346
|
-
if (!client.hasAccessToAccount(address)) return {
|
|
347
|
-
error: ERRORS.permissionDeny({
|
|
348
|
-
account: address
|
|
349
|
-
})
|
|
350
|
-
};
|
|
351
|
-
return callInstance('onMessageSign', {
|
|
352
|
-
message: message,
|
|
353
|
-
onAccount: address
|
|
354
|
-
}, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
355
|
-
var opt,
|
|
356
|
-
onAcc,
|
|
357
|
-
_args4 = arguments;
|
|
358
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context5) {
|
|
359
|
-
while (1) {
|
|
360
|
-
switch (_context5.prev = _context5.next) {
|
|
361
|
-
case 0:
|
|
362
|
-
opt = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
|
|
363
|
-
_context5.prev = 1;
|
|
364
|
-
onAcc = resolveOnAccount(instance.addresses(), address, opt);
|
|
365
|
-
_context5.next = 5;
|
|
366
|
-
return instance.signMessage(message, {
|
|
367
|
-
onAccount: onAcc,
|
|
368
|
-
returnHex: true
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
case 5:
|
|
372
|
-
_context5.t0 = _context5.sent;
|
|
373
|
-
_context5.t1 = {
|
|
374
|
-
signature: _context5.t0
|
|
375
|
-
};
|
|
376
|
-
return _context5.abrupt("return", {
|
|
377
|
-
result: _context5.t1
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
case 10:
|
|
381
|
-
_context5.prev = 10;
|
|
382
|
-
_context5.t2 = _context5["catch"](1);
|
|
383
|
-
console.error(_context5.t2);
|
|
384
|
-
return _context5.abrupt("return", {
|
|
385
|
-
error: ERRORS.internalError({
|
|
386
|
-
msg: _context5.t2.message
|
|
387
|
-
})
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
case 14:
|
|
391
|
-
case "end":
|
|
392
|
-
return _context5.stop();
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}, _callee4, null, [[1, 10]]);
|
|
396
|
-
})), function (error) {
|
|
397
|
-
return {
|
|
398
|
-
error: ERRORS.rejectedByUser(error)
|
|
399
|
-
};
|
|
400
|
-
});
|
|
401
|
-
}), _REQUESTS);
|
|
402
|
-
|
|
403
|
-
var handleMessage = function handleMessage(instance, id) {
|
|
404
|
-
return /*#__PURE__*/function () {
|
|
405
|
-
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(msg, origin) {
|
|
406
|
-
var client, _id, method, callInstance, errorObjectOrHandler, response;
|
|
407
|
-
|
|
408
|
-
return _regeneratorRuntime.wrap(function _callee5$(_context6) {
|
|
409
|
-
while (1) {
|
|
410
|
-
switch (_context6.prev = _context6.next) {
|
|
411
|
-
case 0:
|
|
412
|
-
client = instance.rpcClients[id];
|
|
413
|
-
|
|
414
|
-
if (msg.id) {
|
|
415
|
-
_context6.next = 3;
|
|
416
|
-
break;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
return _context6.abrupt("return", getHandler(NOTIFICATIONS, msg, {
|
|
420
|
-
debug: instance.debug
|
|
421
|
-
})(instance, {
|
|
422
|
-
client: client
|
|
423
|
-
})(msg, origin));
|
|
424
|
-
|
|
425
|
-
case 3:
|
|
426
|
-
if (!Object.prototype.hasOwnProperty.call(client.callbacks, msg.id)) {
|
|
427
|
-
_context6.next = 7;
|
|
428
|
-
break;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
return _context6.abrupt("return", getHandler(RESPONSES, msg, {
|
|
432
|
-
debug: instance.debug
|
|
433
|
-
})(instance, {
|
|
434
|
-
client: client
|
|
435
|
-
})(msg, origin));
|
|
436
|
-
|
|
437
|
-
case 7:
|
|
438
|
-
_id = msg.id, method = msg.method;
|
|
439
|
-
|
|
440
|
-
callInstance = function callInstance(methodName, params, _accept, _deny) {
|
|
441
|
-
return function () {
|
|
442
|
-
return new _Promise(function (resolve) {
|
|
443
|
-
instance[methodName](client, {
|
|
444
|
-
id: _id,
|
|
445
|
-
method: method,
|
|
446
|
-
params: params,
|
|
447
|
-
accept: function accept() {
|
|
448
|
-
return resolve(_accept.apply(void 0, arguments));
|
|
449
|
-
},
|
|
450
|
-
deny: function deny() {
|
|
451
|
-
return resolve(_deny.apply(void 0, arguments));
|
|
452
|
-
}
|
|
453
|
-
}, origin);
|
|
454
|
-
});
|
|
455
|
-
};
|
|
456
|
-
}; // TODO make one structure for handler functions
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
errorObjectOrHandler = getHandler(REQUESTS, msg, {
|
|
460
|
-
debug: instance.debug
|
|
461
|
-
})(callInstance, instance, client, msg.params);
|
|
462
|
-
|
|
463
|
-
if (!(typeof errorObjectOrHandler === 'function')) {
|
|
464
|
-
_context6.next = 16;
|
|
465
|
-
break;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
_context6.next = 13;
|
|
469
|
-
return errorObjectOrHandler();
|
|
470
|
-
|
|
471
|
-
case 13:
|
|
472
|
-
_context6.t0 = _context6.sent;
|
|
473
|
-
_context6.next = 17;
|
|
474
|
-
break;
|
|
475
|
-
|
|
476
|
-
case 16:
|
|
477
|
-
_context6.t0 = errorObjectOrHandler;
|
|
478
|
-
|
|
479
|
-
case 17:
|
|
480
|
-
response = _context6.t0;
|
|
481
|
-
sendResponseMessage(client)(_id, method, response);
|
|
482
|
-
|
|
483
|
-
case 19:
|
|
484
|
-
case "end":
|
|
485
|
-
return _context6.stop();
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
}, _callee5);
|
|
489
|
-
}));
|
|
490
|
-
|
|
491
|
-
return function (_x3, _x4) {
|
|
492
|
-
return _ref12.apply(this, arguments);
|
|
493
|
-
};
|
|
494
|
-
}();
|
|
495
|
-
};
|
|
496
|
-
/**
|
|
497
|
-
* Contain functionality for aepp interaction and managing multiple aepps
|
|
498
|
-
* @alias module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/wallet-rpc
|
|
499
|
-
* @function
|
|
500
|
-
* @rtype Stamp
|
|
501
|
-
* @param {Object} param Init params object
|
|
502
|
-
* @param {String=} [param.name] Wallet name
|
|
503
|
-
* @param {Function} onConnection Call-back function for incoming AEPP connection (Second argument contain function for accept/deny request)
|
|
504
|
-
* @param {Function} onSubscription Call-back function for incoming AEPP account subscription (Second argument contain function for accept/deny request)
|
|
505
|
-
* @param {Function} onSign Call-back function for incoming AEPP sign request (Second argument contain function for accept/deny request)
|
|
506
|
-
* @param {Function} onAskAccounts Call-back function for incoming AEPP get address request (Second argument contain function for accept/deny request)
|
|
507
|
-
* @param {Function} onMessageSign Call-back function for incoming AEPP sign message request (Second argument contain function for accept/deny request)
|
|
508
|
-
* @param {Function} onDisconnect Call-back function for disconnect event
|
|
509
|
-
* @return {Object}
|
|
510
|
-
*/
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
export default Ae.compose(AccountMultiple, {
|
|
514
|
-
init: function init() {
|
|
515
|
-
var _this = this,
|
|
516
|
-
_context7,
|
|
517
|
-
_context8,
|
|
518
|
-
_context9;
|
|
519
|
-
|
|
520
|
-
var _ref13 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
521
|
-
name = _ref13.name,
|
|
522
|
-
onConnection = _ref13.onConnection,
|
|
523
|
-
onSubscription = _ref13.onSubscription,
|
|
524
|
-
onSign = _ref13.onSign,
|
|
525
|
-
onDisconnect = _ref13.onDisconnect,
|
|
526
|
-
onAskAccounts = _ref13.onAskAccounts,
|
|
527
|
-
onMessageSign = _ref13.onMessageSign,
|
|
528
|
-
_ref13$forceValidatio = _ref13.forceValidation,
|
|
529
|
-
forceValidation = _ref13$forceValidatio === void 0 ? false : _ref13$forceValidatio,
|
|
530
|
-
_ref13$debug = _ref13.debug,
|
|
531
|
-
debug = _ref13$debug === void 0 ? false : _ref13$debug;
|
|
532
|
-
|
|
533
|
-
this.debug = debug;
|
|
534
|
-
var eventsHandlers = ['onConnection', 'onSubscription', 'onSign', 'onDisconnect', 'onMessageSign']; // CallBacks for events
|
|
535
|
-
|
|
536
|
-
this.onConnection = onConnection;
|
|
537
|
-
this.onSubscription = onSubscription;
|
|
538
|
-
this.onSign = onSign;
|
|
539
|
-
this.onDisconnect = onDisconnect;
|
|
540
|
-
this.onAskAccounts = onAskAccounts;
|
|
541
|
-
this.onMessageSign = onMessageSign;
|
|
542
|
-
this.rpcClients = {};
|
|
543
|
-
|
|
544
|
-
_forEachInstanceProperty(eventsHandlers).call(eventsHandlers, function (event) {
|
|
545
|
-
if (!forceValidation && typeof _this[event] !== 'function') throw new Error("Call-back for ".concat(event, " must be an function!"));
|
|
546
|
-
}); //
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
this.name = name;
|
|
550
|
-
this.id = uuid();
|
|
551
|
-
|
|
552
|
-
var _selectAccount = _bindInstanceProperty(_context7 = this.selectAccount).call(_context7, this);
|
|
553
|
-
|
|
554
|
-
var _addAccount = _bindInstanceProperty(_context8 = this.addAccount).call(_context8, this);
|
|
555
|
-
|
|
556
|
-
var _selectNode = _bindInstanceProperty(_context9 = this.selectNode).call(_context9, this); // Overwrite AE methods
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
this.selectAccount = function (address) {
|
|
560
|
-
var _context10, _context11;
|
|
561
|
-
|
|
562
|
-
var _ref14 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
563
|
-
_ref14$condition = _ref14.condition,
|
|
564
|
-
condition = _ref14$condition === void 0 ? function () {
|
|
565
|
-
return true;
|
|
566
|
-
} : _ref14$condition;
|
|
567
|
-
|
|
568
|
-
_selectAccount(address);
|
|
569
|
-
|
|
570
|
-
_forEachInstanceProperty(_context10 = _filterInstanceProperty(_context11 = _Object$values(_this.rpcClients)).call(_context11, function (client) {
|
|
571
|
-
return client.isConnected() && client.isSubscribed() && client.hasAccessToAccount(address) && condition(client);
|
|
572
|
-
})).call(_context10, function (client) {
|
|
573
|
-
var _context12, _context13;
|
|
574
|
-
|
|
575
|
-
return client.setAccounts({
|
|
576
|
-
current: _defineProperty({}, address, {}),
|
|
577
|
-
connected: _objectSpread(_objectSpread({}, client.accounts.current), _reduceInstanceProperty(_context12 = _filterInstanceProperty(_context13 = _Object$entries(client.accounts.connected)).call(_context13, function (_ref15) {
|
|
578
|
-
var _ref16 = _slicedToArray(_ref15, 2),
|
|
579
|
-
k = _ref16[0],
|
|
580
|
-
v = _ref16[1];
|
|
581
|
-
|
|
582
|
-
return k !== address;
|
|
583
|
-
})).call(_context12, function (acc, _ref17) {
|
|
584
|
-
var _ref18 = _slicedToArray(_ref17, 2),
|
|
585
|
-
k = _ref18[0],
|
|
586
|
-
v = _ref18[1];
|
|
587
|
-
|
|
588
|
-
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, k, v));
|
|
589
|
-
}, {}))
|
|
590
|
-
});
|
|
591
|
-
});
|
|
592
|
-
};
|
|
593
|
-
|
|
594
|
-
this.addAccount = /*#__PURE__*/function () {
|
|
595
|
-
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(account) {
|
|
596
|
-
var _context14, _context15;
|
|
597
|
-
|
|
598
|
-
var _ref20,
|
|
599
|
-
select,
|
|
600
|
-
_ref20$meta,
|
|
601
|
-
meta,
|
|
602
|
-
_ref20$condition,
|
|
603
|
-
condition,
|
|
604
|
-
address,
|
|
605
|
-
_args6 = arguments;
|
|
606
|
-
|
|
607
|
-
return _regeneratorRuntime.wrap(function _callee6$(_context16) {
|
|
608
|
-
while (1) {
|
|
609
|
-
switch (_context16.prev = _context16.next) {
|
|
610
|
-
case 0:
|
|
611
|
-
_ref20 = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {}, select = _ref20.select, _ref20$meta = _ref20.meta, meta = _ref20$meta === void 0 ? {} : _ref20$meta, _ref20$condition = _ref20.condition, condition = _ref20$condition === void 0 ? function () {
|
|
612
|
-
return true;
|
|
613
|
-
} : _ref20$condition;
|
|
614
|
-
_context16.next = 3;
|
|
615
|
-
return _addAccount(account, {
|
|
616
|
-
select: select
|
|
617
|
-
});
|
|
618
|
-
|
|
619
|
-
case 3:
|
|
620
|
-
_context16.next = 5;
|
|
621
|
-
return account.address();
|
|
622
|
-
|
|
623
|
-
case 5:
|
|
624
|
-
address = _context16.sent;
|
|
625
|
-
|
|
626
|
-
// Send notification 'update.address' to all Aepp which are subscribed for connected accounts
|
|
627
|
-
_forEachInstanceProperty(_context14 = _filterInstanceProperty(_context15 = _Object$values(_this.rpcClients)).call(_context15, function (client) {
|
|
628
|
-
return client.isConnected() && client.isSubscribed() && condition(client);
|
|
629
|
-
})).call(_context14, function (client) {
|
|
630
|
-
return client.setAccounts({
|
|
631
|
-
current: _objectSpread({}, select ? _defineProperty({}, address, meta) : client.accounts.current),
|
|
632
|
-
connected: _objectSpread(_objectSpread({}, select ? client.accounts.current : _defineProperty({}, address, meta)), client.accounts.connected)
|
|
633
|
-
});
|
|
634
|
-
});
|
|
635
|
-
|
|
636
|
-
case 7:
|
|
637
|
-
case "end":
|
|
638
|
-
return _context16.stop();
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
}, _callee6);
|
|
642
|
-
}));
|
|
643
|
-
|
|
644
|
-
return function (_x5) {
|
|
645
|
-
return _ref19.apply(this, arguments);
|
|
646
|
-
};
|
|
647
|
-
}();
|
|
648
|
-
|
|
649
|
-
this.selectNode = function (name) {
|
|
650
|
-
var _context17, _context18;
|
|
651
|
-
|
|
652
|
-
_selectNode(name); // Send notification 'update.network' to all Aepp which connected
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
_forEachInstanceProperty(_context17 = _filterInstanceProperty(_context18 = _Object$values(_this.rpcClients)).call(_context18, function (client) {
|
|
656
|
-
return client.isConnected();
|
|
657
|
-
})).call(_context17, function (client) {
|
|
658
|
-
return client.sendMessage(message(METHODS.updateNetwork, {
|
|
659
|
-
networkId: _this.getNetworkId()
|
|
660
|
-
}), true);
|
|
661
|
-
});
|
|
662
|
-
};
|
|
663
|
-
},
|
|
664
|
-
methods: {
|
|
665
|
-
/**
|
|
666
|
-
* Remove specific RpcClient by ID
|
|
667
|
-
* @function removeRpcClient
|
|
668
|
-
* @instance
|
|
669
|
-
* @rtype (id: string) => void
|
|
670
|
-
* @param {String} id Client ID
|
|
671
|
-
* @param {Object} [opt = {}]
|
|
672
|
-
* @return {void}
|
|
673
|
-
*/
|
|
674
|
-
removeRpcClient: function removeRpcClient(id) {
|
|
675
|
-
var _ref23 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
676
|
-
_ref23$forceConnectio = _ref23.forceConnectionClose,
|
|
677
|
-
forceConnectionClose = _ref23$forceConnectio === void 0 ? false : _ref23$forceConnectio;
|
|
678
|
-
|
|
679
|
-
var client = this.rpcClients[id];
|
|
680
|
-
if (!client) throw new Error("RpcClient with id ".concat(id, " do not exist"));
|
|
681
|
-
client.disconnect(forceConnectionClose);
|
|
682
|
-
delete this.rpcClients[id];
|
|
683
|
-
},
|
|
684
|
-
|
|
685
|
-
/**
|
|
686
|
-
* Add new client by AEPP connection
|
|
687
|
-
* @function addRpcClient
|
|
688
|
-
* @instance
|
|
689
|
-
* @rtype (clientConnection: Object) => Object
|
|
690
|
-
* @param {Object} clientConnection AEPP connection object
|
|
691
|
-
* @return {String} Client ID
|
|
692
|
-
*/
|
|
693
|
-
addRpcClient: function addRpcClient(clientConnection) {
|
|
694
|
-
// @TODO detect if aepp has some history based on origin????: if yes use this instance for connection
|
|
695
|
-
var id = uuid();
|
|
696
|
-
this.rpcClients[id] = RpcClient({
|
|
697
|
-
id: id,
|
|
698
|
-
info: {
|
|
699
|
-
status: RPC_STATUS.WAITING_FOR_CONNECTION_REQUEST
|
|
700
|
-
},
|
|
701
|
-
connection: clientConnection,
|
|
702
|
-
handlers: [handleMessage(this, id), this.onDisconnect]
|
|
703
|
-
});
|
|
704
|
-
return id;
|
|
705
|
-
},
|
|
706
|
-
|
|
707
|
-
/**
|
|
708
|
-
* Share wallet info
|
|
709
|
-
* Send shareWalletInfo message to notify AEPP about wallet
|
|
710
|
-
* @function shareWalletInfo
|
|
711
|
-
* @instance
|
|
712
|
-
* @rtype (postFn: Function) => void
|
|
713
|
-
* @param {Function} postFn Send message function like `(msg) => void`
|
|
714
|
-
* @return {void}
|
|
715
|
-
*/
|
|
716
|
-
shareWalletInfo: function shareWalletInfo(postFn) {
|
|
717
|
-
postFn(_objectSpread({
|
|
718
|
-
jsonrpc: '2.0'
|
|
719
|
-
}, message(METHODS.wallet.readyToConnect, this.getWalletInfo())));
|
|
720
|
-
},
|
|
721
|
-
|
|
722
|
-
/**
|
|
723
|
-
* Get Wallet info object
|
|
724
|
-
* @function getWalletInfo
|
|
725
|
-
* @instance
|
|
726
|
-
* @rtype () => Object
|
|
727
|
-
* @return {Object} Object with wallet information(id, name, network, ...)
|
|
728
|
-
*/
|
|
729
|
-
getWalletInfo: function getWalletInfo() {
|
|
730
|
-
var runtime = getBrowserAPI(true).runtime;
|
|
731
|
-
return {
|
|
732
|
-
id: runtime && runtime.id ? runtime.id : this.id,
|
|
733
|
-
name: this.name,
|
|
734
|
-
networkId: this.getNetworkId(),
|
|
735
|
-
origin: window.location.origin,
|
|
736
|
-
type: runtime && runtime.id ? WALLET_TYPE.extension : WALLET_TYPE.window
|
|
737
|
-
};
|
|
738
|
-
},
|
|
739
|
-
|
|
740
|
-
/**
|
|
741
|
-
* Get Wallet accounts
|
|
742
|
-
* @function getAccounts
|
|
743
|
-
* @instance
|
|
744
|
-
* @rtype () => Object
|
|
745
|
-
* @return {Object} Object with accounts information({ connected: Object, current: Object })
|
|
746
|
-
*/
|
|
747
|
-
getAccounts: function getAccounts() {
|
|
748
|
-
var _context19,
|
|
749
|
-
_context20,
|
|
750
|
-
_this2 = this;
|
|
751
|
-
|
|
752
|
-
return {
|
|
753
|
-
current: this.selectedAddress ? _defineProperty({}, this.selectedAddress, {}) : {},
|
|
754
|
-
connected: _reduceInstanceProperty(_context19 = _filterInstanceProperty(_context20 = this.addresses()).call(_context20, function (a) {
|
|
755
|
-
return a !== _this2.selectedAddress;
|
|
756
|
-
})).call(_context19, function (acc, a) {
|
|
757
|
-
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, a, {}));
|
|
758
|
-
}, {})
|
|
759
|
-
};
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
});
|
|
763
|
-
//# sourceMappingURL=wallet-rpc.js.map
|