@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
package/es/chain/node.js DELETED
@@ -1,1119 +0,0 @@
1
- import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
2
- import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
3
- import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
4
- import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
5
- import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
6
- import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
7
- import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
8
- import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/objectWithoutProperties";
9
- import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
10
- import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
11
- import _merge from "ramda/src/merge";
12
- import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
13
- var _excluded = ["result", "reason"],
14
- _excluded2 = ["results"];
15
- import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
16
-
17
- 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; }
18
-
19
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context30; _forEachInstanceProperty(_context30 = ownKeys(Object(source), true)).call(_context30, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context31; _forEachInstanceProperty(_context31 = ownKeys(Object(source))).call(_context31, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
20
-
21
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
22
- import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
23
- import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
24
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
25
- import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
26
- import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
27
- import Chain from './';
28
- import { AE_AMOUNT_FORMATS, formatAmount } from '../utils/amount-formatter';
29
- import verifyTransaction from '../tx/validator';
30
- import NodePool from '../node-pool';
31
- import { pause } from '../utils/other';
32
- import { isNameValid, produceNameId, decode } from '../tx/builder/helpers';
33
- import { DRY_RUN_ACCOUNT, NAME_ID_KEY } from '../tx/builder/schema';
34
- /**
35
- * ChainNode module
36
- *
37
- * This is the complement to {@link module:@aeternity/aepp-sdk/es/chain}.
38
- * @module @aeternity/aepp-sdk/es/chain/node
39
- * @export ChainNode
40
- * @example import { ChainNode } from '@aeternity/aepp-sdk'
41
- */
42
-
43
- function sendTransaction(_x) {
44
- return _sendTransaction.apply(this, arguments);
45
- }
46
-
47
- function _sendTransaction() {
48
- _sendTransaction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(tx) {
49
- var _this = this;
50
-
51
- var options,
52
- _R$merge,
53
- waitMined,
54
- verify,
55
- validation,
56
- message,
57
- _yield$this$api$postT,
58
- txHash,
59
- txData,
60
- _args = arguments;
61
-
62
- return _regeneratorRuntime.wrap(function _callee$(_context) {
63
- while (1) {
64
- switch (_context.prev = _context.next) {
65
- case 0:
66
- options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
67
- _R$merge = _merge(this.Ae.defaults, options), waitMined = _R$merge.waitMined, verify = _R$merge.verify;
68
-
69
- if (!verify) {
70
- _context.next = 9;
71
- break;
72
- }
73
-
74
- _context.next = 5;
75
- return verifyTransaction(tx, this.selectedNode.instance);
76
-
77
- case 5:
78
- validation = _context.sent;
79
-
80
- if (!validation.length) {
81
- _context.next = 9;
82
- break;
83
- }
84
-
85
- message = 'Transaction verification errors: ' + _mapInstanceProperty(validation).call(validation, function (v) {
86
- return v.message;
87
- }).join(', ');
88
- throw _Object$assign(new Error(message), {
89
- code: 'TX_VERIFICATION_ERROR',
90
- validation: validation,
91
- transaction: tx
92
- });
93
-
94
- case 9:
95
- _context.prev = 9;
96
- _context.next = 12;
97
- return this.api.postTransaction({
98
- tx: tx
99
- });
100
-
101
- case 12:
102
- _yield$this$api$postT = _context.sent;
103
- txHash = _yield$this$api$postT.txHash;
104
-
105
- if (!waitMined) {
106
- _context.next = 35;
107
- break;
108
- }
109
-
110
- _context.t0 = _objectSpread;
111
- _context.t1 = _objectSpread;
112
- _context.t2 = {};
113
- _context.next = 20;
114
- return this.poll(txHash, options);
115
-
116
- case 20:
117
- _context.t3 = _context.sent;
118
- _context.t4 = (0, _context.t1)(_context.t2, _context.t3);
119
- _context.t5 = {};
120
- _context.t6 = {
121
- rawTx: tx
122
- };
123
- txData = (0, _context.t0)(_context.t4, _context.t5, _context.t6);
124
-
125
- if (!options.confirm) {
126
- _context.next = 34;
127
- break;
128
- }
129
-
130
- _context.t7 = _objectSpread;
131
- _context.t8 = _objectSpread({}, txData);
132
- _context.t9 = {};
133
- _context.next = 31;
134
- return this.waitForTxConfirm(txHash, options);
135
-
136
- case 31:
137
- _context.t10 = _context.sent;
138
- _context.t11 = {
139
- confirmationHeight: _context.t10
140
- };
141
- return _context.abrupt("return", (0, _context.t7)(_context.t8, _context.t9, _context.t11));
142
-
143
- case 34:
144
- return _context.abrupt("return", txData);
145
-
146
- case 35:
147
- return _context.abrupt("return", {
148
- hash: txHash,
149
- rawTx: tx
150
- });
151
-
152
- case 38:
153
- _context.prev = 38;
154
- _context.t12 = _context["catch"](9);
155
- throw _Object$assign(_context.t12, {
156
- rawTx: tx,
157
- verifyTx: function verifyTx() {
158
- return verifyTransaction(tx, _this.selectedNode.instance);
159
- }
160
- });
161
-
162
- case 41:
163
- case "end":
164
- return _context.stop();
165
- }
166
- }
167
- }, _callee, this, [[9, 38]]);
168
- }));
169
- return _sendTransaction.apply(this, arguments);
170
- }
171
-
172
- function waitForTxConfirm(_x2) {
173
- return _waitForTxConfirm.apply(this, arguments);
174
- }
175
-
176
- function _waitForTxConfirm() {
177
- _waitForTxConfirm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(txHash) {
178
- var options,
179
- _yield$this$tx,
180
- blockHeight,
181
- height,
182
- _yield$this$tx2,
183
- newBlockHeight,
184
- _args2 = arguments;
185
-
186
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
187
- while (1) {
188
- switch (_context2.prev = _context2.next) {
189
- case 0:
190
- options = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {
191
- confirm: 3
192
- };
193
- options.confirm = options.confirm === true ? 3 : options.confirm;
194
- _context2.next = 4;
195
- return this.tx(txHash);
196
-
197
- case 4:
198
- _yield$this$tx = _context2.sent;
199
- blockHeight = _yield$this$tx.blockHeight;
200
- _context2.next = 8;
201
- return this.awaitHeight(blockHeight + options.confirm, options);
202
-
203
- case 8:
204
- height = _context2.sent;
205
- _context2.next = 11;
206
- return this.tx(txHash);
207
-
208
- case 11:
209
- _yield$this$tx2 = _context2.sent;
210
- newBlockHeight = _yield$this$tx2.blockHeight;
211
- _context2.t0 = newBlockHeight;
212
- _context2.next = _context2.t0 === -1 ? 16 : _context2.t0 === blockHeight ? 17 : 18;
213
- break;
214
-
215
- case 16:
216
- throw new Error("Transaction ".concat(txHash, " is removed from chain"));
217
-
218
- case 17:
219
- return _context2.abrupt("return", height);
220
-
221
- case 18:
222
- return _context2.abrupt("return", waitForTxConfirm(txHash, options));
223
-
224
- case 19:
225
- case "end":
226
- return _context2.stop();
227
- }
228
- }
229
- }, _callee2, this);
230
- }));
231
- return _waitForTxConfirm.apply(this, arguments);
232
- }
233
-
234
- function getAccount(_x3) {
235
- return _getAccount.apply(this, arguments);
236
- }
237
- /**
238
- * @function
239
- * @deprecated
240
- */
241
-
242
-
243
- function _getAccount() {
244
- _getAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(address) {
245
- var _ref,
246
- height,
247
- hash,
248
- _args3 = arguments;
249
-
250
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
251
- while (1) {
252
- switch (_context3.prev = _context3.next) {
253
- case 0:
254
- _ref = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {}, height = _ref.height, hash = _ref.hash;
255
-
256
- if (!height) {
257
- _context3.next = 3;
258
- break;
259
- }
260
-
261
- return _context3.abrupt("return", this.api.getAccountByPubkeyAndHeight(address, height));
262
-
263
- case 3:
264
- if (!hash) {
265
- _context3.next = 5;
266
- break;
267
- }
268
-
269
- return _context3.abrupt("return", this.api.getAccountByPubkeyAndHash(address, hash));
270
-
271
- case 5:
272
- return _context3.abrupt("return", this.api.getAccountByPubkey(address));
273
-
274
- case 6:
275
- case "end":
276
- return _context3.stop();
277
- }
278
- }
279
- }, _callee3, this);
280
- }));
281
- return _getAccount.apply(this, arguments);
282
- }
283
-
284
- function balance(_x4) {
285
- return _balance.apply(this, arguments);
286
- }
287
-
288
- function _balance() {
289
- _balance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(address) {
290
- var _ref2,
291
- height,
292
- hash,
293
- _ref2$format,
294
- format,
295
- _yield$this$getAccoun,
296
- balance,
297
- _args4 = arguments;
298
-
299
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
300
- while (1) {
301
- switch (_context4.prev = _context4.next) {
302
- case 0:
303
- _ref2 = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {}, height = _ref2.height, hash = _ref2.hash, _ref2$format = _ref2.format, format = _ref2$format === void 0 ? AE_AMOUNT_FORMATS.AETTOS : _ref2$format;
304
- _context4.next = 3;
305
- return this.getAccount(address, {
306
- hash: hash,
307
- height: height
308
- });
309
-
310
- case 3:
311
- _yield$this$getAccoun = _context4.sent;
312
- balance = _yield$this$getAccoun.balance;
313
- return _context4.abrupt("return", formatAmount(balance, {
314
- targetDenomination: format
315
- }).toString());
316
-
317
- case 6:
318
- case "end":
319
- return _context4.stop();
320
- }
321
- }
322
- }, _callee4, this);
323
- }));
324
- return _balance.apply(this, arguments);
325
- }
326
-
327
- function getBalance(_x5) {
328
- return _getBalance.apply(this, arguments);
329
- }
330
-
331
- function _getBalance() {
332
- _getBalance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(address) {
333
- var _ref3,
334
- height,
335
- hash,
336
- _ref3$format,
337
- format,
338
- _yield$this$getAccoun2,
339
- balance,
340
- _args5 = arguments;
341
-
342
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
343
- while (1) {
344
- switch (_context5.prev = _context5.next) {
345
- case 0:
346
- _ref3 = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {}, height = _ref3.height, hash = _ref3.hash, _ref3$format = _ref3.format, format = _ref3$format === void 0 ? AE_AMOUNT_FORMATS.AETTOS : _ref3$format;
347
- _context5.next = 3;
348
- return this.getAccount(address, {
349
- hash: hash,
350
- height: height
351
- })["catch"](function (_) {
352
- return {
353
- balance: 0
354
- };
355
- });
356
-
357
- case 3:
358
- _yield$this$getAccoun2 = _context5.sent;
359
- balance = _yield$this$getAccoun2.balance;
360
- return _context5.abrupt("return", formatAmount(balance, {
361
- targetDenomination: format
362
- }).toString());
363
-
364
- case 6:
365
- case "end":
366
- return _context5.stop();
367
- }
368
- }
369
- }, _callee5, this);
370
- }));
371
- return _getBalance.apply(this, arguments);
372
- }
373
-
374
- function tx(_x6) {
375
- return _tx.apply(this, arguments);
376
- }
377
-
378
- function _tx() {
379
- _tx = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(hash) {
380
- var _context6;
381
-
382
- var info,
383
- tx,
384
- _args6 = arguments;
385
- return _regeneratorRuntime.wrap(function _callee6$(_context7) {
386
- while (1) {
387
- switch (_context7.prev = _context7.next) {
388
- case 0:
389
- info = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : true;
390
- _context7.next = 3;
391
- return this.api.getTransactionByHash(hash);
392
-
393
- case 3:
394
- tx = _context7.sent;
395
-
396
- if (!(_includesInstanceProperty(_context6 = ['ContractCreateTx', 'ContractCallTx', 'ChannelForceProgressTx']).call(_context6, tx.tx.type) && info && tx.blockHeight !== -1)) {
397
- _context7.next = 16;
398
- break;
399
- }
400
-
401
- _context7.prev = 5;
402
- _context7.t0 = _objectSpread;
403
- _context7.t1 = _objectSpread({}, tx);
404
- _context7.next = 10;
405
- return this.getTxInfo(hash);
406
-
407
- case 10:
408
- _context7.t2 = _context7.sent;
409
- return _context7.abrupt("return", (0, _context7.t0)(_context7.t1, _context7.t2));
410
-
411
- case 14:
412
- _context7.prev = 14;
413
- _context7.t3 = _context7["catch"](5);
414
-
415
- case 16:
416
- return _context7.abrupt("return", tx);
417
-
418
- case 17:
419
- case "end":
420
- return _context7.stop();
421
- }
422
- }
423
- }, _callee6, this, [[5, 14]]);
424
- }));
425
- return _tx.apply(this, arguments);
426
- }
427
-
428
- function height() {
429
- return _height.apply(this, arguments);
430
- }
431
-
432
- function _height() {
433
- _height = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
434
- return _regeneratorRuntime.wrap(function _callee7$(_context8) {
435
- while (1) {
436
- switch (_context8.prev = _context8.next) {
437
- case 0:
438
- _context8.prev = 0;
439
-
440
- if (!this._heightPromise) {
441
- this._heightPromise = this.api.getCurrentKeyBlockHeight();
442
- }
443
-
444
- _context8.next = 4;
445
- return this._heightPromise;
446
-
447
- case 4:
448
- return _context8.abrupt("return", _context8.sent.height);
449
-
450
- case 5:
451
- _context8.prev = 5;
452
- delete this._heightPromise;
453
- return _context8.finish(5);
454
-
455
- case 8:
456
- case "end":
457
- return _context8.stop();
458
- }
459
- }
460
- }, _callee7, this, [[0,, 5, 8]]);
461
- }));
462
- return _height.apply(this, arguments);
463
- }
464
-
465
- function awaitHeight(_x7) {
466
- return _awaitHeight.apply(this, arguments);
467
- }
468
- /**
469
- * @deprecated
470
- */
471
-
472
-
473
- function _awaitHeight() {
474
- _awaitHeight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(height) {
475
- var _context9, _context10;
476
-
477
- var _ref4,
478
- _ref4$interval,
479
- interval,
480
- _ref4$attempts,
481
- attempts,
482
- currentHeight,
483
- i,
484
- _args8 = arguments;
485
-
486
- return _regeneratorRuntime.wrap(function _callee8$(_context11) {
487
- while (1) {
488
- switch (_context11.prev = _context11.next) {
489
- case 0:
490
- _ref4 = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {}, _ref4$interval = _ref4.interval, interval = _ref4$interval === void 0 ? 5000 : _ref4$interval, _ref4$attempts = _ref4.attempts, attempts = _ref4$attempts === void 0 ? 20 : _ref4$attempts;
491
- i = 0;
492
-
493
- case 2:
494
- if (!(i < attempts)) {
495
- _context11.next = 14;
496
- break;
497
- }
498
-
499
- if (!i) {
500
- _context11.next = 6;
501
- break;
502
- }
503
-
504
- _context11.next = 6;
505
- return pause(interval);
506
-
507
- case 6:
508
- _context11.next = 8;
509
- return this.height();
510
-
511
- case 8:
512
- currentHeight = _context11.sent;
513
-
514
- if (!(currentHeight >= height)) {
515
- _context11.next = 11;
516
- break;
517
- }
518
-
519
- return _context11.abrupt("return", currentHeight);
520
-
521
- case 11:
522
- i++;
523
- _context11.next = 2;
524
- break;
525
-
526
- case 14:
527
- throw new Error(_concatInstanceProperty(_context9 = _concatInstanceProperty(_context10 = "Giving up after ".concat((attempts - 1) * interval, "ms, current height: ")).call(_context10, currentHeight, ", desired height: ")).call(_context9, height));
528
-
529
- case 15:
530
- case "end":
531
- return _context11.stop();
532
- }
533
- }
534
- }, _callee8, this);
535
- }));
536
- return _awaitHeight.apply(this, arguments);
537
- }
538
-
539
- function topBlock() {
540
- return _topBlock.apply(this, arguments);
541
- }
542
-
543
- function _topBlock() {
544
- _topBlock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
545
- return _regeneratorRuntime.wrap(function _callee9$(_context12) {
546
- while (1) {
547
- switch (_context12.prev = _context12.next) {
548
- case 0:
549
- return _context12.abrupt("return", this.api.getTopHeader());
550
-
551
- case 1:
552
- case "end":
553
- return _context12.stop();
554
- }
555
- }
556
- }, _callee9, this);
557
- }));
558
- return _topBlock.apply(this, arguments);
559
- }
560
-
561
- function poll(_x8) {
562
- return _poll.apply(this, arguments);
563
- }
564
-
565
- function _poll() {
566
- _poll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(th) {
567
- var _context13;
568
-
569
- var _ref5,
570
- _ref5$blocks,
571
- blocks,
572
- _ref5$interval,
573
- interval,
574
- _ref5$allowUnsynced,
575
- allowUnsynced,
576
- max,
577
- _tx2,
578
- _args10 = arguments;
579
-
580
- return _regeneratorRuntime.wrap(function _callee10$(_context14) {
581
- while (1) {
582
- switch (_context14.prev = _context14.next) {
583
- case 0:
584
- _ref5 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref5$blocks = _ref5.blocks, blocks = _ref5$blocks === void 0 ? 10 : _ref5$blocks, _ref5$interval = _ref5.interval, interval = _ref5$interval === void 0 ? 5000 : _ref5$interval, _ref5$allowUnsynced = _ref5.allowUnsynced, allowUnsynced = _ref5$allowUnsynced === void 0 ? false : _ref5$allowUnsynced;
585
- _context14.next = 3;
586
- return this.height();
587
-
588
- case 3:
589
- _context14.t0 = _context14.sent;
590
- _context14.t1 = blocks;
591
- max = _context14.t0 + _context14.t1;
592
-
593
- case 6:
594
- _context14.next = 8;
595
- return this.tx(th)["catch"](function (_) {
596
- return null;
597
- });
598
-
599
- case 8:
600
- _tx2 = _context14.sent;
601
-
602
- if (!(_tx2 && (_tx2.blockHeight !== -1 || allowUnsynced && _tx2.height))) {
603
- _context14.next = 11;
604
- break;
605
- }
606
-
607
- return _context14.abrupt("return", _tx2);
608
-
609
- case 11:
610
- _context14.next = 13;
611
- return pause(interval);
612
-
613
- case 13:
614
- _context14.next = 15;
615
- return this.height();
616
-
617
- case 15:
618
- _context14.t2 = _context14.sent;
619
- _context14.t3 = max;
620
-
621
- if (_context14.t2 < _context14.t3) {
622
- _context14.next = 6;
623
- break;
624
- }
625
-
626
- case 18:
627
- throw new Error(_concatInstanceProperty(_context13 = "Giving up after ".concat(blocks, " blocks mined, transaction hash: ")).call(_context13, th));
628
-
629
- case 19:
630
- case "end":
631
- return _context14.stop();
632
- }
633
- }
634
- }, _callee10, this);
635
- }));
636
- return _poll.apply(this, arguments);
637
- }
638
-
639
- function getTxInfo(_x9) {
640
- return _getTxInfo.apply(this, arguments);
641
- }
642
-
643
- function _getTxInfo() {
644
- _getTxInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(hash) {
645
- var result;
646
- return _regeneratorRuntime.wrap(function _callee11$(_context15) {
647
- while (1) {
648
- switch (_context15.prev = _context15.next) {
649
- case 0:
650
- _context15.next = 2;
651
- return this.api.getTransactionInfoByHash(hash);
652
-
653
- case 2:
654
- result = _context15.sent;
655
- return _context15.abrupt("return", result.callInfo || result);
656
-
657
- case 4:
658
- case "end":
659
- return _context15.stop();
660
- }
661
- }
662
- }, _callee11, this);
663
- }));
664
- return _getTxInfo.apply(this, arguments);
665
- }
666
-
667
- function mempool() {
668
- return _mempool.apply(this, arguments);
669
- }
670
-
671
- function _mempool() {
672
- _mempool = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
673
- return _regeneratorRuntime.wrap(function _callee12$(_context16) {
674
- while (1) {
675
- switch (_context16.prev = _context16.next) {
676
- case 0:
677
- return _context16.abrupt("return", this.api.getPendingTransactions());
678
-
679
- case 1:
680
- case "end":
681
- return _context16.stop();
682
- }
683
- }
684
- }, _callee12, this);
685
- }));
686
- return _mempool.apply(this, arguments);
687
- }
688
-
689
- function getCurrentGeneration() {
690
- return _getCurrentGeneration.apply(this, arguments);
691
- }
692
-
693
- function _getCurrentGeneration() {
694
- _getCurrentGeneration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
695
- return _regeneratorRuntime.wrap(function _callee13$(_context17) {
696
- while (1) {
697
- switch (_context17.prev = _context17.next) {
698
- case 0:
699
- return _context17.abrupt("return", this.api.getCurrentGeneration());
700
-
701
- case 1:
702
- case "end":
703
- return _context17.stop();
704
- }
705
- }
706
- }, _callee13, this);
707
- }));
708
- return _getCurrentGeneration.apply(this, arguments);
709
- }
710
-
711
- function getGeneration(_x10) {
712
- return _getGeneration.apply(this, arguments);
713
- }
714
-
715
- function _getGeneration() {
716
- _getGeneration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(hashOrHeight) {
717
- return _regeneratorRuntime.wrap(function _callee14$(_context18) {
718
- while (1) {
719
- switch (_context18.prev = _context18.next) {
720
- case 0:
721
- if (!(typeof hashOrHeight === 'string')) {
722
- _context18.next = 2;
723
- break;
724
- }
725
-
726
- return _context18.abrupt("return", this.api.getGenerationByHash(hashOrHeight));
727
-
728
- case 2:
729
- if (!(typeof hashOrHeight === 'number')) {
730
- _context18.next = 4;
731
- break;
732
- }
733
-
734
- return _context18.abrupt("return", this.api.getGenerationByHeight(hashOrHeight));
735
-
736
- case 4:
737
- throw new Error('Invalid param, param must be hash or height');
738
-
739
- case 5:
740
- case "end":
741
- return _context18.stop();
742
- }
743
- }
744
- }, _callee14, this);
745
- }));
746
- return _getGeneration.apply(this, arguments);
747
- }
748
-
749
- function getMicroBlockTransactions(_x11) {
750
- return _getMicroBlockTransactions.apply(this, arguments);
751
- }
752
-
753
- function _getMicroBlockTransactions() {
754
- _getMicroBlockTransactions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(hash) {
755
- return _regeneratorRuntime.wrap(function _callee15$(_context19) {
756
- while (1) {
757
- switch (_context19.prev = _context19.next) {
758
- case 0:
759
- _context19.next = 2;
760
- return this.api.getMicroBlockTransactionsByHash(hash);
761
-
762
- case 2:
763
- return _context19.abrupt("return", _context19.sent.transactions);
764
-
765
- case 3:
766
- case "end":
767
- return _context19.stop();
768
- }
769
- }
770
- }, _callee15, this);
771
- }));
772
- return _getMicroBlockTransactions.apply(this, arguments);
773
- }
774
-
775
- function getKeyBlock(_x12) {
776
- return _getKeyBlock.apply(this, arguments);
777
- }
778
-
779
- function _getKeyBlock() {
780
- _getKeyBlock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(hashOrHeight) {
781
- return _regeneratorRuntime.wrap(function _callee16$(_context20) {
782
- while (1) {
783
- switch (_context20.prev = _context20.next) {
784
- case 0:
785
- if (!(typeof hashOrHeight === 'string')) {
786
- _context20.next = 2;
787
- break;
788
- }
789
-
790
- return _context20.abrupt("return", this.api.getKeyBlockByHash(hashOrHeight));
791
-
792
- case 2:
793
- if (!(typeof hashOrHeight === 'number')) {
794
- _context20.next = 4;
795
- break;
796
- }
797
-
798
- return _context20.abrupt("return", this.api.getKeyBlockByHeight(hashOrHeight));
799
-
800
- case 4:
801
- throw new Error('Invalid param, param must be hash or height');
802
-
803
- case 5:
804
- case "end":
805
- return _context20.stop();
806
- }
807
- }
808
- }, _callee16, this);
809
- }));
810
- return _getKeyBlock.apply(this, arguments);
811
- }
812
-
813
- function getMicroBlockHeader(_x13) {
814
- return _getMicroBlockHeader.apply(this, arguments);
815
- }
816
-
817
- function _getMicroBlockHeader() {
818
- _getMicroBlockHeader = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(hash) {
819
- return _regeneratorRuntime.wrap(function _callee17$(_context21) {
820
- while (1) {
821
- switch (_context21.prev = _context21.next) {
822
- case 0:
823
- return _context21.abrupt("return", this.api.getMicroBlockHeaderByHash(hash));
824
-
825
- case 1:
826
- case "end":
827
- return _context21.stop();
828
- }
829
- }
830
- }, _callee17, this);
831
- }));
832
- return _getMicroBlockHeader.apply(this, arguments);
833
- }
834
-
835
- function txDryRun(_x14, _x15, _x16) {
836
- return _txDryRun.apply(this, arguments);
837
- }
838
-
839
- function _txDryRun() {
840
- _txDryRun = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(tx, accountAddress, options) {
841
- var _yield$this$api$prote, _yield$this$api$prote2, _yield$this$api$prote3, result, reason, resultPayload, other;
842
-
843
- return _regeneratorRuntime.wrap(function _callee18$(_context22) {
844
- while (1) {
845
- switch (_context22.prev = _context22.next) {
846
- case 0:
847
- _context22.next = 2;
848
- return this.api.protectedDryRunTxs(_objectSpread(_objectSpread({}, options), {}, {
849
- txs: [{
850
- tx: tx
851
- }],
852
- accounts: [{
853
- pubKey: accountAddress,
854
- amount: DRY_RUN_ACCOUNT.amount
855
- }]
856
- }));
857
-
858
- case 2:
859
- _yield$this$api$prote = _context22.sent;
860
- _yield$this$api$prote2 = _slicedToArray(_yield$this$api$prote.results, 1);
861
- _yield$this$api$prote3 = _yield$this$api$prote2[0];
862
- result = _yield$this$api$prote3.result;
863
- reason = _yield$this$api$prote3.reason;
864
- resultPayload = _objectWithoutProperties(_yield$this$api$prote3, _excluded);
865
- other = _objectWithoutProperties(_yield$this$api$prote, _excluded2);
866
-
867
- if (!(result === 'ok')) {
868
- _context22.next = 11;
869
- break;
870
- }
871
-
872
- return _context22.abrupt("return", _objectSpread(_objectSpread({}, resultPayload), other));
873
-
874
- case 11:
875
- throw _Object$assign(new Error('Dry run error, ' + reason), {
876
- tx: tx,
877
- accountAddress: accountAddress,
878
- options: options
879
- });
880
-
881
- case 12:
882
- case "end":
883
- return _context22.stop();
884
- }
885
- }
886
- }, _callee18, this);
887
- }));
888
- return _txDryRun.apply(this, arguments);
889
- }
890
-
891
- function getContractByteCode(_x17) {
892
- return _getContractByteCode.apply(this, arguments);
893
- }
894
-
895
- function _getContractByteCode() {
896
- _getContractByteCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(contractId) {
897
- return _regeneratorRuntime.wrap(function _callee19$(_context23) {
898
- while (1) {
899
- switch (_context23.prev = _context23.next) {
900
- case 0:
901
- return _context23.abrupt("return", this.api.getContractCode(contractId));
902
-
903
- case 1:
904
- case "end":
905
- return _context23.stop();
906
- }
907
- }
908
- }, _callee19, this);
909
- }));
910
- return _getContractByteCode.apply(this, arguments);
911
- }
912
-
913
- function getContract(_x18) {
914
- return _getContract.apply(this, arguments);
915
- }
916
-
917
- function _getContract() {
918
- _getContract = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(contractId) {
919
- return _regeneratorRuntime.wrap(function _callee20$(_context24) {
920
- while (1) {
921
- switch (_context24.prev = _context24.next) {
922
- case 0:
923
- return _context24.abrupt("return", this.api.getContract(contractId));
924
-
925
- case 1:
926
- case "end":
927
- return _context24.stop();
928
- }
929
- }
930
- }, _callee20, this);
931
- }));
932
- return _getContract.apply(this, arguments);
933
- }
934
-
935
- function getName(_x19) {
936
- return _getName.apply(this, arguments);
937
- }
938
- /**
939
- * Resolve AENS name and return name hash
940
- * @param {String} nameOrId
941
- * @param {String} prefix
942
- * @param {Object} [options]
943
- * @param {Boolean} [options.verify] To ensure that name exist and have a corresponding pointer
944
- * @param {Boolean} [options.resolveByNode] Enables pointer resolving using node // TODO: avoid that to don't trust to current api gateway
945
- * @return {String} Address or AENS name hash
946
- */
947
-
948
-
949
- function _getName() {
950
- _getName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(name) {
951
- return _regeneratorRuntime.wrap(function _callee21$(_context25) {
952
- while (1) {
953
- switch (_context25.prev = _context25.next) {
954
- case 0:
955
- return _context25.abrupt("return", this.api.getNameEntryByName(name));
956
-
957
- case 1:
958
- case "end":
959
- return _context25.stop();
960
- }
961
- }
962
- }, _callee21, this);
963
- }));
964
- return _getName.apply(this, arguments);
965
- }
966
-
967
- function resolveName(_x20, _x21) {
968
- return _resolveName.apply(this, arguments);
969
- }
970
- /**
971
- * ChainNode Stamp
972
- *
973
- * This is implementation of {@link module:@aeternity/aepp-sdk/es/chain--Chain}
974
- * composed with {@link module:@aeternity/aepp-sdk/es/contract/node--ContractNodeAPI} and {@link module:@aeternity/aepp-sdk/es/oracle/node--OracleNodeAPI}
975
- * @function
976
- * @alias module:@aeternity/aepp-sdk/es/chain/node
977
- * @rtype Stamp
978
- * @param {Object} [options={}] - Initializer object
979
- * @return {Object} ChainNode instance
980
- * @example ChainNode({url: 'https://testnet.aeternity.io/'})
981
- */
982
-
983
-
984
- function _resolveName() {
985
- _resolveName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(nameOrId, prefix) {
986
- var _ref6,
987
- verify,
988
- resolveByNode,
989
- prefixes,
990
- _context26,
991
- _context27,
992
- _context28,
993
- name,
994
- pointer,
995
- _args22 = arguments;
996
-
997
- return _regeneratorRuntime.wrap(function _callee22$(_context29) {
998
- while (1) {
999
- switch (_context29.prev = _context29.next) {
1000
- case 0:
1001
- _ref6 = _args22.length > 2 && _args22[2] !== undefined ? _args22[2] : {}, verify = _ref6.verify, resolveByNode = _ref6.resolveByNode;
1002
-
1003
- if (!(!nameOrId || typeof nameOrId !== 'string')) {
1004
- _context29.next = 3;
1005
- break;
1006
- }
1007
-
1008
- throw new Error("Name or address should be a string: ".concat(nameOrId));
1009
-
1010
- case 3:
1011
- prefixes = _Object$keys(NAME_ID_KEY);
1012
-
1013
- if (_includesInstanceProperty(prefixes).call(prefixes, prefix)) {
1014
- _context29.next = 6;
1015
- break;
1016
- }
1017
-
1018
- throw new Error(_concatInstanceProperty(_context26 = "Invalid prefix ".concat(prefix, ", should be one of [")).call(_context26, prefixes, "]"));
1019
-
1020
- case 6:
1021
- _context29.prev = 6;
1022
- decode(nameOrId, prefix);
1023
- return _context29.abrupt("return", nameOrId);
1024
-
1025
- case 11:
1026
- _context29.prev = 11;
1027
- _context29.t0 = _context29["catch"](6);
1028
-
1029
- case 13:
1030
- if (!isNameValid(nameOrId)) {
1031
- _context29.next = 26;
1032
- break;
1033
- }
1034
-
1035
- if (!(verify || resolveByNode)) {
1036
- _context29.next = 25;
1037
- break;
1038
- }
1039
-
1040
- _context29.next = 17;
1041
- return this.getName(nameOrId)["catch"](function (_) {
1042
- return null;
1043
- });
1044
-
1045
- case 17:
1046
- name = _context29.sent;
1047
-
1048
- if (name) {
1049
- _context29.next = 20;
1050
- break;
1051
- }
1052
-
1053
- throw new Error("Name not found: ".concat(nameOrId));
1054
-
1055
- case 20:
1056
- pointer = _findInstanceProperty(_context27 = name.pointers).call(_context27, function (_ref7) {
1057
- var id = _ref7.id;
1058
- return id.split('_')[0] === prefix;
1059
- });
1060
-
1061
- if (pointer) {
1062
- _context29.next = 23;
1063
- break;
1064
- }
1065
-
1066
- throw new Error(_concatInstanceProperty(_context28 = "Name ".concat(nameOrId, " don't have pointers for ")).call(_context28, prefix));
1067
-
1068
- case 23:
1069
- if (!resolveByNode) {
1070
- _context29.next = 25;
1071
- break;
1072
- }
1073
-
1074
- return _context29.abrupt("return", pointer.id);
1075
-
1076
- case 25:
1077
- return _context29.abrupt("return", produceNameId(nameOrId));
1078
-
1079
- case 26:
1080
- throw new Error("Invalid name or address: ".concat(nameOrId));
1081
-
1082
- case 27:
1083
- case "end":
1084
- return _context29.stop();
1085
- }
1086
- }
1087
- }, _callee22, this, [[6, 11]]);
1088
- }));
1089
- return _resolveName.apply(this, arguments);
1090
- }
1091
-
1092
- var ChainNode = Chain.compose(NodePool, {
1093
- methods: {
1094
- sendTransaction: sendTransaction,
1095
- balance: balance,
1096
- getBalance: getBalance,
1097
- getAccount: getAccount,
1098
- topBlock: topBlock,
1099
- tx: tx,
1100
- height: height,
1101
- awaitHeight: awaitHeight,
1102
- poll: poll,
1103
- getTxInfo: getTxInfo,
1104
- mempool: mempool,
1105
- getCurrentGeneration: getCurrentGeneration,
1106
- getGeneration: getGeneration,
1107
- getMicroBlockHeader: getMicroBlockHeader,
1108
- getMicroBlockTransactions: getMicroBlockTransactions,
1109
- getKeyBlock: getKeyBlock,
1110
- txDryRun: txDryRun,
1111
- getContractByteCode: getContractByteCode,
1112
- getContract: getContract,
1113
- getName: getName,
1114
- waitForTxConfirm: waitForTxConfirm,
1115
- resolveName: resolveName
1116
- }
1117
- });
1118
- export default ChainNode;
1119
- //# sourceMappingURL=node.js.map