@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.
- package/README.md +15 -14
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +7 -36
- 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.mjs +179 -0
- package/es/account/base.mjs.map +1 -0
- package/es/account/memory.mjs +99 -0
- package/es/account/memory.mjs.map +1 -0
- package/es/account/multiple.mjs +179 -0
- package/es/account/multiple.mjs.map +1 -0
- package/es/ae/aens.mjs +404 -0
- package/es/ae/aens.mjs.map +1 -0
- package/es/ae/{aepp.js → aepp.mjs} +9 -9
- package/es/ae/aepp.mjs.map +1 -0
- package/es/ae/contract.mjs +159 -0
- package/es/ae/contract.mjs.map +1 -0
- package/es/ae/index.mjs +207 -0
- package/es/ae/index.mjs.map +1 -0
- package/es/ae/oracle.mjs +339 -0
- package/es/ae/oracle.mjs.map +1 -0
- package/es/ae/{universal.js → universal.mjs} +10 -10
- package/es/ae/universal.mjs.map +1 -0
- package/es/ae/{wallet.js → wallet.mjs} +10 -10
- package/es/ae/wallet.mjs.map +1 -0
- package/es/aepp-wallet-communication/schema.d.ts +74 -0
- package/es/bignumber.d.ts +1 -7
- package/es/chain/{index.js → index.mjs} +29 -9
- package/es/chain/index.mjs.map +1 -0
- package/es/chain/node.mjs +442 -0
- package/es/chain/node.mjs.map +1 -0
- package/es/channel/handlers.mjs +1110 -0
- package/es/channel/handlers.mjs.map +1 -0
- package/es/channel/{index.js → index.mjs} +245 -472
- package/es/channel/index.mjs.map +1 -0
- package/es/channel/internal.mjs +283 -0
- package/es/channel/internal.mjs.map +1 -0
- package/es/contract/aci.mjs +477 -0
- package/es/contract/aci.mjs.map +1 -0
- package/es/contract/compiler.mjs +115 -0
- package/es/contract/compiler.mjs.map +1 -0
- package/es/contract/ga/helpers.mjs +30 -0
- package/es/contract/ga/helpers.mjs.map +1 -0
- package/es/contract/ga/index.mjs +178 -0
- package/es/contract/ga/index.mjs.map +1 -0
- package/es/errors.d.ts +284 -0
- package/es/index.mjs +57 -0
- package/es/index.mjs.map +1 -0
- package/es/node-pool/index.mjs +188 -0
- package/es/node-pool/index.mjs.map +1 -0
- package/es/node.mjs +133 -0
- package/es/node.mjs.map +1 -0
- package/es/other.d.ts +1 -1
- package/es/tx/builder/field-types.mjs +74 -0
- package/es/tx/builder/field-types.mjs.map +1 -0
- package/es/tx/builder/helpers.mjs +363 -0
- package/es/tx/builder/helpers.mjs.map +1 -0
- package/es/tx/builder/index.mjs +606 -0
- package/es/tx/builder/index.mjs.map +1 -0
- package/es/tx/builder/schema.mjs +760 -0
- package/es/tx/builder/schema.mjs.map +1 -0
- package/es/tx/{index.js → index.mjs} +107 -15
- package/es/tx/index.mjs.map +1 -0
- package/es/tx/tx-object.mjs +283 -0
- package/es/tx/tx-object.mjs.map +1 -0
- package/es/tx/tx.mjs +938 -0
- package/es/tx/tx.mjs.map +1 -0
- package/es/tx/validator.mjs +247 -0
- package/es/tx/validator.mjs.map +1 -0
- package/es/typings/blakejs/index.d.mjs +2 -0
- package/es/typings/blakejs/{index.d.js.map → index.d.mjs.map} +1 -1
- package/es/utils/aepp-wallet-communication/connection/{browser-runtime.js → browser-runtime.mjs} +27 -29
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +183 -0
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/connection/{index.js → index.mjs} +7 -3
- package/es/utils/aepp-wallet-communication/connection/index.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/{content-script-bridge.js → content-script-bridge.mjs} +29 -23
- package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/helpers.mjs +92 -0
- package/es/utils/aepp-wallet-communication/helpers.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +375 -0
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +275 -0
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +541 -0
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/schema.mjs +102 -0
- package/es/utils/aepp-wallet-communication/schema.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs +110 -0
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
- package/es/utils/amount-formatter.mjs +139 -0
- package/es/utils/amount-formatter.mjs.map +1 -0
- package/es/utils/async-init.mjs +64 -0
- package/es/utils/async-init.mjs.map +1 -0
- package/es/utils/bignumber.mjs +21 -0
- package/es/utils/bignumber.mjs.map +1 -0
- package/es/utils/{bytes.js → bytes.mjs} +16 -12
- package/es/utils/bytes.mjs.map +1 -0
- package/es/utils/{crypto-ts.js → crypto-ts.mjs} +11 -3
- package/es/utils/crypto-ts.mjs.map +1 -0
- package/es/utils/crypto.mjs +239 -0
- package/es/utils/crypto.mjs.map +1 -0
- package/es/utils/errors.mjs +689 -0
- package/es/utils/errors.mjs.map +1 -0
- package/es/utils/hd-wallet.mjs +111 -0
- package/es/utils/hd-wallet.mjs.map +1 -0
- package/es/utils/json-big.mjs +45 -0
- package/es/utils/json-big.mjs.map +1 -0
- package/es/utils/keystore.mjs +240 -0
- package/es/utils/keystore.mjs.map +1 -0
- package/es/utils/mptree.mjs +161 -0
- package/es/utils/mptree.mjs.map +1 -0
- package/es/utils/other.mjs +43 -0
- package/es/utils/other.mjs.map +1 -0
- package/es/utils/semver-satisfies.mjs +16 -0
- package/es/utils/semver-satisfies.mjs.map +1 -0
- package/es/utils/{string.js → string.mjs} +5 -14
- package/es/utils/string.mjs.map +1 -0
- package/es/utils/swagger.mjs +164 -0
- package/es/utils/swagger.mjs.map +1 -0
- package/package.json +55 -62
- package/src/account/base.js +3 -1
- package/src/account/memory.js +13 -8
- package/src/account/multiple.js +31 -22
- package/src/ae/aens.js +75 -77
- package/src/ae/aepp.js +2 -2
- package/src/ae/contract.js +27 -291
- package/src/ae/index.js +9 -7
- package/src/ae/oracle.js +51 -28
- package/src/ae/universal.js +4 -2
- package/src/ae/wallet.js +2 -2
- package/src/chain/index.js +29 -6
- package/src/chain/node.js +95 -67
- package/src/channel/handlers.js +30 -21
- package/src/channel/index.js +44 -20
- package/src/channel/internal.js +30 -24
- package/src/contract/aci.js +376 -0
- package/src/contract/compiler.js +41 -91
- package/src/contract/ga/helpers.js +10 -13
- package/src/contract/ga/index.js +42 -33
- package/src/index.js +9 -10
- package/src/node-pool/index.js +29 -17
- package/src/node.js +33 -36
- package/src/tx/builder/field-types.js +61 -0
- package/src/tx/builder/helpers.js +126 -84
- package/src/tx/builder/index.js +83 -41
- package/src/tx/builder/schema.js +50 -40
- package/src/tx/index.js +101 -12
- package/src/tx/tx-object.js +35 -15
- package/src/tx/tx.js +232 -153
- package/src/tx/validator.js +34 -12
- package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +11 -5
- package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +35 -13
- package/src/utils/aepp-wallet-communication/connection/index.js +2 -1
- package/src/utils/aepp-wallet-communication/content-script-bridge.js +14 -7
- package/src/utils/aepp-wallet-communication/helpers.js +6 -14
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +107 -60
- package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +24 -11
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +98 -56
- package/src/utils/aepp-wallet-communication/schema.ts +80 -0
- package/src/utils/aepp-wallet-communication/wallet-detector.js +6 -2
- package/src/utils/amount-formatter.ts +4 -3
- package/src/utils/async-init.js +10 -6
- package/src/utils/bignumber.ts +3 -10
- package/src/utils/bytes.ts +3 -2
- package/src/utils/crypto-ts.ts +2 -2
- package/src/utils/crypto.js +10 -144
- package/src/utils/errors.ts +683 -0
- package/src/utils/hd-wallet.js +11 -26
- package/src/utils/keystore.js +57 -53
- package/src/utils/mptree.ts +12 -6
- package/src/utils/other.ts +1 -1
- package/src/utils/semver-satisfies.ts +1 -1
- package/src/utils/swagger.js +75 -45
- package/es/account/base.js +0 -259
- package/es/account/base.js.map +0 -1
- package/es/account/memory.js +0 -86
- package/es/account/memory.js.map +0 -1
- package/es/account/multiple.js +0 -267
- package/es/account/multiple.js.map +0 -1
- package/es/ae/aens.js +0 -829
- package/es/ae/aens.js.map +0 -1
- package/es/ae/aepp.js.map +0 -1
- package/es/ae/contract.js +0 -985
- package/es/ae/contract.js.map +0 -1
- package/es/ae/index.js +0 -442
- package/es/ae/index.js.map +0 -1
- package/es/ae/oracle.js +0 -690
- package/es/ae/oracle.js.map +0 -1
- package/es/ae/universal.js.map +0 -1
- package/es/ae/wallet.js.map +0 -1
- package/es/chain/index.js.map +0 -1
- package/es/chain/node.js +0 -1119
- package/es/chain/node.js.map +0 -1
- package/es/channel/handlers.js +0 -1601
- package/es/channel/handlers.js.map +0 -1
- package/es/channel/index.js.map +0 -1
- package/es/channel/internal.js +0 -438
- package/es/channel/internal.js.map +0 -1
- package/es/contract/aci/helpers.js +0 -298
- package/es/contract/aci/helpers.js.map +0 -1
- package/es/contract/aci/index.js +0 -517
- package/es/contract/aci/index.js.map +0 -1
- package/es/contract/aci/transformation.js +0 -742
- package/es/contract/aci/transformation.js.map +0 -1
- package/es/contract/compiler.js +0 -316
- package/es/contract/compiler.js.map +0 -1
- package/es/contract/ga/helpers.js +0 -120
- package/es/contract/ga/helpers.js.map +0 -1
- package/es/contract/ga/index.js +0 -307
- package/es/contract/ga/index.js.map +0 -1
- package/es/contract/index.js +0 -158
- package/es/contract/index.js.map +0 -1
- package/es/index.js +0 -57
- package/es/index.js.map +0 -1
- package/es/node-pool/index.js +0 -204
- package/es/node-pool/index.js.map +0 -1
- package/es/node.js +0 -228
- package/es/node.js.map +0 -1
- package/es/tx/builder/helpers.js +0 -355
- package/es/tx/builder/helpers.js.map +0 -1
- package/es/tx/builder/index.js +0 -686
- package/es/tx/builder/index.js.map +0 -1
- package/es/tx/builder/schema.js +0 -695
- package/es/tx/builder/schema.js.map +0 -1
- package/es/tx/index.js.map +0 -1
- package/es/tx/tx-object.js +0 -297
- package/es/tx/tx-object.js.map +0 -1
- package/es/tx/tx.js +0 -1757
- package/es/tx/tx.js.map +0 -1
- package/es/tx/validator.js +0 -344
- package/es/tx/validator.js.map +0 -1
- package/es/typings/blakejs/index.d.js +0 -2
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -211
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/index.js.map +0 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +0 -1
- package/es/utils/aepp-wallet-communication/helpers.js +0 -148
- package/es/utils/aepp-wallet-communication/helpers.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -652
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -285
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -763
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +0 -1
- package/es/utils/aepp-wallet-communication/schema.js +0 -103
- package/es/utils/aepp-wallet-communication/schema.js.map +0 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.js +0 -135
- package/es/utils/aepp-wallet-communication/wallet-detector.js.map +0 -1
- package/es/utils/amount-formatter.js +0 -152
- package/es/utils/amount-formatter.js.map +0 -1
- package/es/utils/async-init.js +0 -103
- package/es/utils/async-init.js.map +0 -1
- package/es/utils/bignumber.js +0 -36
- package/es/utils/bignumber.js.map +0 -1
- package/es/utils/bytes.js.map +0 -1
- package/es/utils/crypto-ts.js.map +0 -1
- package/es/utils/crypto.js +0 -358
- package/es/utils/crypto.js.map +0 -1
- package/es/utils/hd-wallet.js +0 -148
- package/es/utils/hd-wallet.js.map +0 -1
- package/es/utils/json-big.js +0 -78
- package/es/utils/json-big.js.map +0 -1
- package/es/utils/keystore.js +0 -393
- package/es/utils/keystore.js.map +0 -1
- package/es/utils/mptree.js +0 -198
- package/es/utils/mptree.js.map +0 -1
- package/es/utils/other.js +0 -93
- package/es/utils/other.js.map +0 -1
- package/es/utils/semver-satisfies.js +0 -35
- package/es/utils/semver-satisfies.js.map +0 -1
- package/es/utils/string.js.map +0 -1
- package/es/utils/swagger.js +0 -269
- package/es/utils/swagger.js.map +0 -1
- package/src/contract/aci/helpers.js +0 -140
- package/src/contract/aci/index.js +0 -191
- package/src/contract/aci/transformation.js +0 -464
- package/src/contract/index.js +0 -159
- package/src/utils/aepp-wallet-communication/schema.js +0 -110
package/src/chain/index.js
CHANGED
|
@@ -37,13 +37,32 @@ import { required } from '@stamp/required'
|
|
|
37
37
|
* @return {Object} Chain instance
|
|
38
38
|
*/
|
|
39
39
|
const Chain = stampit({
|
|
40
|
-
deepProps: {
|
|
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:
|
|
117
|
-
*
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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, {
|
|
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.
|
|
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.
|
|
85
|
+
const { blockHeight: newBlockHeight } = await this.api.getTransactionByHash(txHash)
|
|
73
86
|
switch (newBlockHeight) {
|
|
74
87
|
case -1:
|
|
75
|
-
throw new
|
|
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
|
-
|
|
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 (
|
|
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
|
|
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 =
|
|
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.
|
|
147
|
-
if (tx
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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}
|
|
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
|
-
*
|
|
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,
|
|
259
|
+
async function resolveName (nameOrId, key, { verify, resolveByNode } = {}) {
|
|
229
260
|
if (!nameOrId || typeof nameOrId !== 'string') {
|
|
230
|
-
throw new
|
|
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
|
|
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.
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
|
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
|
|
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,
|
package/src/channel/handlers.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { generateKeyPair, encodeContractAddress
|
|
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
|
-
|
|
33
|
-
|
|
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(
|
|
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
|
|
44
|
+
return buildTx({
|
|
42
45
|
signatures: signatures.concat(signedTx.signatures),
|
|
43
46
|
encodedTx: signedTx.encodedTx.rlpEncoded
|
|
44
|
-
}, txType).
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
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
|
|
263
|
+
state.reject(new InsufficientBalanceError('Insufficient balance'))
|
|
259
264
|
} else if (data.find(i => i.code === 1002)) {
|
|
260
|
-
state.reject(new
|
|
265
|
+
state.reject(new IllegalArgumentError('Amount cannot be negative'))
|
|
261
266
|
} else {
|
|
262
|
-
state.reject(new
|
|
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
|
|
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
|
|
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(
|
|
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(
|
|
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
|
|
657
|
+
state.reject(new UnexpectedChannelMessageError('Unexpected message received'))
|
|
649
658
|
return { handler: channelClosed }
|
|
650
659
|
}
|
|
651
660
|
|
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
|