@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/es/channel/index.js
CHANGED
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
2
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
3
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
4
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
5
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
6
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
7
|
-
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
|
8
|
-
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
|
9
|
-
import _reduce from "ramda/src/reduce";
|
|
10
|
-
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
11
|
-
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
12
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
13
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
14
|
-
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
15
|
-
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context10; _forEachInstanceProperty(_context10 = ownKeys(Object(source), true)).call(_context10, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context11; _forEachInstanceProperty(_context11 = ownKeys(Object(source))).call(_context11, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
19
|
-
|
|
20
|
-
import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
|
|
21
|
-
import _Object$entries from "@babel/runtime-corejs3/core-js-stable/object/entries";
|
|
22
|
-
import _parseInt from "@babel/runtime-corejs3/core-js-stable/parse-int";
|
|
23
|
-
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
24
|
-
import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
|
|
25
|
-
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
|
26
|
-
|
|
27
1
|
/*
|
|
28
2
|
* ISC License (ISC)
|
|
29
3
|
* Copyright (c) 2018 aeternity developers
|
|
@@ -55,14 +29,11 @@ import * as handlers from './handlers';
|
|
|
55
29
|
import { eventEmitters, status as channelStatus, state as channelState, initialize, enqueueAction, send, channelId, call, disconnect as channelDisconnect, fsmId as channelFsmId } from './internal';
|
|
56
30
|
|
|
57
31
|
function snakeToPascalObjKeys(obj) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
val = _ref2[1];
|
|
64
|
-
|
|
65
|
-
return _objectSpread(_objectSpread({}, result), {}, _defineProperty({}, snakeToPascal(key), val));
|
|
32
|
+
return Object.entries(obj).reduce((result, _ref) => {
|
|
33
|
+
let [key, val] = _ref;
|
|
34
|
+
return { ...result,
|
|
35
|
+
[snakeToPascal(key)]: val
|
|
36
|
+
};
|
|
66
37
|
}, {});
|
|
67
38
|
}
|
|
68
39
|
/**
|
|
@@ -121,8 +92,8 @@ function status() {
|
|
|
121
92
|
*/
|
|
122
93
|
|
|
123
94
|
|
|
124
|
-
function state() {
|
|
125
|
-
return
|
|
95
|
+
async function state() {
|
|
96
|
+
return snakeToPascalObjKeys(await call(this, 'channels.get.offchain_state', {}));
|
|
126
97
|
}
|
|
127
98
|
/**
|
|
128
99
|
* Get current round
|
|
@@ -134,40 +105,17 @@ function state() {
|
|
|
134
105
|
*/
|
|
135
106
|
|
|
136
107
|
|
|
137
|
-
function _state() {
|
|
138
|
-
_state = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
139
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context3) {
|
|
140
|
-
while (1) {
|
|
141
|
-
switch (_context3.prev = _context3.next) {
|
|
142
|
-
case 0:
|
|
143
|
-
_context3.t0 = snakeToPascalObjKeys;
|
|
144
|
-
_context3.next = 3;
|
|
145
|
-
return call(this, 'channels.get.offchain_state', {});
|
|
146
|
-
|
|
147
|
-
case 3:
|
|
148
|
-
_context3.t1 = _context3.sent;
|
|
149
|
-
return _context3.abrupt("return", (0, _context3.t0)(_context3.t1));
|
|
150
|
-
|
|
151
|
-
case 5:
|
|
152
|
-
case "end":
|
|
153
|
-
return _context3.stop();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}, _callee2, this);
|
|
157
|
-
}));
|
|
158
|
-
return _state.apply(this, arguments);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
108
|
function round() {
|
|
162
|
-
|
|
109
|
+
const state = channelState.get(this);
|
|
163
110
|
|
|
164
111
|
if (!state) {
|
|
165
112
|
return null;
|
|
166
113
|
}
|
|
167
114
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
115
|
+
const {
|
|
116
|
+
txType,
|
|
117
|
+
tx
|
|
118
|
+
} = unpackTx(channelState.get(this)).tx.encodedTx;
|
|
171
119
|
|
|
172
120
|
switch (txType) {
|
|
173
121
|
case TX_TYPE.channelCreate:
|
|
@@ -176,7 +124,7 @@ function round() {
|
|
|
176
124
|
case TX_TYPE.channelOffChain:
|
|
177
125
|
case TX_TYPE.channelWithdraw:
|
|
178
126
|
case TX_TYPE.channelDeposit:
|
|
179
|
-
return
|
|
127
|
+
return parseInt(tx.round, 10);
|
|
180
128
|
|
|
181
129
|
default:
|
|
182
130
|
return null;
|
|
@@ -231,28 +179,24 @@ function fsmId() {
|
|
|
231
179
|
|
|
232
180
|
|
|
233
181
|
function update(from, to, amount, sign, metadata) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return new _Promise(function (resolve, reject) {
|
|
237
|
-
enqueueAction(_this, function (channel, state) {
|
|
238
|
-
return state.handler === handlers.channelOpen;
|
|
239
|
-
}, function (channel, state) {
|
|
182
|
+
return new Promise((resolve, reject) => {
|
|
183
|
+
enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
|
|
240
184
|
send(channel, {
|
|
241
185
|
jsonrpc: '2.0',
|
|
242
186
|
method: 'channels.update.new',
|
|
243
187
|
params: {
|
|
244
|
-
from
|
|
245
|
-
to
|
|
246
|
-
amount
|
|
188
|
+
from,
|
|
189
|
+
to,
|
|
190
|
+
amount,
|
|
247
191
|
meta: metadata
|
|
248
192
|
}
|
|
249
193
|
});
|
|
250
194
|
return {
|
|
251
195
|
handler: handlers.awaitingOffChainTx,
|
|
252
196
|
state: {
|
|
253
|
-
resolve
|
|
254
|
-
reject
|
|
255
|
-
sign
|
|
197
|
+
resolve,
|
|
198
|
+
reject,
|
|
199
|
+
sign
|
|
256
200
|
}
|
|
257
201
|
};
|
|
258
202
|
});
|
|
@@ -278,8 +222,15 @@ function update(from, to, amount, sign, metadata) {
|
|
|
278
222
|
*/
|
|
279
223
|
|
|
280
224
|
|
|
281
|
-
function poi(
|
|
282
|
-
|
|
225
|
+
async function poi(_ref2) {
|
|
226
|
+
let {
|
|
227
|
+
accounts,
|
|
228
|
+
contracts
|
|
229
|
+
} = _ref2;
|
|
230
|
+
return (await call(this, 'channels.get.poi', {
|
|
231
|
+
accounts,
|
|
232
|
+
contracts
|
|
233
|
+
})).poi;
|
|
283
234
|
}
|
|
284
235
|
/**
|
|
285
236
|
* Get balances
|
|
@@ -302,35 +253,10 @@ function poi(_x) {
|
|
|
302
253
|
*/
|
|
303
254
|
|
|
304
255
|
|
|
305
|
-
function
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
while (1) {
|
|
310
|
-
switch (_context4.prev = _context4.next) {
|
|
311
|
-
case 0:
|
|
312
|
-
accounts = _ref3.accounts, contracts = _ref3.contracts;
|
|
313
|
-
_context4.next = 3;
|
|
314
|
-
return call(this, 'channels.get.poi', {
|
|
315
|
-
accounts: accounts,
|
|
316
|
-
contracts: contracts
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
case 3:
|
|
320
|
-
return _context4.abrupt("return", _context4.sent.poi);
|
|
321
|
-
|
|
322
|
-
case 4:
|
|
323
|
-
case "end":
|
|
324
|
-
return _context4.stop();
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}, _callee3, this);
|
|
328
|
-
}));
|
|
329
|
-
return _poi.apply(this, arguments);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
function balances(_x2) {
|
|
333
|
-
return _balances.apply(this, arguments);
|
|
256
|
+
async function balances(accounts) {
|
|
257
|
+
return Object.fromEntries((await call(this, 'channels.get.balances', {
|
|
258
|
+
accounts
|
|
259
|
+
})).map(item => [item.account, item.balance]));
|
|
334
260
|
}
|
|
335
261
|
/**
|
|
336
262
|
* Leave channel
|
|
@@ -352,45 +278,9 @@ function balances(_x2) {
|
|
|
352
278
|
*/
|
|
353
279
|
|
|
354
280
|
|
|
355
|
-
function _balances() {
|
|
356
|
-
_balances = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(accounts) {
|
|
357
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context5) {
|
|
358
|
-
while (1) {
|
|
359
|
-
switch (_context5.prev = _context5.next) {
|
|
360
|
-
case 0:
|
|
361
|
-
_context5.t0 = _reduce;
|
|
362
|
-
|
|
363
|
-
_context5.t1 = function (acc, item) {
|
|
364
|
-
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, item.account, item.balance));
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
_context5.t2 = {};
|
|
368
|
-
_context5.next = 5;
|
|
369
|
-
return call(this, 'channels.get.balances', {
|
|
370
|
-
accounts: accounts
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
case 5:
|
|
374
|
-
_context5.t3 = _context5.sent;
|
|
375
|
-
return _context5.abrupt("return", (0, _context5.t0)(_context5.t1, _context5.t2, _context5.t3));
|
|
376
|
-
|
|
377
|
-
case 7:
|
|
378
|
-
case "end":
|
|
379
|
-
return _context5.stop();
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}, _callee4, this);
|
|
383
|
-
}));
|
|
384
|
-
return _balances.apply(this, arguments);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
281
|
function leave() {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
return new _Promise(function (resolve, reject) {
|
|
391
|
-
enqueueAction(_this2, function (channel, state) {
|
|
392
|
-
return state.handler === handlers.channelOpen;
|
|
393
|
-
}, function (channel, state) {
|
|
282
|
+
return new Promise((resolve, reject) => {
|
|
283
|
+
enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
|
|
394
284
|
send(channel, {
|
|
395
285
|
jsonrpc: '2.0',
|
|
396
286
|
method: 'channels.leave',
|
|
@@ -399,8 +289,8 @@ function leave() {
|
|
|
399
289
|
return {
|
|
400
290
|
handler: handlers.awaitingLeave,
|
|
401
291
|
state: {
|
|
402
|
-
resolve
|
|
403
|
-
reject
|
|
292
|
+
resolve,
|
|
293
|
+
reject
|
|
404
294
|
}
|
|
405
295
|
};
|
|
406
296
|
});
|
|
@@ -421,12 +311,8 @@ function leave() {
|
|
|
421
311
|
|
|
422
312
|
|
|
423
313
|
function shutdown(sign) {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
return new _Promise(function (resolve, reject) {
|
|
427
|
-
enqueueAction(_this3, function (channel, state) {
|
|
428
|
-
return state.handler === handlers.channelOpen;
|
|
429
|
-
}, function (channel, state) {
|
|
314
|
+
return new Promise((resolve, reject) => {
|
|
315
|
+
enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
|
|
430
316
|
send(channel, {
|
|
431
317
|
jsonrpc: '2.0',
|
|
432
318
|
method: 'channels.shutdown',
|
|
@@ -435,9 +321,9 @@ function shutdown(sign) {
|
|
|
435
321
|
return {
|
|
436
322
|
handler: handlers.awaitingShutdownTx,
|
|
437
323
|
state: {
|
|
438
|
-
sign
|
|
439
|
-
resolve
|
|
440
|
-
reject
|
|
324
|
+
sign,
|
|
325
|
+
resolve,
|
|
326
|
+
reject
|
|
441
327
|
}
|
|
442
328
|
};
|
|
443
329
|
});
|
|
@@ -473,7 +359,8 @@ function shutdown(sign) {
|
|
|
473
359
|
* @param {Number} amount - Amount of tokens to withdraw
|
|
474
360
|
* @param {Function} sign - Function which verifies and signs withdraw transaction
|
|
475
361
|
* @param {Object} [callbacks]
|
|
476
|
-
* @param {Function} [callbacks.onOnChainTx] - Called when withdraw transaction has been posted
|
|
362
|
+
* @param {Function} [callbacks.onOnChainTx] - Called when withdraw transaction has been posted
|
|
363
|
+
* on chain
|
|
477
364
|
* @param {Function} [callbacks.onOwnWithdrawLocked]
|
|
478
365
|
* @param {Function} [callbacks.onWithdrawLocked]
|
|
479
366
|
* @return {Promise<Object>}
|
|
@@ -492,33 +379,29 @@ function shutdown(sign) {
|
|
|
492
379
|
|
|
493
380
|
|
|
494
381
|
function withdraw(amount, sign) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
return new _Promise(function (resolve, reject) {
|
|
503
|
-
enqueueAction(_this4, function (channel, state) {
|
|
504
|
-
return state.handler === handlers.channelOpen;
|
|
505
|
-
}, function (channel, state) {
|
|
382
|
+
let {
|
|
383
|
+
onOnChainTx,
|
|
384
|
+
onOwnWithdrawLocked,
|
|
385
|
+
onWithdrawLocked
|
|
386
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
387
|
+
return new Promise((resolve, reject) => {
|
|
388
|
+
enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
|
|
506
389
|
send(channel, {
|
|
507
390
|
jsonrpc: '2.0',
|
|
508
391
|
method: 'channels.withdraw',
|
|
509
392
|
params: {
|
|
510
|
-
amount
|
|
393
|
+
amount
|
|
511
394
|
}
|
|
512
395
|
});
|
|
513
396
|
return {
|
|
514
397
|
handler: handlers.awaitingWithdrawTx,
|
|
515
398
|
state: {
|
|
516
|
-
sign
|
|
517
|
-
resolve
|
|
518
|
-
reject
|
|
519
|
-
onOnChainTx
|
|
520
|
-
onOwnWithdrawLocked
|
|
521
|
-
onWithdrawLocked
|
|
399
|
+
sign,
|
|
400
|
+
resolve,
|
|
401
|
+
reject,
|
|
402
|
+
onOnChainTx,
|
|
403
|
+
onOwnWithdrawLocked,
|
|
404
|
+
onWithdrawLocked
|
|
522
405
|
}
|
|
523
406
|
};
|
|
524
407
|
});
|
|
@@ -554,7 +437,8 @@ function withdraw(amount, sign) {
|
|
|
554
437
|
* @param {Number} amount - Amount of tokens to deposit
|
|
555
438
|
* @param {Function} sign - Function which verifies and signs deposit transaction
|
|
556
439
|
* @param {Object} [callbacks]
|
|
557
|
-
* @param {Function} [callbacks.onOnChainTx] - Called when deposit transaction has been posted
|
|
440
|
+
* @param {Function} [callbacks.onOnChainTx] - Called when deposit transaction has been posted
|
|
441
|
+
* on chain
|
|
558
442
|
* @param {Function} [callbacks.onOwnDepositLocked]
|
|
559
443
|
* @param {Function} [callbacks.onDepositLocked]
|
|
560
444
|
* @return {Promise<Object>}
|
|
@@ -574,33 +458,29 @@ function withdraw(amount, sign) {
|
|
|
574
458
|
|
|
575
459
|
|
|
576
460
|
function deposit(amount, sign) {
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
return new _Promise(function (resolve, reject) {
|
|
585
|
-
enqueueAction(_this5, function (channel, state) {
|
|
586
|
-
return state.handler === handlers.channelOpen;
|
|
587
|
-
}, function (channel, state) {
|
|
461
|
+
let {
|
|
462
|
+
onOnChainTx,
|
|
463
|
+
onOwnDepositLocked,
|
|
464
|
+
onDepositLocked
|
|
465
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
466
|
+
return new Promise((resolve, reject) => {
|
|
467
|
+
enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
|
|
588
468
|
send(channel, {
|
|
589
469
|
jsonrpc: '2.0',
|
|
590
470
|
method: 'channels.deposit',
|
|
591
471
|
params: {
|
|
592
|
-
amount
|
|
472
|
+
amount
|
|
593
473
|
}
|
|
594
474
|
});
|
|
595
475
|
return {
|
|
596
476
|
handler: handlers.awaitingDepositTx,
|
|
597
477
|
state: {
|
|
598
|
-
sign
|
|
599
|
-
resolve
|
|
600
|
-
reject
|
|
601
|
-
onOnChainTx
|
|
602
|
-
onOwnDepositLocked
|
|
603
|
-
onDepositLocked
|
|
478
|
+
sign,
|
|
479
|
+
resolve,
|
|
480
|
+
reject,
|
|
481
|
+
onOnChainTx,
|
|
482
|
+
onOwnDepositLocked,
|
|
483
|
+
onDepositLocked
|
|
604
484
|
}
|
|
605
485
|
};
|
|
606
486
|
});
|
|
@@ -640,25 +520,23 @@ function deposit(amount, sign) {
|
|
|
640
520
|
*/
|
|
641
521
|
|
|
642
522
|
|
|
643
|
-
function createContract(
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
return new
|
|
652
|
-
enqueueAction(
|
|
653
|
-
return state.handler === handlers.channelOpen;
|
|
654
|
-
}, function (channel, state) {
|
|
523
|
+
function createContract(_ref3, sign) {
|
|
524
|
+
let {
|
|
525
|
+
code,
|
|
526
|
+
callData,
|
|
527
|
+
deposit,
|
|
528
|
+
vmVersion,
|
|
529
|
+
abiVersion
|
|
530
|
+
} = _ref3;
|
|
531
|
+
return new Promise((resolve, reject) => {
|
|
532
|
+
enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
|
|
655
533
|
send(channel, {
|
|
656
534
|
jsonrpc: '2.0',
|
|
657
535
|
method: 'channels.update.new_contract',
|
|
658
536
|
params: {
|
|
659
|
-
code
|
|
537
|
+
code,
|
|
660
538
|
call_data: callData,
|
|
661
|
-
deposit
|
|
539
|
+
deposit,
|
|
662
540
|
vm_version: vmVersion,
|
|
663
541
|
abi_version: abiVersion
|
|
664
542
|
}
|
|
@@ -666,9 +544,9 @@ function createContract(_ref6, sign) {
|
|
|
666
544
|
return {
|
|
667
545
|
handler: handlers.awaitingNewContractTx,
|
|
668
546
|
state: {
|
|
669
|
-
sign
|
|
670
|
-
resolve
|
|
671
|
-
reject
|
|
547
|
+
sign,
|
|
548
|
+
resolve,
|
|
549
|
+
reject
|
|
672
550
|
}
|
|
673
551
|
};
|
|
674
552
|
});
|
|
@@ -712,22 +590,20 @@ function createContract(_ref6, sign) {
|
|
|
712
590
|
*/
|
|
713
591
|
|
|
714
592
|
|
|
715
|
-
function callContract(
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
return new
|
|
723
|
-
enqueueAction(
|
|
724
|
-
return state.handler === handlers.channelOpen;
|
|
725
|
-
}, function (channel, state) {
|
|
593
|
+
function callContract(_ref4, sign) {
|
|
594
|
+
let {
|
|
595
|
+
amount,
|
|
596
|
+
callData,
|
|
597
|
+
contract,
|
|
598
|
+
abiVersion
|
|
599
|
+
} = _ref4;
|
|
600
|
+
return new Promise((resolve, reject) => {
|
|
601
|
+
enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
|
|
726
602
|
send(channel, {
|
|
727
603
|
jsonrpc: '2.0',
|
|
728
604
|
method: 'channels.update.call_contract',
|
|
729
605
|
params: {
|
|
730
|
-
amount
|
|
606
|
+
amount,
|
|
731
607
|
call_data: callData,
|
|
732
608
|
contract_id: contract,
|
|
733
609
|
abi_version: abiVersion
|
|
@@ -736,9 +612,9 @@ function callContract(_ref7, sign) {
|
|
|
736
612
|
return {
|
|
737
613
|
handler: handlers.awaitingCallContractUpdateTx,
|
|
738
614
|
state: {
|
|
739
|
-
resolve
|
|
740
|
-
reject
|
|
741
|
-
sign
|
|
615
|
+
resolve,
|
|
616
|
+
reject,
|
|
617
|
+
sign
|
|
742
618
|
}
|
|
743
619
|
};
|
|
744
620
|
});
|
|
@@ -773,45 +649,40 @@ function callContract(_ref7, sign) {
|
|
|
773
649
|
*/
|
|
774
650
|
|
|
775
651
|
|
|
776
|
-
function forceProgress(
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
return new _Promise(function (resolve, reject) {
|
|
793
|
-
enqueueAction(_this8, function (channel, state) {
|
|
794
|
-
return state.handler === handlers.channelOpen;
|
|
795
|
-
}, function (channel, state) {
|
|
652
|
+
function forceProgress(_ref5, sign) {
|
|
653
|
+
let {
|
|
654
|
+
amount,
|
|
655
|
+
callData,
|
|
656
|
+
contract,
|
|
657
|
+
abiVersion,
|
|
658
|
+
gas = 1000000,
|
|
659
|
+
gasPrice = 1000000000,
|
|
660
|
+
nonce
|
|
661
|
+
} = _ref5;
|
|
662
|
+
let {
|
|
663
|
+
onOnChainTx
|
|
664
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
665
|
+
return new Promise((resolve, reject) => {
|
|
666
|
+
enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
|
|
796
667
|
send(channel, {
|
|
797
668
|
jsonrpc: '2.0',
|
|
798
669
|
method: 'channels.force_progress',
|
|
799
670
|
params: {
|
|
800
|
-
amount
|
|
671
|
+
amount,
|
|
801
672
|
call_data: callData,
|
|
802
673
|
contract_id: contract,
|
|
803
674
|
abi_version: abiVersion,
|
|
804
675
|
gas_price: gasPrice,
|
|
805
|
-
gas
|
|
676
|
+
gas
|
|
806
677
|
}
|
|
807
678
|
});
|
|
808
679
|
return {
|
|
809
680
|
handler: handlers.awaitingCallContractForceProgressUpdate,
|
|
810
681
|
state: {
|
|
811
|
-
resolve
|
|
812
|
-
reject
|
|
813
|
-
sign
|
|
814
|
-
onOnChainTx
|
|
682
|
+
resolve,
|
|
683
|
+
reject,
|
|
684
|
+
sign,
|
|
685
|
+
onOnChainTx
|
|
815
686
|
}
|
|
816
687
|
};
|
|
817
688
|
});
|
|
@@ -846,8 +717,19 @@ function forceProgress(_ref8, sign) {
|
|
|
846
717
|
*/
|
|
847
718
|
|
|
848
719
|
|
|
849
|
-
function callContractStatic(
|
|
850
|
-
|
|
720
|
+
async function callContractStatic(_ref6) {
|
|
721
|
+
let {
|
|
722
|
+
amount,
|
|
723
|
+
callData,
|
|
724
|
+
contract,
|
|
725
|
+
abiVersion
|
|
726
|
+
} = _ref6;
|
|
727
|
+
return snakeToPascalObjKeys(await call(this, 'channels.dry_run.call_contract', {
|
|
728
|
+
amount,
|
|
729
|
+
call_data: callData,
|
|
730
|
+
contract_id: contract,
|
|
731
|
+
abi_version: abiVersion
|
|
732
|
+
}));
|
|
851
733
|
}
|
|
852
734
|
/**
|
|
853
735
|
* Get contract call result
|
|
@@ -870,39 +752,17 @@ function callContractStatic(_x3) {
|
|
|
870
752
|
*/
|
|
871
753
|
|
|
872
754
|
|
|
873
|
-
function
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
return call(this, 'channels.dry_run.call_contract', {
|
|
884
|
-
amount: amount,
|
|
885
|
-
call_data: callData,
|
|
886
|
-
contract_id: contract,
|
|
887
|
-
abi_version: abiVersion
|
|
888
|
-
});
|
|
889
|
-
|
|
890
|
-
case 4:
|
|
891
|
-
_context6.t1 = _context6.sent;
|
|
892
|
-
return _context6.abrupt("return", (0, _context6.t0)(_context6.t1));
|
|
893
|
-
|
|
894
|
-
case 6:
|
|
895
|
-
case "end":
|
|
896
|
-
return _context6.stop();
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
}, _callee5, this);
|
|
755
|
+
async function getContractCall(_ref7) {
|
|
756
|
+
let {
|
|
757
|
+
caller,
|
|
758
|
+
contract,
|
|
759
|
+
round
|
|
760
|
+
} = _ref7;
|
|
761
|
+
return snakeToPascalObjKeys(await call(this, 'channels.get.contract_call', {
|
|
762
|
+
caller_id: caller,
|
|
763
|
+
contract_id: contract,
|
|
764
|
+
round
|
|
900
765
|
}));
|
|
901
|
-
return _callContractStatic.apply(this, arguments);
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
function getContractCall(_x4) {
|
|
905
|
-
return _getContractCall.apply(this, arguments);
|
|
906
766
|
}
|
|
907
767
|
/**
|
|
908
768
|
* Get contract latest state
|
|
@@ -917,38 +777,13 @@ function getContractCall(_x4) {
|
|
|
917
777
|
*/
|
|
918
778
|
|
|
919
779
|
|
|
920
|
-
function
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
caller = _ref11.caller, contract = _ref11.contract, round = _ref11.round;
|
|
928
|
-
_context7.t0 = snakeToPascalObjKeys;
|
|
929
|
-
_context7.next = 4;
|
|
930
|
-
return call(this, 'channels.get.contract_call', {
|
|
931
|
-
caller_id: caller,
|
|
932
|
-
contract_id: contract,
|
|
933
|
-
round: round
|
|
934
|
-
});
|
|
935
|
-
|
|
936
|
-
case 4:
|
|
937
|
-
_context7.t1 = _context7.sent;
|
|
938
|
-
return _context7.abrupt("return", (0, _context7.t0)(_context7.t1));
|
|
939
|
-
|
|
940
|
-
case 6:
|
|
941
|
-
case "end":
|
|
942
|
-
return _context7.stop();
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
}, _callee6, this);
|
|
946
|
-
}));
|
|
947
|
-
return _getContractCall.apply(this, arguments);
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
function getContractState(_x5) {
|
|
951
|
-
return _getContractState.apply(this, arguments);
|
|
780
|
+
async function getContractState(contract) {
|
|
781
|
+
const result = await call(this, 'channels.get.contract', {
|
|
782
|
+
pubkey: contract
|
|
783
|
+
});
|
|
784
|
+
return snakeToPascalObjKeys({ ...result,
|
|
785
|
+
contract: snakeToPascalObjKeys(result.contract)
|
|
786
|
+
});
|
|
952
787
|
}
|
|
953
788
|
/**
|
|
954
789
|
* Clean up all locally stored contract calls
|
|
@@ -962,41 +797,9 @@ function getContractState(_x5) {
|
|
|
962
797
|
*/
|
|
963
798
|
|
|
964
799
|
|
|
965
|
-
function _getContractState() {
|
|
966
|
-
_getContractState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(contract) {
|
|
967
|
-
var result;
|
|
968
|
-
return _regeneratorRuntime.wrap(function _callee7$(_context8) {
|
|
969
|
-
while (1) {
|
|
970
|
-
switch (_context8.prev = _context8.next) {
|
|
971
|
-
case 0:
|
|
972
|
-
_context8.next = 2;
|
|
973
|
-
return call(this, 'channels.get.contract', {
|
|
974
|
-
pubkey: contract
|
|
975
|
-
});
|
|
976
|
-
|
|
977
|
-
case 2:
|
|
978
|
-
result = _context8.sent;
|
|
979
|
-
return _context8.abrupt("return", snakeToPascalObjKeys(_objectSpread(_objectSpread({}, result), {}, {
|
|
980
|
-
contract: snakeToPascalObjKeys(result.contract)
|
|
981
|
-
})));
|
|
982
|
-
|
|
983
|
-
case 4:
|
|
984
|
-
case "end":
|
|
985
|
-
return _context8.stop();
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
}, _callee7, this);
|
|
989
|
-
}));
|
|
990
|
-
return _getContractState.apply(this, arguments);
|
|
991
|
-
}
|
|
992
|
-
|
|
993
800
|
function cleanContractCalls() {
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
return new _Promise(function (resolve, reject) {
|
|
997
|
-
enqueueAction(_this9, function (channel, state) {
|
|
998
|
-
return state.handler === handlers.channelOpen;
|
|
999
|
-
}, function (channel, state) {
|
|
801
|
+
return new Promise((resolve, reject) => {
|
|
802
|
+
enqueueAction(this, (channel, state) => state.handler === handlers.channelOpen, (channel, state) => {
|
|
1000
803
|
send(channel, {
|
|
1001
804
|
jsonrpc: '2.0',
|
|
1002
805
|
method: 'channels.clean_contract_calls',
|
|
@@ -1005,8 +808,8 @@ function cleanContractCalls() {
|
|
|
1005
808
|
return {
|
|
1006
809
|
handler: handlers.awaitingCallsPruned,
|
|
1007
810
|
state: {
|
|
1008
|
-
resolve
|
|
1009
|
-
reject
|
|
811
|
+
resolve,
|
|
812
|
+
reject
|
|
1010
813
|
}
|
|
1011
814
|
};
|
|
1012
815
|
});
|
|
@@ -1031,35 +834,28 @@ function cleanContractCalls() {
|
|
|
1031
834
|
|
|
1032
835
|
|
|
1033
836
|
function sendMessage(message, recipient) {
|
|
1034
|
-
|
|
837
|
+
let info = message;
|
|
1035
838
|
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
if (_typeof(message) === 'object') {
|
|
1039
|
-
info = _JSON$stringify(message);
|
|
839
|
+
if (typeof message === 'object') {
|
|
840
|
+
info = JSON.stringify(message);
|
|
1040
841
|
}
|
|
1041
842
|
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
});
|
|
1051
|
-
};
|
|
843
|
+
const doSend = channel => send(channel, {
|
|
844
|
+
jsonrpc: '2.0',
|
|
845
|
+
method: 'channels.message',
|
|
846
|
+
params: {
|
|
847
|
+
info,
|
|
848
|
+
to: recipient
|
|
849
|
+
}
|
|
850
|
+
});
|
|
1052
851
|
|
|
1053
852
|
if (this.status() === 'connecting') {
|
|
1054
|
-
|
|
853
|
+
const onStatusChanged = status => {
|
|
1055
854
|
if (status !== 'connecting') {
|
|
1056
855
|
// For some reason we can't immediately send a message when connection is
|
|
1057
856
|
// established. Thus we wait 500ms which seems to work.
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
}, 500);
|
|
1061
|
-
|
|
1062
|
-
_this10.off('statusChanged', onStatusChanged);
|
|
857
|
+
setTimeout(() => doSend(this), 500);
|
|
858
|
+
this.off('statusChanged', onStatusChanged);
|
|
1063
859
|
}
|
|
1064
860
|
};
|
|
1065
861
|
|
|
@@ -1069,8 +865,13 @@ function sendMessage(message, recipient) {
|
|
|
1069
865
|
}
|
|
1070
866
|
}
|
|
1071
867
|
|
|
1072
|
-
function reconnect(
|
|
1073
|
-
|
|
868
|
+
async function reconnect(options, txParams) {
|
|
869
|
+
const {
|
|
870
|
+
sign
|
|
871
|
+
} = options;
|
|
872
|
+
return Channel({ ...options,
|
|
873
|
+
reconnectTx: await sign('reconnect', buildTx(txParams, TX_TYPE.channelReconnect).tx)
|
|
874
|
+
});
|
|
1074
875
|
}
|
|
1075
876
|
/**
|
|
1076
877
|
* Channel
|
|
@@ -1084,23 +885,42 @@ function reconnect(_x6, _x7) {
|
|
|
1084
885
|
* @param {String} options.initiatorId - Initiator's public key
|
|
1085
886
|
* @param {String} options.responderId - Responder's public key
|
|
1086
887
|
* @param {Number} options.pushAmount - Initial deposit in favour of the responder by the initiator
|
|
1087
|
-
* @param {Number} options.initiatorAmount - Amount of tokens the initiator has committed to
|
|
1088
|
-
*
|
|
888
|
+
* @param {Number} options.initiatorAmount - Amount of tokens the initiator has committed to
|
|
889
|
+
* the channel
|
|
890
|
+
* @param {Number} options.responderAmount - Amount of tokens the responder has committed to
|
|
891
|
+
* the channel
|
|
1089
892
|
* @param {Number} options.channelReserve - The minimum amount both peers need to maintain
|
|
1090
893
|
* @param {Number} [options.ttl] - Minimum block height to include the channel_create_tx
|
|
1091
894
|
* @param {String} options.host - Host of the responder's node
|
|
1092
895
|
* @param {Number} options.port - The port of the responders node
|
|
1093
896
|
* @param {Number} options.lockPeriod - Amount of blocks for disputing a solo close
|
|
1094
|
-
* @param {Number} [options.existingChannelId] - Existing channel id (required if reestablishing a
|
|
1095
|
-
*
|
|
1096
|
-
* @param {Number} [options.
|
|
1097
|
-
*
|
|
1098
|
-
* @param {Number} [options.
|
|
1099
|
-
*
|
|
1100
|
-
* @param {Number} [options.
|
|
1101
|
-
*
|
|
1102
|
-
* @param {Number} [options.
|
|
1103
|
-
*
|
|
897
|
+
* @param {Number} [options.existingChannelId] - Existing channel id (required if reestablishing a
|
|
898
|
+
* channel)
|
|
899
|
+
* @param {Number} [options.offchainTx] - Offchain transaction (required if reestablishing
|
|
900
|
+
* a channel)
|
|
901
|
+
* @param {Number} [options.timeoutIdle] - The time waiting for a new event to be initiated
|
|
902
|
+
* (default: 600000)
|
|
903
|
+
* @param {Number} [options.timeoutFundingCreate] - The time waiting for the initiator to produce
|
|
904
|
+
* the create channel transaction after the noise session had been established (default: 120000)
|
|
905
|
+
* @param {Number} [options.timeoutFundingSign] - The time frame the other client has to sign an
|
|
906
|
+
* off-chain update after our client had initiated and signed it. This applies only for double
|
|
907
|
+
* signed on-chain intended updates: channel create transaction, deposit, withdrawal and etc.
|
|
908
|
+
* (default: 120000)
|
|
909
|
+
* @param {Number} [options.timeoutFundingLock] - The time frame the other client has to confirm an
|
|
910
|
+
* on-chain transaction reaching maturity (passing minimum depth) after the local node has detected
|
|
911
|
+
* this. This applies only for double signed on-chain intended updates: channel create transaction,
|
|
912
|
+
* deposit, withdrawal and etc. (default: 360000)
|
|
913
|
+
* @param {Number} [options.timeoutSign] - The time frame the client has to return a signed
|
|
914
|
+
* off-chain update or to decline it. This applies for all off-chain updates (default: 500000)
|
|
915
|
+
* @param {Number} [options.timeoutAccept] - The time frame the other client has to react to an
|
|
916
|
+
* event. This applies for all off-chain updates that are not meant to land on-chain, as well as
|
|
917
|
+
* some special cases: opening a noise connection, mutual closing acknowledgement and
|
|
918
|
+
* reestablishing an existing channel (default: 120000)
|
|
919
|
+
* @param {Number} [options.timeoutInitialized] - the time frame the responder has to accept an
|
|
920
|
+
* incoming noise session. Applicable only for initiator (default: timeout_accept's value)
|
|
921
|
+
* @param {Number} [options.timeoutAwaitingOpen] - The time frame the initiator has to start an
|
|
922
|
+
* outgoing noise session to the responder's node. Applicable only for responder (default:
|
|
923
|
+
* timeout_idle's value)
|
|
1104
924
|
* @param {Number} [options.debug=false] - Log websocket communication
|
|
1105
925
|
* @param {Function} options.sign - Function which verifies and signs transactions
|
|
1106
926
|
* @return {Promise<Object>} Channel instance
|
|
@@ -1122,85 +942,38 @@ function reconnect(_x6, _x7) {
|
|
|
1122
942
|
*/
|
|
1123
943
|
|
|
1124
944
|
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
return _regeneratorRuntime.wrap(function _callee8$(_context9) {
|
|
1129
|
-
while (1) {
|
|
1130
|
-
switch (_context9.prev = _context9.next) {
|
|
1131
|
-
case 0:
|
|
1132
|
-
sign = options.sign;
|
|
1133
|
-
_context9.t0 = Channel;
|
|
1134
|
-
_context9.t1 = _objectSpread;
|
|
1135
|
-
_context9.t2 = _objectSpread({}, options);
|
|
1136
|
-
_context9.t3 = {};
|
|
1137
|
-
_context9.next = 7;
|
|
1138
|
-
return sign('reconnect', buildTx(txParams, TX_TYPE.channelReconnect).tx);
|
|
1139
|
-
|
|
1140
|
-
case 7:
|
|
1141
|
-
_context9.t4 = _context9.sent;
|
|
1142
|
-
_context9.t5 = {
|
|
1143
|
-
reconnectTx: _context9.t4
|
|
1144
|
-
};
|
|
1145
|
-
_context9.t6 = (0, _context9.t1)(_context9.t2, _context9.t3, _context9.t5);
|
|
1146
|
-
return _context9.abrupt("return", (0, _context9.t0)(_context9.t6));
|
|
1147
|
-
|
|
1148
|
-
case 11:
|
|
1149
|
-
case "end":
|
|
1150
|
-
return _context9.stop();
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
}, _callee8);
|
|
1154
|
-
}));
|
|
1155
|
-
return _reconnect.apply(this, arguments);
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
var Channel = AsyncInit.compose({
|
|
1159
|
-
init: function init(options) {
|
|
1160
|
-
var _this11 = this;
|
|
1161
|
-
|
|
1162
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
1163
|
-
return _regeneratorRuntime.wrap(function _callee$(_context2) {
|
|
1164
|
-
while (1) {
|
|
1165
|
-
switch (_context2.prev = _context2.next) {
|
|
1166
|
-
case 0:
|
|
1167
|
-
initialize(_this11, options);
|
|
1168
|
-
|
|
1169
|
-
case 1:
|
|
1170
|
-
case "end":
|
|
1171
|
-
return _context2.stop();
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
}, _callee);
|
|
1175
|
-
}))();
|
|
945
|
+
const Channel = AsyncInit.compose({
|
|
946
|
+
async init(options) {
|
|
947
|
+
initialize(this, options);
|
|
1176
948
|
},
|
|
949
|
+
|
|
1177
950
|
methods: {
|
|
1178
|
-
on
|
|
1179
|
-
off
|
|
1180
|
-
status
|
|
1181
|
-
state
|
|
1182
|
-
round
|
|
1183
|
-
id
|
|
1184
|
-
fsmId
|
|
1185
|
-
update
|
|
1186
|
-
poi
|
|
1187
|
-
balances
|
|
1188
|
-
leave
|
|
1189
|
-
shutdown
|
|
1190
|
-
sendMessage
|
|
1191
|
-
withdraw
|
|
1192
|
-
deposit
|
|
1193
|
-
createContract
|
|
1194
|
-
callContract
|
|
1195
|
-
callContractStatic
|
|
1196
|
-
getContractCall
|
|
1197
|
-
getContractState
|
|
1198
|
-
disconnect
|
|
1199
|
-
cleanContractCalls
|
|
1200
|
-
forceProgress
|
|
951
|
+
on,
|
|
952
|
+
off,
|
|
953
|
+
status,
|
|
954
|
+
state,
|
|
955
|
+
round,
|
|
956
|
+
id,
|
|
957
|
+
fsmId,
|
|
958
|
+
update,
|
|
959
|
+
poi,
|
|
960
|
+
balances,
|
|
961
|
+
leave,
|
|
962
|
+
shutdown,
|
|
963
|
+
sendMessage,
|
|
964
|
+
withdraw,
|
|
965
|
+
deposit,
|
|
966
|
+
createContract,
|
|
967
|
+
callContract,
|
|
968
|
+
callContractStatic,
|
|
969
|
+
getContractCall,
|
|
970
|
+
getContractState,
|
|
971
|
+
disconnect,
|
|
972
|
+
cleanContractCalls,
|
|
973
|
+
forceProgress
|
|
1201
974
|
},
|
|
1202
975
|
statics: {
|
|
1203
|
-
reconnect
|
|
976
|
+
reconnect
|
|
1204
977
|
}
|
|
1205
978
|
});
|
|
1206
979
|
export default Channel;
|