diff --git a/apps/ledger-live-desktop/tests/fixtures/common.ts b/apps/ledger-live-desktop/tests/fixtures/common.ts index 60964fca7e2d..46b7b69f1a63 100644 --- a/apps/ledger-live-desktop/tests/fixtures/common.ts +++ b/apps/ledger-live-desktop/tests/fixtures/common.ts @@ -13,15 +13,7 @@ import { captureArtifacts } from "tests/utils/allureUtils"; import { randomUUID } from "crypto"; import { AppInfos } from "@ledgerhq/live-common/e2e/enum/AppInfos"; import { lastValueFrom, Observable } from "rxjs"; -import { commandCLI } from "tests/utils/cliUtils"; import { registerSpeculosTransport } from "@ledgerhq/live-cli/src/live-common-setup"; -import { activateLedgerSync } from "@ledgerhq/live-common/e2e/speculos"; - -type Command Observable | Promise | string> = { - command: T; - args: Parameters[0]; // Infer the first argument type - output?: (output: any) => void; -}; type TestFixtures = { lang: string; @@ -38,7 +30,7 @@ type TestFixtures = { featureFlags: OptionalFeatureMap; simulateCamera: string; app: Application; - cliCommands: Command<(typeof commandCLI)[keyof typeof commandCLI]>[]; + cliCommands?: ((appjsonPath: string) => Observable | Promise | string)[]; }; const IS_NOT_MOCK = process.env.MOCK == "0"; @@ -121,31 +113,16 @@ export const test = base.extend({ setEnv("SPECULOS_API_PORT", device?.ports.apiPort?.toString()); setEnv("MOCK", ""); - if (cliCommands) { + if (cliCommands?.length) { registerSpeculosTransport(device?.ports.apiPort); - for (const command of cliCommands) { - if (command.args && "appjson" in command.args) { - command.args.appjson = `${userdataDestinationPath}/app.json`; - } - - const resultPromise = handleResult(command.command(command.args as any)); - - if (command.args && "getKeyRingTree" in command.args) { - await activateLedgerSync(); - } - - const result = await resultPromise; - command?.output?.(result); + for (const cmd of cliCommands) { + const promise = await cmd(`${userdataDestinationPath}/app.json`); + const result = + promise instanceof Observable ? await lastValueFrom(promise) : await promise; console.log("CLI result: ", result); } } } - async function handleResult(result: Promise | Observable | string): Promise { - if (result instanceof Observable) { - return lastValueFrom(result); // Converts Observable to Promise - } - return result; // Return Promise directly - } // default environment variables env = Object.assign( diff --git a/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts index 214660444c95..dedd44581489 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts @@ -3,7 +3,7 @@ import { Account } from "@ledgerhq/live-common/e2e/enum/Account"; import { Delegate } from "../../models/Delegate"; import { addTmsLink } from "tests/utils/allureUtils"; import { getDescription } from "../../utils/customJsonReporter"; -import { commandCLI } from "tests/utils/cliUtils"; +import { CLI } from "tests/utils/cliUtils"; import { isRunningInScheduledWorkflow } from "tests/utils/githubUtils"; import { Currency } from "@ledgerhq/live-common/e2e/enum/Currency"; @@ -60,14 +60,13 @@ test.describe("Delegate flows", () => { userdata: "skip-onboarding", speculosApp: account.delegate.account.currency.speculosApp, cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: account.delegate.account.currency.ticker, index: account.delegate.account.index, add: true, - appjson: "", - }, + appjson: appjsonPath, + }); }, ], }); @@ -120,14 +119,13 @@ test.describe("Delegate flows", () => { userdata: "skip-onboarding", speculosApp: validator.delegate.account.currency.speculosApp, cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: validator.delegate.account.currency.ticker, index: validator.delegate.account.index, add: true, - appjson: "", - }, + appjson: appjsonPath, + }); }, ], }); @@ -176,14 +174,13 @@ test.describe("Delegate flows", () => { userdata: "skip-onboarding", speculosApp: delegateAccount.account.currency.speculosApp, cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: delegateAccount.account.currency.ticker, index: delegateAccount.account.index, add: true, - appjson: "", - }, + appjson: appjsonPath, + }); }, ], }); diff --git a/apps/ledger-live-desktop/tests/specs/speculos/delete.account.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/delete.account.spec.ts index eaab81c0cde5..52002a31dee9 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/delete.account.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/delete.account.spec.ts @@ -2,7 +2,7 @@ import { test } from "../../fixtures/common"; import { Account } from "@ledgerhq/live-common/e2e/enum/Account"; import { addTmsLink } from "tests/utils/allureUtils"; import { getDescription } from "../../utils/customJsonReporter"; -import { commandCLI } from "tests/utils/cliUtils"; +import { CLI } from "tests/utils/cliUtils"; const accounts = [ { account: Account.BTC_NATIVE_SEGWIT_1, xrayTicket: "B2CQA-2548" }, @@ -24,14 +24,13 @@ for (const account of accounts) { test.use({ userdata: "skip-onboarding", cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: account.account.currency.currencyId, index: account.account.index, - appjson: "", add: true, - }, + appjson: appjsonPath, + }); }, ], speculosApp: account.account.currency.speculosApp, diff --git a/apps/ledger-live-desktop/tests/specs/speculos/ledgerSync.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/ledgerSync.spec.ts index 8c8a9f66c91e..faa97500d294 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/ledgerSync.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/ledgerSync.spec.ts @@ -2,55 +2,65 @@ import { test } from "../../fixtures/common"; import { AppInfos } from "@ledgerhq/live-common/e2e/enum/AppInfos"; import { addTmsLink } from "tests/utils/allureUtils"; import { getDescription } from "../../utils/customJsonReporter"; -import { commandCLI } from "tests/utils/cliUtils"; +import { CLI } from "tests/utils/cliUtils"; +import { activateLedgerSync } from "@ledgerhq/live-common/e2e/speculos"; const app: AppInfos = AppInfos.LS; test.describe(`[${app.name}] Sync Accounts`, () => { const ledgerKeyRingProtocolArgs = { - getKeyRingTree: true, - pubKey: undefined, - privateKey: undefined, + pubKey: "", + privateKey: "", }; const ledgerSyncPushDataArgs = { - pubKey: undefined, - privateKey: undefined, - rootId: undefined, - walletSyncEncryptionKey: undefined, - applicationPath: undefined, + rootId: "", + walletSyncEncryptionKey: "", + applicationPath: "", push: true, data: '{"accounts":[{"id":"mock:1:dogecoin:0.790010769447963:","currencyId":"dogecoin","index":1,"seedIdentifier":"mock","derivationMode":"","freshAddress":"1uVnrWAzycYqKUXSuNXt3XSjJ8"},{"id":"mock:1:bitcoin_gold:0.8027791663782486:","currencyId":"bitcoin_gold","index":1,"seedIdentifier":"mock","derivationMode":"","freshAddress":"1Y5T8JQqBKUS7cXbxUYCR4wg3YSbV9R"}],"accountNames":{"mock:1:dogecoin:0.790010769447963:":"Renamed Dogecoin 2","mock:1:bitcoin_gold:0.8027791663782486:":"Bitcoin Gold 2"}}', }; + async function initializeLedgerKeyRingProtocol() { + return CLI.ledgerKeyRingProtocol({ initMemberCredentials: true }).then(output => { + if (output && typeof output !== "string" && "pubkey" in output) { + ledgerKeyRingProtocolArgs.pubKey = output.pubkey; + ledgerKeyRingProtocolArgs.privateKey = output.privatekey; + } + return output; + }); + } + + async function initializeLedgerSync() { + const output = CLI.ledgerKeyRingProtocol({ + getKeyRingTree: true, + ...ledgerKeyRingProtocolArgs, + }).then(out => { + if (out && typeof out !== "string" && "rootId" in out) { + ledgerSyncPushDataArgs.rootId = out.rootId; + ledgerSyncPushDataArgs.walletSyncEncryptionKey = out.walletSyncEncryptionKey; + ledgerSyncPushDataArgs.applicationPath = out.applicationPath; + } + return out; + }); + await activateLedgerSync(); + return output; + } + test.use({ userdata: "skip-onboarding", speculosApp: app, cliCommands: [ - { - command: commandCLI.ledgerKeyRingProtocol, - args: { - initMemberCredentials: true, - }, - output: output => { - ledgerKeyRingProtocolArgs.pubKey = output.pubkey; - ledgerKeyRingProtocolArgs.privateKey = output.privatekey; - - ledgerSyncPushDataArgs.pubKey = output.pubkey; - ledgerSyncPushDataArgs.privateKey = output.privatekey; - }, + async () => { + return initializeLedgerKeyRingProtocol(); }, - { - command: commandCLI.ledgerKeyRingProtocol, - args: ledgerKeyRingProtocolArgs, - output: output => { - ledgerSyncPushDataArgs.rootId = output.rootId; - ledgerSyncPushDataArgs.walletSyncEncryptionKey = output.walletSyncEncryptionKey; - ledgerSyncPushDataArgs.applicationPath = output.applicationPath; - }, + async () => { + return initializeLedgerSync(); }, - { - command: commandCLI.ledgerSync, - args: ledgerSyncPushDataArgs, + async () => { + return CLI.ledgerSync({ + ...ledgerKeyRingProtocolArgs, + ...ledgerSyncPushDataArgs, + }); }, ], }); diff --git a/apps/ledger-live-desktop/tests/specs/speculos/nft.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/nft.spec.ts index df68a1db6809..b3f8f1dc1723 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/nft.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/nft.spec.ts @@ -5,7 +5,7 @@ import { Nft } from "@ledgerhq/live-common/e2e/enum/Nft"; import { Fee } from "@ledgerhq/live-common/e2e/enum/Fee"; import { addTmsLink } from "tests/utils/allureUtils"; import { getDescription } from "../../utils/customJsonReporter"; -import { commandCLI } from "tests/utils/cliUtils"; +import { CLI } from "tests/utils/cliUtils"; import invariant from "invariant"; test.describe("send NFT to ENS address", () => { @@ -19,14 +19,13 @@ test.describe("send NFT to ENS address", () => { test.use({ userdata: "skip-onboarding", cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: transaction.accountToDebit.currency.currencyId, index: transaction.accountToDebit.index, - appjson: "", add: true, - }, + appjson: appjsonPath, + }); }, ], speculosApp: transaction.accountToDebit.currency.speculosApp, @@ -67,14 +66,13 @@ test.describe("The user can see his NFT floor price", () => { test.use({ userdata: "skip-onboarding", cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: account.currency.currencyId, index: account.index, - appjson: "", add: true, - }, + appjson: appjsonPath, + }); }, ], speculosApp: account.currency.speculosApp, @@ -116,14 +114,13 @@ for (const account of accounts) { test.use({ userdata: "skip-onboarding", cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: account.account.currency.currencyId, index: account.account.index, - appjson: "", add: true, - }, + appjson: appjsonPath, + }); }, ], speculosApp: account.account.currency.speculosApp, @@ -152,14 +149,13 @@ for (const account of accounts) { test.use({ userdata: "skip-onboarding", cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: account.account.currency.currencyId, index: account.account.index, - appjson: "", add: true, - }, + appjson: appjsonPath, + }); }, ], speculosApp: account.account.currency.speculosApp, diff --git a/apps/ledger-live-desktop/tests/specs/speculos/receive.address.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/receive.address.spec.ts index 818ae768b4f2..8b901f7b1626 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/receive.address.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/receive.address.spec.ts @@ -2,7 +2,7 @@ import { test } from "../../fixtures/common"; import { Account } from "@ledgerhq/live-common/e2e/enum/Account"; import { addTmsLink } from "tests/utils/allureUtils"; import { getDescription } from "../../utils/customJsonReporter"; -import { commandCLI } from "tests/utils/cliUtils"; +import { CLI } from "tests/utils/cliUtils"; const accounts = [ { account: Account.BTC_NATIVE_SEGWIT_1, xrayTicket: "B2CQA-2559, B2CQA-2687" }, @@ -24,14 +24,13 @@ for (const account of accounts) { userdata: "skip-onboarding", speculosApp: account.account.currency.speculosApp, cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: account.account.currency.currencyId, index: account.account.index, - appjson: "", add: true, - }, + appjson: appjsonPath, + }); }, ], }); @@ -82,14 +81,13 @@ test.describe("Receive", () => { userdata: "skip-onboarding", speculosApp: account.currency.speculosApp, cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: account.currency.currencyId, index: account.index, add: true, - appjson: "", - }, + appjson: appjsonPath, + }); }, ], }); diff --git a/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts index ddda98ebfd24..391f2e5e9061 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts @@ -4,7 +4,7 @@ import { Fee } from "@ledgerhq/live-common/e2e/enum/Fee"; import { Transaction } from "../../models/Transaction"; import { addTmsLink } from "tests/utils/allureUtils"; import { getDescription } from "../../utils/customJsonReporter"; -import { commandCLI } from "tests/utils/cliUtils"; +import { CLI } from "tests/utils/cliUtils"; import { isRunningInScheduledWorkflow } from "tests/utils/githubUtils"; //Warning 🚨: XRP Tests may fail due to API HTTP 429 issue - Jira: LIVE-14237 @@ -224,23 +224,21 @@ test.describe("Send flows", () => { userdata: "skip-onboarding", speculosApp: transaction.transaction.accountToDebit.currency.speculosApp, cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: transaction.transaction.accountToCredit.currency.currencyId, index: transaction.transaction.accountToCredit.index, add: true, - appjson: "", - }, + appjson: appjsonPath, + }); }, - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: transaction.transaction.accountToDebit.currency.currencyId, index: transaction.transaction.accountToDebit.index, add: true, - appjson: "", - }, + appjson: appjsonPath, + }); }, ], }); @@ -299,14 +297,13 @@ test.describe("Send flows", () => { userdata: "skip-onboarding", speculosApp: tokenTransactionInvalid.transaction.accountToDebit.currency.speculosApp, cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: tokenTransactionInvalid.transaction.accountToDebit.currency.currencyId, index: tokenTransactionInvalid.transaction.accountToDebit.index, add: true, - appjson: "", - }, + appjson: appjsonPath, + }); }, ], }); @@ -341,14 +338,13 @@ test.describe("Send flows", () => { userdata: "skip-onboarding", speculosApp: transaction.transaction.accountToDebit.currency.speculosApp, cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: transaction.transaction.accountToDebit.currency.currencyId, index: transaction.transaction.accountToDebit.index, add: true, - appjson: "", - }, + appjson: appjsonPath, + }); }, ], }); @@ -388,14 +384,13 @@ test.describe("Send flows", () => { userdata: "skip-onboarding", speculosApp: tokenTransactionValid.accountToDebit.currency.speculosApp, cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: tokenTransactionValid.accountToDebit.currency.currencyId, index: tokenTransactionValid.accountToDebit.index, add: true, - appjson: "", - }, + appjson: appjsonPath, + }); }, ], }); @@ -431,14 +426,13 @@ test.describe("Send flows", () => { userdata: "skip-onboarding", speculosApp: transaction.transaction.accountToDebit.currency.speculosApp, cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: transaction.transaction.accountToDebit.currency.currencyId, index: transaction.transaction.accountToDebit.index, add: true, - appjson: "", - }, + appjson: appjsonPath, + }); }, ], }); @@ -478,14 +472,13 @@ test.describe("Send flows", () => { userdata: "skip-onboarding", speculosApp: transactionInputValid.accountToDebit.currency.speculosApp, cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: transactionInputValid.accountToDebit.currency.currencyId, index: transactionInputValid.accountToDebit.index, add: true, - appjson: "", - }, + appjson: appjsonPath, + }); }, ], }); @@ -521,15 +514,14 @@ test.describe("Send flows", () => { userdata: "skip-onboarding", speculosApp: transaction.transaction.accountToDebit.currency.speculosApp, cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: transaction.transaction.accountToDebit.currency.currencyId, index: transaction.transaction.accountToDebit.index, scheme: transaction.transaction.accountToDebit.derivationMode, add: true, - appjson: "", - }, + appjson: appjsonPath, + }); }, ], }); @@ -564,14 +556,13 @@ test.describe("Send flows", () => { userdata: "skip-onboarding", speculosApp: transaction.transaction.accountToDebit.currency.speculosApp, cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: transaction.transaction.accountToDebit.currency.currencyId, index: transaction.transaction.accountToDebit.index, add: true, - appjson: "", - }, + appjson: appjsonPath, + }); }, ], }); diff --git a/apps/ledger-live-desktop/tests/specs/speculos/settings.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/settings.spec.ts index be183cc26793..66462e21a8ac 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/settings.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/settings.spec.ts @@ -2,7 +2,7 @@ import { test } from "../../fixtures/common"; import { addTmsLink } from "tests/utils/allureUtils"; import { getDescription } from "../../utils/customJsonReporter"; import { Account } from "@ledgerhq/live-common/e2e/enum/Account"; -import { commandCLI } from "tests/utils/cliUtils"; +import { CLI } from "tests/utils/cliUtils"; test.describe("Settings", () => { test.use({ @@ -43,14 +43,13 @@ test.describe("Password", () => { test.use({ userdata: "skip-onboarding", cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: account.currency.currencyId, index: account.index, - appjson: "", add: true, - }, + appjson: appjsonPath, + }); }, ], speculosApp: account.currency.speculosApp, @@ -89,14 +88,13 @@ test.describe("counter value selection", () => { test.use({ userdata: "skip-onboarding", cliCommands: [ - { - command: commandCLI.liveData, - args: { + (appjsonPath: string) => { + return CLI.liveData({ currency: account.currency.currencyId, index: account.index, - appjson: "", add: true, - }, + appjson: appjsonPath, + }); }, ], speculosApp: account.currency.speculosApp, diff --git a/apps/ledger-live-desktop/tests/utils/cliUtils.ts b/apps/ledger-live-desktop/tests/utils/cliUtils.ts index f622da0932ef..76ca73cea7cb 100644 --- a/apps/ledger-live-desktop/tests/utils/cliUtils.ts +++ b/apps/ledger-live-desktop/tests/utils/cliUtils.ts @@ -1,220 +1,69 @@ -import bot, { BotJobOpts } from "@ledgerhq/live-cli/src/commands/blockchain/bot"; -import botPortfolio, { - BotPortfolioJobOpts, -} from "@ledgerhq/live-cli/src/commands/blockchain/botPortfolio"; +import bot from "@ledgerhq/live-cli/src/commands/blockchain/bot"; +import botPortfolio from "@ledgerhq/live-cli/src/commands/blockchain/botPortfolio"; import botTransfer from "@ledgerhq/live-cli/src/commands/blockchain/botTransfer"; -import broadcast, { BroadcastJobOpts } from "@ledgerhq/live-cli/src/commands/blockchain/broadcast"; -import confirmOp, { ConfirmOpJobOpts } from "@ledgerhq/live-cli/src/commands/blockchain/confirmOp"; +import broadcast from "@ledgerhq/live-cli/src/commands/blockchain/broadcast"; +import confirmOp from "@ledgerhq/live-cli/src/commands/blockchain/confirmOp"; import derivation from "@ledgerhq/live-cli/src/commands/blockchain/derivation"; -import estimateMaxSpendable, { - EstimateMaxSpendableJobOpts, -} from "@ledgerhq/live-cli/src/commands/blockchain/estimateMaxSpendable"; -import generateTestScanAccounts, { - GenerateTestScanAccountsJobOpts, -} from "@ledgerhq/live-cli/src/commands/blockchain/generateTestScanAccounts"; -import generateTestTransaction, { - GenerateTestTransactionJobOpts, -} from "@ledgerhq/live-cli/src/commands/blockchain/generateTestTransaction"; -import getAddress, { - GetAddressJobOpts, -} from "@ledgerhq/live-cli/src/commands/blockchain/getAddress"; -import getTransactionStatus, { - GetTransactionStatusJobOpts, -} from "@ledgerhq/live-cli/src/commands/blockchain/getTransactionStatus"; -import receive, { ReceiveJobOpts } from "@ledgerhq/live-cli/src/commands/blockchain/receive"; -import satstack, { SatstackJobOpts } from "@ledgerhq/live-cli/src/commands/blockchain/satstack"; -import satstackStatus, { - SatstackStatusJobOpts, -} from "@ledgerhq/live-cli/src/commands/blockchain/satstackStatus"; -import scanDescriptors, { - ScanDescriptorsJobOpts, -} from "@ledgerhq/live-cli/src/commands/blockchain/scanDescriptors"; -import send, { SendJobOpts } from "@ledgerhq/live-cli/src/commands/blockchain/send"; -import signMessage, { - SignMessageJobOpts, -} from "@ledgerhq/live-cli/src/commands/blockchain/signMessage"; -import sync, { SyncJobOpts } from "@ledgerhq/live-cli/src/commands/blockchain/sync"; -import testDetectOpCollision, { - TestDetectOpCollisionJobOpts, -} from "@ledgerhq/live-cli/src/commands/blockchain/testDetectOpCollision"; -import testGetTrustedInputFromTxHash, { - TestGetTrustedInputFromTxHashJobOpts, -} from "@ledgerhq/live-cli/src/commands/blockchain/testGetTrustedInputFromTxHash"; -import app, { AppJobOpts } from "@ledgerhq/live-cli/src/commands/device/app"; -import appUninstallAll, { - AppsUninstallAllJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/appUninstallAll"; -import appsCheckAllAppVersions, { - AppsCheckAllAppVersionsJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/appsCheckAllAppVersions"; -import appsInstallAll, { - AppsInstallAllJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/appsInstallAll"; -import appsUpdateTestAll, { - AppsUpdateTestAllJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/appsUpdateTestAll"; +import estimateMaxSpendable from "@ledgerhq/live-cli/src/commands/blockchain/estimateMaxSpendable"; +import generateTestScanAccounts from "@ledgerhq/live-cli/src/commands/blockchain/generateTestScanAccounts"; +import generateTestTransaction from "@ledgerhq/live-cli/src/commands/blockchain/generateTestTransaction"; +import getAddress from "@ledgerhq/live-cli/src/commands/blockchain/getAddress"; +import getTransactionStatus from "@ledgerhq/live-cli/src/commands/blockchain/getTransactionStatus"; +import receive from "@ledgerhq/live-cli/src/commands/blockchain/receive"; +import satstack from "@ledgerhq/live-cli/src/commands/blockchain/satstack"; +import satstackStatus from "@ledgerhq/live-cli/src/commands/blockchain/satstackStatus"; +import scanDescriptors from "@ledgerhq/live-cli/src/commands/blockchain/scanDescriptors"; +import send from "@ledgerhq/live-cli/src/commands/blockchain/send"; +import signMessage from "@ledgerhq/live-cli/src/commands/blockchain/signMessage"; +import sync from "@ledgerhq/live-cli/src/commands/blockchain/sync"; +import testDetectOpCollision from "@ledgerhq/live-cli/src/commands/blockchain/testDetectOpCollision"; +import testGetTrustedInputFromTxHash from "@ledgerhq/live-cli/src/commands/blockchain/testGetTrustedInputFromTxHash"; +import app from "@ledgerhq/live-cli/src/commands/device/app"; +import appUninstallAll from "@ledgerhq/live-cli/src/commands/device/appUninstallAll"; +import appsCheckAllAppVersions from "@ledgerhq/live-cli/src/commands/device/appsCheckAllAppVersions"; +import appsInstallAll from "@ledgerhq/live-cli/src/commands/device/appsInstallAll"; +import appsUpdateTestAll from "@ledgerhq/live-cli/src/commands/device/appsUpdateTestAll"; import cleanSpeculos from "@ledgerhq/live-cli/src/commands/device/cleanSpeculos"; -import customLockScreenFetch, { - CustomLockScreenFetchJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/customLockScreenFetch"; -import customLockScreenFetchAndRestore, { - CustomLockScreenFetchAndRestoreJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/customLockScreenFetchAndRestore"; -import customLockScreenFetchHash, { - CustomLockScreenFetchHashJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/customLockScreenFetchHash"; -import customLockScreenLoad, { - CustomLockScreenLoadJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/customLockScreenLoad"; -import customLockScreenRemove, { - CustomLockScreenRemoveJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/customLockScreenRemove"; -import devDeviceAppsScenario, { - DevDeviceAppsScenarioJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/devDeviceAppsScenario"; -import deviceAppVersion, { - DeviceAppVersionJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/deviceAppVersion"; -import deviceInfo, { DeviceInfoJobOpts } from "@ledgerhq/live-cli/src/commands/device/deviceInfo"; -import deviceSDKFirmwareUpdate, { - DeviceSDKFirmwareUpdateJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/deviceSDKFirmwareUpdate"; -import deviceSDKGetBatteryStatuses, { - DeviceSDKGetBatteryStatusesJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/deviceSDKGetBatteryStatuses"; -import deviceSDKGetDeviceInfo, { - DeviceSDKGetDeviceInfoJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/deviceSDKGetDeviceInfo"; -import deviceSDKToggleOnboardingEarlyCheck, { - DeviceSDKToggleOnboardingEarlyCheckJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/deviceSDKToggleOnboardingEarlyCheck"; -import deviceVersion, { - DeviceVersionJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/deviceVersion"; -import discoverDevices, { - DiscoverDevicesJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/discoverDevices"; -import firmwareRepair, { - FirmwareRepairJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/firmwareRepair"; -import firmwareUpdate, { - FirmwareUpdateJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/firmwareUpdate"; -import genuineCheck, { - GenuineCheckJobArgs, -} from "@ledgerhq/live-cli/src/commands/device/genuineCheck"; -import getBatteryStatus, { - GetBatteryStatusJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/getBatteryStatus"; -import getDeviceRunningMode, { - GetDeviceRunningModeJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/getDeviceRunningMode"; -import i18n, { I18nJobOpts } from "@ledgerhq/live-cli/src/commands/device/i18n"; -import listApps, { ListAppsJobOpts } from "@ledgerhq/live-cli/src/commands/device/listApps"; -import managerListApps, { - ManagerListAppsJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/managerListApps"; -import proxy, { ProxyJobOpts } from "@ledgerhq/live-cli/src/commands/device/proxy"; -import reinstallConfigurationConsent, { - ReinstallConfigurationConsentJobOpts, -} from "@ledgerhq/live-cli/src/commands/device/reinstallConfigurationConsent"; -import repl, { ReplJobOpts } from "@ledgerhq/live-cli/src/commands/device/repl"; +import customLockScreenFetch from "@ledgerhq/live-cli/src/commands/device/customLockScreenFetch"; +import customLockScreenFetchAndRestore from "@ledgerhq/live-cli/src/commands/device/customLockScreenFetchAndRestore"; +import customLockScreenFetchHash from "@ledgerhq/live-cli/src/commands/device/customLockScreenFetchHash"; +import customLockScreenLoad from "@ledgerhq/live-cli/src/commands/device/customLockScreenLoad"; +import customLockScreenRemove from "@ledgerhq/live-cli/src/commands/device/customLockScreenRemove"; +import devDeviceAppsScenario from "@ledgerhq/live-cli/src/commands/device/devDeviceAppsScenario"; +import deviceAppVersion from "@ledgerhq/live-cli/src/commands/device/deviceAppVersion"; +import deviceInfo from "@ledgerhq/live-cli/src/commands/device/deviceInfo"; +import deviceSDKFirmwareUpdate from "@ledgerhq/live-cli/src/commands/device/deviceSDKFirmwareUpdate"; +import deviceSDKGetBatteryStatuses from "@ledgerhq/live-cli/src/commands/device/deviceSDKGetBatteryStatuses"; +import deviceSDKGetDeviceInfo from "@ledgerhq/live-cli/src/commands/device/deviceSDKGetDeviceInfo"; +import deviceSDKToggleOnboardingEarlyCheck from "@ledgerhq/live-cli/src/commands/device/deviceSDKToggleOnboardingEarlyCheck"; +import deviceVersion from "@ledgerhq/live-cli/src/commands/device/deviceVersion"; +import discoverDevices from "@ledgerhq/live-cli/src/commands/device/discoverDevices"; +import firmwareRepair from "@ledgerhq/live-cli/src/commands/device/firmwareRepair"; +import firmwareUpdate from "@ledgerhq/live-cli/src/commands/device/firmwareUpdate"; +import genuineCheck from "@ledgerhq/live-cli/src/commands/device/genuineCheck"; +import getBatteryStatus from "@ledgerhq/live-cli/src/commands/device/getBatteryStatus"; +import getDeviceRunningMode from "@ledgerhq/live-cli/src/commands/device/getDeviceRunningMode"; +import i18n from "@ledgerhq/live-cli/src/commands/device/i18n"; +import listApps from "@ledgerhq/live-cli/src/commands/device/listApps"; +import managerListApps from "@ledgerhq/live-cli/src/commands/device/managerListApps"; +import proxy from "@ledgerhq/live-cli/src/commands/device/proxy"; +import reinstallConfigurationConsent from "@ledgerhq/live-cli/src/commands/device/reinstallConfigurationConsent"; +import repl from "@ledgerhq/live-cli/src/commands/device/repl"; import speculosList from "@ledgerhq/live-cli/src/commands/device/speculosList"; -import balanceHistory, { - BalanceHistoryJobOpts, -} from "@ledgerhq/live-cli/src/commands/live/balanceHistory"; -import countervalues, { - CountervaluesJobOpts, -} from "@ledgerhq/live-cli/src/commands/live/countervalues"; +import balanceHistory from "@ledgerhq/live-cli/src/commands/live/balanceHistory"; +import countervalues from "@ledgerhq/live-cli/src/commands/live/countervalues"; import envs from "@ledgerhq/live-cli/src/commands/live/envs"; -import exportAccounts, { - ExportAccountsJobOpts, -} from "@ledgerhq/live-cli/src/commands/live/exportAccounts"; -import ledgerKeyRingProtocol, { - LedgerKeyRingProtocolJobOpts, -} from "@ledgerhq/live-cli/src/commands/live/ledgerKeyRingProtocol"; -import ledgerSync, { LedgerSyncJobOpts } from "@ledgerhq/live-cli/src/commands/live/ledgerSync"; -import liveData, { LiveDataJobOpts } from "@ledgerhq/live-cli/src/commands/live/liveData"; -import portfolio, { PortfolioJobOpts } from "@ledgerhq/live-cli/src/commands/live/portfolio"; -import synchronousOnboarding, { - SynchronousOnboardingJobOpts, -} from "@ledgerhq/live-cli/src/commands/live/synchronousOnboarding"; +import exportAccounts from "@ledgerhq/live-cli/src/commands/live/exportAccounts"; +import ledgerKeyRingProtocol from "@ledgerhq/live-cli/src/commands/live/ledgerKeyRingProtocol"; +import ledgerSync from "@ledgerhq/live-cli/src/commands/live/ledgerSync"; +import liveData from "@ledgerhq/live-cli/src/commands/live/liveData"; +import portfolio from "@ledgerhq/live-cli/src/commands/live/portfolio"; +import synchronousOnboarding from "@ledgerhq/live-cli/src/commands/live/synchronousOnboarding"; import user from "@ledgerhq/live-cli/src/commands/live/user"; import version from "@ledgerhq/live-cli/src/commands/live/version"; -import swap, { SwapJobOpts } from "@ledgerhq/live-cli/src/commands/ptx/swap"; -import { Observable } from "rxjs"; +import swap from "@ledgerhq/live-cli/src/commands/ptx/swap"; -export type Command = (arg: JobOpts) => Observable | Promise | string; // Job accepts a single object -type EmtyArgs = {}; - -export type Commands = { - bot: Command; - botPortfolio: Command; - botTransfer: Command; - broadcast: Command; - confirmOp: Command; - derivation: Command; - estimateMaxSpendable: Command; - generateTestScanAccounts: Command; - generateTestTransaction: Command; - getAddress: Command; - getTransactionStatus: Command; - receive: Command; - satstack: Command; - satstackStatus: Command; - scanDescriptors: Command; - send: Command; - signMessage: Command; - sync: Command; - testDetectOpCollision: Command; - testGetTrustedInputFromTxHash: Command; - app: Command; - appUninstallAll: Command; - appsCheckAllAppVersions: Command; - appsInstallAll: Command; - appsUpdateTestAll: Command; - cleanSpeculos: Command; - customLockScreenFetch: Command; - customLockScreenFetchAndRestore: Command; - customLockScreenFetchHash: Command; - customLockScreenLoad: Command; - customLockScreenRemove: Command; - devDeviceAppsScenario: Command; - deviceAppVersion: Command; - deviceInfo: Command; - deviceSDKFirmwareUpdate: Command; - deviceSDKGetBatteryStatuses: Command; - deviceSDKGetDeviceInfo: Command; - deviceSDKToggleOnboardingEarlyCheck: Command; - deviceVersion: Command; - discoverDevices: Command; - firmwareRepair: Command; - firmwareUpdate: Command; - genuineCheck: Command; - getBatteryStatus: Command; - getDeviceRunningMode: Command; - i18n: Command; - listApps: Command; - managerListApps: Command; - proxy: Command; - reinstallConfigurationConsent: Command; - repl: Command; - speculosList: Command; - balanceHistory: Command; - countervalues: Command; - envs: Command; - exportAccounts: Command; - ledgerKeyRingProtocol: Command; - ledgerSync: Command; - liveData: Command; - portfolio: Command; - synchronousOnboarding: Command; - user: Command; - version: Command; - swap: Command; -}; - -export const commandCLI = { +export const CLI = { bot: bot.job, botPortfolio: botPortfolio.job, botTransfer: botTransfer.job,