@ledgerhq/live-cli 21.32.2-nightly.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 +520 -0
- package/bin/index.js +2 -0
- package/lib/cli.d.ts +2 -0
- package/lib/cli.d.ts.map +1 -0
- package/lib/cli.js +137 -0
- package/lib/cli.js.map +1 -0
- package/lib/commands/app.d.ts +45 -0
- package/lib/commands/app.d.ts.map +1 -0
- package/lib/commands/app.js +131 -0
- package/lib/commands/app.js.map +1 -0
- package/lib/commands/appUninstallAll.d.ts +15 -0
- package/lib/commands/appUninstallAll.d.ts.map +1 -0
- package/lib/commands/appUninstallAll.js +31 -0
- package/lib/commands/appUninstallAll.js.map +1 -0
- package/lib/commands/appsCheckAllAppVersions.d.ts +20 -0
- package/lib/commands/appsCheckAllAppVersions.d.ts.map +1 -0
- package/lib/commands/appsCheckAllAppVersions.js +484 -0
- package/lib/commands/appsCheckAllAppVersions.js.map +1 -0
- package/lib/commands/appsInstallAll.d.ts +15 -0
- package/lib/commands/appsInstallAll.d.ts.map +1 -0
- package/lib/commands/appsInstallAll.js +34 -0
- package/lib/commands/appsInstallAll.js.map +1 -0
- package/lib/commands/appsUpdateTestAll.d.ts +20 -0
- package/lib/commands/appsUpdateTestAll.d.ts.map +1 -0
- package/lib/commands/appsUpdateTestAll.js +101 -0
- package/lib/commands/appsUpdateTestAll.js.map +1 -0
- package/lib/commands/balanceHistory.d.ts +50 -0
- package/lib/commands/balanceHistory.d.ts.map +1 -0
- package/lib/commands/balanceHistory.js +110 -0
- package/lib/commands/balanceHistory.js.map +1 -0
- package/lib/commands/bot.d.ts +12 -0
- package/lib/commands/bot.d.ts.map +1 -0
- package/lib/commands/bot.js +33 -0
- package/lib/commands/bot.js.map +1 -0
- package/lib/commands/botPortfolio.d.ts +15 -0
- package/lib/commands/botPortfolio.d.ts.map +1 -0
- package/lib/commands/botPortfolio.js +41 -0
- package/lib/commands/botPortfolio.js.map +1 -0
- package/lib/commands/botTransfer.d.ts +7 -0
- package/lib/commands/botTransfer.d.ts.map +1 -0
- package/lib/commands/botTransfer.js +376 -0
- package/lib/commands/botTransfer.js.map +1 -0
- package/lib/commands/broadcast.d.ts +42 -0
- package/lib/commands/broadcast.d.ts.map +1 -0
- package/lib/commands/broadcast.js +48 -0
- package/lib/commands/broadcast.js.map +1 -0
- package/lib/commands/cleanSpeculos.d.ts +7 -0
- package/lib/commands/cleanSpeculos.d.ts.map +1 -0
- package/lib/commands/cleanSpeculos.js +20 -0
- package/lib/commands/cleanSpeculos.js.map +1 -0
- package/lib/commands/countervalues.d.ts +84 -0
- package/lib/commands/countervalues.d.ts.map +1 -0
- package/lib/commands/countervalues.js +302 -0
- package/lib/commands/countervalues.js.map +1 -0
- package/lib/commands/derivation.d.ts +6 -0
- package/lib/commands/derivation.d.ts.map +1 -0
- package/lib/commands/derivation.js +44 -0
- package/lib/commands/derivation.js.map +1 -0
- package/lib/commands/devDeviceAppsScenario.d.ts +24 -0
- package/lib/commands/devDeviceAppsScenario.d.ts.map +1 -0
- package/lib/commands/devDeviceAppsScenario.js +97 -0
- package/lib/commands/devDeviceAppsScenario.js.map +1 -0
- package/lib/commands/deviceAppVersion.d.ts +19 -0
- package/lib/commands/deviceAppVersion.d.ts.map +1 -0
- package/lib/commands/deviceAppVersion.js +17 -0
- package/lib/commands/deviceAppVersion.js.map +1 -0
- package/lib/commands/deviceInfo.d.ts +14 -0
- package/lib/commands/deviceInfo.d.ts.map +1 -0
- package/lib/commands/deviceInfo.js +17 -0
- package/lib/commands/deviceInfo.js.map +1 -0
- package/lib/commands/deviceVersion.d.ts +14 -0
- package/lib/commands/deviceVersion.d.ts.map +1 -0
- package/lib/commands/deviceVersion.js +17 -0
- package/lib/commands/deviceVersion.js.map +1 -0
- package/lib/commands/discoverDevices.d.ts +23 -0
- package/lib/commands/discoverDevices.d.ts.map +1 -0
- package/lib/commands/discoverDevices.js +86 -0
- package/lib/commands/discoverDevices.js.map +1 -0
- package/lib/commands/envs.d.ts +7 -0
- package/lib/commands/envs.d.ts.map +1 -0
- package/lib/commands/envs.js +15 -0
- package/lib/commands/envs.js.map +1 -0
- package/lib/commands/estimateMaxSpendable.d.ts +41 -0
- package/lib/commands/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/commands/estimateMaxSpendable.js +65 -0
- package/lib/commands/estimateMaxSpendable.js.map +1 -0
- package/lib/commands/exportAccounts.d.ts +48 -0
- package/lib/commands/exportAccounts.d.ts.map +1 -0
- package/lib/commands/exportAccounts.js +69 -0
- package/lib/commands/exportAccounts.js.map +1 -0
- package/lib/commands/firmwareRepair.d.ts +22 -0
- package/lib/commands/firmwareRepair.d.ts.map +1 -0
- package/lib/commands/firmwareRepair.js +23 -0
- package/lib/commands/firmwareRepair.js.map +1 -0
- package/lib/commands/firmwareUpdate.d.ts +26 -0
- package/lib/commands/firmwareUpdate.d.ts.map +1 -0
- package/lib/commands/firmwareUpdate.js +154 -0
- package/lib/commands/firmwareUpdate.js.map +1 -0
- package/lib/commands/generateAppJsonFromDataset.d.ts +7 -0
- package/lib/commands/generateAppJsonFromDataset.d.ts.map +1 -0
- package/lib/commands/generateAppJsonFromDataset.js +212 -0
- package/lib/commands/generateAppJsonFromDataset.js.map +1 -0
- package/lib/commands/generateTestScanAccounts.d.ts +49 -0
- package/lib/commands/generateTestScanAccounts.d.ts.map +1 -0
- package/lib/commands/generateTestScanAccounts.js +60 -0
- package/lib/commands/generateTestScanAccounts.js.map +1 -0
- package/lib/commands/generateTestTransaction.d.ts +44 -0
- package/lib/commands/generateTestTransaction.d.ts.map +1 -0
- package/lib/commands/generateTestTransaction.js +118 -0
- package/lib/commands/generateTestTransaction.js.map +1 -0
- package/lib/commands/genuineCheck.d.ts +15 -0
- package/lib/commands/genuineCheck.d.ts.map +1 -0
- package/lib/commands/genuineCheck.js +22 -0
- package/lib/commands/genuineCheck.js.map +1 -0
- package/lib/commands/getAddress.d.ts +28 -0
- package/lib/commands/getAddress.d.ts.map +1 -0
- package/lib/commands/getAddress.js +53 -0
- package/lib/commands/getAddress.js.map +1 -0
- package/lib/commands/getTransactionStatus.d.ts +52 -0
- package/lib/commands/getTransactionStatus.d.ts.map +1 -0
- package/lib/commands/getTransactionStatus.js +86 -0
- package/lib/commands/getTransactionStatus.js.map +1 -0
- package/lib/commands/liveData.d.ts +49 -0
- package/lib/commands/liveData.d.ts.map +1 -0
- package/lib/commands/liveData.js +82 -0
- package/lib/commands/liveData.js.map +1 -0
- package/lib/commands/makeCompoundSummary.d.ts +54 -0
- package/lib/commands/makeCompoundSummary.d.ts.map +1 -0
- package/lib/commands/makeCompoundSummary.js +190 -0
- package/lib/commands/makeCompoundSummary.js.map +1 -0
- package/lib/commands/managerListApps.d.ts +21 -0
- package/lib/commands/managerListApps.d.ts.map +1 -0
- package/lib/commands/managerListApps.js +47 -0
- package/lib/commands/managerListApps.js.map +1 -0
- package/lib/commands/portfolio.d.ts +66 -0
- package/lib/commands/portfolio.d.ts.map +1 -0
- package/lib/commands/portfolio.js +138 -0
- package/lib/commands/portfolio.js.map +1 -0
- package/lib/commands/proxy.d.ts +36 -0
- package/lib/commands/proxy.d.ts.map +1 -0
- package/lib/commands/proxy.js +413 -0
- package/lib/commands/proxy.js.map +1 -0
- package/lib/commands/receive.d.ts +48 -0
- package/lib/commands/receive.d.ts.map +1 -0
- package/lib/commands/receive.js +68 -0
- package/lib/commands/receive.js.map +1 -0
- package/lib/commands/repl.d.ts +22 -0
- package/lib/commands/repl.d.ts.map +1 -0
- package/lib/commands/repl.js +26 -0
- package/lib/commands/repl.js.map +1 -0
- package/lib/commands/satstack.d.ts +37 -0
- package/lib/commands/satstack.d.ts.map +1 -0
- package/lib/commands/satstack.js +110 -0
- package/lib/commands/satstack.js.map +1 -0
- package/lib/commands/satstackStatus.d.ts +13 -0
- package/lib/commands/satstackStatus.d.ts.map +1 -0
- package/lib/commands/satstackStatus.js +24 -0
- package/lib/commands/satstackStatus.js.map +1 -0
- package/lib/commands/scanDescriptors.d.ts +15 -0
- package/lib/commands/scanDescriptors.d.ts.map +1 -0
- package/lib/commands/scanDescriptors.js +18 -0
- package/lib/commands/scanDescriptors.js.map +1 -0
- package/lib/commands/send.d.ts +48 -0
- package/lib/commands/send.d.ts.map +1 -0
- package/lib/commands/send.js +116 -0
- package/lib/commands/send.js.map +1 -0
- package/lib/commands/signMessage.d.ts +16 -0
- package/lib/commands/signMessage.d.ts.map +1 -0
- package/lib/commands/signMessage.js +58 -0
- package/lib/commands/signMessage.js.map +1 -0
- package/lib/commands/speculosList.d.ts +7 -0
- package/lib/commands/speculosList.d.ts.map +1 -0
- package/lib/commands/speculosList.js +71 -0
- package/lib/commands/speculosList.js.map +1 -0
- package/lib/commands/swap.d.ts +55 -0
- package/lib/commands/swap.d.ts.map +1 -0
- package/lib/commands/swap.js +341 -0
- package/lib/commands/swap.js.map +1 -0
- package/lib/commands/sync.d.ts +49 -0
- package/lib/commands/sync.d.ts.map +1 -0
- package/lib/commands/sync.js +135 -0
- package/lib/commands/sync.js.map +1 -0
- package/lib/commands/testDetectOpCollision.d.ts +41 -0
- package/lib/commands/testDetectOpCollision.d.ts.map +1 -0
- package/lib/commands/testDetectOpCollision.js +57 -0
- package/lib/commands/testDetectOpCollision.js.map +1 -0
- package/lib/commands/testGetTrustedInputFromTxHash.d.ts +23 -0
- package/lib/commands/testGetTrustedInputFromTxHash.d.ts.map +1 -0
- package/lib/commands/testGetTrustedInputFromTxHash.js +114 -0
- package/lib/commands/testGetTrustedInputFromTxHash.js.map +1 -0
- package/lib/commands/user.d.ts +6 -0
- package/lib/commands/user.d.ts.map +1 -0
- package/lib/commands/user.js +9 -0
- package/lib/commands/user.js.map +1 -0
- package/lib/commands/version.d.ts +7 -0
- package/lib/commands/version.d.ts.map +1 -0
- package/lib/commands/version.js +12 -0
- package/lib/commands/version.js.map +1 -0
- package/lib/commands/walletconnect.d.ts +62 -0
- package/lib/commands/walletconnect.d.ts.map +1 -0
- package/lib/commands/walletconnect.js +272 -0
- package/lib/commands/walletconnect.js.map +1 -0
- package/lib/commands-index.d.ts +1511 -0
- package/lib/commands-index.d.ts.map +1 -0
- package/lib/commands-index.js +106 -0
- package/lib/commands-index.js.map +1 -0
- package/lib/live-common-setup-base.d.ts +2 -0
- package/lib/live-common-setup-base.d.ts.map +1 -0
- package/lib/live-common-setup-base.js +131 -0
- package/lib/live-common-setup-base.js.map +1 -0
- package/lib/live-common-setup.d.ts +5 -0
- package/lib/live-common-setup.d.ts.map +1 -0
- package/lib/live-common-setup.js +318 -0
- package/lib/live-common-setup.js.map +1 -0
- package/lib/qr.d.ts +3 -0
- package/lib/qr.d.ts.map +1 -0
- package/lib/qr.js +18 -0
- package/lib/qr.js.map +1 -0
- package/lib/scan.d.ts +71 -0
- package/lib/scan.d.ts.map +1 -0
- package/lib/scan.js +299 -0
- package/lib/scan.js.map +1 -0
- package/lib/signedOperation.d.ts +13 -0
- package/lib/signedOperation.d.ts.map +1 -0
- package/lib/signedOperation.js +31 -0
- package/lib/signedOperation.js.map +1 -0
- package/lib/stream.d.ts +7 -0
- package/lib/stream.d.ts.map +1 -0
- package/lib/stream.js +82 -0
- package/lib/stream.js.map +1 -0
- package/lib/transaction.d.ts +31 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +202 -0
- package/lib/transaction.js.map +1 -0
- package/package.json +63 -0
package/lib/scan.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import type { Account, CryptoCurrency } from "@ledgerhq/live-common/lib/types";
|
|
3
|
+
export declare const deviceOpt: {
|
|
4
|
+
name: string;
|
|
5
|
+
alias: string;
|
|
6
|
+
type: StringConstructor;
|
|
7
|
+
descOpt: string;
|
|
8
|
+
desc: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const currencyOpt: {
|
|
11
|
+
name: string;
|
|
12
|
+
alias: string;
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
desc: string;
|
|
15
|
+
};
|
|
16
|
+
export declare type ScanCommonOpts = Partial<{
|
|
17
|
+
device: string;
|
|
18
|
+
id: string[];
|
|
19
|
+
xpub: string[];
|
|
20
|
+
file: string;
|
|
21
|
+
appjsonFile: string;
|
|
22
|
+
currency: string;
|
|
23
|
+
scheme: string;
|
|
24
|
+
index: number;
|
|
25
|
+
length: number;
|
|
26
|
+
paginateOperations: number;
|
|
27
|
+
}>;
|
|
28
|
+
export declare const scanCommonOpts: ({
|
|
29
|
+
name: string;
|
|
30
|
+
alias: string;
|
|
31
|
+
type: StringConstructor;
|
|
32
|
+
desc: string;
|
|
33
|
+
} | {
|
|
34
|
+
name: string;
|
|
35
|
+
type: StringConstructor;
|
|
36
|
+
desc: string;
|
|
37
|
+
multiple: boolean;
|
|
38
|
+
typeDesc?: undefined;
|
|
39
|
+
alias?: undefined;
|
|
40
|
+
} | {
|
|
41
|
+
name: string;
|
|
42
|
+
type: StringConstructor;
|
|
43
|
+
typeDesc: string;
|
|
44
|
+
desc: string;
|
|
45
|
+
multiple?: undefined;
|
|
46
|
+
alias?: undefined;
|
|
47
|
+
} | {
|
|
48
|
+
name: string;
|
|
49
|
+
alias: string;
|
|
50
|
+
type: NumberConstructor;
|
|
51
|
+
desc: string;
|
|
52
|
+
multiple?: undefined;
|
|
53
|
+
typeDesc?: undefined;
|
|
54
|
+
} | {
|
|
55
|
+
name: string;
|
|
56
|
+
type: NumberConstructor;
|
|
57
|
+
desc: string;
|
|
58
|
+
multiple?: undefined;
|
|
59
|
+
typeDesc?: undefined;
|
|
60
|
+
alias?: undefined;
|
|
61
|
+
})[];
|
|
62
|
+
export declare const inferManagerApp: (keyword: string) => string;
|
|
63
|
+
export declare const inferCurrency: <T extends {
|
|
64
|
+
device: string;
|
|
65
|
+
currency: string;
|
|
66
|
+
file: string;
|
|
67
|
+
xpub: string[];
|
|
68
|
+
id: string[];
|
|
69
|
+
}>({ device, currency, file, xpub, id, }: Partial<T>) => Observable<CryptoCurrency | null | undefined>;
|
|
70
|
+
export declare function scan(arg: ScanCommonOpts): Observable<Account>;
|
|
71
|
+
//# sourceMappingURL=scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAuC,MAAM,MAAM,CAAC;AAUvE,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EAEf,MAAM,iCAAiC,CAAC;AA4BzC,eAAO,MAAM,SAAS;;;;;;CAMrB,CAAC;AACF,eAAO,MAAM,WAAW;;;;;CAKvB,CAAC;AAYF,oBAAY,cAAc,GAAG,OAAO,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC,CAAC;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkD1B,CAAC;AACF,eAAO,MAAM,eAAe,YAAa,MAAM,KAAG,MAQjD,CAAC;AAYF,eAAO,MAAM,aAAa;YAEd,MAAM;cACJ,MAAM;UACV,MAAM;UACN,MAAM,EAAE;QACV,MAAM,EAAE;sGA2Bf,CAAC;AAiBF,wBAAgB,IAAI,CAAC,GAAG,EAAE,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,CAkN7D"}
|
package/lib/scan.js
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.scan = exports.inferCurrency = exports.inferManagerApp = exports.scanCommonOpts = exports.currencyOpt = exports.deviceOpt = void 0;
|
|
7
|
+
var bignumber_js_1 = require("bignumber.js");
|
|
8
|
+
var rxjs_1 = require("rxjs");
|
|
9
|
+
var operators_1 = require("rxjs/operators");
|
|
10
|
+
var account_1 = require("@ledgerhq/live-common/lib/account");
|
|
11
|
+
var derivation_1 = require("@ledgerhq/live-common/lib/derivation");
|
|
12
|
+
var bridge_1 = require("@ledgerhq/live-common/lib/bridge");
|
|
13
|
+
var currencies_1 = require("@ledgerhq/live-common/lib/currencies");
|
|
14
|
+
var derivation_2 = require("@ledgerhq/live-common/lib/derivation");
|
|
15
|
+
var cache_1 = require("@ledgerhq/live-common/lib/bridge/cache");
|
|
16
|
+
var getAppAndVersion_1 = __importDefault(require("@ledgerhq/live-common/lib/hw/getAppAndVersion"));
|
|
17
|
+
var deviceAccess_1 = require("@ledgerhq/live-common/lib/hw/deviceAccess");
|
|
18
|
+
var promise_1 = require("@ledgerhq/live-common/lib/promise");
|
|
19
|
+
var stream_1 = require("./stream");
|
|
20
|
+
var helpers_1 = require("@ledgerhq/live-common/lib/account/helpers");
|
|
21
|
+
var fs_1 = __importDefault(require("fs"));
|
|
22
|
+
exports.deviceOpt = {
|
|
23
|
+
name: "device",
|
|
24
|
+
alias: "d",
|
|
25
|
+
type: String,
|
|
26
|
+
descOpt: "usb path",
|
|
27
|
+
desc: "provide a specific HID path of a device"
|
|
28
|
+
};
|
|
29
|
+
exports.currencyOpt = {
|
|
30
|
+
name: "currency",
|
|
31
|
+
alias: "c",
|
|
32
|
+
type: String,
|
|
33
|
+
desc: "Currency name or ticker. If not provided, it will be inferred from the device."
|
|
34
|
+
};
|
|
35
|
+
var localCache = {};
|
|
36
|
+
var cache = (0, cache_1.makeBridgeCacheSystem)({
|
|
37
|
+
saveData: function (c, d) {
|
|
38
|
+
localCache[c.id] = d;
|
|
39
|
+
return Promise.resolve();
|
|
40
|
+
},
|
|
41
|
+
getData: function (c) {
|
|
42
|
+
return Promise.resolve(localCache[c.id]);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
exports.scanCommonOpts = [
|
|
46
|
+
exports.deviceOpt,
|
|
47
|
+
{
|
|
48
|
+
name: "xpub",
|
|
49
|
+
type: String,
|
|
50
|
+
desc: "use an xpub (alternatively to --device) [DEPRECATED: prefer use of id]",
|
|
51
|
+
multiple: true
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "id",
|
|
55
|
+
type: String,
|
|
56
|
+
desc: "restore an account id (or a partial version of an id) (alternatively to --device)",
|
|
57
|
+
multiple: true
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "file",
|
|
61
|
+
type: String,
|
|
62
|
+
typeDesc: "filename",
|
|
63
|
+
desc: "use a JSON account file or '-' for stdin (alternatively to --device)"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "appjsonFile",
|
|
67
|
+
type: String,
|
|
68
|
+
typeDesc: "filename",
|
|
69
|
+
desc: "use a desktop app.json (alternatively to --device)"
|
|
70
|
+
},
|
|
71
|
+
exports.currencyOpt,
|
|
72
|
+
{
|
|
73
|
+
name: "scheme",
|
|
74
|
+
alias: "s",
|
|
75
|
+
type: String,
|
|
76
|
+
desc: "if provided, filter the derivation path that are scanned by a given sceme. Providing '' empty string will only use the default standard derivation scheme."
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "index",
|
|
80
|
+
alias: "i",
|
|
81
|
+
type: Number,
|
|
82
|
+
desc: "select the account by index"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "length",
|
|
86
|
+
alias: "l",
|
|
87
|
+
type: Number,
|
|
88
|
+
desc: "set the number of accounts after the index. Defaults to 1 if index was provided, Infinity otherwise."
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "paginateOperations",
|
|
92
|
+
type: Number,
|
|
93
|
+
desc: "if defined, will paginate operations"
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
var inferManagerApp = function (keyword) {
|
|
97
|
+
try {
|
|
98
|
+
var currency = (0, currencies_1.findCryptoCurrencyByKeyword)(keyword);
|
|
99
|
+
if (!currency || !currency.managerAppName)
|
|
100
|
+
return keyword;
|
|
101
|
+
return currency.managerAppName;
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
return keyword;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
exports.inferManagerApp = inferManagerApp;
|
|
108
|
+
var implTypePerFamily = {
|
|
109
|
+
tron: "js",
|
|
110
|
+
ripple: "js",
|
|
111
|
+
ethereum: "js",
|
|
112
|
+
polkadot: "js",
|
|
113
|
+
bitcoin: "js"
|
|
114
|
+
};
|
|
115
|
+
var possibleImpls = {
|
|
116
|
+
js: 1,
|
|
117
|
+
mock: 1
|
|
118
|
+
};
|
|
119
|
+
var inferCurrency = function (_a) {
|
|
120
|
+
var device = _a.device, currency = _a.currency, file = _a.file, xpub = _a.xpub, id = _a.id;
|
|
121
|
+
if (currency) {
|
|
122
|
+
return (0, rxjs_1.defer)(function () { return (0, rxjs_1.of)((0, currencies_1.findCryptoCurrencyByKeyword)(currency)); });
|
|
123
|
+
}
|
|
124
|
+
if (file || xpub || id) {
|
|
125
|
+
return (0, rxjs_1.of)(undefined);
|
|
126
|
+
}
|
|
127
|
+
return (0, deviceAccess_1.withDevice)(device || "")(function (t) {
|
|
128
|
+
return (0, rxjs_1.from)((0, getAppAndVersion_1["default"])(t)
|
|
129
|
+
.then(function (r) { return (0, currencies_1.findCryptoCurrencyByKeyword)(r.name); }, function () { return undefined; })
|
|
130
|
+
.then(function (r) { return (0, promise_1.delay)(500).then(function () { return r; }); }));
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
exports.inferCurrency = inferCurrency;
|
|
134
|
+
function requiredCurrency(cur) {
|
|
135
|
+
if (!cur)
|
|
136
|
+
throw new Error("--currency is required");
|
|
137
|
+
return cur;
|
|
138
|
+
}
|
|
139
|
+
var prepareCurrency = function (fn) { return function (observable) {
|
|
140
|
+
return observable.pipe((0, operators_1.concatMap)(function (item) {
|
|
141
|
+
var maybeCurrency = fn(item);
|
|
142
|
+
return maybeCurrency
|
|
143
|
+
? (0, rxjs_1.from)(cache.prepareCurrency(maybeCurrency).then(function () { return item; }))
|
|
144
|
+
: (0, rxjs_1.of)(item);
|
|
145
|
+
}));
|
|
146
|
+
}; };
|
|
147
|
+
function scan(arg) {
|
|
148
|
+
var device = arg.device, idArray = arg.id, xpubArray = arg.xpub, file = arg.file, appjsonFile = arg.appjsonFile, scheme = arg.scheme, index = arg.index, length = arg.length, paginateOperations = arg.paginateOperations;
|
|
149
|
+
var syncConfig = {
|
|
150
|
+
paginationConfig: {
|
|
151
|
+
operations: undefined
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
if (typeof paginateOperations === "number") {
|
|
155
|
+
syncConfig.paginationConfig.operations = paginateOperations;
|
|
156
|
+
}
|
|
157
|
+
if (typeof appjsonFile === "string") {
|
|
158
|
+
var appjsondata = appjsonFile
|
|
159
|
+
? JSON.parse(fs_1["default"].readFileSync(appjsonFile, "utf-8"))
|
|
160
|
+
: {
|
|
161
|
+
data: {
|
|
162
|
+
accounts: []
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
if (typeof appjsondata.data.accounts === "string") {
|
|
166
|
+
return (0, rxjs_1.throwError)(new Error("encrypted ledger live data is not supported"));
|
|
167
|
+
}
|
|
168
|
+
return (0, rxjs_1.from)(appjsondata.data.accounts.map(function (a) { return (0, account_1.fromAccountRaw)(a.data); })).pipe((0, operators_1.skip)(index || 0), (0, operators_1.take)(length === undefined ? (index !== undefined ? 1 : Infinity) : length));
|
|
169
|
+
}
|
|
170
|
+
if (typeof file === "string") {
|
|
171
|
+
return (0, stream_1.jsonFromFile)(file).pipe((0, operators_1.map)(account_1.fromAccountRaw), prepareCurrency(function (a) { return a.currency; }), (0, operators_1.concatMap)(function (account) {
|
|
172
|
+
return (0, bridge_1.getAccountBridge)(account, null)
|
|
173
|
+
.sync(account, syncConfig)
|
|
174
|
+
.pipe((0, operators_1.reduce)(function (a, f) { return f(a); }, account));
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
return (0, exports.inferCurrency)(arg).pipe((0, operators_1.mergeMap)(function (cur) {
|
|
178
|
+
var ids = idArray;
|
|
179
|
+
if (xpubArray) {
|
|
180
|
+
console.warn("Usage of --xpub is deprecated. Prefer usage of `--id`");
|
|
181
|
+
ids = (ids || []).concat(xpubArray);
|
|
182
|
+
}
|
|
183
|
+
// TODO this should be a "inferAccountId" that needs to look at available impl and do same logic as in bridge.. + we should accept full id as param
|
|
184
|
+
// we kill the --xpub to something else too (--id)
|
|
185
|
+
// Restore from ids
|
|
186
|
+
if (ids) {
|
|
187
|
+
// Infer the full ids
|
|
188
|
+
var fullIds = ids.map(function (id) {
|
|
189
|
+
var _a, _b;
|
|
190
|
+
try {
|
|
191
|
+
// preserve if decodeAccountId don't fail
|
|
192
|
+
(0, account_1.decodeAccountId)(id);
|
|
193
|
+
return id;
|
|
194
|
+
}
|
|
195
|
+
catch (e) {
|
|
196
|
+
var splitted_1 = id.split(":");
|
|
197
|
+
var findAndEat = function (predicate) {
|
|
198
|
+
var res = splitted_1.find(predicate);
|
|
199
|
+
if (typeof res === "string") {
|
|
200
|
+
splitted_1.splice(splitted_1.indexOf(res), 1);
|
|
201
|
+
return res;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
var currencyId = findAndEat(function (s) { return (0, currencies_1.findCryptoCurrencyById)(s); }) ||
|
|
205
|
+
requiredCurrency(cur).id;
|
|
206
|
+
var currency_1 = (0, currencies_1.getCryptoCurrencyById)(currencyId);
|
|
207
|
+
var type = findAndEat(function (s) { return possibleImpls[s]; }) ||
|
|
208
|
+
implTypePerFamily[currency_1.family] ||
|
|
209
|
+
"js";
|
|
210
|
+
var version = findAndEat(function (s) { return s.match(/^\d+$/); }) || "1";
|
|
211
|
+
var derivationMode = (0, derivation_1.asDerivationMode)((_b = (_a = findAndEat(function (s) {
|
|
212
|
+
try {
|
|
213
|
+
return (0, derivation_1.asDerivationMode)(s);
|
|
214
|
+
}
|
|
215
|
+
catch (e) {
|
|
216
|
+
// this is therefore not a derivation mode
|
|
217
|
+
}
|
|
218
|
+
})) !== null && _a !== void 0 ? _a : scheme) !== null && _b !== void 0 ? _b : "");
|
|
219
|
+
if (splitted_1.length === 0) {
|
|
220
|
+
throw new Error("invalid id='" + id + "': missing xpub or address part");
|
|
221
|
+
}
|
|
222
|
+
if (splitted_1.length > 1) {
|
|
223
|
+
throw new Error("invalid id='" +
|
|
224
|
+
id +
|
|
225
|
+
"': couldn't understand which of these are the xpub or address part: " +
|
|
226
|
+
splitted_1.join(" | "));
|
|
227
|
+
}
|
|
228
|
+
var xpubOrAddress = splitted_1[0];
|
|
229
|
+
return (0, account_1.encodeAccountId)({
|
|
230
|
+
type: type,
|
|
231
|
+
version: version,
|
|
232
|
+
currencyId: currencyId,
|
|
233
|
+
xpubOrAddress: xpubOrAddress,
|
|
234
|
+
derivationMode: derivationMode
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
return (0, rxjs_1.from)(fullIds.map(function (id) {
|
|
239
|
+
var _a = (0, account_1.decodeAccountId)(id), derivationMode = _a.derivationMode, xpubOrAddress = _a.xpubOrAddress, currencyId = _a.currencyId;
|
|
240
|
+
var currency = (0, currencies_1.getCryptoCurrencyById)(currencyId);
|
|
241
|
+
var scheme = (0, derivation_2.getDerivationScheme)({
|
|
242
|
+
derivationMode: derivationMode,
|
|
243
|
+
currency: currency
|
|
244
|
+
});
|
|
245
|
+
var index = 0;
|
|
246
|
+
var freshAddressPath = (0, derivation_2.runDerivationScheme)(scheme, currency, {
|
|
247
|
+
account: index,
|
|
248
|
+
node: 0,
|
|
249
|
+
address: 0
|
|
250
|
+
});
|
|
251
|
+
var account = {
|
|
252
|
+
type: "Account",
|
|
253
|
+
name: currency.name +
|
|
254
|
+
" " +
|
|
255
|
+
(derivationMode || "legacy") +
|
|
256
|
+
" " +
|
|
257
|
+
(0, helpers_1.shortAddressPreview)(xpubOrAddress),
|
|
258
|
+
xpub: xpubOrAddress,
|
|
259
|
+
seedIdentifier: xpubOrAddress,
|
|
260
|
+
starred: true,
|
|
261
|
+
used: true,
|
|
262
|
+
swapHistory: [],
|
|
263
|
+
id: id,
|
|
264
|
+
derivationMode: derivationMode,
|
|
265
|
+
currency: currency,
|
|
266
|
+
unit: currency.units[0],
|
|
267
|
+
index: index,
|
|
268
|
+
freshAddress: xpubOrAddress,
|
|
269
|
+
freshAddressPath: freshAddressPath,
|
|
270
|
+
freshAddresses: [],
|
|
271
|
+
creationDate: new Date(),
|
|
272
|
+
lastSyncDate: new Date(0),
|
|
273
|
+
blockHeight: 0,
|
|
274
|
+
balance: new bignumber_js_1.BigNumber(0),
|
|
275
|
+
spendableBalance: new bignumber_js_1.BigNumber(0),
|
|
276
|
+
operationsCount: 0,
|
|
277
|
+
operations: [],
|
|
278
|
+
pendingOperations: [],
|
|
279
|
+
balanceHistoryCache: account_1.emptyHistoryCache
|
|
280
|
+
};
|
|
281
|
+
return account;
|
|
282
|
+
})).pipe(prepareCurrency(function (a) { return a.currency; }), (0, operators_1.concatMap)(function (account) {
|
|
283
|
+
return (0, bridge_1.getAccountBridge)(account, null)
|
|
284
|
+
.sync(account, syncConfig)
|
|
285
|
+
.pipe((0, operators_1.reduce)(function (a, f) { return f(a); }, account));
|
|
286
|
+
}));
|
|
287
|
+
}
|
|
288
|
+
var currency = requiredCurrency(cur);
|
|
289
|
+
// otherwise we just scan for accounts
|
|
290
|
+
return (0, rxjs_1.concat)((0, rxjs_1.of)(currency).pipe(prepareCurrency(function (a) { return a; })), (0, bridge_1.getCurrencyBridge)(currency).scanAccounts({
|
|
291
|
+
currency: currency,
|
|
292
|
+
deviceId: device || "",
|
|
293
|
+
scheme: scheme && (0, derivation_1.asDerivationMode)(scheme),
|
|
294
|
+
syncConfig: syncConfig
|
|
295
|
+
})).pipe((0, operators_1.filter)(function (e) { return e.type === "discovered"; }), (0, operators_1.map)(function (e) { return e.account; }));
|
|
296
|
+
}), (0, operators_1.skip)(index || 0), (0, operators_1.take)(length === undefined ? (index !== undefined ? 1 : Infinity) : length));
|
|
297
|
+
}
|
|
298
|
+
exports.scan = scan;
|
|
299
|
+
//# sourceMappingURL=scan.js.map
|
package/lib/scan.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAyC;AACzC,6BAAuE;AACvE,4CAQwB;AAMxB,6DAK2C;AAC3C,mEAAwE;AACxE,2DAG0C;AAC1C,mEAI8C;AAC9C,mEAG8C;AAC9C,gEAA+E;AAC/E,mGAA6E;AAC7E,0EAAuE;AACvE,6DAA0D;AAC1D,mCAAwC;AACxC,qEAAgF;AAChF,0CAAoB;AACP,QAAA,SAAS,GAAG;IACvB,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,yCAAyC;CAChD,CAAC;AACW,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,gFAAgF;CACvF,CAAC;AACF,IAAM,UAAU,GAAG,EAAE,CAAC;AACtB,IAAM,KAAK,GAAG,IAAA,6BAAqB,EAAC;IAClC,QAAQ,YAAC,CAAC,EAAE,CAAC;QACX,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QACrB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,OAAO,YAAC,CAAC;QACP,OAAO,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,E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,CAAC;AACJ,CAAC;AAlND,oBAkNC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Observable } from "rxjs";
|
|
2
|
+
import type { SignedOperation, Account } from "@ledgerhq/live-common/lib/types";
|
|
3
|
+
export declare type InferSignedOperationsOpts = Partial<{
|
|
4
|
+
"signed-operation": string;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const inferSignedOperationsOpts: {
|
|
7
|
+
name: string;
|
|
8
|
+
alias: string;
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
desc: string;
|
|
11
|
+
}[];
|
|
12
|
+
export declare function inferSignedOperations(mainAccount: Account, opts: InferSignedOperationsOpts): Observable<SignedOperation>;
|
|
13
|
+
//# sourceMappingURL=signedOperation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signedOperation.d.ts","sourceRoot":"","sources":["../src/signedOperation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGvC,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAGhF,oBAAY,yBAAyB,GAAG,OAAO,CAAC;IAC9C,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC,CAAC;AACH,eAAO,MAAM,yBAAyB;;;;;GAOrC,CAAC;AACF,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,OAAO,EACpB,IAAI,EAAE,yBAAyB,GAC9B,UAAU,CAAC,eAAe,CAAC,CAe7B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.inferSignedOperations = exports.inferSignedOperationsOpts = void 0;
|
|
7
|
+
var operators_1 = require("rxjs/operators");
|
|
8
|
+
var invariant_1 = __importDefault(require("invariant"));
|
|
9
|
+
var transaction_1 = require("@ledgerhq/live-common/lib/transaction");
|
|
10
|
+
var stream_1 = require("./stream");
|
|
11
|
+
exports.inferSignedOperationsOpts = [
|
|
12
|
+
{
|
|
13
|
+
name: "signed-operation",
|
|
14
|
+
alias: "t",
|
|
15
|
+
type: String,
|
|
16
|
+
desc: "JSON file of a signed operation (- for stdin)"
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
function inferSignedOperations(mainAccount, opts) {
|
|
20
|
+
var file = opts["signed-operation"];
|
|
21
|
+
(0, invariant_1["default"])(file, "--signed-operation file is required");
|
|
22
|
+
return (0, stream_1.jsonFromFile)(file).pipe((0, operators_1.map)(function (json) {
|
|
23
|
+
(0, invariant_1["default"])(typeof json === "object", "not an object JSON");
|
|
24
|
+
(0, invariant_1["default"])(typeof json.signature === "string", "missing signature");
|
|
25
|
+
(0, invariant_1["default"])(typeof json.operation === "object", "missing operation object");
|
|
26
|
+
(0, invariant_1["default"])(json.operation.accountId === mainAccount.id, "the operation does not match the specified account");
|
|
27
|
+
return (0, transaction_1.fromSignedOperationRaw)(json, mainAccount.id);
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
exports.inferSignedOperations = inferSignedOperations;
|
|
31
|
+
//# sourceMappingURL=signedOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signedOperation.js","sourceRoot":"","sources":["../src/signedOperation.ts"],"names":[],"mappings":";;;;;;AACA,4CAAqC;AACrC,wDAAkC;AAElC,qEAA+E;AAC/E,mCAAwC;AAI3B,QAAA,yBAAyB,GAAG;IACvC;QACE,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,+CAA+C;KACtD;CACF,CAAC;AACF,SAAgB,qBAAqB,CACnC,WAAoB,EACpB,IAA+B;IAE/B,IAAM,IAAI,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACtC,IAAA,sBAAS,EAAC,IAAI,EAAE,qCAAqC,CAAC,CAAC;IACvD,OAAO,IAAA,qBAAY,EAAC,IAAc,CAAC,CAAC,IAAI,CACtC,IAAA,eAAG,EAAC,UAAC,IAAI;QACP,IAAA,sBAAS,EAAC,OAAO,IAAI,KAAK,QAAQ,EAAE,oBAAoB,CAAC,CAAC;QAC1D,IAAA,sBAAS,EAAC,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,EAAE,mBAAmB,CAAC,CAAC;QACnE,IAAA,sBAAS,EAAC,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,EAAE,0BAA0B,CAAC,CAAC;QAC1E,IAAA,sBAAS,EACP,IAAI,CAAC,SAAS,CAAC,SAAS,KAAK,WAAW,CAAC,EAAE,EAC3C,oDAAoD,CACrD,CAAC;QACF,OAAO,IAAA,oCAAsB,EAAC,IAAI,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;IACtD,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAlBD,sDAkBC"}
|
package/lib/stream.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
export declare const fromNodeStream: (stream: any) => Observable<Buffer>;
|
|
4
|
+
export declare const fromFile: (file: string) => Observable<Buffer>;
|
|
5
|
+
export declare const apdusFromFile: (file: string) => Observable<Buffer>;
|
|
6
|
+
export declare const jsonFromFile: (file: string, rawValue?: boolean) => Observable<any>;
|
|
7
|
+
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,eAAO,MAAM,cAAc,WAAY,GAAG,KAAG,WAAW,MAAM,CAgB1D,CAAC;AACL,eAAO,MAAM,QAAQ,SAAU,MAAM,uBACqC,CAAC;AAC3E,eAAO,MAAM,aAAa,SAAU,MAAM,uBAYvC,CAAC;AACJ,eAAO,MAAM,YAAY,SAAU,MAAM,yBAAqB,WAAW,GAAG,CA4CxE,CAAC"}
|
package/lib/stream.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.jsonFromFile = exports.apdusFromFile = exports.fromFile = exports.fromNodeStream = void 0;
|
|
7
|
+
var fs_1 = __importDefault(require("fs"));
|
|
8
|
+
var rxjs_1 = require("rxjs");
|
|
9
|
+
var operators_1 = require("rxjs/operators");
|
|
10
|
+
var fromNodeStream = function (stream) {
|
|
11
|
+
return rxjs_1.Observable.create(function (o) {
|
|
12
|
+
var endHandler = function () { return o.complete(); };
|
|
13
|
+
var errorHandler = function (e) { return o.error(e); };
|
|
14
|
+
var dataHandler = function (data) { return o.next(data); };
|
|
15
|
+
stream.addListener("end", endHandler);
|
|
16
|
+
stream.addListener("error", errorHandler);
|
|
17
|
+
stream.addListener("data", dataHandler);
|
|
18
|
+
return function () {
|
|
19
|
+
stream.removeListener("end", endHandler);
|
|
20
|
+
stream.removeListener("error", errorHandler);
|
|
21
|
+
stream.removeListener("data", dataHandler);
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
exports.fromNodeStream = fromNodeStream;
|
|
26
|
+
var fromFile = function (file) {
|
|
27
|
+
return (0, exports.fromNodeStream)(file === "-" ? process.stdin : fs_1["default"].createReadStream(file));
|
|
28
|
+
};
|
|
29
|
+
exports.fromFile = fromFile;
|
|
30
|
+
var apdusFromFile = function (file) {
|
|
31
|
+
return (0, exports.fromFile)(file).pipe((0, operators_1.map)(function (b) { return b.toString(); }), (0, operators_1.concatMap)(function (str) {
|
|
32
|
+
return str
|
|
33
|
+
.replace(/ /g, "")
|
|
34
|
+
.split("\n") // we supports => <= recorded files but will just clear out the <= and =>
|
|
35
|
+
.filter(function (line) { return !line.startsWith("<="); }) // we remove the responses
|
|
36
|
+
.map(function (line) { return (line.startsWith("=>") ? line.slice(2) : line); }) // we just keep the sending
|
|
37
|
+
.filter(Boolean);
|
|
38
|
+
}), (0, operators_1.map)(function (line) { return Buffer.from(line, "hex"); }));
|
|
39
|
+
};
|
|
40
|
+
exports.apdusFromFile = apdusFromFile;
|
|
41
|
+
var jsonFromFile = function (file, rawValue) {
|
|
42
|
+
if (rawValue === void 0) { rawValue = false; }
|
|
43
|
+
return rxjs_1.Observable.create(function (o) {
|
|
44
|
+
var acc = "";
|
|
45
|
+
var count = 0;
|
|
46
|
+
return (0, exports.fromFile)(file).subscribe({
|
|
47
|
+
error: function (e) { return o.error(e); },
|
|
48
|
+
complete: function () { return o.complete(); },
|
|
49
|
+
next: function (chunk) {
|
|
50
|
+
var lastIndex = 0;
|
|
51
|
+
var str = chunk.toString();
|
|
52
|
+
for (var i = 0; i < str.length; i++) {
|
|
53
|
+
switch (str[i]) {
|
|
54
|
+
case "[":
|
|
55
|
+
case "{":
|
|
56
|
+
count++;
|
|
57
|
+
break;
|
|
58
|
+
case "]":
|
|
59
|
+
case "}":
|
|
60
|
+
count--;
|
|
61
|
+
if (count === 0) {
|
|
62
|
+
acc += str.slice(lastIndex, i + 1);
|
|
63
|
+
lastIndex = i + 1;
|
|
64
|
+
try {
|
|
65
|
+
o.next(rawValue ? acc : JSON.parse(acc));
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
o.error(e);
|
|
69
|
+
}
|
|
70
|
+
acc = "";
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
default:
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
acc += str.slice(lastIndex);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
exports.jsonFrom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
|
+
export declare type InferTransactionsOpts = Partial<{
|
|
4
|
+
"self-transaction": boolean;
|
|
5
|
+
"use-all-amount": boolean;
|
|
6
|
+
recipient: string[];
|
|
7
|
+
amount: string;
|
|
8
|
+
shuffle: boolean;
|
|
9
|
+
"fees-strategy": string;
|
|
10
|
+
collection: string;
|
|
11
|
+
tokenIds: string;
|
|
12
|
+
quantities: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const inferTransactionsOpts: ({
|
|
15
|
+
name: string;
|
|
16
|
+
type: BooleanConstructor;
|
|
17
|
+
desc: string;
|
|
18
|
+
multiple?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
name: string;
|
|
21
|
+
type: StringConstructor;
|
|
22
|
+
desc: string;
|
|
23
|
+
multiple: boolean;
|
|
24
|
+
} | {
|
|
25
|
+
name: string;
|
|
26
|
+
type: StringConstructor;
|
|
27
|
+
desc: string;
|
|
28
|
+
multiple?: undefined;
|
|
29
|
+
})[];
|
|
30
|
+
export declare function inferTransactions(mainAccount: Account, opts: InferTransactionsOpts): Promise<[Transaction, TransactionStatus][]>;
|
|
31
|
+
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAOxB,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EAEX,OAAO,EACR,MAAM,iCAAiC,CAAC;AA4BzC,oBAAY,qBAAqB,GAAG,OAAO,CAAC;IAC1C,kBAAkB,EAAE,OAAO,CAAC;IAC5B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC,CAAC;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;IA+CjC,CAAC;AACF,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,OAAO,EACpB,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,CAAC,WAAW,EAAE,iBAAiB,CAAC,EAAE,CAAC,CA+D7C"}
|