@aeternity/aepp-sdk 8.2.0 → 10.0.0-beta.1

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