@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.
Files changed (284) hide show
  1. package/README.md +15 -14
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +7 -36
  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.mjs +179 -0
  10. package/es/account/base.mjs.map +1 -0
  11. package/es/account/memory.mjs +99 -0
  12. package/es/account/memory.mjs.map +1 -0
  13. package/es/account/multiple.mjs +179 -0
  14. package/es/account/multiple.mjs.map +1 -0
  15. package/es/ae/aens.mjs +404 -0
  16. package/es/ae/aens.mjs.map +1 -0
  17. package/es/ae/{aepp.js → aepp.mjs} +9 -9
  18. package/es/ae/aepp.mjs.map +1 -0
  19. package/es/ae/contract.mjs +159 -0
  20. package/es/ae/contract.mjs.map +1 -0
  21. package/es/ae/index.mjs +207 -0
  22. package/es/ae/index.mjs.map +1 -0
  23. package/es/ae/oracle.mjs +339 -0
  24. package/es/ae/oracle.mjs.map +1 -0
  25. package/es/ae/{universal.js → universal.mjs} +10 -10
  26. package/es/ae/universal.mjs.map +1 -0
  27. package/es/ae/{wallet.js → wallet.mjs} +10 -10
  28. package/es/ae/wallet.mjs.map +1 -0
  29. package/es/aepp-wallet-communication/schema.d.ts +74 -0
  30. package/es/bignumber.d.ts +1 -7
  31. package/es/chain/{index.js → index.mjs} +29 -9
  32. package/es/chain/index.mjs.map +1 -0
  33. package/es/chain/node.mjs +442 -0
  34. package/es/chain/node.mjs.map +1 -0
  35. package/es/channel/handlers.mjs +1110 -0
  36. package/es/channel/handlers.mjs.map +1 -0
  37. package/es/channel/{index.js → index.mjs} +245 -472
  38. package/es/channel/index.mjs.map +1 -0
  39. package/es/channel/internal.mjs +283 -0
  40. package/es/channel/internal.mjs.map +1 -0
  41. package/es/contract/aci.mjs +477 -0
  42. package/es/contract/aci.mjs.map +1 -0
  43. package/es/contract/compiler.mjs +115 -0
  44. package/es/contract/compiler.mjs.map +1 -0
  45. package/es/contract/ga/helpers.mjs +30 -0
  46. package/es/contract/ga/helpers.mjs.map +1 -0
  47. package/es/contract/ga/index.mjs +178 -0
  48. package/es/contract/ga/index.mjs.map +1 -0
  49. package/es/errors.d.ts +284 -0
  50. package/es/index.mjs +57 -0
  51. package/es/index.mjs.map +1 -0
  52. package/es/node-pool/index.mjs +188 -0
  53. package/es/node-pool/index.mjs.map +1 -0
  54. package/es/node.mjs +133 -0
  55. package/es/node.mjs.map +1 -0
  56. package/es/other.d.ts +1 -1
  57. package/es/tx/builder/field-types.mjs +74 -0
  58. package/es/tx/builder/field-types.mjs.map +1 -0
  59. package/es/tx/builder/helpers.mjs +363 -0
  60. package/es/tx/builder/helpers.mjs.map +1 -0
  61. package/es/tx/builder/index.mjs +606 -0
  62. package/es/tx/builder/index.mjs.map +1 -0
  63. package/es/tx/builder/schema.mjs +760 -0
  64. package/es/tx/builder/schema.mjs.map +1 -0
  65. package/es/tx/{index.js → index.mjs} +107 -15
  66. package/es/tx/index.mjs.map +1 -0
  67. package/es/tx/tx-object.mjs +283 -0
  68. package/es/tx/tx-object.mjs.map +1 -0
  69. package/es/tx/tx.mjs +938 -0
  70. package/es/tx/tx.mjs.map +1 -0
  71. package/es/tx/validator.mjs +247 -0
  72. package/es/tx/validator.mjs.map +1 -0
  73. package/es/typings/blakejs/index.d.mjs +2 -0
  74. package/es/typings/blakejs/{index.d.js.map → index.d.mjs.map} +1 -1
  75. package/es/utils/aepp-wallet-communication/connection/{browser-runtime.js → browser-runtime.mjs} +27 -29
  76. package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +1 -0
  77. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +183 -0
  78. package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +1 -0
  79. package/es/utils/aepp-wallet-communication/connection/{index.js → index.mjs} +7 -3
  80. package/es/utils/aepp-wallet-communication/connection/index.mjs.map +1 -0
  81. package/es/utils/aepp-wallet-communication/{content-script-bridge.js → content-script-bridge.mjs} +29 -23
  82. package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +1 -0
  83. package/es/utils/aepp-wallet-communication/helpers.mjs +92 -0
  84. package/es/utils/aepp-wallet-communication/helpers.mjs.map +1 -0
  85. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +375 -0
  86. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +1 -0
  87. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +275 -0
  88. package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +1 -0
  89. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +541 -0
  90. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +1 -0
  91. package/es/utils/aepp-wallet-communication/schema.mjs +102 -0
  92. package/es/utils/aepp-wallet-communication/schema.mjs.map +1 -0
  93. package/es/utils/aepp-wallet-communication/wallet-detector.mjs +110 -0
  94. package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
  95. package/es/utils/amount-formatter.mjs +139 -0
  96. package/es/utils/amount-formatter.mjs.map +1 -0
  97. package/es/utils/async-init.mjs +64 -0
  98. package/es/utils/async-init.mjs.map +1 -0
  99. package/es/utils/bignumber.mjs +21 -0
  100. package/es/utils/bignumber.mjs.map +1 -0
  101. package/es/utils/{bytes.js → bytes.mjs} +16 -12
  102. package/es/utils/bytes.mjs.map +1 -0
  103. package/es/utils/{crypto-ts.js → crypto-ts.mjs} +11 -3
  104. package/es/utils/crypto-ts.mjs.map +1 -0
  105. package/es/utils/crypto.mjs +239 -0
  106. package/es/utils/crypto.mjs.map +1 -0
  107. package/es/utils/errors.mjs +689 -0
  108. package/es/utils/errors.mjs.map +1 -0
  109. package/es/utils/hd-wallet.mjs +111 -0
  110. package/es/utils/hd-wallet.mjs.map +1 -0
  111. package/es/utils/json-big.mjs +45 -0
  112. package/es/utils/json-big.mjs.map +1 -0
  113. package/es/utils/keystore.mjs +240 -0
  114. package/es/utils/keystore.mjs.map +1 -0
  115. package/es/utils/mptree.mjs +161 -0
  116. package/es/utils/mptree.mjs.map +1 -0
  117. package/es/utils/other.mjs +43 -0
  118. package/es/utils/other.mjs.map +1 -0
  119. package/es/utils/semver-satisfies.mjs +16 -0
  120. package/es/utils/semver-satisfies.mjs.map +1 -0
  121. package/es/utils/{string.js → string.mjs} +5 -14
  122. package/es/utils/string.mjs.map +1 -0
  123. package/es/utils/swagger.mjs +164 -0
  124. package/es/utils/swagger.mjs.map +1 -0
  125. package/package.json +55 -62
  126. package/src/account/base.js +3 -1
  127. package/src/account/memory.js +13 -8
  128. package/src/account/multiple.js +31 -22
  129. package/src/ae/aens.js +75 -77
  130. package/src/ae/aepp.js +2 -2
  131. package/src/ae/contract.js +27 -291
  132. package/src/ae/index.js +9 -7
  133. package/src/ae/oracle.js +51 -28
  134. package/src/ae/universal.js +4 -2
  135. package/src/ae/wallet.js +2 -2
  136. package/src/chain/index.js +29 -6
  137. package/src/chain/node.js +95 -67
  138. package/src/channel/handlers.js +30 -21
  139. package/src/channel/index.js +44 -20
  140. package/src/channel/internal.js +30 -24
  141. package/src/contract/aci.js +376 -0
  142. package/src/contract/compiler.js +41 -91
  143. package/src/contract/ga/helpers.js +10 -13
  144. package/src/contract/ga/index.js +42 -33
  145. package/src/index.js +9 -10
  146. package/src/node-pool/index.js +29 -17
  147. package/src/node.js +33 -36
  148. package/src/tx/builder/field-types.js +61 -0
  149. package/src/tx/builder/helpers.js +126 -84
  150. package/src/tx/builder/index.js +83 -41
  151. package/src/tx/builder/schema.js +50 -40
  152. package/src/tx/index.js +101 -12
  153. package/src/tx/tx-object.js +35 -15
  154. package/src/tx/tx.js +232 -153
  155. package/src/tx/validator.js +34 -12
  156. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +11 -5
  157. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +35 -13
  158. package/src/utils/aepp-wallet-communication/connection/index.js +2 -1
  159. package/src/utils/aepp-wallet-communication/content-script-bridge.js +14 -7
  160. package/src/utils/aepp-wallet-communication/helpers.js +6 -14
  161. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +107 -60
  162. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +24 -11
  163. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +98 -56
  164. package/src/utils/aepp-wallet-communication/schema.ts +80 -0
  165. package/src/utils/aepp-wallet-communication/wallet-detector.js +6 -2
  166. package/src/utils/amount-formatter.ts +4 -3
  167. package/src/utils/async-init.js +10 -6
  168. package/src/utils/bignumber.ts +3 -10
  169. package/src/utils/bytes.ts +3 -2
  170. package/src/utils/crypto-ts.ts +2 -2
  171. package/src/utils/crypto.js +10 -144
  172. package/src/utils/errors.ts +683 -0
  173. package/src/utils/hd-wallet.js +11 -26
  174. package/src/utils/keystore.js +57 -53
  175. package/src/utils/mptree.ts +12 -6
  176. package/src/utils/other.ts +1 -1
  177. package/src/utils/semver-satisfies.ts +1 -1
  178. package/src/utils/swagger.js +75 -45
  179. package/es/account/base.js +0 -259
  180. package/es/account/base.js.map +0 -1
  181. package/es/account/memory.js +0 -86
  182. package/es/account/memory.js.map +0 -1
  183. package/es/account/multiple.js +0 -267
  184. package/es/account/multiple.js.map +0 -1
  185. package/es/ae/aens.js +0 -829
  186. package/es/ae/aens.js.map +0 -1
  187. package/es/ae/aepp.js.map +0 -1
  188. package/es/ae/contract.js +0 -985
  189. package/es/ae/contract.js.map +0 -1
  190. package/es/ae/index.js +0 -442
  191. package/es/ae/index.js.map +0 -1
  192. package/es/ae/oracle.js +0 -690
  193. package/es/ae/oracle.js.map +0 -1
  194. package/es/ae/universal.js.map +0 -1
  195. package/es/ae/wallet.js.map +0 -1
  196. package/es/chain/index.js.map +0 -1
  197. package/es/chain/node.js +0 -1119
  198. package/es/chain/node.js.map +0 -1
  199. package/es/channel/handlers.js +0 -1601
  200. package/es/channel/handlers.js.map +0 -1
  201. package/es/channel/index.js.map +0 -1
  202. package/es/channel/internal.js +0 -438
  203. package/es/channel/internal.js.map +0 -1
  204. package/es/contract/aci/helpers.js +0 -298
  205. package/es/contract/aci/helpers.js.map +0 -1
  206. package/es/contract/aci/index.js +0 -517
  207. package/es/contract/aci/index.js.map +0 -1
  208. package/es/contract/aci/transformation.js +0 -742
  209. package/es/contract/aci/transformation.js.map +0 -1
  210. package/es/contract/compiler.js +0 -316
  211. package/es/contract/compiler.js.map +0 -1
  212. package/es/contract/ga/helpers.js +0 -120
  213. package/es/contract/ga/helpers.js.map +0 -1
  214. package/es/contract/ga/index.js +0 -307
  215. package/es/contract/ga/index.js.map +0 -1
  216. package/es/contract/index.js +0 -158
  217. package/es/contract/index.js.map +0 -1
  218. package/es/index.js +0 -57
  219. package/es/index.js.map +0 -1
  220. package/es/node-pool/index.js +0 -204
  221. package/es/node-pool/index.js.map +0 -1
  222. package/es/node.js +0 -228
  223. package/es/node.js.map +0 -1
  224. package/es/tx/builder/helpers.js +0 -355
  225. package/es/tx/builder/helpers.js.map +0 -1
  226. package/es/tx/builder/index.js +0 -686
  227. package/es/tx/builder/index.js.map +0 -1
  228. package/es/tx/builder/schema.js +0 -695
  229. package/es/tx/builder/schema.js.map +0 -1
  230. package/es/tx/index.js.map +0 -1
  231. package/es/tx/tx-object.js +0 -297
  232. package/es/tx/tx-object.js.map +0 -1
  233. package/es/tx/tx.js +0 -1757
  234. package/es/tx/tx.js.map +0 -1
  235. package/es/tx/validator.js +0 -344
  236. package/es/tx/validator.js.map +0 -1
  237. package/es/typings/blakejs/index.d.js +0 -2
  238. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +0 -1
  239. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -211
  240. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +0 -1
  241. package/es/utils/aepp-wallet-communication/connection/index.js.map +0 -1
  242. package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +0 -1
  243. package/es/utils/aepp-wallet-communication/helpers.js +0 -148
  244. package/es/utils/aepp-wallet-communication/helpers.js.map +0 -1
  245. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -652
  246. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +0 -1
  247. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -285
  248. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +0 -1
  249. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -763
  250. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +0 -1
  251. package/es/utils/aepp-wallet-communication/schema.js +0 -103
  252. package/es/utils/aepp-wallet-communication/schema.js.map +0 -1
  253. package/es/utils/aepp-wallet-communication/wallet-detector.js +0 -135
  254. package/es/utils/aepp-wallet-communication/wallet-detector.js.map +0 -1
  255. package/es/utils/amount-formatter.js +0 -152
  256. package/es/utils/amount-formatter.js.map +0 -1
  257. package/es/utils/async-init.js +0 -103
  258. package/es/utils/async-init.js.map +0 -1
  259. package/es/utils/bignumber.js +0 -36
  260. package/es/utils/bignumber.js.map +0 -1
  261. package/es/utils/bytes.js.map +0 -1
  262. package/es/utils/crypto-ts.js.map +0 -1
  263. package/es/utils/crypto.js +0 -358
  264. package/es/utils/crypto.js.map +0 -1
  265. package/es/utils/hd-wallet.js +0 -148
  266. package/es/utils/hd-wallet.js.map +0 -1
  267. package/es/utils/json-big.js +0 -78
  268. package/es/utils/json-big.js.map +0 -1
  269. package/es/utils/keystore.js +0 -393
  270. package/es/utils/keystore.js.map +0 -1
  271. package/es/utils/mptree.js +0 -198
  272. package/es/utils/mptree.js.map +0 -1
  273. package/es/utils/other.js +0 -93
  274. package/es/utils/other.js.map +0 -1
  275. package/es/utils/semver-satisfies.js +0 -35
  276. package/es/utils/semver-satisfies.js.map +0 -1
  277. package/es/utils/string.js.map +0 -1
  278. package/es/utils/swagger.js +0 -269
  279. package/es/utils/swagger.js.map +0 -1
  280. package/src/contract/aci/helpers.js +0 -140
  281. package/src/contract/aci/index.js +0 -191
  282. package/src/contract/aci/transformation.js +0 -464
  283. package/src/contract/index.js +0 -159
  284. package/src/utils/aepp-wallet-communication/schema.js +0 -110
@@ -1,652 +0,0 @@
1
- import _merge from "ramda/src/merge";
2
- import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
3
- import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
4
- import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
5
-
6
- var _NOTIFICATIONS, _RESPONSES;
7
-
8
- 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; }
9
-
10
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context13; _forEachInstanceProperty(_context13 = ownKeys(Object(source), true)).call(_context13, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context14; _forEachInstanceProperty(_context14 = ownKeys(Object(source))).call(_context14, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
11
-
12
- import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
13
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
14
- import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
15
- import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
16
- import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
17
- import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
18
- import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
19
- import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
20
- import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
21
- import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
22
- import { v4 as uuid } from 'uuid';
23
- import Ae from '../../../ae';
24
- import RpcClient from './rpc-client';
25
- import { getHandler, message, voidFn } from '../helpers';
26
- import { METHODS, RPC_STATUS, VERSION } from '../schema';
27
- var NOTIFICATIONS = (_NOTIFICATIONS = {}, _defineProperty(_NOTIFICATIONS, METHODS.wallet.updateAddress, function (instance) {
28
- return function (_ref) {
29
- var params = _ref.params;
30
- instance.rpcClient.accounts = params;
31
- instance.onAddressChange(params);
32
- };
33
- }), _defineProperty(_NOTIFICATIONS, METHODS.updateNetwork, function (instance) {
34
- return function (msg) {
35
- instance.rpcClient.info.networkId = msg.params.networkId;
36
- instance.onNetworkChange(msg.params);
37
- };
38
- }), _defineProperty(_NOTIFICATIONS, METHODS.closeConnection, function (instance) {
39
- return function (msg) {
40
- instance.disconnectWallet();
41
- instance.onDisconnect(msg.params);
42
- };
43
- }), _NOTIFICATIONS);
44
- var RESPONSES = (_RESPONSES = {}, _defineProperty(_RESPONSES, METHODS.aepp.address, function (instance) {
45
- return function (msg) {
46
- return instance.rpcClient.processResponse(msg);
47
- };
48
- }), _defineProperty(_RESPONSES, METHODS.aepp.connect, function (instance) {
49
- return function (msg) {
50
- if (msg.result) instance.rpcClient.info.status = RPC_STATUS.CONNECTED;
51
- instance.rpcClient.processResponse(msg);
52
- };
53
- }), _defineProperty(_RESPONSES, METHODS.aepp.subscribeAddress, function (instance) {
54
- return function (msg) {
55
- if (msg.result) {
56
- msg.result.address && (instance.rpcClient.accounts = msg.result.address);
57
- msg.result.subscription && (instance.rpcClient.addressSubscription = msg.result.subscription);
58
- }
59
-
60
- instance.rpcClient.processResponse(msg, function (_ref2) {
61
- var id = _ref2.id,
62
- result = _ref2.result;
63
- return [result];
64
- });
65
- };
66
- }), _defineProperty(_RESPONSES, METHODS.aepp.sign, function (instance) {
67
- return function (msg) {
68
- instance.rpcClient.processResponse(msg, function (_ref3) {
69
- var id = _ref3.id,
70
- result = _ref3.result;
71
- return [result.signedTransaction || result.transactionHash];
72
- });
73
- };
74
- }), _defineProperty(_RESPONSES, METHODS.aepp.signMessage, function (instance) {
75
- return function (msg) {
76
- instance.rpcClient.processResponse(msg, function (_ref4) {
77
- var id = _ref4.id,
78
- result = _ref4.result;
79
- return [result.signature];
80
- });
81
- };
82
- }), _RESPONSES);
83
- var REQUESTS = {};
84
-
85
- var handleMessage = function handleMessage(instance) {
86
- return /*#__PURE__*/function () {
87
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(msg) {
88
- return _regeneratorRuntime.wrap(function _callee$(_context) {
89
- while (1) {
90
- switch (_context.prev = _context.next) {
91
- case 0:
92
- if (msg.id) {
93
- _context.next = 4;
94
- break;
95
- }
96
-
97
- return _context.abrupt("return", getHandler(NOTIFICATIONS, msg, {
98
- debug: instance.debug
99
- })(instance)(msg));
100
-
101
- case 4:
102
- if (!Object.prototype.hasOwnProperty.call(instance.rpcClient.callbacks, msg.id)) {
103
- _context.next = 8;
104
- break;
105
- }
106
-
107
- return _context.abrupt("return", getHandler(RESPONSES, msg, {
108
- debug: instance.debug
109
- })(instance)(msg));
110
-
111
- case 8:
112
- return _context.abrupt("return", getHandler(REQUESTS, msg, {
113
- debug: instance.debug
114
- })(instance)(msg));
115
-
116
- case 9:
117
- case "end":
118
- return _context.stop();
119
- }
120
- }
121
- }, _callee);
122
- }));
123
-
124
- return function (_x) {
125
- return _ref5.apply(this, arguments);
126
- };
127
- }();
128
- };
129
- /**
130
- * Contain functionality for wallet interaction and connect it to sdk
131
- * @alias module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc
132
- * @function
133
- * @rtype Stamp
134
- * @param {Object} param Init params object
135
- * @param {String=} [param.name] Aepp name
136
- * @param {Function} onAddressChange Call-back function for update address event
137
- * @param {Function} onDisconnect Call-back function for disconnect event
138
- * @param {Function} onNetworkChange Call-back function for update network event
139
- * @param {Object} connection Wallet connection object
140
- * @return {Object}
141
- */
142
-
143
-
144
- export default Ae.compose({
145
- init: function init(_ref6) {
146
- var _this = this;
147
-
148
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
149
- var name, _ref6$onAddressChange, onAddressChange, _ref6$onDisconnect, onDisconnect, _ref6$onNetworkChange, onNetworkChange, connection, _ref6$forceValidation, forceValidation, _ref6$debug, debug, eventsHandlers;
150
-
151
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
152
- while (1) {
153
- switch (_context2.prev = _context2.next) {
154
- case 0:
155
- name = _ref6.name, _ref6$onAddressChange = _ref6.onAddressChange, onAddressChange = _ref6$onAddressChange === void 0 ? voidFn : _ref6$onAddressChange, _ref6$onDisconnect = _ref6.onDisconnect, onDisconnect = _ref6$onDisconnect === void 0 ? voidFn : _ref6$onDisconnect, _ref6$onNetworkChange = _ref6.onNetworkChange, onNetworkChange = _ref6$onNetworkChange === void 0 ? voidFn : _ref6$onNetworkChange, connection = _ref6.connection, _ref6$forceValidation = _ref6.forceValidation, forceValidation = _ref6$forceValidation === void 0 ? false : _ref6$forceValidation, _ref6$debug = _ref6.debug, debug = _ref6$debug === void 0 ? false : _ref6$debug;
156
- eventsHandlers = ['onDisconnect', 'onAddressChange', 'onNetworkChange'];
157
- _this.connection = connection;
158
- _this.name = name;
159
- _this.debug = debug;
160
-
161
- if (!connection) {
162
- _context2.next = 8;
163
- break;
164
- }
165
-
166
- _context2.next = 8;
167
- return _this.connectToWallet(connection);
168
-
169
- case 8:
170
- // Event callbacks
171
- _this.onDisconnect = onDisconnect;
172
- _this.onAddressChange = onAddressChange;
173
- _this.onNetworkChange = onNetworkChange; // validation
174
-
175
- _forEachInstanceProperty(eventsHandlers).call(eventsHandlers, function (event) {
176
- if (!forceValidation && typeof _this[event] !== 'function') throw new Error("Call-back for ".concat(event, " must be an function!"));
177
- });
178
-
179
- case 12:
180
- case "end":
181
- return _context2.stop();
182
- }
183
- }
184
- }, _callee2);
185
- }))();
186
- },
187
- deepProps: {
188
- Ae: {
189
- defaults: {
190
- walletBroadcast: true
191
- }
192
- }
193
- },
194
- methods: {
195
- sign: function sign() {},
196
- addresses: function addresses() {
197
- var _context3;
198
-
199
- if (!this.rpcClient.currentAccount) throw new Error('You are not subscribed for an account.');
200
- return _concatInstanceProperty(_context3 = [this.rpcClient.currentAccount]).call(_context3, _toConsumableArray(_Object$keys(this.rpcClient.accounts.connected)));
201
- },
202
-
203
- /**
204
- * Connect to wallet
205
- * @function connectToWallet
206
- * @instance
207
- * @rtype (connection: Object) => void
208
- * @param {Object} connection Wallet connection object
209
- * @return {void}
210
- */
211
- connectToWallet: function connectToWallet(connection) {
212
- var _this2 = this;
213
-
214
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
215
- return _regeneratorRuntime.wrap(function _callee3$(_context4) {
216
- while (1) {
217
- switch (_context4.prev = _context4.next) {
218
- case 0:
219
- if (!(_this2.rpcClient && _this2.rpcClient.isConnected())) {
220
- _context4.next = 2;
221
- break;
222
- }
223
-
224
- throw new Error('You are already connected to wallet ' + _this2.rpcClient);
225
-
226
- case 2:
227
- _this2.rpcClient = RpcClient(_objectSpread(_objectSpread({
228
- connection: connection,
229
- networkId: _this2.getNetworkId({
230
- force: true
231
- })
232
- }, connection.connectionInfo), {}, {
233
- id: uuid(),
234
- handlers: [handleMessage(_this2), _this2.onDisconnect]
235
- }));
236
- return _context4.abrupt("return", _this2.sendConnectRequest());
237
-
238
- case 4:
239
- case "end":
240
- return _context4.stop();
241
- }
242
- }
243
- }, _callee3);
244
- }))();
245
- },
246
-
247
- /**
248
- * Disconnect from wallet
249
- * @function disconnectWallet
250
- * @instance
251
- * @rtype (force: Boolean = false) => void
252
- * @param {Boolean} sendDisconnect=false Force sending close connection message
253
- * @return {void}
254
- */
255
- disconnectWallet: function disconnectWallet() {
256
- var _arguments = arguments,
257
- _this3 = this;
258
-
259
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
260
- var sendDisconnect;
261
- return _regeneratorRuntime.wrap(function _callee4$(_context5) {
262
- while (1) {
263
- switch (_context5.prev = _context5.next) {
264
- case 0:
265
- sendDisconnect = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : true;
266
-
267
- if (!(!_this3.rpcClient || !_this3.rpcClient.isConnected())) {
268
- _context5.next = 3;
269
- break;
270
- }
271
-
272
- throw new Error('You are not connected to Wallet');
273
-
274
- case 3:
275
- sendDisconnect && _this3.rpcClient.sendMessage(message(METHODS.closeConnection, {
276
- reason: 'bye'
277
- }), true);
278
-
279
- _this3.rpcClient.disconnect();
280
-
281
- _this3.rpcClient = null;
282
-
283
- case 6:
284
- case "end":
285
- return _context5.stop();
286
- }
287
- }
288
- }, _callee4);
289
- }))();
290
- },
291
- address: function address() {
292
- var _arguments2 = arguments,
293
- _this4 = this;
294
-
295
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
296
- var _ref7, onAccount, current;
297
-
298
- return _regeneratorRuntime.wrap(function _callee5$(_context6) {
299
- while (1) {
300
- switch (_context6.prev = _context6.next) {
301
- case 0:
302
- _ref7 = _arguments2.length > 0 && _arguments2[0] !== undefined ? _arguments2[0] : {}, onAccount = _ref7.onAccount;
303
-
304
- if (!(!_this4.rpcClient || !_this4.rpcClient.isConnected())) {
305
- _context6.next = 3;
306
- break;
307
- }
308
-
309
- throw new Error('You are not connected to Wallet');
310
-
311
- case 3:
312
- current = _this4.rpcClient.currentAccount;
313
-
314
- if (current) {
315
- _context6.next = 6;
316
- break;
317
- }
318
-
319
- throw new Error('You are not subscribed for an account.');
320
-
321
- case 6:
322
- if (!(onAccount && !_this4.rpcClient.hasAccessToAccount(onAccount))) {
323
- _context6.next = 8;
324
- break;
325
- }
326
-
327
- throw new Error("You do not have access to account ".concat(onAccount));
328
-
329
- case 8:
330
- return _context6.abrupt("return", onAccount || current);
331
-
332
- case 9:
333
- case "end":
334
- return _context6.stop();
335
- }
336
- }
337
- }, _callee5);
338
- }))();
339
- },
340
-
341
- /**
342
- * Ask address from wallet
343
- * @function askAddresses
344
- * @instance
345
- * @rtype () => Promise
346
- * @return {Promise} Address from wallet
347
- */
348
- askAddresses: function askAddresses() {
349
- var _this5 = this;
350
-
351
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
352
- return _regeneratorRuntime.wrap(function _callee6$(_context7) {
353
- while (1) {
354
- switch (_context7.prev = _context7.next) {
355
- case 0:
356
- if (!(!_this5.rpcClient || !_this5.rpcClient.isConnected())) {
357
- _context7.next = 2;
358
- break;
359
- }
360
-
361
- throw new Error('You are not connected to Wallet');
362
-
363
- case 2:
364
- if (_this5.rpcClient.currentAccount) {
365
- _context7.next = 4;
366
- break;
367
- }
368
-
369
- throw new Error('You are not subscribed for an account.');
370
-
371
- case 4:
372
- return _context7.abrupt("return", _this5.rpcClient.request(METHODS.aepp.address));
373
-
374
- case 5:
375
- case "end":
376
- return _context7.stop();
377
- }
378
- }
379
- }, _callee6);
380
- }))();
381
- },
382
-
383
- /**
384
- * Subscribe for addresses from wallet
385
- * @function subscribeAddress
386
- * @instance
387
- * @rtype (type: String, value: String) => Promise
388
- * @param {String} type Type of subscription can be one of ['current'(just for selected account updates), 'connected(all accounts)']
389
- * @param {String} value Subscription action('subscribe'|'unsubscribe')
390
- * @return {Promise} Address from wallet
391
- */
392
- subscribeAddress: function subscribeAddress(type, value) {
393
- var _this6 = this;
394
-
395
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
396
- return _regeneratorRuntime.wrap(function _callee7$(_context8) {
397
- while (1) {
398
- switch (_context8.prev = _context8.next) {
399
- case 0:
400
- if (!(!_this6.rpcClient || !_this6.rpcClient.isConnected())) {
401
- _context8.next = 2;
402
- break;
403
- }
404
-
405
- throw new Error('You are not connected to Wallet');
406
-
407
- case 2:
408
- return _context8.abrupt("return", _this6.rpcClient.request(METHODS.aepp.subscribeAddress, {
409
- type: type,
410
- value: value
411
- }));
412
-
413
- case 3:
414
- case "end":
415
- return _context8.stop();
416
- }
417
- }
418
- }, _callee7);
419
- }))();
420
- },
421
-
422
- /**
423
- * Overwriting of `signTransaction` AE method
424
- * All sdk API which use it will be send notification to wallet and wait for callBack
425
- * @function signTransaction
426
- * @instance
427
- * @rtype (tx: String, options = {}) => Promise
428
- * @return {Promise<String>} Signed transaction
429
- */
430
- signTransaction: function signTransaction(tx) {
431
- var _arguments3 = arguments,
432
- _this7 = this;
433
-
434
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
435
- var opt;
436
- return _regeneratorRuntime.wrap(function _callee8$(_context9) {
437
- while (1) {
438
- switch (_context9.prev = _context9.next) {
439
- case 0:
440
- opt = _arguments3.length > 1 && _arguments3[1] !== undefined ? _arguments3[1] : {};
441
-
442
- if (!(!_this7.rpcClient || !_this7.rpcClient.isConnected())) {
443
- _context9.next = 3;
444
- break;
445
- }
446
-
447
- throw new Error('You are not connected to Wallet');
448
-
449
- case 3:
450
- if (_this7.rpcClient.currentAccount) {
451
- _context9.next = 5;
452
- break;
453
- }
454
-
455
- throw new Error('You are not subscribed for an account.');
456
-
457
- case 5:
458
- if (!(opt.onAccount && !_this7.rpcClient.hasAccessToAccount(opt.onAccount))) {
459
- _context9.next = 7;
460
- break;
461
- }
462
-
463
- throw new Error("You do not have access to account ".concat(opt.onAccount));
464
-
465
- case 7:
466
- return _context9.abrupt("return", _this7.rpcClient.request(METHODS.aepp.sign, _objectSpread(_objectSpread({}, opt), {}, {
467
- tx: tx,
468
- returnSigned: true,
469
- networkId: _this7.getNetworkId()
470
- })));
471
-
472
- case 8:
473
- case "end":
474
- return _context9.stop();
475
- }
476
- }
477
- }, _callee8);
478
- }))();
479
- },
480
-
481
- /**
482
- * Overwriting of `signMessage` AE method
483
- * All sdk API which use it will be send notification to wallet and wait for callBack
484
- * @function signMessage
485
- * @instance
486
- * @rtype (msg: String, options = {}) => Promise
487
- * @return {Promise<String>} Signed transaction
488
- */
489
- signMessage: function signMessage(msg) {
490
- var _arguments4 = arguments,
491
- _this8 = this;
492
-
493
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
494
- var opt;
495
- return _regeneratorRuntime.wrap(function _callee9$(_context10) {
496
- while (1) {
497
- switch (_context10.prev = _context10.next) {
498
- case 0:
499
- opt = _arguments4.length > 1 && _arguments4[1] !== undefined ? _arguments4[1] : {};
500
-
501
- if (!(!_this8.rpcClient || !_this8.rpcClient.isConnected())) {
502
- _context10.next = 3;
503
- break;
504
- }
505
-
506
- throw new Error('You are not connected to Wallet');
507
-
508
- case 3:
509
- if (_this8.rpcClient.currentAccount) {
510
- _context10.next = 5;
511
- break;
512
- }
513
-
514
- throw new Error('You are not subscribed for an account.');
515
-
516
- case 5:
517
- if (!(opt.onAccount && !_this8.rpcClient.hasAccessToAccount(opt.onAccount))) {
518
- _context10.next = 7;
519
- break;
520
- }
521
-
522
- throw new Error("You do not have access to account ".concat(opt.onAccount));
523
-
524
- case 7:
525
- return _context10.abrupt("return", _this8.rpcClient.request(METHODS.aepp.signMessage, _objectSpread(_objectSpread({}, opt), {}, {
526
- message: msg
527
- })));
528
-
529
- case 8:
530
- case "end":
531
- return _context10.stop();
532
- }
533
- }
534
- }, _callee9);
535
- }))();
536
- },
537
-
538
- /**
539
- * Send connection request to wallet
540
- * @function sendConnectRequest
541
- * @instance
542
- * @rtype () => Promise
543
- * @return {Promise} Connection response
544
- */
545
- sendConnectRequest: function sendConnectRequest() {
546
- var _this9 = this;
547
-
548
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
549
- return _regeneratorRuntime.wrap(function _callee10$(_context11) {
550
- while (1) {
551
- switch (_context11.prev = _context11.next) {
552
- case 0:
553
- return _context11.abrupt("return", _this9.rpcClient.request(METHODS.aepp.connect, {
554
- name: _this9.name,
555
- version: VERSION,
556
- networkId: _this9.getNetworkId({
557
- force: true
558
- })
559
- }));
560
-
561
- case 1:
562
- case "end":
563
- return _context11.stop();
564
- }
565
- }
566
- }, _callee10);
567
- }))();
568
- },
569
-
570
- /**
571
- * Overwriting of `send` AE method
572
- * All sdk API which use it will be send notification to wallet and wait for callBack
573
- * This method will sign, broadcast and wait until transaction will be accepted using rpc communication with wallet
574
- * @function send
575
- * @instance
576
- * @rtype (tx: String, options = {}) => Promise
577
- * @param {String} tx
578
- * @param {Object} [options={}]
579
- * @param {Object} [options.walletBroadcast=true]
580
- * @return {Promise<Object>} Transaction broadcast result
581
- */
582
- send: function send(tx) {
583
- var _arguments5 = arguments,
584
- _this10 = this;
585
-
586
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
587
- var options, opt, signed;
588
- return _regeneratorRuntime.wrap(function _callee11$(_context12) {
589
- while (1) {
590
- switch (_context12.prev = _context12.next) {
591
- case 0:
592
- options = _arguments5.length > 1 && _arguments5[1] !== undefined ? _arguments5[1] : {};
593
-
594
- if (!(!_this10.rpcClient || !_this10.rpcClient.isConnected())) {
595
- _context12.next = 3;
596
- break;
597
- }
598
-
599
- throw new Error('You are not connected to Wallet');
600
-
601
- case 3:
602
- if (_this10.rpcClient.currentAccount) {
603
- _context12.next = 5;
604
- break;
605
- }
606
-
607
- throw new Error('You are not subscribed for an account.');
608
-
609
- case 5:
610
- if (!(options.onAccount && !_this10.rpcClient.hasAccessToAccount(options.onAccount))) {
611
- _context12.next = 7;
612
- break;
613
- }
614
-
615
- throw new Error("You do not have access to account ".concat(options.onAccount));
616
-
617
- case 7:
618
- opt = _merge(_this10.Ae.defaults, options);
619
-
620
- if (opt.walletBroadcast) {
621
- _context12.next = 13;
622
- break;
623
- }
624
-
625
- _context12.next = 11;
626
- return _this10.signTransaction(tx, {
627
- onAccount: opt.onAccount
628
- });
629
-
630
- case 11:
631
- signed = _context12.sent;
632
- return _context12.abrupt("return", _this10.sendTransaction(signed, opt));
633
-
634
- case 13:
635
- return _context12.abrupt("return", _this10.rpcClient.request(METHODS.aepp.sign, {
636
- onAccount: opt.onAccount,
637
- tx: tx,
638
- returnSigned: false,
639
- networkId: _this10.getNetworkId()
640
- }));
641
-
642
- case 14:
643
- case "end":
644
- return _context12.stop();
645
- }
646
- }
647
- }, _callee11);
648
- }))();
649
- }
650
- }
651
- });
652
- //# sourceMappingURL=aepp-rpc.js.map