@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.
- package/CHANGELOG.md +216 -337
- package/README.md +16 -9
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -9
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +1 -1
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +1 -1
- package/dist/aepp-sdk.js.map +1 -1
- package/es/account/base.js +36 -120
- package/es/account/base.js.map +1 -1
- package/es/account/memory.js +17 -19
- package/es/account/memory.js.map +1 -1
- package/es/account/multiple.js +79 -156
- package/es/account/multiple.js.map +1 -1
- package/es/ae/aens.js +205 -626
- package/es/ae/aens.js.map +1 -1
- package/es/ae/contract.js +114 -918
- package/es/ae/contract.js.map +1 -1
- package/es/ae/index.js +90 -250
- package/es/ae/index.js.map +1 -1
- package/es/ae/oracle.js +136 -504
- package/es/ae/oracle.js.map +1 -1
- package/es/ae/universal.js.map +1 -1
- package/es/chain/index.js +12 -27
- package/es/chain/index.js.map +1 -1
- package/es/chain/node.js +289 -1020
- package/es/chain/node.js.map +1 -1
- package/es/channel/handlers.js +597 -1086
- package/es/channel/handlers.js.map +1 -1
- package/es/channel/index.js +238 -465
- package/es/channel/index.js.map +1 -1
- package/es/channel/internal.js +129 -301
- package/es/channel/internal.js.map +1 -1
- package/es/contract/aci/index.js +328 -495
- package/es/contract/aci/index.js.map +1 -1
- package/es/contract/aci/transformation.js +35 -711
- package/es/contract/aci/transformation.js.map +1 -1
- package/es/contract/compiler.js +131 -203
- package/es/contract/compiler.js.map +1 -1
- package/es/contract/ga/helpers.js +17 -122
- package/es/contract/ga/helpers.js.map +1 -1
- package/es/contract/ga/index.js +108 -249
- package/es/contract/ga/index.js.map +1 -1
- package/es/contract/index.js +7 -3
- package/es/contract/index.js.map +1 -1
- package/es/index.js +3 -3
- package/es/index.js.map +1 -1
- package/es/node-pool/index.js +57 -74
- package/es/node-pool/index.js.map +1 -1
- package/es/node.js +65 -161
- package/es/node.js.map +1 -1
- package/es/other.d.ts +1 -1
- package/es/tx/builder/helpers.js +62 -115
- package/es/tx/builder/helpers.js.map +1 -1
- package/es/tx/builder/index.js +218 -309
- package/es/tx/builder/index.js.map +1 -1
- package/es/tx/builder/schema.js +586 -573
- package/es/tx/builder/schema.js.map +1 -1
- package/es/tx/index.js +102 -13
- package/es/tx/index.js.map +1 -1
- package/es/tx/tx-object.js +114 -138
- package/es/tx/tx-object.js.map +1 -1
- package/es/tx/tx.js +810 -1586
- package/es/tx/tx.js.map +1 -1
- package/es/tx/validator.js +191 -426
- package/es/tx/validator.js.map +1 -1
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +20 -23
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +1 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +53 -80
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +1 -1
- package/es/utils/aepp-wallet-communication/connection/index.js +2 -1
- package/es/utils/aepp-wallet-communication/connection/index.js.map +1 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.js +24 -19
- package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +1 -1
- package/es/utils/aepp-wallet-communication/helpers.js +60 -105
- package/es/utils/aepp-wallet-communication/helpers.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +191 -514
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +78 -93
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +381 -613
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +1 -1
- package/es/utils/aepp-wallet-communication/schema.js +43 -39
- package/es/utils/aepp-wallet-communication/schema.js.map +1 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.js +32 -58
- package/es/utils/aepp-wallet-communication/wallet-detector.js.map +1 -1
- package/es/utils/amount-formatter.js +41 -61
- package/es/utils/amount-formatter.js.map +1 -1
- package/es/utils/async-init.js +28 -64
- package/es/utils/async-init.js.map +1 -1
- package/es/utils/bignumber.js +3 -11
- package/es/utils/bignumber.js.map +1 -1
- package/es/utils/bytes.js +5 -9
- package/es/utils/bytes.js.map +1 -1
- package/es/utils/crypto.js +41 -106
- package/es/utils/crypto.js.map +1 -1
- package/es/utils/hd-wallet.js +45 -81
- package/es/utils/hd-wallet.js.map +1 -1
- package/es/utils/json-big.js +16 -49
- package/es/utils/json-big.js.map +1 -1
- package/es/utils/keystore.js +81 -246
- package/es/utils/keystore.js.map +1 -1
- package/es/utils/mptree.js +88 -134
- package/es/utils/mptree.js.map +1 -1
- package/es/utils/other.js +10 -60
- package/es/utils/other.js.map +1 -1
- package/es/utils/semver-satisfies.js +9 -28
- package/es/utils/semver-satisfies.js.map +1 -1
- package/es/utils/string.js +4 -13
- package/es/utils/string.js.map +1 -1
- package/es/utils/swagger.js +87 -224
- package/es/utils/swagger.js.map +1 -1
- package/package.json +51 -44
- package/src/account/base.js +11 -10
- package/src/account/multiple.js +24 -18
- package/src/ae/aens.js +64 -61
- package/src/ae/contract.js +71 -248
- package/src/ae/index.js +34 -9
- package/src/ae/oracle.js +30 -22
- package/src/ae/universal.js +3 -1
- package/src/chain/index.js +10 -16
- package/src/chain/node.js +38 -38
- package/src/channel/handlers.js +10 -4
- package/src/channel/index.js +44 -20
- package/src/contract/aci/index.js +234 -112
- package/src/contract/aci/transformation.js +30 -422
- package/src/contract/compiler.js +50 -5
- package/src/contract/ga/helpers.js +6 -14
- package/src/contract/ga/index.js +28 -28
- package/src/contract/index.js +6 -2
- package/src/index.js +4 -4
- package/src/node-pool/index.js +24 -13
- package/src/node.js +29 -30
- package/src/tx/builder/helpers.js +31 -56
- package/src/tx/builder/index.js +67 -28
- package/src/tx/builder/schema.js +79 -121
- package/src/tx/index.js +101 -12
- package/src/tx/tx-object.js +25 -8
- package/src/tx/tx.js +229 -150
- package/src/tx/validator.js +134 -202
- package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +3 -2
- package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +25 -7
- package/src/utils/aepp-wallet-communication/connection/index.js +2 -1
- package/src/utils/aepp-wallet-communication/content-script-bridge.js +10 -4
- package/src/utils/aepp-wallet-communication/helpers.js +4 -2
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +33 -12
- package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +9 -5
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +59 -29
- package/src/utils/aepp-wallet-communication/schema.js +1 -3
- package/src/utils/aepp-wallet-communication/wallet-detector.js +4 -1
- package/src/utils/amount-formatter.ts +1 -1
- package/src/utils/bignumber.ts +2 -1
- package/src/utils/crypto.js +4 -68
- package/src/utils/keystore.js +10 -2
- package/src/utils/other.ts +1 -1
- package/src/utils/semver-satisfies.ts +1 -1
- package/src/utils/swagger.js +22 -10
- package/src/contract/aci/helpers.js +0 -140
package/src/chain/index.js
CHANGED
|
@@ -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
|
|
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:
|
|
127
|
-
*
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 } =
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
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
|
-
|
|
46
|
-
|
|
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, {
|
|
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 =
|
|
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}
|
|
223
|
+
* @param {String} key in AENS pointers record
|
|
223
224
|
* @param {Object} [options]
|
|
224
|
-
* @param {Boolean} [options.verify]
|
|
225
|
-
*
|
|
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,
|
|
230
|
+
async function resolveName (nameOrId, key, { verify, resolveByNode } = {}) {
|
|
229
231
|
if (!nameOrId || typeof nameOrId !== 'string') {
|
|
230
|
-
throw new Error(
|
|
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
|
-
|
|
237
|
-
|
|
234
|
+
try {
|
|
235
|
+
decode(nameOrId)
|
|
236
|
+
return nameOrId
|
|
237
|
+
} catch (error) {}
|
|
238
238
|
if (isNameValid(nameOrId)) {
|
|
239
|
-
if (
|
|
240
|
-
const name = await this.
|
|
241
|
-
if (!name) throw new Error(
|
|
242
|
-
const pointer = name.pointers.find(
|
|
243
|
-
if (!pointer)
|
|
244
|
-
|
|
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(
|
|
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
|
|
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(
|
|
264
|
-
init ({ verifyTx = true }) {
|
|
265
|
-
this.verifyTxBeforeSend = verifyTx
|
|
266
|
-
},
|
|
266
|
+
const ChainNode = Chain.compose(NodePool, {
|
|
267
267
|
methods: {
|
|
268
268
|
sendTransaction,
|
|
269
269
|
balance,
|
package/src/channel/handlers.js
CHANGED
|
@@ -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(
|
|
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(
|
|
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(
|
|
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)
|
package/src/channel/index.js
CHANGED
|
@@ -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
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
|
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
|
|
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 (
|
|
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
|
|
805
|
-
*
|
|
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
|
|
812
|
-
*
|
|
813
|
-
* @param {Number} [options.
|
|
814
|
-
*
|
|
815
|
-
* @param {Number} [options.
|
|
816
|
-
*
|
|
817
|
-
* @param {Number} [options.
|
|
818
|
-
*
|
|
819
|
-
* @param {Number} [options.
|
|
820
|
-
*
|
|
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
|