@ledgerhq/live-cli 21.32.1
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
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (_) try {
|
|
19
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
40
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
41
|
+
if (!m) return o;
|
|
42
|
+
var i = m.call(o), r, ar = [], e;
|
|
43
|
+
try {
|
|
44
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
45
|
+
}
|
|
46
|
+
catch (error) { e = { error: error }; }
|
|
47
|
+
finally {
|
|
48
|
+
try {
|
|
49
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
50
|
+
}
|
|
51
|
+
finally { if (e) throw e.error; }
|
|
52
|
+
}
|
|
53
|
+
return ar;
|
|
54
|
+
};
|
|
55
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
56
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
57
|
+
if (ar || !(i in from)) {
|
|
58
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
59
|
+
ar[i] = from[i];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
63
|
+
};
|
|
64
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
65
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
66
|
+
};
|
|
67
|
+
exports.__esModule = true;
|
|
68
|
+
/* eslint-disable no-fallthrough */
|
|
69
|
+
var scan_1 = require("../scan");
|
|
70
|
+
var rxjs_1 = require("rxjs");
|
|
71
|
+
var operators_1 = require("rxjs/operators");
|
|
72
|
+
var rxjs_2 = require("rxjs");
|
|
73
|
+
var logs_1 = require("@ledgerhq/logs");
|
|
74
|
+
var client_1 = __importDefault(require("@walletconnect/client"));
|
|
75
|
+
var bridge_1 = require("@ledgerhq/live-common/lib/bridge");
|
|
76
|
+
var walletconnect_1 = require("@ledgerhq/live-common/lib/walletconnect");
|
|
77
|
+
var deviceAccess_1 = require("@ledgerhq/live-common/lib/hw/deviceAccess");
|
|
78
|
+
var signMessage_1 = __importDefault(require("@ledgerhq/live-common/lib/hw/signMessage"));
|
|
79
|
+
var Ethereum_1 = require("@ledgerhq/live-common/lib/api/Ethereum");
|
|
80
|
+
var start = function (opts) { return __awaiter(void 0, void 0, void 0, function () {
|
|
81
|
+
var account, connector, rejectRequest, approveRequest, handleCallRequest;
|
|
82
|
+
return __generator(this, function (_a) {
|
|
83
|
+
switch (_a.label) {
|
|
84
|
+
case 0: return [4 /*yield*/, (0, scan_1.scan)(opts).pipe((0, operators_1.take)(1)).toPromise()];
|
|
85
|
+
case 1:
|
|
86
|
+
account = _a.sent();
|
|
87
|
+
if (!account) {
|
|
88
|
+
throw new Error("No account");
|
|
89
|
+
}
|
|
90
|
+
(0, logs_1.log)("walletconnect", "account", account);
|
|
91
|
+
connector = new client_1["default"](opts.walletConnectSession
|
|
92
|
+
? {
|
|
93
|
+
session: JSON.parse(opts.walletConnectSession)
|
|
94
|
+
}
|
|
95
|
+
: {
|
|
96
|
+
// Required
|
|
97
|
+
uri: opts.walletConnectURI,
|
|
98
|
+
// Required
|
|
99
|
+
clientMeta: {
|
|
100
|
+
description: "LedgerLive CLI",
|
|
101
|
+
url: "https://ledger.fr",
|
|
102
|
+
icons: [
|
|
103
|
+
"https://avatars0.githubusercontent.com/u/9784193?s=400&v=4",
|
|
104
|
+
],
|
|
105
|
+
name: "LedgerLive CLI"
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
rejectRequest = function (id, message) {
|
|
109
|
+
var rejection = {
|
|
110
|
+
id: id,
|
|
111
|
+
error: {
|
|
112
|
+
message: message
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
(0, logs_1.log)("walletconnect", "rejected", rejection);
|
|
116
|
+
connector.rejectRequest(rejection);
|
|
117
|
+
};
|
|
118
|
+
approveRequest = function (id, result) {
|
|
119
|
+
var approval = {
|
|
120
|
+
id: id,
|
|
121
|
+
result: result
|
|
122
|
+
};
|
|
123
|
+
(0, logs_1.log)("walletconnect", "approved", approval);
|
|
124
|
+
connector.approveRequest(approval);
|
|
125
|
+
};
|
|
126
|
+
handleCallRequest = function (payload) { return __awaiter(void 0, void 0, void 0, function () {
|
|
127
|
+
var wcCallRequest, result, bridge, api, operation;
|
|
128
|
+
return __generator(this, function (_a) {
|
|
129
|
+
switch (_a.label) {
|
|
130
|
+
case 0:
|
|
131
|
+
(0, logs_1.log)("walletconnect", "call_request", payload);
|
|
132
|
+
return [4 /*yield*/, (0, walletconnect_1.parseCallRequest)(account, payload)];
|
|
133
|
+
case 1:
|
|
134
|
+
wcCallRequest = _a.sent();
|
|
135
|
+
bridge = (0, bridge_1.getAccountBridge)(account);
|
|
136
|
+
if (!(wcCallRequest.type === "broadcast")) return [3 /*break*/, 3];
|
|
137
|
+
api = (0, Ethereum_1.apiForCurrency)(account.currency);
|
|
138
|
+
return [4 /*yield*/, api.broadcastTransaction(wcCallRequest.data)];
|
|
139
|
+
case 2:
|
|
140
|
+
result = _a.sent();
|
|
141
|
+
(0, logs_1.log)("walletconnect", "hash", result);
|
|
142
|
+
return [2 /*return*/, result];
|
|
143
|
+
case 3:
|
|
144
|
+
if (!(wcCallRequest.type === "message")) return [3 /*break*/, 5];
|
|
145
|
+
(0, logs_1.log)("walletconnect", "message to sign", wcCallRequest.data);
|
|
146
|
+
return [4 /*yield*/, (0, deviceAccess_1.withDevice)(opts.device || "")(function (t) {
|
|
147
|
+
return (0, rxjs_1.from)((0, signMessage_1["default"])(t, wcCallRequest.data));
|
|
148
|
+
}).toPromise()];
|
|
149
|
+
case 4:
|
|
150
|
+
result = _a.sent();
|
|
151
|
+
result = result.signature;
|
|
152
|
+
(0, logs_1.log)("walletconnect", "message signature", result);
|
|
153
|
+
return [2 /*return*/, result];
|
|
154
|
+
case 5:
|
|
155
|
+
if (!(wcCallRequest.type === "transaction")) return [3 /*break*/, 8];
|
|
156
|
+
return [4 /*yield*/, bridge
|
|
157
|
+
.signOperation({
|
|
158
|
+
account: account,
|
|
159
|
+
deviceId: opts.device || "",
|
|
160
|
+
transaction: wcCallRequest.data
|
|
161
|
+
})
|
|
162
|
+
.pipe((0, operators_1.tap)(function (e) { return console.log(e); }), (0, operators_1.first)(function (e) { return e.type === "signed"; }), (0, operators_1.map)(function (e) {
|
|
163
|
+
if (e.type === "signed") {
|
|
164
|
+
return e.signedOperation;
|
|
165
|
+
}
|
|
166
|
+
}))
|
|
167
|
+
.toPromise()];
|
|
168
|
+
case 6:
|
|
169
|
+
operation = _a.sent();
|
|
170
|
+
(0, logs_1.log)("walletconnect", "operation", operation);
|
|
171
|
+
if (wcCallRequest.method === "sign") {
|
|
172
|
+
return [2 /*return*/, operation.signature];
|
|
173
|
+
}
|
|
174
|
+
return [4 /*yield*/, bridge.broadcast({
|
|
175
|
+
account: account,
|
|
176
|
+
signedOperation: operation
|
|
177
|
+
})];
|
|
178
|
+
case 7:
|
|
179
|
+
operation = _a.sent();
|
|
180
|
+
(0, logs_1.log)("walletconnect", "operation broadcasted", operation);
|
|
181
|
+
return [2 /*return*/, operation.hash];
|
|
182
|
+
case 8: throw new Error("JSON RPC method not supported");
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}); };
|
|
186
|
+
connector.on("session_request", function (error, payload) {
|
|
187
|
+
if (error) {
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
190
|
+
(0, logs_1.log)("walletconnect", "session_request", payload);
|
|
191
|
+
connector.approveSession({
|
|
192
|
+
accounts: [account.freshAddress],
|
|
193
|
+
chainId: account.currency.ethereumLikeInfo.chainId
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
connector.on("call_request", function (error, payload) { return __awaiter(void 0, void 0, void 0, function () {
|
|
197
|
+
var result, e_1;
|
|
198
|
+
return __generator(this, function (_a) {
|
|
199
|
+
switch (_a.label) {
|
|
200
|
+
case 0:
|
|
201
|
+
if (error) {
|
|
202
|
+
throw error;
|
|
203
|
+
}
|
|
204
|
+
_a.label = 1;
|
|
205
|
+
case 1:
|
|
206
|
+
_a.trys.push([1, 3, , 4]);
|
|
207
|
+
return [4 /*yield*/, handleCallRequest(payload)];
|
|
208
|
+
case 2:
|
|
209
|
+
result = _a.sent();
|
|
210
|
+
approveRequest(payload.id, result);
|
|
211
|
+
return [3 /*break*/, 4];
|
|
212
|
+
case 3:
|
|
213
|
+
e_1 = _a.sent();
|
|
214
|
+
rejectRequest(payload.id, e_1.message);
|
|
215
|
+
return [3 /*break*/, 4];
|
|
216
|
+
case 4: return [2 /*return*/];
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}); });
|
|
220
|
+
connector.on("connect", function (error) {
|
|
221
|
+
if (error) {
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
(0, logs_1.log)("walletconnect", "connected", JSON.stringify(connector.session).replace(/"/g, "\\\""));
|
|
225
|
+
});
|
|
226
|
+
return [2 /*return*/];
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}); };
|
|
230
|
+
exports["default"] = {
|
|
231
|
+
description: "Create a walletconnect session",
|
|
232
|
+
args: __spreadArray(__spreadArray([], __read(scan_1.scanCommonOpts), false), [
|
|
233
|
+
{
|
|
234
|
+
name: "walletConnectURI",
|
|
235
|
+
type: String,
|
|
236
|
+
desc: "WallecConnect URI to use."
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
name: "walletConnectSession",
|
|
240
|
+
type: String,
|
|
241
|
+
desc: "WallecConnect Session to use."
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: "verbose",
|
|
245
|
+
alias: "v",
|
|
246
|
+
type: Boolean,
|
|
247
|
+
desc: "verbose mode"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: "silent",
|
|
251
|
+
type: Boolean,
|
|
252
|
+
desc: "do not output the proxy logs"
|
|
253
|
+
},
|
|
254
|
+
], false),
|
|
255
|
+
job: function (opts) {
|
|
256
|
+
return rxjs_2.Observable.create(function (o) {
|
|
257
|
+
var unsub = (0, logs_1.listen)(function (l) {
|
|
258
|
+
if (opts.verbose) {
|
|
259
|
+
o.next(l.type + ": " + l.message);
|
|
260
|
+
}
|
|
261
|
+
else if (!opts.silent && l.type === "walletconnect") {
|
|
262
|
+
o.next(l.message);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
start(opts);
|
|
266
|
+
return function () {
|
|
267
|
+
unsub();
|
|
268
|
+
};
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
//# sourceMappingURL=walletconnect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletconnect.js","sourceRoot":"","sources":["../../src/commands/walletconnect.ts"],"names":[],"mappings":";AAAA,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE/B,mCAAmC;AACnC,gCAA+C;AAE/C,6BAA4B;AAC5B,4CAAuD;AACvD,6BAAkC;AAClC,uCAA6C;AAC7C,iEAAkD;AAClD,2DAAoE;AACpE,yEAA2E;AAK3E,0EAAuE;AACvE,yFAAmE;AACnE,mEAAwE;AAWxE,IAAM,KAAK,GAAG,UAAO,IAAU;;;;oBACb,qBAAM,IAAA,WAAI,EAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAA,gBAAI,EAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,EAAA;;gBAApD,OAAO,GAAG,SAA0C;gBAE1D,IAAI,CAAC,OAAO,EAAE;oBACZ,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;iBAC/B;gBACD,IAAA,UAAG,EAAC,eAAe,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;gBACnC,SAAS,GAAG,IAAI,mBAAa,CACjC,IAAI,CAAC,oBAAoB;oBACvB,CAAC,CAAC;wBACE,OAAO,EAAE,IAAI,CAAC,KAAK,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