@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
@@ -37,13 +37,32 @@ import { required } from '@stamp/required'
37
37
  * @return {Object} Chain instance
38
38
  */
39
39
  const Chain = stampit({
40
- deepProps: { Ae: { defaults: { waitMined: true, verify: true } } }
40
+ deepProps: {
41
+ Ae: {
42
+ defaults: {
43
+ waitMined: true,
44
+ verify: true,
45
+ _expectedMineRate: 180000,
46
+ _microBlockCycle: 3000,
47
+ _maxPollInterval: 5000
48
+ }
49
+ }
50
+ },
51
+ methods: {
52
+ _getPollInterval (type) {
53
+ const base = {
54
+ block: this.Ae.defaults._expectedMineRate,
55
+ microblock: this.Ae.defaults._microBlockCycle
56
+ }[type]
57
+ if (!base) throw new Error(`Unknown poll type: ${type}`)
58
+ return Math.min(base / 3, this.Ae.defaults._maxPollInterval)
59
+ }
60
+ }
41
61
  }, required({
42
62
  methods: {
43
63
  sendTransaction: required,
44
64
  height: required,
45
65
  awaitHeight: required,
46
- topBlock: required,
47
66
  poll: required,
48
67
  balance: required,
49
68
  getBalance: required,
@@ -113,8 +132,10 @@ const Chain = stampit({
113
132
  * @rtype (address: String, options?: Object) => balance: Number
114
133
  * @param {String} address - The public account address to obtain the balance for
115
134
  * @param {Object} [options={}] - Options
116
- * @param {Number} options.height - The chain height at which to obtain the balance for (default: top of chain)
117
- * @param {String} options.hash - The block hash on which to obtain the balance for (default: top of chain)
135
+ * @param {Number} options.height - The chain height at which to obtain the balance for (default:
136
+ * top of chain)
137
+ * @param {String} options.hash - The block hash on which to obtain the balance for (default: top
138
+ * of chain)
118
139
  * @return {Object} The transaction as it was mined
119
140
  */
120
141
 
@@ -126,7 +147,8 @@ const Chain = stampit({
126
147
  * @category async
127
148
  * @rtype (hash: String, info = false) => tx: Object
128
149
  * @param {String} hash - Transaction hash
129
- * @param {Boolean} info - Retrieve additional transaction date. Works only for (ContractCreate and ContractCall transaction's)
150
+ * @param {Boolean} info - Retrieve additional transaction date. Works only for (ContractCreate and
151
+ * ContractCall transaction's)
130
152
  * @return {Object} Transaction
131
153
  */
132
154
 
@@ -239,7 +261,8 @@ const Chain = stampit({
239
261
  * @param {String} tx - transaction to execute
240
262
  * @param {String} accountAddress - address that will be used to execute transaction
241
263
  * @param {String|Number} [options.top] - hash of block on which to make dry-run
242
- * @param {Boolean} [options.txEvents] - collect and return on-chain tx events that would result from the call
264
+ * @param {Boolean} [options.txEvents] - collect and return on-chain tx events that would result
265
+ * from the call
243
266
  * @return {Object} Result
244
267
  */
245
268
 
package/src/chain/node.js CHANGED
@@ -14,15 +14,23 @@
14
14
  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
15
  * PERFORMANCE OF THIS SOFTWARE.
16
16
  */
17
- import * as R from 'ramda'
18
-
19
17
  import Chain from './'
20
18
  import { AE_AMOUNT_FORMATS, formatAmount } from '../utils/amount-formatter'
21
19
  import verifyTransaction from '../tx/validator'
22
20
  import NodePool from '../node-pool'
23
21
  import { pause } from '../utils/other'
24
22
  import { isNameValid, produceNameId, decode } from '../tx/builder/helpers'
25
- import { DRY_RUN_ACCOUNT, NAME_ID_KEY } from '../tx/builder/schema'
23
+ import { DRY_RUN_ACCOUNT } from '../tx/builder/schema'
24
+ import {
25
+ AensPointerContextError,
26
+ DryRunError,
27
+ InvalidAensNameError,
28
+ InvalidTxError,
29
+ RequestTimedOutError,
30
+ TxTimedOutError,
31
+ TxNotInChainError,
32
+ ArgumentError
33
+ } from '../utils/errors'
26
34
 
27
35
  /**
28
36
  * ChainNode module
@@ -34,13 +42,13 @@ import { DRY_RUN_ACCOUNT, NAME_ID_KEY } from '../tx/builder/schema'
34
42
  */
35
43
 
36
44
  async function sendTransaction (tx, options = {}) {
37
- const { waitMined, verify } = R.merge(this.Ae.defaults, options)
38
- if (verify) {
45
+ const opt = { ...this.Ae.defaults, ...options }
46
+ if (opt.verify) {
39
47
  const validation = await verifyTransaction(tx, this.selectedNode.instance)
40
48
  if (validation.length) {
41
49
  const message = 'Transaction verification errors: ' +
42
50
  validation.map(v => v.message).join(', ')
43
- throw Object.assign(new Error(message), {
51
+ throw Object.assign(new InvalidTxError(message), {
44
52
  code: 'TX_VERIFICATION_ERROR',
45
53
  validation,
46
54
  transaction: tx
@@ -49,9 +57,11 @@ async function sendTransaction (tx, options = {}) {
49
57
  }
50
58
 
51
59
  try {
52
- const { txHash } = await this.api.postTransaction({ tx })
60
+ const { txHash } = await this.api.postTransaction({ tx }, {
61
+ __queue: `tx-${await this.address?.(options).catch(() => '')}`
62
+ })
53
63
 
54
- if (waitMined) {
64
+ if (opt.waitMined) {
55
65
  const txData = { ...await this.poll(txHash, options), rawTx: tx }
56
66
  // wait for transaction confirmation
57
67
  if (options.confirm) {
@@ -61,18 +71,21 @@ async function sendTransaction (tx, options = {}) {
61
71
  }
62
72
  return { hash: txHash, rawTx: tx }
63
73
  } catch (error) {
64
- throw Object.assign(error, { rawTx: tx, verifyTx: () => verifyTransaction(tx, this.selectedNode.instance) })
74
+ throw Object.assign(error, {
75
+ rawTx: tx,
76
+ verifyTx: () => verifyTransaction(tx, this.selectedNode.instance)
77
+ })
65
78
  }
66
79
  }
67
80
 
68
81
  async function waitForTxConfirm (txHash, options = { confirm: 3 }) {
69
82
  options.confirm = options.confirm === true ? 3 : options.confirm
70
- const { blockHeight } = await this.tx(txHash)
83
+ const { blockHeight } = await this.api.getTransactionByHash(txHash)
71
84
  const height = await this.awaitHeight(blockHeight + options.confirm, options)
72
- const { blockHeight: newBlockHeight } = await this.tx(txHash)
85
+ const { blockHeight: newBlockHeight } = await this.api.getTransactionByHash(txHash)
73
86
  switch (newBlockHeight) {
74
87
  case -1:
75
- throw new Error(`Transaction ${txHash} is removed from chain`)
88
+ throw new TxNotInChainError(txHash)
76
89
  case blockHeight:
77
90
  return height
78
91
  default:
@@ -102,6 +115,9 @@ async function getBalance (address, { height, hash, format = AE_AMOUNT_FORMATS.A
102
115
  return formatAmount(balance, { targetDenomination: format }).toString()
103
116
  }
104
117
 
118
+ /**
119
+ * @deprecated use `sdk.api.getTransactionByHash/getTransactionInfoByHash` instead
120
+ */
105
121
  async function tx (hash, info = true) {
106
122
  const tx = await this.api.getTransactionByHash(hash)
107
123
  if (['ContractCreateTx', 'ContractCallTx', 'ChannelForceProgressTx'].includes(tx.tx.type) && info && tx.blockHeight !== -1) {
@@ -113,45 +129,36 @@ async function tx (hash, info = true) {
113
129
  }
114
130
 
115
131
  async function height () {
116
- try {
117
- if (!this._heightPromise) {
118
- this._heightPromise = this.api.getCurrentKeyBlockHeight()
119
- }
120
- return (await this._heightPromise).height
121
- } finally {
122
- delete this._heightPromise
123
- }
132
+ return (await this.api.getCurrentKeyBlockHeight()).height
124
133
  }
125
134
 
126
- async function awaitHeight (height, { interval = 5000, attempts = 20 } = {}) {
135
+ async function awaitHeight (
136
+ height,
137
+ { interval = this._getPollInterval('block'), attempts = 20 } = {}
138
+ ) {
127
139
  let currentHeight
128
140
  for (let i = 0; i < attempts; i++) {
129
141
  if (i) await pause(interval)
130
142
  currentHeight = await this.height()
131
143
  if (currentHeight >= height) return currentHeight
132
144
  }
133
- throw new Error(`Giving up after ${(attempts - 1) * interval}ms, current height: ${currentHeight}, desired height: ${height}`)
134
- }
135
-
136
- /**
137
- * @deprecated
138
- */
139
- async function topBlock () {
140
- return this.api.getTopHeader()
145
+ throw new RequestTimedOutError((attempts - 1) * interval, currentHeight, height)
141
146
  }
142
147
 
143
- async function poll (th, { blocks = 10, interval = 5000, allowUnsynced = false } = {}) {
148
+ async function poll (th, { blocks = 10, interval = this._getPollInterval('microblock') } = {}) {
144
149
  const max = await this.height() + blocks
145
150
  do {
146
- const tx = await this.tx(th).catch(_ => null)
147
- if (tx && (tx.blockHeight !== -1 || (allowUnsynced && tx.height))) {
148
- return tx
149
- }
151
+ const tx = await this.api.getTransactionByHash(th)
152
+ if (tx.blockHeight !== -1) return tx
150
153
  await pause(interval)
151
154
  } while (await this.height() < max)
152
- throw new Error(`Giving up after ${blocks} blocks mined, transaction hash: ${th}`)
155
+ const status = this.api.getCheckTxInPool && (await this.api.getCheckTxInPool(th)).status
156
+ throw new TxTimedOutError(blocks, th, status)
153
157
  }
154
158
 
159
+ /**
160
+ * @deprecated use `sdk.api.getTransactionInfoByHash` instead
161
+ */
155
162
  async function getTxInfo (hash) {
156
163
  const result = await this.api.getTransactionInfoByHash(hash)
157
164
  return result.callInfo || result
@@ -168,7 +175,7 @@ async function getCurrentGeneration () {
168
175
  async function getGeneration (hashOrHeight) {
169
176
  if (typeof hashOrHeight === 'string') return this.api.getGenerationByHash(hashOrHeight)
170
177
  if (typeof hashOrHeight === 'number') return this.api.getGenerationByHeight(hashOrHeight)
171
- throw new Error('Invalid param, param must be hash or height')
178
+ throw new ArgumentError('hashOrHeight', 'a string or number', hashOrHeight)
172
179
  }
173
180
 
174
181
  async function getMicroBlockTransactions (hash) {
@@ -178,30 +185,53 @@ async function getMicroBlockTransactions (hash) {
178
185
  async function getKeyBlock (hashOrHeight) {
179
186
  if (typeof hashOrHeight === 'string') return this.api.getKeyBlockByHash(hashOrHeight)
180
187
  if (typeof hashOrHeight === 'number') return this.api.getKeyBlockByHeight(hashOrHeight)
181
- throw new Error('Invalid param, param must be hash or height')
188
+ throw new ArgumentError('hashOrHeight', 'a string or number', hashOrHeight)
182
189
  }
183
190
 
184
191
  async function getMicroBlockHeader (hash) {
185
192
  return this.api.getMicroBlockHeaderByHash(hash)
186
193
  }
187
194
 
188
- async function txDryRun (tx, accountAddress, options) {
189
- const { results: [{ result, reason, ...resultPayload }], ...other } =
190
- await this.api.protectedDryRunTxs({
191
- ...options,
192
- txs: [{ tx }],
193
- accounts: [{
194
- pubKey: accountAddress,
195
- amount: DRY_RUN_ACCOUNT.amount
196
- }]
195
+ async function txDryRunHandler (key) {
196
+ const rs = this._txDryRun[key]
197
+ delete this._txDryRun[key]
198
+
199
+ let dryRunRes
200
+ try {
201
+ dryRunRes = await this.api.protectedDryRunTxs({
202
+ top: rs[0].top,
203
+ txEvents: rs[0].txEvents,
204
+ txs: rs.map(req => ({ tx: req.tx })),
205
+ accounts: Array.from(new Set(rs.map(req => req.accountAddress)))
206
+ .map(pubKey => ({ pubKey, amount: DRY_RUN_ACCOUNT.amount }))
197
207
  })
208
+ } catch (error) {
209
+ rs.forEach(({ reject }) => reject(error))
210
+ return
211
+ }
198
212
 
199
- if (result === 'ok') return { ...resultPayload, ...other }
213
+ const { results, txEvents } = dryRunRes
214
+ results.forEach(({ result, reason, ...resultPayload }, idx) => {
215
+ const { resolve, reject, tx, options, accountAddress } = rs[idx]
216
+ if (result === 'ok') return resolve({ ...resultPayload, txEvents })
217
+ reject(Object.assign(
218
+ new DryRunError(reason), { tx, accountAddress, options }
219
+ ))
220
+ })
221
+ }
200
222
 
201
- throw Object.assign(
202
- new Error('Dry run error, ' + reason),
203
- { tx, accountAddress, options }
204
- )
223
+ async function txDryRun (tx, accountAddress, { top, txEvents, combine }) {
224
+ const key = combine ? [top, txEvents].join() : 'immediate'
225
+ this._txDryRun ??= {}
226
+ this._txDryRun[key] ??= []
227
+ return new Promise((resolve, reject) => {
228
+ this._txDryRun[key].push({ tx, accountAddress, top, txEvents, resolve, reject })
229
+ if (!combine) {
230
+ txDryRunHandler.call(this, key)
231
+ return
232
+ }
233
+ this._txDryRun[key].timeout ??= setTimeout(txDryRunHandler.bind(this, key))
234
+ })
205
235
  }
206
236
 
207
237
  async function getContractByteCode (contractId) {
@@ -219,42 +249,41 @@ async function getName (name) {
219
249
  /**
220
250
  * Resolve AENS name and return name hash
221
251
  * @param {String} nameOrId
222
- * @param {String} prefix
252
+ * @param {String} key in AENS pointers record
223
253
  * @param {Object} [options]
224
254
  * @param {Boolean} [options.verify] To ensure that name exist and have a corresponding pointer
225
- * @param {Boolean} [options.resolveByNode] Enables pointer resolving using node // TODO: avoid that to don't trust to current api gateway
255
+ * // TODO: avoid that to don't trust to current api gateway
256
+ * @param {Boolean} [options.resolveByNode] Enables pointer resolving using node
226
257
  * @return {String} Address or AENS name hash
227
258
  */
228
- async function resolveName (nameOrId, prefix, { verify, resolveByNode } = {}) {
259
+ async function resolveName (nameOrId, key, { verify, resolveByNode } = {}) {
229
260
  if (!nameOrId || typeof nameOrId !== 'string') {
230
- throw new Error(`Name or address should be a string: ${nameOrId}`)
231
- }
232
- const prefixes = Object.keys(NAME_ID_KEY)
233
- if (!prefixes.includes(prefix)) {
234
- throw new Error(`Invalid prefix ${prefix}, should be one of [${prefixes}]`)
261
+ throw new InvalidAensNameError(`Name or address should be a string: ${nameOrId}`)
235
262
  }
236
263
  try {
237
- decode(nameOrId, prefix)
264
+ decode(nameOrId)
238
265
  return nameOrId
239
266
  } catch (error) {}
240
267
  if (isNameValid(nameOrId)) {
241
268
  if (verify || resolveByNode) {
242
- const name = await this.getName(nameOrId).catch(_ => null)
243
- if (!name) throw new Error(`Name not found: ${nameOrId}`)
244
- const pointer = name.pointers.find(({ id }) => id.split('_')[0] === prefix)
245
- if (!pointer) throw new Error(`Name ${nameOrId} don't have pointers for ${prefix}`)
269
+ const name = await this.api.getNameEntryByName(nameOrId)
270
+ const pointer = name.pointers.find(pointer => pointer.key === key)
271
+ if (!pointer) {
272
+ throw new AensPointerContextError(`Name ${nameOrId} don't have pointers for ${key}`)
273
+ }
246
274
  if (resolveByNode) return pointer.id
247
275
  }
248
276
  return produceNameId(nameOrId)
249
277
  }
250
- throw new Error(`Invalid name or address: ${nameOrId}`)
278
+ throw new InvalidAensNameError(`Invalid name or address: ${nameOrId}`)
251
279
  }
252
280
 
253
281
  /**
254
282
  * ChainNode Stamp
255
283
  *
256
284
  * This is implementation of {@link module:@aeternity/aepp-sdk/es/chain--Chain}
257
- * composed with {@link module:@aeternity/aepp-sdk/es/contract/node--ContractNodeAPI} and {@link module:@aeternity/aepp-sdk/es/oracle/node--OracleNodeAPI}
285
+ * composed with {@link module:@aeternity/aepp-sdk/es/contract/node--ContractNodeAPI} and
286
+ * {@link module:@aeternity/aepp-sdk/es/oracle/node--OracleNodeAPI}
258
287
  * @function
259
288
  * @alias module:@aeternity/aepp-sdk/es/chain/node
260
289
  * @rtype Stamp
@@ -268,7 +297,6 @@ const ChainNode = Chain.compose(NodePool, {
268
297
  balance,
269
298
  getBalance,
270
299
  getAccount,
271
- topBlock,
272
300
  tx,
273
301
  height,
274
302
  awaitHeight,
@@ -15,7 +15,7 @@
15
15
  * PERFORMANCE OF THIS SOFTWARE.
16
16
  */
17
17
 
18
- import { generateKeyPair, encodeContractAddress, encodeBase64Check } from '../utils/crypto'
18
+ import { generateKeyPair, encodeContractAddress } from '../utils/crypto'
19
19
  import {
20
20
  options,
21
21
  changeStatus,
@@ -28,20 +28,23 @@ import {
28
28
  fsmId
29
29
  } from './internal'
30
30
  import { unpackTx, buildTx } from '../tx/builder'
31
-
32
- function encodeRlpTx (rlpBinary) {
33
- return `tx_${encodeBase64Check(rlpBinary)}`
34
- }
31
+ import { encode } from '../tx/builder/helpers'
32
+ import {
33
+ IllegalArgumentError,
34
+ InsufficientBalanceError,
35
+ ChannelConnectionError,
36
+ UnexpectedChannelMessageError
37
+ } from '../utils/errors'
35
38
 
36
39
  async function appendSignature (tx, signFn) {
37
40
  const { signatures, encodedTx } = unpackTx(tx).tx
38
- const result = await signFn(encodeRlpTx(encodedTx.rlpEncoded))
41
+ const result = await signFn(encode(encodedTx.rlpEncoded, 'tx'))
39
42
  if (typeof result === 'string') {
40
43
  const { tx: signedTx, txType } = unpackTx(result)
41
- return encodeRlpTx(buildTx({
44
+ return buildTx({
42
45
  signatures: signatures.concat(signedTx.signatures),
43
46
  encodedTx: signedTx.encodedTx.rlpEncoded
44
- }, txType).rlpEncoded)
47
+ }, txType).tx
45
48
  }
46
49
  return result
47
50
  }
@@ -49,7 +52,7 @@ async function appendSignature (tx, signFn) {
49
52
  function handleUnexpectedMessage (channel, message, state) {
50
53
  if (state && state.reject) {
51
54
  state.reject(Object.assign(
52
- new Error(`Unexpected message received:\n\n${JSON.stringify(message)}`),
55
+ new UnexpectedChannelMessageError(`Unexpected message received:\n\n${JSON.stringify(message)}`),
53
56
  { wsMessage: message }
54
57
  ))
55
58
  }
@@ -75,7 +78,7 @@ export function awaitingConnection (channel, message, state) {
75
78
  return { handler: awaitingConnection }
76
79
  }
77
80
  if (message.method === 'channels.error') {
78
- emit(channel, 'error', new Error(message.payload.message))
81
+ emit(channel, 'error', new ChannelConnectionError(message.payload.message))
79
82
  return { handler: channelClosed }
80
83
  }
81
84
  }
@@ -102,7 +105,9 @@ export async function awaitingChannelCreateTx (channel, message, state) {
102
105
  send(channel, { jsonrpc: '2.0', method: `channels.${tag}`, params: { tx: signedTx } })
103
106
  return { handler: awaitingOnChainTx }
104
107
  }
105
- const signedTx = await appendSignature(message.params.data.signed_tx, tx => options.get(channel).sign(tag, tx))
108
+ const signedTx = await appendSignature(
109
+ message.params.data.signed_tx, tx => options.get(channel).sign(tag, tx)
110
+ )
106
111
  send(channel, { jsonrpc: '2.0', method: `channels.${tag}`, params: { signed_tx: signedTx } })
107
112
  return { handler: awaitingOnChainTx }
108
113
  }
@@ -249,17 +254,17 @@ export async function awaitingOffChainTx (channel, message, state) {
249
254
  }
250
255
  }
251
256
  if (message.method === 'channels.error') {
252
- state.reject(new Error(message.data.message))
257
+ state.reject(new ChannelConnectionError(message.data.message))
253
258
  return { handler: channelOpen }
254
259
  }
255
260
  if (message.error) {
256
261
  const { data = [] } = message.error
257
262
  if (data.find(i => i.code === 1001)) {
258
- state.reject(new Error('Insufficient balance'))
263
+ state.reject(new InsufficientBalanceError('Insufficient balance'))
259
264
  } else if (data.find(i => i.code === 1002)) {
260
- state.reject(new Error('Amount cannot be negative'))
265
+ state.reject(new IllegalArgumentError('Amount cannot be negative'))
261
266
  } else {
262
- state.reject(new Error(message.error.message))
267
+ state.reject(new ChannelConnectionError(message.error.message))
263
268
  }
264
269
  return { handler: channelOpen }
265
270
  }
@@ -301,7 +306,7 @@ export function awaitingOffChainUpdate (channel, message, state) {
301
306
  }
302
307
  }
303
308
  if (message.error) {
304
- state.reject(new Error(message.error.message))
309
+ state.reject(new ChannelConnectionError(message.error.message))
305
310
  return { handler: channelOpen }
306
311
  }
307
312
  return handleUnexpectedMessage(channel, message, state)
@@ -385,7 +390,7 @@ export function awaitingLeave (channel, message, state) {
385
390
  return { handler: channelClosed }
386
391
  }
387
392
  if (message.method === 'channels.error') {
388
- state.reject(new Error(message.data.message))
393
+ state.reject(new ChannelConnectionError(message.data.message))
389
394
  return { handler: channelOpen }
390
395
  }
391
396
  return handleUnexpectedMessage(channel, message, state)
@@ -574,11 +579,16 @@ export function awaitingNewContractCompletion (channel, message, state) {
574
579
  export async function awaitingCallContractUpdateTx (channel, message, state) {
575
580
  if (message.method === 'channels.sign.update') {
576
581
  if (message.params.data.tx) {
577
- const signedTx = await state.sign(message.params.data.tx, { updates: message.params.data.updates })
582
+ const signedTx = await state.sign(
583
+ message.params.data.tx, { updates: message.params.data.updates }
584
+ )
578
585
  send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { tx: signedTx } })
579
586
  return { handler: awaitingCallContractCompletion, state }
580
587
  }
581
- const signedTx = await appendSignature(message.params.data.signed_tx, tx => state.sign(tx, { updates: message.params.data.updates }))
588
+ const signedTx = await appendSignature(
589
+ message.params.data.signed_tx,
590
+ tx => state.sign(tx, { updates: message.params.data.updates })
591
+ )
582
592
  if (typeof signedTx === 'string') {
583
593
  send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { signed_tx: signedTx } })
584
594
  return { handler: awaitingCallContractCompletion, state }
@@ -603,7 +613,6 @@ export async function awaitingCallContractForceProgressUpdate (channel, message,
603
613
  }
604
614
 
605
615
  export function awaitingForceProgressCompletion (channel, message, state) {
606
- console.log('From force progress await completion ->', message)
607
616
  if (message.method === 'channels.on_chain_tx') {
608
617
  if (state.onOnChainTx) {
609
618
  state.onOnChainTx(message.params.data)
@@ -645,7 +654,7 @@ export function awaitingCallsPruned (channels, message, state) {
645
654
  state.resolve()
646
655
  return { handler: channelOpen }
647
656
  }
648
- state.reject(new Error('Unexpected message received'))
657
+ state.reject(new UnexpectedChannelMessageError('Unexpected message received'))
649
658
  return { handler: channelClosed }
650
659
  }
651
660
 
@@ -39,7 +39,6 @@ import {
39
39
  disconnect as channelDisconnect,
40
40
  fsmId as channelFsmId
41
41
  } from './internal'
42
- import * as R from 'ramda'
43
42
 
44
43
  function snakeToPascalObjKeys (obj) {
45
44
  return Object.entries(obj).reduce((result, [key, val]) => ({
@@ -238,10 +237,10 @@ async function poi ({ accounts, contracts }) {
238
237
  * )
239
238
  */
240
239
  async function balances (accounts) {
241
- return R.reduce((acc, item) => ({
242
- ...acc,
243
- [item.account]: item.balance
244
- }), {}, await call(this, 'channels.get.balances', { accounts }))
240
+ return Object.fromEntries(
241
+ (await call(this, 'channels.get.balances', { accounts }))
242
+ .map(item => [item.account, item.balance])
243
+ )
245
244
  }
246
245
 
247
246
  /**
@@ -339,7 +338,8 @@ function shutdown (sign) {
339
338
  * @param {Number} amount - Amount of tokens to withdraw
340
339
  * @param {Function} sign - Function which verifies and signs withdraw transaction
341
340
  * @param {Object} [callbacks]
342
- * @param {Function} [callbacks.onOnChainTx] - Called when withdraw transaction has been posted on chain
341
+ * @param {Function} [callbacks.onOnChainTx] - Called when withdraw transaction has been posted
342
+ * on chain
343
343
  * @param {Function} [callbacks.onOwnWithdrawLocked]
344
344
  * @param {Function} [callbacks.onWithdrawLocked]
345
345
  * @return {Promise<Object>}
@@ -408,7 +408,8 @@ function withdraw (amount, sign, { onOnChainTx, onOwnWithdrawLocked, onWithdrawL
408
408
  * @param {Number} amount - Amount of tokens to deposit
409
409
  * @param {Function} sign - Function which verifies and signs deposit transaction
410
410
  * @param {Object} [callbacks]
411
- * @param {Function} [callbacks.onOnChainTx] - Called when deposit transaction has been posted on chain
411
+ * @param {Function} [callbacks.onOnChainTx] - Called when deposit transaction has been posted
412
+ * on chain
412
413
  * @param {Function} [callbacks.onOwnDepositLocked]
413
414
  * @param {Function} [callbacks.onDepositLocked]
414
415
  * @return {Promise<Object>}
@@ -598,7 +599,11 @@ function callContract ({ amount, callData, contract, abiVersion }, sign) {
598
599
  * }
599
600
  * })
600
601
  */
601
- function forceProgress ({ amount, callData, contract, abiVersion, gas = 1000000, gasPrice = 1000000000, nonce }, sign, { onOnChainTx } = {}) {
602
+ function forceProgress (
603
+ { amount, callData, contract, abiVersion, gas = 1000000, gasPrice = 1000000000, nonce },
604
+ sign,
605
+ { onOnChainTx } = {}
606
+ ) {
602
607
  return new Promise((resolve, reject) => {
603
608
  enqueueAction(
604
609
  this,
@@ -801,23 +806,42 @@ async function reconnect (options, txParams) {
801
806
  * @param {String} options.initiatorId - Initiator's public key
802
807
  * @param {String} options.responderId - Responder's public key
803
808
  * @param {Number} options.pushAmount - Initial deposit in favour of the responder by the initiator
804
- * @param {Number} options.initiatorAmount - Amount of tokens the initiator has committed to the channel
805
- * @param {Number} options.responderAmount - Amount of tokens the responder has committed to the channel
809
+ * @param {Number} options.initiatorAmount - Amount of tokens the initiator has committed to
810
+ * the channel
811
+ * @param {Number} options.responderAmount - Amount of tokens the responder has committed to
812
+ * the channel
806
813
  * @param {Number} options.channelReserve - The minimum amount both peers need to maintain
807
814
  * @param {Number} [options.ttl] - Minimum block height to include the channel_create_tx
808
815
  * @param {String} options.host - Host of the responder's node
809
816
  * @param {Number} options.port - The port of the responders node
810
817
  * @param {Number} options.lockPeriod - Amount of blocks for disputing a solo close
811
- * @param {Number} [options.existingChannelId] - Existing channel id (required if reestablishing a channel)
812
- * @param {Number} [options.offchainTx] - Offchain transaction (required if reestablishing a channel)
813
- * @param {Number} [options.timeoutIdle] - The time waiting for a new event to be initiated (default: 600000)
814
- * @param {Number} [options.timeoutFundingCreate] - The time waiting for the initiator to produce the create channel transaction after the noise session had been established (default: 120000)
815
- * @param {Number} [options.timeoutFundingSign] - The time frame the other client has to sign an off-chain update after our client had initiated and signed it. This applies only for double signed on-chain intended updates: channel create transaction, deposit, withdrawal and etc. (default: 120000)
816
- * @param {Number} [options.timeoutFundingLock] - The time frame the other client has to confirm an on-chain transaction reaching maturity (passing minimum depth) after the local node has detected this. This applies only for double signed on-chain intended updates: channel create transaction, deposit, withdrawal and etc. (default: 360000)
817
- * @param {Number} [options.timeoutSign] - The time frame the client has to return a signed off-chain update or to decline it. This applies for all off-chain updates (default: 500000)
818
- * @param {Number} [options.timeoutAccept] - The time frame the other client has to react to an event. This applies for all off-chain updates that are not meant to land on-chain, as well as some special cases: opening a noise connection, mutual closing acknowledgement and reestablishing an existing channel (default: 120000)
819
- * @param {Number} [options.timeoutInitialized] - the time frame the responder has to accept an incoming noise session. Applicable only for initiator (default: timeout_accept's value)
820
- * @param {Number} [options.timeoutAwaitingOpen] - The time frame the initiator has to start an outgoing noise session to the responder's node. Applicable only for responder (default: timeout_idle's value)
818
+ * @param {Number} [options.existingChannelId] - Existing channel id (required if reestablishing a
819
+ * channel)
820
+ * @param {Number} [options.offchainTx] - Offchain transaction (required if reestablishing
821
+ * a channel)
822
+ * @param {Number} [options.timeoutIdle] - The time waiting for a new event to be initiated
823
+ * (default: 600000)
824
+ * @param {Number} [options.timeoutFundingCreate] - The time waiting for the initiator to produce
825
+ * the create channel transaction after the noise session had been established (default: 120000)
826
+ * @param {Number} [options.timeoutFundingSign] - The time frame the other client has to sign an
827
+ * off-chain update after our client had initiated and signed it. This applies only for double
828
+ * signed on-chain intended updates: channel create transaction, deposit, withdrawal and etc.
829
+ * (default: 120000)
830
+ * @param {Number} [options.timeoutFundingLock] - The time frame the other client has to confirm an
831
+ * on-chain transaction reaching maturity (passing minimum depth) after the local node has detected
832
+ * this. This applies only for double signed on-chain intended updates: channel create transaction,
833
+ * deposit, withdrawal and etc. (default: 360000)
834
+ * @param {Number} [options.timeoutSign] - The time frame the client has to return a signed
835
+ * off-chain update or to decline it. This applies for all off-chain updates (default: 500000)
836
+ * @param {Number} [options.timeoutAccept] - The time frame the other client has to react to an
837
+ * event. This applies for all off-chain updates that are not meant to land on-chain, as well as
838
+ * some special cases: opening a noise connection, mutual closing acknowledgement and
839
+ * reestablishing an existing channel (default: 120000)
840
+ * @param {Number} [options.timeoutInitialized] - the time frame the responder has to accept an
841
+ * incoming noise session. Applicable only for initiator (default: timeout_accept's value)
842
+ * @param {Number} [options.timeoutAwaitingOpen] - The time frame the initiator has to start an
843
+ * outgoing noise session to the responder's node. Applicable only for responder (default:
844
+ * timeout_idle's value)
821
845
  * @param {Number} [options.debug=false] - Log websocket communication
822
846
  * @param {Function} options.sign - Function which verifies and signs transactions
823
847
  * @return {Promise<Object>} Channel instance