Skip to content

Commit

Permalink
change onspeculoscreated hook
Browse files Browse the repository at this point in the history
  • Loading branch information
hedi-edelbloute committed Nov 6, 2023
1 parent 9528f0f commit ed9a8df
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
9 changes: 4 additions & 5 deletions libs/ledger-live-common/src/bot/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
releaseSpeculosDevice,
findAppCandidate,
} from "../load/speculos";
import type { AppCandidate } from "@ledgerhq/coin-framework/bot/types";
import type { AppCandidate, SpeculosTransport } from "@ledgerhq/coin-framework/bot/types";
import { formatReportForConsole, formatTime, formatAppCandidate, formatError } from "./formatters";
import type {
AppSpec,
Expand Down Expand Up @@ -93,7 +93,7 @@ export async function runWithAppSpec<T extends Transaction>(
}

const mutationReports: MutationReport<T>[] = [];
const { appQuery, currency, dependency } = spec;
const { appQuery, currency, dependency, onSpeculosDeviceCreated } = spec;
const appCandidate = findAppCandidate(appCandidates, appQuery);
if (!appCandidate) {
console.warn("no app found for " + spec.name);
Expand All @@ -113,8 +113,10 @@ export async function runWithAppSpec<T extends Transaction>(
seed,
dependency,
coinapps,
onSpeculosDeviceCreated,
};
let device;

const hintWarnings: string[] = [];
const appReport: SpecReport<T> = {
spec,
Expand All @@ -137,9 +139,6 @@ export async function runWithAppSpec<T extends Transaction>(
try {
device = await createSpeculosDevice(deviceParams);
appReport.appPath = device.appPath;
if (spec.onSpeculosDeviceCreated) {
await spec.onSpeculosDeviceCreated(device);
}
const bridge = getCurrencyBridge(currency);
const syncConfig = {
paginationConfig: {},
Expand Down
7 changes: 2 additions & 5 deletions libs/ledger-live-common/src/bot/portfolio/process-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async function main(): Promise<Report> {

const appCandidates = await listAppCandidates(COINAPPS);

const { appQuery, currency, dependency } = spec;
const { appQuery, currency, dependency, onSpeculosDeviceCreated } = spec;
const appCandidate = findAppCandidate(appCandidates, appQuery);
if (!appCandidate) {
console.warn("no app found for " + spec.name);
Expand All @@ -68,14 +68,11 @@ async function main(): Promise<Report> {
seed: SEED,
dependency,
coinapps: COINAPPS,
onSpeculosDeviceCreated,
};

const device = await createSpeculosDevice(deviceParams);

if (spec.onSpeculosDeviceCreated) {
await spec.onSpeculosDeviceCreated(device);
}

try {
const audit = new Audit();

Expand Down
14 changes: 13 additions & 1 deletion libs/ledger-live-common/src/load/speculos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ export async function createSpeculosDevice(
seed: string;
// Folder where we have app binaries
coinapps: string;
onSpeculosDeviceCreated?: (device: {
transport: SpeculosTransport;
id: string;
appPath: string;
}) => Promise<void>;
},
maxRetry = 3,
): Promise<{
Expand Down Expand Up @@ -271,11 +276,18 @@ export async function createSpeculosDevice(
destroy,
};
}
return {

const device = {
id: speculosID,
transport,
appPath,
};

if (arg.onSpeculosDeviceCreated != null) {
await arg.onSpeculosDeviceCreated(device);
}

return device;
}

function hackBadSemver(str) {
Expand Down

1 comment on commit ed9a8df

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Bot] Testing with 'Nitrogen' ❌ 1 txs ($0.10) ⏲ 13.8s

❌ 1 specs have problems: VeChain VET

What is the bot and how does it work? Everything is documented here!

❌ 1 mutation errors
necessary accounts resynced in 0.38ms
▬ VeChain 1.1.1 on nanoX 2.2.2
→ FROM Vechain 1 cross: 0 VET (4ops) (0xc4B17901FECf86932c3bb296BB00E7c6816Fd416 on 44'/818'/0'/0/0) vechain#0 js:2:vechain:0xc4B17901FECf86932c3bb296BB00E7c6816Fd416:vechain 0 VET spendable. 
  TokenAccount Vethor: 54.3706899375 VTHO (2 ops) (! sum of ops 55 VTHO)
max spendable ~0
★ using mutation 'move ~50% VTHO'
→ TO Vechain 2: 5 VET (3ops) (0x7850ddc6a26AF0C078b9f1569Ca16746B2ACd3bD on 44'/818'/0'/0/1) vechain#1 js:2:vechain:0x7850ddc6a26AF0C078b9f1569Ca16746B2ACd3bD:vechain
✔️ transaction SEND  27.18534496875 VET TO 0x7850ddc6a26AF0C078b9f1569Ca16746B2ACd3bD
STATUS (1085ms)
  amount: 27.18534496875 VTHO
  estimated fees: 0.5171 VET
  total spent: 27.70244496875 VTHO
errors: 
errors: 
⚠️ VechainAppPleaseEnableContractDataAndMultiClause: Please enable contract data in Vechain app settings
(totally spent 1100ms – ends at 2023-11-06T15:19:17.259Z)
⚠️ 2 spec hints
  • Spec VeChain VET:
    • There are not enough accounts to cover all mutations. Please increase the account target to at least 5 accounts
    • mutations should define a testDestination(): move ~50% VTHO
Details of the 1 mutations

Spec VeChain VET (3)

Spec VeChain VET found 3 Vechain accounts. Will use VeChain 1.1.1 on nanoX 2.2.2
Vechain 1 cross: 0 VET (4ops) (0xc4B17901FECf86932c3bb296BB00E7c6816Fd416 on 44'/818'/0'/0/0) vechain#0 js:2:vechain:0xc4B17901FECf86932c3bb296BB00E7c6816Fd416:vechain
Vechain 2: 5 VET (3ops) (0x7850ddc6a26AF0C078b9f1569Ca16746B2ACd3bD on 44'/818'/0'/0/1) vechain#1 js:2:vechain:0x7850ddc6a26AF0C078b9f1569Ca16746B2ACd3bD:vechain
Vechain 3: 0 VET (0ops) (0x6fc5998724338CDe55Bba798273FAdcDE79c5074 on 44'/818'/0'/0/2) vechain#2 js:2:vechain:0x6fc5998724338CDe55Bba798273FAdcDE79c5074:vechain
necessary accounts resynced in 0.38ms
▬ VeChain 1.1.1 on nanoX 2.2.2
→ FROM Vechain 1 cross: 0 VET (4ops) (0xc4B17901FECf86932c3bb296BB00E7c6816Fd416 on 44'/818'/0'/0/0) vechain#0 js:2:vechain:0xc4B17901FECf86932c3bb296BB00E7c6816Fd416:vechain 0 VET spendable. 
  TokenAccount Vethor: 54.3706899375 VTHO (2 ops) (! sum of ops 55 VTHO)
max spendable ~0
★ using mutation 'move ~50% VTHO'
→ TO Vechain 2: 5 VET (3ops) (0x7850ddc6a26AF0C078b9f1569Ca16746B2ACd3bD on 44'/818'/0'/0/1) vechain#1 js:2:vechain:0x7850ddc6a26AF0C078b9f1569Ca16746B2ACd3bD:vechain
✔️ transaction SEND  27.18534496875 VET TO 0x7850ddc6a26AF0C078b9f1569Ca16746B2ACd3bD
STATUS (1085ms)
  amount: 27.18534496875 VTHO
  estimated fees: 0.5171 VET
  total spent: 27.70244496875 VTHO
errors: 
errors: 
⚠️ VechainAppPleaseEnableContractDataAndMultiClause: Please enable contract data in Vechain app settings
(totally spent 1100ms – ends at 2023-11-06T15:19:17.262Z)

Details of the 3 uncovered mutations

Spec VeChain VET (3)

  • move ~50% VET: Vechain: VTHO balance is not enough (1), Vechain: VET balance is empty (1)
  • move all VET: Vechain: VTHO balance is not enough (1), Vechain: VET balance is empty (1)
  • move all VTHO: Vechain: VTHO balance is not enough (2)
Portfolio ($0.10) – Details of the 1 currencies
Spec (accounts) State Remaining Runs (est) funds?
VeChain VET (3) 7 ops , 5 VET ($0.10) ⚠️ 6 0xc4B17901FECf86932c3bb296BB00E7c6816Fd416
Vechain 1 cross: 0 VET (4ops) (0xc4B17901FECf86932c3bb296BB00E7c6816Fd416 on 44'/818'/0'/0/0) vechain#0 js:2:vechain:0xc4B17901FECf86932c3bb296BB00E7c6816Fd416:vechain
Vechain 2: 5 VET (3ops) (0x7850ddc6a26AF0C078b9f1569Ca16746B2ACd3bD on 44'/818'/0'/0/1) vechain#1 js:2:vechain:0x7850ddc6a26AF0C078b9f1569Ca16746B2ACd3bD:vechain
Vechain 3: 0 VET (0ops) (0x6fc5998724338CDe55Bba798273FAdcDE79c5074 on 44'/818'/0'/0/2) vechain#2 js:2:vechain:0x6fc5998724338CDe55Bba798273FAdcDE79c5074:vechain
Performance ⏲ 13.8s

Time spent for each spec: (total across mutations)

Spec (accounts) preload scan re-sync tx status sign op broadcast test destination test
TOTAL 1.26ms 6.9s 1.05ms 1085ms N/A N/A N/A N/A
VeChain VET (2) 1.26ms 6.9s 1.05ms 1085ms N/A N/A N/A N/A

What is the bot and how does it work? Everything is documented here!

Please sign in to comment.