@aeternity/aepp-sdk 8.2.1 → 10.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 (159) hide show
  1. package/CHANGELOG.md +216 -337
  2. package/README.md +16 -9
  3. package/dist/aepp-sdk.browser-script.js +1 -1
  4. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -9
  5. package/dist/aepp-sdk.browser-script.js.map +1 -1
  6. package/dist/aepp-sdk.browser.js +1 -1
  7. package/dist/aepp-sdk.browser.js.map +1 -1
  8. package/dist/aepp-sdk.js +1 -1
  9. package/dist/aepp-sdk.js.map +1 -1
  10. package/es/account/base.js +36 -120
  11. package/es/account/base.js.map +1 -1
  12. package/es/account/memory.js +17 -19
  13. package/es/account/memory.js.map +1 -1
  14. package/es/account/multiple.js +79 -156
  15. package/es/account/multiple.js.map +1 -1
  16. package/es/ae/aens.js +205 -626
  17. package/es/ae/aens.js.map +1 -1
  18. package/es/ae/contract.js +114 -918
  19. package/es/ae/contract.js.map +1 -1
  20. package/es/ae/index.js +90 -250
  21. package/es/ae/index.js.map +1 -1
  22. package/es/ae/oracle.js +136 -504
  23. package/es/ae/oracle.js.map +1 -1
  24. package/es/ae/universal.js.map +1 -1
  25. package/es/chain/index.js +12 -27
  26. package/es/chain/index.js.map +1 -1
  27. package/es/chain/node.js +289 -1020
  28. package/es/chain/node.js.map +1 -1
  29. package/es/channel/handlers.js +597 -1086
  30. package/es/channel/handlers.js.map +1 -1
  31. package/es/channel/index.js +238 -465
  32. package/es/channel/index.js.map +1 -1
  33. package/es/channel/internal.js +129 -301
  34. package/es/channel/internal.js.map +1 -1
  35. package/es/contract/aci/index.js +328 -495
  36. package/es/contract/aci/index.js.map +1 -1
  37. package/es/contract/aci/transformation.js +35 -711
  38. package/es/contract/aci/transformation.js.map +1 -1
  39. package/es/contract/compiler.js +131 -203
  40. package/es/contract/compiler.js.map +1 -1
  41. package/es/contract/ga/helpers.js +17 -122
  42. package/es/contract/ga/helpers.js.map +1 -1
  43. package/es/contract/ga/index.js +108 -249
  44. package/es/contract/ga/index.js.map +1 -1
  45. package/es/contract/index.js +7 -3
  46. package/es/contract/index.js.map +1 -1
  47. package/es/index.js +3 -3
  48. package/es/index.js.map +1 -1
  49. package/es/node-pool/index.js +57 -74
  50. package/es/node-pool/index.js.map +1 -1
  51. package/es/node.js +65 -161
  52. package/es/node.js.map +1 -1
  53. package/es/other.d.ts +1 -1
  54. package/es/tx/builder/helpers.js +62 -115
  55. package/es/tx/builder/helpers.js.map +1 -1
  56. package/es/tx/builder/index.js +218 -309
  57. package/es/tx/builder/index.js.map +1 -1
  58. package/es/tx/builder/schema.js +586 -573
  59. package/es/tx/builder/schema.js.map +1 -1
  60. package/es/tx/index.js +102 -13
  61. package/es/tx/index.js.map +1 -1
  62. package/es/tx/tx-object.js +114 -138
  63. package/es/tx/tx-object.js.map +1 -1
  64. package/es/tx/tx.js +810 -1586
  65. package/es/tx/tx.js.map +1 -1
  66. package/es/tx/validator.js +191 -426
  67. package/es/tx/validator.js.map +1 -1
  68. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +20 -23
  69. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +1 -1
  70. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +53 -80
  71. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +1 -1
  72. package/es/utils/aepp-wallet-communication/connection/index.js +2 -1
  73. package/es/utils/aepp-wallet-communication/connection/index.js.map +1 -1
  74. package/es/utils/aepp-wallet-communication/content-script-bridge.js +24 -19
  75. package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +1 -1
  76. package/es/utils/aepp-wallet-communication/helpers.js +60 -105
  77. package/es/utils/aepp-wallet-communication/helpers.js.map +1 -1
  78. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +191 -514
  79. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +1 -1
  80. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +78 -93
  81. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +1 -1
  82. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +381 -613
  83. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +1 -1
  84. package/es/utils/aepp-wallet-communication/schema.js +43 -39
  85. package/es/utils/aepp-wallet-communication/schema.js.map +1 -1
  86. package/es/utils/aepp-wallet-communication/wallet-detector.js +32 -58
  87. package/es/utils/aepp-wallet-communication/wallet-detector.js.map +1 -1
  88. package/es/utils/amount-formatter.js +41 -61
  89. package/es/utils/amount-formatter.js.map +1 -1
  90. package/es/utils/async-init.js +28 -64
  91. package/es/utils/async-init.js.map +1 -1
  92. package/es/utils/bignumber.js +3 -11
  93. package/es/utils/bignumber.js.map +1 -1
  94. package/es/utils/bytes.js +5 -9
  95. package/es/utils/bytes.js.map +1 -1
  96. package/es/utils/crypto.js +41 -106
  97. package/es/utils/crypto.js.map +1 -1
  98. package/es/utils/hd-wallet.js +45 -81
  99. package/es/utils/hd-wallet.js.map +1 -1
  100. package/es/utils/json-big.js +16 -49
  101. package/es/utils/json-big.js.map +1 -1
  102. package/es/utils/keystore.js +81 -246
  103. package/es/utils/keystore.js.map +1 -1
  104. package/es/utils/mptree.js +88 -134
  105. package/es/utils/mptree.js.map +1 -1
  106. package/es/utils/other.js +10 -60
  107. package/es/utils/other.js.map +1 -1
  108. package/es/utils/semver-satisfies.js +9 -28
  109. package/es/utils/semver-satisfies.js.map +1 -1
  110. package/es/utils/string.js +4 -13
  111. package/es/utils/string.js.map +1 -1
  112. package/es/utils/swagger.js +87 -224
  113. package/es/utils/swagger.js.map +1 -1
  114. package/package.json +51 -44
  115. package/src/account/base.js +11 -10
  116. package/src/account/multiple.js +24 -18
  117. package/src/ae/aens.js +64 -61
  118. package/src/ae/contract.js +71 -248
  119. package/src/ae/index.js +34 -9
  120. package/src/ae/oracle.js +30 -22
  121. package/src/ae/universal.js +3 -1
  122. package/src/chain/index.js +10 -16
  123. package/src/chain/node.js +38 -38
  124. package/src/channel/handlers.js +10 -4
  125. package/src/channel/index.js +44 -20
  126. package/src/contract/aci/index.js +234 -112
  127. package/src/contract/aci/transformation.js +30 -422
  128. package/src/contract/compiler.js +50 -5
  129. package/src/contract/ga/helpers.js +6 -14
  130. package/src/contract/ga/index.js +28 -28
  131. package/src/contract/index.js +6 -2
  132. package/src/index.js +4 -4
  133. package/src/node-pool/index.js +24 -13
  134. package/src/node.js +29 -30
  135. package/src/tx/builder/helpers.js +31 -56
  136. package/src/tx/builder/index.js +67 -28
  137. package/src/tx/builder/schema.js +79 -121
  138. package/src/tx/index.js +101 -12
  139. package/src/tx/tx-object.js +25 -8
  140. package/src/tx/tx.js +229 -150
  141. package/src/tx/validator.js +134 -202
  142. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +3 -2
  143. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +25 -7
  144. package/src/utils/aepp-wallet-communication/connection/index.js +2 -1
  145. package/src/utils/aepp-wallet-communication/content-script-bridge.js +10 -4
  146. package/src/utils/aepp-wallet-communication/helpers.js +4 -2
  147. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +33 -12
  148. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +9 -5
  149. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +59 -29
  150. package/src/utils/aepp-wallet-communication/schema.js +1 -3
  151. package/src/utils/aepp-wallet-communication/wallet-detector.js +4 -1
  152. package/src/utils/amount-formatter.ts +1 -1
  153. package/src/utils/bignumber.ts +2 -1
  154. package/src/utils/crypto.js +4 -68
  155. package/src/utils/keystore.js +10 -2
  156. package/src/utils/other.ts +1 -1
  157. package/src/utils/semver-satisfies.ts +1 -1
  158. package/src/utils/swagger.js +22 -10
  159. package/src/contract/aci/helpers.js +0 -140
@@ -37,8 +37,7 @@ import { required } from '@stamp/required'
37
37
  * @return {Object} Chain instance
38
38
  */
39
39
  const Chain = stampit({
40
- deepProps: { Ae: { defaults: { waitMined: true } } },
41
- statics: { waitMined (bool) { return this.deepProps({ Ae: { defaults: { waitMined: bool } } }) } }
40
+ deepProps: { Ae: { defaults: { waitMined: true, verify: true } } }
42
41
  }, required({
43
42
  methods: {
44
43
  sendTransaction: required,
@@ -56,15 +55,6 @@ const Chain = stampit({
56
55
  }
57
56
  }))
58
57
 
59
- /**
60
- * Reconfigure Stamp to (not) wait until transactions are mined
61
- * @function waitMined
62
- * @static
63
- * @rtype (bool: Boolean) => Stamp
64
- * @param {boolean} bool - Whether to wait for transactions
65
- * @return {Stamp} Reconfigured Chain Stamp
66
- */
67
-
68
58
  /**
69
59
  * Submit a signed transaction for mining
70
60
  * @function sendTransaction
@@ -74,7 +64,7 @@ const Chain = stampit({
74
64
  * @rtype (tx: String, options?: Object) => tx: Promise[Object]|txHash: Promise[String]
75
65
  * @param {String} tx - Transaction to submit
76
66
  * @param {String} [options={}] - Options to pass to the implementation
77
- * @param {String} [options.verify = false] - Verify transaction before broadcast.
67
+ * @param {String} [options.verify=true] - Verify transaction before broadcast.
78
68
  * @return {Object} Transaction
79
69
  */
80
70
 
@@ -123,8 +113,10 @@ const Chain = stampit({
123
113
  * @rtype (address: String, options?: Object) => balance: Number
124
114
  * @param {String} address - The public account address to obtain the balance for
125
115
  * @param {Object} [options={}] - Options
126
- * @param {Number} options.height - The chain height at which to obtain the balance for (default: top of chain)
127
- * @param {String} options.hash - The block hash on which to obtain the balance for (default: top of chain)
116
+ * @param {Number} options.height - The chain height at which to obtain the balance for (default:
117
+ * top of chain)
118
+ * @param {String} options.hash - The block hash on which to obtain the balance for (default: top
119
+ * of chain)
128
120
  * @return {Object} The transaction as it was mined
129
121
  */
130
122
 
@@ -136,7 +128,8 @@ const Chain = stampit({
136
128
  * @category async
137
129
  * @rtype (hash: String, info = false) => tx: Object
138
130
  * @param {String} hash - Transaction hash
139
- * @param {Boolean} info - Retrieve additional transaction date. Works only for (ContractCreate and ContractCall transaction's)
131
+ * @param {Boolean} info - Retrieve additional transaction date. Works only for (ContractCreate and
132
+ * ContractCall transaction's)
140
133
  * @return {Object} Transaction
141
134
  */
142
135
 
@@ -249,7 +242,8 @@ const Chain = stampit({
249
242
  * @param {String} tx - transaction to execute
250
243
  * @param {String} accountAddress - address that will be used to execute transaction
251
244
  * @param {String|Number} [options.top] - hash of block on which to make dry-run
252
- * @param {Boolean} [options.txEvents] - collect and return on-chain tx events that would result from the call
245
+ * @param {Boolean} [options.txEvents] - collect and return on-chain tx events that would result
246
+ * from the call
253
247
  * @return {Object} Result
254
248
  */
255
249
 
package/src/chain/node.js CHANGED
@@ -14,16 +14,13 @@
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
- import TransactionValidator from '../tx/validator'
19
+ import verifyTransaction from '../tx/validator'
22
20
  import NodePool from '../node-pool'
23
- import { assertedType } from '../utils/crypto'
24
21
  import { pause } from '../utils/other'
25
- import { isNameValid, produceNameId } from '../tx/builder/helpers'
26
- import { DRY_RUN_ACCOUNT, NAME_ID_KEY } from '../tx/builder/schema'
22
+ import { isNameValid, produceNameId, decode } from '../tx/builder/helpers'
23
+ import { DRY_RUN_ACCOUNT } from '../tx/builder/schema'
27
24
 
28
25
  /**
29
26
  * ChainNode module
@@ -35,15 +32,16 @@ import { DRY_RUN_ACCOUNT, NAME_ID_KEY } from '../tx/builder/schema'
35
32
  */
36
33
 
37
34
  async function sendTransaction (tx, options = {}) {
38
- const { waitMined, verify } = R.merge(this.Ae.defaults, options)
39
- // Verify transaction before broadcast
40
- if (verify || (typeof verify !== 'boolean' && this.verifyTxBeforeSend)) {
41
- const { validation, tx: txObject, txType } = await this.unpackAndVerify(tx)
35
+ const { waitMined, verify } = { ...this.Ae.defaults, ...options }
36
+ if (verify) {
37
+ const validation = await verifyTransaction(tx, this.selectedNode.instance)
42
38
  if (validation.length) {
43
- throw Object.assign(new Error('Transaction verification error: ' + JSON.stringify(validation)), {
39
+ const message = 'Transaction verification errors: ' +
40
+ validation.map(v => v.message).join(', ')
41
+ throw Object.assign(new Error(message), {
44
42
  code: 'TX_VERIFICATION_ERROR',
45
- errorData: { validation, tx: txObject, txType },
46
- txHash: tx
43
+ validation,
44
+ transaction: tx
47
45
  })
48
46
  }
49
47
  }
@@ -61,7 +59,10 @@ async function sendTransaction (tx, options = {}) {
61
59
  }
62
60
  return { hash: txHash, rawTx: tx }
63
61
  } catch (error) {
64
- throw Object.assign(error, { rawTx: tx, verifyTx: () => this.unpackAndVerify(tx) })
62
+ throw Object.assign(error, {
63
+ rawTx: tx,
64
+ verifyTx: () => verifyTransaction(tx, this.selectedNode.instance)
65
+ })
65
66
  }
66
67
  }
67
68
 
@@ -140,7 +141,7 @@ async function topBlock () {
140
141
  return this.api.getTopHeader()
141
142
  }
142
143
 
143
- async function poll (th, { blocks = 10, interval = 5000, allowUnsynced = false } = {}) {
144
+ async function poll (th, { blocks = 10, interval = 500, allowUnsynced = false } = {}) {
144
145
  const max = await this.height() + blocks
145
146
  do {
146
147
  const tx = await this.tx(th).catch(_ => null)
@@ -219,40 +220,42 @@ async function getName (name) {
219
220
  /**
220
221
  * Resolve AENS name and return name hash
221
222
  * @param {String} nameOrId
222
- * @param {String} prefix
223
+ * @param {String} key in AENS pointers record
223
224
  * @param {Object} [options]
224
- * @param {Boolean} [options.verify] Enables resolving by node, needed for compatibility with `verify` option of other methods
225
- * @param {Boolean} [options.resolveByNode] Enables pointer resolving using node (isn't more durable to resolve it on the node side?)
225
+ * @param {Boolean} [options.verify] To ensure that name exist and have a corresponding pointer
226
+ * // TODO: avoid that to don't trust to current api gateway
227
+ * @param {Boolean} [options.resolveByNode] Enables pointer resolving using node
226
228
  * @return {String} Address or AENS name hash
227
229
  */
228
- async function resolveName (nameOrId, prefix, { verify, resolveByNode } = {}) {
230
+ async function resolveName (nameOrId, key, { verify, resolveByNode } = {}) {
229
231
  if (!nameOrId || typeof nameOrId !== 'string') {
230
- throw new Error('Invalid name or address. Should be a string')
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}]`)
232
+ throw new Error(`Name or address should be a string: ${nameOrId}`)
235
233
  }
236
- if (assertedType(nameOrId, prefix, true)) return nameOrId
237
-
234
+ try {
235
+ decode(nameOrId)
236
+ return nameOrId
237
+ } catch (error) {}
238
238
  if (isNameValid(nameOrId)) {
239
- if (resolveByNode || verify) {
240
- const name = await this.getName(nameOrId).catch(_ => null)
241
- if (!name) throw new Error('Name not found')
242
- const pointer = name.pointers.find(({ id }) => id.split('_')[0] === prefix)
243
- if (!pointer) throw new Error(`Name ${nameOrId} do not have pointers for ${prefix}`)
244
- return pointer.id
239
+ if (verify || resolveByNode) {
240
+ const name = await this.api.getNameEntryByName(nameOrId).catch(_ => null)
241
+ if (!name) throw new Error(`Name not found: ${nameOrId}`)
242
+ const pointer = name.pointers.find(pointer => pointer.key === key)
243
+ if (!pointer) {
244
+ throw new Error(`Name ${nameOrId} don't have pointers for ${key}`)
245
+ }
246
+ if (resolveByNode) return pointer.id
245
247
  }
246
248
  return produceNameId(nameOrId)
247
249
  }
248
- throw new Error('Invalid name or address')
250
+ throw new Error(`Invalid name or address: ${nameOrId}`)
249
251
  }
250
252
 
251
253
  /**
252
254
  * ChainNode Stamp
253
255
  *
254
256
  * This is implementation of {@link module:@aeternity/aepp-sdk/es/chain--Chain}
255
- * composed with {@link module:@aeternity/aepp-sdk/es/contract/node--ContractNodeAPI} and {@link module:@aeternity/aepp-sdk/es/oracle/node--OracleNodeAPI}
257
+ * composed with {@link module:@aeternity/aepp-sdk/es/contract/node--ContractNodeAPI} and
258
+ * {@link module:@aeternity/aepp-sdk/es/oracle/node--OracleNodeAPI}
256
259
  * @function
257
260
  * @alias module:@aeternity/aepp-sdk/es/chain/node
258
261
  * @rtype Stamp
@@ -260,10 +263,7 @@ async function resolveName (nameOrId, prefix, { verify, resolveByNode } = {}) {
260
263
  * @return {Object} ChainNode instance
261
264
  * @example ChainNode({url: 'https://testnet.aeternity.io/'})
262
265
  */
263
- const ChainNode = Chain.compose(TransactionValidator, NodePool, {
264
- init ({ verifyTx = true }) {
265
- this.verifyTxBeforeSend = verifyTx
266
- },
266
+ const ChainNode = Chain.compose(NodePool, {
267
267
  methods: {
268
268
  sendTransaction,
269
269
  balance,
@@ -102,7 +102,9 @@ export async function awaitingChannelCreateTx (channel, message, state) {
102
102
  send(channel, { jsonrpc: '2.0', method: `channels.${tag}`, params: { tx: signedTx } })
103
103
  return { handler: awaitingOnChainTx }
104
104
  }
105
- const signedTx = await appendSignature(message.params.data.signed_tx, tx => options.get(channel).sign(tag, tx))
105
+ const signedTx = await appendSignature(
106
+ message.params.data.signed_tx, tx => options.get(channel).sign(tag, tx)
107
+ )
106
108
  send(channel, { jsonrpc: '2.0', method: `channels.${tag}`, params: { signed_tx: signedTx } })
107
109
  return { handler: awaitingOnChainTx }
108
110
  }
@@ -574,11 +576,16 @@ export function awaitingNewContractCompletion (channel, message, state) {
574
576
  export async function awaitingCallContractUpdateTx (channel, message, state) {
575
577
  if (message.method === 'channels.sign.update') {
576
578
  if (message.params.data.tx) {
577
- const signedTx = await state.sign(message.params.data.tx, { updates: message.params.data.updates })
579
+ const signedTx = await state.sign(
580
+ message.params.data.tx, { updates: message.params.data.updates }
581
+ )
578
582
  send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { tx: signedTx } })
579
583
  return { handler: awaitingCallContractCompletion, state }
580
584
  }
581
- const signedTx = await appendSignature(message.params.data.signed_tx, tx => state.sign(tx, { updates: message.params.data.updates }))
585
+ const signedTx = await appendSignature(
586
+ message.params.data.signed_tx,
587
+ tx => state.sign(tx, { updates: message.params.data.updates })
588
+ )
582
589
  if (typeof signedTx === 'string') {
583
590
  send(channel, { jsonrpc: '2.0', method: 'channels.update', params: { signed_tx: signedTx } })
584
591
  return { handler: awaitingCallContractCompletion, state }
@@ -603,7 +610,6 @@ export async function awaitingCallContractForceProgressUpdate (channel, message,
603
610
  }
604
611
 
605
612
  export function awaitingForceProgressCompletion (channel, message, state) {
606
- console.log('From force progress await completion ->', message)
607
613
  if (message.method === 'channels.on_chain_tx') {
608
614
  if (state.onOnChainTx) {
609
615
  state.onOnChainTx(message.params.data)
@@ -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