@ledgerhq/live-common 27.1.0-next.5 → 27.2.0-next.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/lib/api/socket.js.map +1 -1
- package/lib/bot/index.d.ts.map +1 -1
- package/lib/bot/index.js +90 -81
- package/lib/bot/index.js.map +1 -1
- package/lib/bot/specs.d.ts.map +1 -1
- package/lib/bot/specs.js +11 -2
- package/lib/bot/specs.js.map +1 -1
- package/lib/errors.d.ts +306 -102
- package/lib/errors.d.ts.map +1 -1
- package/lib/exchange/swap/getKYCStatus.d.ts.map +1 -1
- package/lib/exchange/swap/getKYCStatus.js +1 -1
- package/lib/exchange/swap/getKYCStatus.js.map +1 -1
- package/lib/families/bitcoin/cache.js +3 -3
- package/lib/families/bitcoin/cache.js.map +1 -1
- package/lib/families/bitcoin/errors.d.ts +3 -1
- package/lib/families/bitcoin/errors.d.ts.map +1 -1
- package/lib/families/bitcoin/hw-signMessage.d.ts +5 -3
- package/lib/families/bitcoin/hw-signMessage.d.ts.map +1 -1
- package/lib/families/bitcoin/hw-signMessage.js +2 -2
- package/lib/families/bitcoin/hw-signMessage.js.map +1 -1
- package/lib/families/cardano/errors.d.ts +6 -2
- package/lib/families/cardano/errors.d.ts.map +1 -1
- package/lib/families/celo/errors.d.ts +3 -1
- package/lib/families/celo/errors.d.ts.map +1 -1
- package/lib/families/cosmos/banner.d.ts +1 -1
- package/lib/families/cosmos/banner.d.ts.map +1 -1
- package/lib/families/cosmos/banner.js +53 -98
- package/lib/families/cosmos/banner.js.map +1 -1
- package/lib/families/cosmos/banner.test.js +85 -65
- package/lib/families/cosmos/banner.test.js.map +1 -1
- package/lib/families/cosmos/logic.d.ts +1 -1
- package/lib/families/cosmos/logic.d.ts.map +1 -1
- package/lib/families/cosmos/logic.js.map +1 -1
- package/lib/families/cosmos/specs.d.ts.map +1 -1
- package/lib/families/cosmos/specs.js +12 -8
- package/lib/families/cosmos/specs.js.map +1 -1
- package/lib/families/crypto_org/errors.d.ts +9 -3
- package/lib/families/crypto_org/errors.d.ts.map +1 -1
- package/lib/families/ethereum/hw-signMessage.d.ts +7 -3
- package/lib/families/ethereum/hw-signMessage.d.ts.map +1 -1
- package/lib/families/ethereum/hw-signMessage.js +73 -14
- package/lib/families/ethereum/hw-signMessage.js.map +1 -1
- package/lib/families/ethereum/hw-signMessage.test.js +99 -23
- package/lib/families/ethereum/hw-signMessage.test.js.map +1 -1
- package/lib/families/ethereum/transaction.d.ts +1 -1
- package/lib/families/ethereum/transaction.d.ts.map +1 -1
- package/lib/families/ethereum/types.d.ts +6 -8
- package/lib/families/ethereum/types.d.ts.map +1 -1
- package/lib/families/filecoin/bridge.integration.test.js +1 -1
- package/lib/families/filecoin/bridge.integration.test.js.map +1 -1
- package/lib/families/filecoin/hw-signMessage.d.ts +5 -3
- package/lib/families/filecoin/hw-signMessage.d.ts.map +1 -1
- package/lib/families/filecoin/hw-signMessage.js +2 -2
- package/lib/families/filecoin/hw-signMessage.js.map +1 -1
- package/lib/families/osmosis/errors.d.ts +9 -3
- package/lib/families/osmosis/errors.d.ts.map +1 -1
- package/lib/families/osmosis/specs.d.ts.map +1 -1
- package/lib/families/osmosis/specs.js +32 -22
- package/lib/families/osmosis/specs.js.map +1 -1
- package/lib/families/polkadot/errors.d.ts +36 -12
- package/lib/families/polkadot/errors.d.ts.map +1 -1
- package/lib/families/solana/errors.d.ts +60 -20
- package/lib/families/solana/errors.d.ts.map +1 -1
- package/lib/families/stellar/api/horizon.js +3 -3
- package/lib/families/stellar/api/horizon.js.map +1 -1
- package/lib/families/stellar/errors.d.ts +33 -11
- package/lib/families/stellar/errors.d.ts.map +1 -1
- package/lib/families/tezos/bridge/js.js.map +1 -1
- package/lib/families/tron/specs.js +1 -1
- package/lib/families/tron/specs.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +9 -3
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/generated/hw-signMessage.d.ts +10 -3
- package/lib/generated/hw-signMessage.d.ts.map +1 -1
- package/lib/hw/connectApp.js.map +1 -1
- package/lib/hw/connectManager.js.map +1 -1
- package/lib/hw/deviceAccess.d.ts +1 -1
- package/lib/hw/deviceAccess.d.ts.map +1 -1
- package/lib/hw/deviceAccess.js.map +1 -1
- package/lib/hw/getOnboardingStatePolling.d.ts +1 -1
- package/lib/hw/getOnboardingStatePolling.d.ts.map +1 -1
- package/lib/hw/getOnboardingStatePolling.js +1 -0
- package/lib/hw/getOnboardingStatePolling.js.map +1 -1
- package/lib/hw/installLanguage.js.map +1 -1
- package/lib/hw/signMessage/index.d.ts +5 -5
- package/lib/hw/signMessage/index.d.ts.map +1 -1
- package/lib/hw/signMessage/index.js +10 -6
- package/lib/hw/signMessage/index.js.map +1 -1
- package/lib/hw/signMessage/index.test.js +42 -43
- package/lib/hw/signMessage/index.test.js.map +1 -1
- package/lib/hw/signMessage/types.d.ts +1 -1
- package/lib/hw/signMessage/types.d.ts.map +1 -1
- package/lib/hw/uninstallLanguage.js.map +1 -1
- package/lib/walletconnect/index.d.ts +1 -1
- package/lib/walletconnect/index.d.ts.map +1 -1
- package/lib/walletconnect/index.js +1 -9
- package/lib/walletconnect/index.js.map +1 -1
- package/lib/walletconnect/walletconnect.test.js.map +1 -1
- package/package.json +18 -18
- package/src/api/socket.ts +1 -1
- package/src/bot/index.ts +174 -113
- package/src/bot/specs.ts +16 -2
- package/src/exchange/swap/getKYCStatus.ts +3 -1
- package/src/families/bitcoin/cache.ts +2 -2
- package/src/families/bitcoin/hw-signMessage.ts +3 -3
- package/src/families/cosmos/banner.test.ts +40 -15
- package/src/families/cosmos/banner.ts +6 -13
- package/src/families/cosmos/logic.ts +1 -1
- package/src/families/cosmos/specs.ts +14 -10
- package/src/families/ethereum/hw-signMessage.test.ts +105 -21
- package/src/families/ethereum/hw-signMessage.ts +68 -16
- package/src/families/ethereum/types.ts +6 -8
- package/src/families/filecoin/__snapshots__/bridge.integration.test.ts.snap +27 -0
- package/src/families/filecoin/bridge.integration.test.ts +6 -2
- package/src/families/filecoin/hw-signMessage.ts +3 -3
- package/src/families/osmosis/specs.ts +35 -25
- package/src/families/stellar/api/horizon.ts +4 -4
- package/src/families/tezos/bridge/js.ts +1 -1
- package/src/families/tron/specs.ts +1 -1
- package/src/featureFlags/defaultFeatures.ts +9 -3
- package/src/hw/connectApp.ts +1 -1
- package/src/hw/connectManager.ts +1 -1
- package/src/hw/deviceAccess.ts +2 -2
- package/src/hw/getOnboardingStatePolling.ts +5 -1
- package/src/hw/installLanguage.ts +1 -1
- package/src/hw/signMessage/index.test.ts +48 -45
- package/src/hw/signMessage/index.ts +23 -9
- package/src/hw/signMessage/types.ts +4 -1
- package/src/hw/uninstallLanguage.ts +1 -1
- package/src/walletconnect/index.ts +3 -11
- package/src/walletconnect/walletconnect.test.ts +2 -0
package/src/bot/index.ts
CHANGED
|
@@ -249,6 +249,15 @@ export async function bot({
|
|
|
249
249
|
const { GITHUB_RUN_ID, GITHUB_WORKFLOW } = process.env;
|
|
250
250
|
|
|
251
251
|
let body = "";
|
|
252
|
+
let githubBody = "";
|
|
253
|
+
function appendBody(content) {
|
|
254
|
+
body += content;
|
|
255
|
+
githubBody += content;
|
|
256
|
+
}
|
|
257
|
+
function appendBodyFullOnly(content) {
|
|
258
|
+
body += content;
|
|
259
|
+
}
|
|
260
|
+
|
|
252
261
|
let title = "";
|
|
253
262
|
const runURL = `https://github.com/LedgerHQ/ledger-live/actions/runs/${String(
|
|
254
263
|
GITHUB_RUN_ID
|
|
@@ -282,14 +291,14 @@ export async function bot({
|
|
|
282
291
|
}
|
|
283
292
|
|
|
284
293
|
let slackBody = "";
|
|
285
|
-
|
|
294
|
+
appendBody(`## ${title}`);
|
|
286
295
|
|
|
287
296
|
if (GITHUB_RUN_ID && GITHUB_WORKFLOW) {
|
|
288
|
-
|
|
297
|
+
appendBody(` for [**${GITHUB_WORKFLOW}**](${runURL})\n\n`);
|
|
289
298
|
}
|
|
290
299
|
|
|
291
|
-
|
|
292
|
-
|
|
300
|
+
appendBody("\n\n");
|
|
301
|
+
appendBody(subtitle);
|
|
293
302
|
|
|
294
303
|
if (fullySuccessfulSpecs.length) {
|
|
295
304
|
const msg = `> ✅ ${
|
|
@@ -297,7 +306,7 @@ export async function bot({
|
|
|
297
306
|
} specs are successful: _${fullySuccessfulSpecs
|
|
298
307
|
.map((o) => o.spec.name)
|
|
299
308
|
.join(", ")}_\n`;
|
|
300
|
-
|
|
309
|
+
appendBody(msg);
|
|
301
310
|
slackBody += msg;
|
|
302
311
|
}
|
|
303
312
|
|
|
@@ -307,7 +316,7 @@ export async function bot({
|
|
|
307
316
|
} specs have problems: _${specsWithErrors
|
|
308
317
|
.map((o) => o.spec.name)
|
|
309
318
|
.join(", ")}_\n`;
|
|
310
|
-
|
|
319
|
+
appendBody(msg);
|
|
311
320
|
slackBody += msg;
|
|
312
321
|
}
|
|
313
322
|
|
|
@@ -315,7 +324,7 @@ export async function bot({
|
|
|
315
324
|
const missingFundsWarn = `> 💰 ${
|
|
316
325
|
withoutFunds.length
|
|
317
326
|
} specs may miss funds: _${withoutFunds.join(", ")}_\n`;
|
|
318
|
-
|
|
327
|
+
appendBody(missingFundsWarn);
|
|
319
328
|
slackBody += missingFundsWarn;
|
|
320
329
|
}
|
|
321
330
|
|
|
@@ -325,21 +334,23 @@ export async function bot({
|
|
|
325
334
|
} specs may have issues: *${specsWithoutOperations
|
|
326
335
|
.map((o) => o.spec.name)
|
|
327
336
|
.join(", ")}*\n`;
|
|
328
|
-
|
|
337
|
+
appendBody(warn);
|
|
329
338
|
slackBody += warn;
|
|
330
339
|
}
|
|
331
340
|
|
|
332
|
-
|
|
341
|
+
appendBody("\n\n");
|
|
333
342
|
|
|
334
343
|
if (specFatals.length) {
|
|
335
|
-
|
|
336
|
-
|
|
344
|
+
appendBody("<details>\n");
|
|
345
|
+
appendBody(
|
|
346
|
+
`<summary>${specFatals.length} critical spec errors</summary>\n\n`
|
|
347
|
+
);
|
|
337
348
|
specFatals.forEach(({ spec, fatalError }) => {
|
|
338
|
-
|
|
339
|
-
|
|
349
|
+
appendBody(`**Spec ${spec.name} failed!**\n`);
|
|
350
|
+
appendBody("```\n" + formatError(fatalError, true) + "\n```\n\n");
|
|
340
351
|
slackBody += `❌ *Spec ${spec.name}*: \`${formatError(fatalError)}\`\n`;
|
|
341
352
|
});
|
|
342
|
-
|
|
353
|
+
appendBody("</details>\n\n");
|
|
343
354
|
}
|
|
344
355
|
|
|
345
356
|
// summarize the error causes
|
|
@@ -361,65 +372,77 @@ export async function bot({
|
|
|
361
372
|
}
|
|
362
373
|
|
|
363
374
|
if (errorCases.length) {
|
|
364
|
-
|
|
365
|
-
|
|
375
|
+
appendBody("<details>\n");
|
|
376
|
+
appendBody(`<summary>${errorCases.length} mutation errors</summary>\n\n`);
|
|
366
377
|
errorCases.forEach((c) => {
|
|
367
|
-
|
|
378
|
+
appendBody("```\n" + formatReportForConsole(c) + "\n```\n\n");
|
|
368
379
|
});
|
|
369
|
-
|
|
380
|
+
appendBody("</details>\n\n");
|
|
370
381
|
}
|
|
371
382
|
|
|
372
|
-
|
|
373
|
-
|
|
383
|
+
appendBodyFullOnly("<details>\n");
|
|
384
|
+
|
|
385
|
+
appendBodyFullOnly(
|
|
386
|
+
`<summary>Details of the ${mutationReports.length} mutations</summary>\n\n`
|
|
387
|
+
);
|
|
374
388
|
results.forEach((r, i) => {
|
|
375
389
|
const spec = specs[i];
|
|
376
390
|
const logs = specsLogs[i];
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
391
|
+
appendBodyFullOnly(
|
|
392
|
+
`#### Spec ${spec.name} (${
|
|
393
|
+
r.mutations ? r.mutations.length : "failed"
|
|
394
|
+
})\n`
|
|
395
|
+
);
|
|
396
|
+
appendBodyFullOnly("\n```\n");
|
|
397
|
+
appendBodyFullOnly(logs.join("\n"));
|
|
382
398
|
|
|
383
399
|
if (r.mutations) {
|
|
384
400
|
r.mutations.forEach((m) => {
|
|
385
401
|
if (m.error || m.mutation) {
|
|
386
|
-
|
|
402
|
+
appendBodyFullOnly(formatReportForConsole(m) + "\n");
|
|
387
403
|
}
|
|
388
404
|
});
|
|
389
405
|
}
|
|
390
406
|
|
|
391
|
-
|
|
407
|
+
appendBodyFullOnly("\n```\n");
|
|
392
408
|
});
|
|
393
|
-
|
|
409
|
+
appendBodyFullOnly("</details>\n\n");
|
|
394
410
|
|
|
395
411
|
if (uncoveredMutations.length > 0) {
|
|
396
|
-
|
|
397
|
-
|
|
412
|
+
appendBodyFullOnly("<details>\n");
|
|
413
|
+
appendBodyFullOnly(
|
|
414
|
+
`<summary>Details of the ${uncoveredMutations.length} uncovered mutations</summary>\n\n`
|
|
415
|
+
);
|
|
398
416
|
specsWithUncoveredMutations.forEach(({ spec, unavailableMutations }) => {
|
|
399
|
-
|
|
417
|
+
appendBodyFullOnly(
|
|
418
|
+
`#### Spec ${spec.name} (${unavailableMutations.length})\n`
|
|
419
|
+
);
|
|
400
420
|
unavailableMutations.forEach((m) => {
|
|
401
421
|
// FIXME: we definitely got to stop using Maybe types or | undefined | null
|
|
402
422
|
if (!m) return;
|
|
403
423
|
const msgs = groupBy(m.errors.map((e) => e.message));
|
|
404
|
-
|
|
424
|
+
appendBodyFullOnly(
|
|
405
425
|
"- **" +
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
426
|
+
m.mutation.name +
|
|
427
|
+
"**: " +
|
|
428
|
+
Object.keys(msgs)
|
|
429
|
+
.map((msg) => `${msg} (${msgs[msg].length})`)
|
|
430
|
+
.join(", ") +
|
|
431
|
+
"\n"
|
|
432
|
+
);
|
|
412
433
|
});
|
|
413
434
|
});
|
|
414
|
-
|
|
435
|
+
appendBodyFullOnly("</details>\n\n");
|
|
415
436
|
}
|
|
416
437
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
438
|
+
appendBody("<details>\n");
|
|
439
|
+
appendBody(
|
|
440
|
+
`<summary>Portfolio ${
|
|
441
|
+
totalUSD ? " (" + totalUSD + ")" : ""
|
|
442
|
+
} – Details of the ${results.length} currencies</summary>\n\n`
|
|
443
|
+
);
|
|
444
|
+
appendBody("| Spec (accounts) | Operations | Balance | funds? |\n");
|
|
445
|
+
appendBody("|-----------------|------------|---------|--------|\n");
|
|
423
446
|
results.forEach((r) => {
|
|
424
447
|
function sumAccounts(all) {
|
|
425
448
|
if (!all || all.length === 0) return;
|
|
@@ -486,22 +509,30 @@ export async function bot({
|
|
|
486
509
|
const beforeOps = countOps(r.accountsBefore);
|
|
487
510
|
const afterOps = countOps(r.accountsAfter);
|
|
488
511
|
const firstAccount = (r.accountsAfter || r.accountsBefore || [])[0];
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
512
|
+
appendBody(
|
|
513
|
+
`| ${r.spec.name} (${
|
|
514
|
+
(r.accountsBefore || []).filter((a) => a.used).length
|
|
515
|
+
}) `
|
|
516
|
+
);
|
|
517
|
+
appendBody(
|
|
518
|
+
`| ${afterOps || beforeOps}${
|
|
519
|
+
afterOps > beforeOps ? ` (+${afterOps - beforeOps})` : ""
|
|
520
|
+
} `
|
|
521
|
+
);
|
|
522
|
+
appendBody(`| ${balance} `);
|
|
523
|
+
appendBody(
|
|
524
|
+
`| ${etaTxs} ${(firstAccount && firstAccount.freshAddress) || ""} `
|
|
525
|
+
);
|
|
526
|
+
appendBody("|\n");
|
|
498
527
|
});
|
|
499
|
-
|
|
528
|
+
appendBody("\n</details>\n\n");
|
|
500
529
|
|
|
501
530
|
// Add performance details
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
531
|
+
appendBody("<details>\n");
|
|
532
|
+
appendBody(
|
|
533
|
+
`<summary>Performance ⏲ ${formatTime(totalDuration)}</summary>\n\n`
|
|
534
|
+
);
|
|
535
|
+
appendBody("**Time spent for each spec:** (total across mutations)\n");
|
|
505
536
|
|
|
506
537
|
function sumMutation(mutations, f) {
|
|
507
538
|
return mutations?.reduce((sum, m) => sum + (f(m) || 0), 0) || 0;
|
|
@@ -513,73 +544,98 @@ export async function bot({
|
|
|
513
544
|
return sumResults((r) => sumMutation(r.mutations, f));
|
|
514
545
|
}
|
|
515
546
|
|
|
516
|
-
|
|
517
|
-
"| Spec (accounts) | preload | scan | re-sync | tx status | sign op | broadcast | mutation confirm |\n"
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
sumResultsMutation((m) =>
|
|
533
|
-
m.statusTime && m.signedTime ? m.signedTime - m.statusTime : 0
|
|
534
|
-
)
|
|
535
|
-
)}** |`;
|
|
536
|
-
body += `**${formatTime(
|
|
537
|
-
sumResultsMutation((m) =>
|
|
538
|
-
m.signedTime && m.broadcastedTime ? m.broadcastedTime - m.signedTime : 0
|
|
539
|
-
)
|
|
540
|
-
)}** |`;
|
|
541
|
-
body += `**${formatTime(
|
|
542
|
-
sumResultsMutation((m) =>
|
|
543
|
-
m.broadcastedTime && m.confirmedTime
|
|
544
|
-
? m.confirmedTime - m.broadcastedTime
|
|
545
|
-
: 0
|
|
546
|
-
)
|
|
547
|
-
)}** |\n`;
|
|
548
|
-
|
|
549
|
-
results.forEach((r) => {
|
|
550
|
-
body += `| ${r.spec.name} (${
|
|
551
|
-
(r.accountsBefore || []).filter((a) => a.used).length
|
|
552
|
-
}) |`;
|
|
553
|
-
body += `${formatTime(r.preloadDuration || 0)} |`;
|
|
554
|
-
body += `${formatTime(r.scanDuration || 0)} |`;
|
|
555
|
-
body += `${formatTime(
|
|
556
|
-
sumMutation(r.mutations, (m) => m.resyncAccountsDuration || 0)
|
|
557
|
-
)} |`;
|
|
558
|
-
body += `${formatTime(
|
|
559
|
-
sumMutation(r.mutations, (m) =>
|
|
547
|
+
appendBody(
|
|
548
|
+
"| Spec (accounts) | preload | scan | re-sync | tx status | sign op | broadcast | mutation confirm |\n"
|
|
549
|
+
);
|
|
550
|
+
appendBody("|---|---|---|---|---|---|---|---|\n");
|
|
551
|
+
|
|
552
|
+
appendBody("| **TOTAL** |");
|
|
553
|
+
appendBody(`**${formatTime(sumResults((r) => r.preloadDuration))}** |`);
|
|
554
|
+
appendBody(`**${formatTime(sumResults((r) => r.scanDuration))}** |`);
|
|
555
|
+
appendBody(
|
|
556
|
+
`**${formatTime(
|
|
557
|
+
sumResultsMutation((m) => m.resyncAccountsDuration || 0)
|
|
558
|
+
)}** |`
|
|
559
|
+
);
|
|
560
|
+
appendBody(
|
|
561
|
+
`**${formatTime(
|
|
562
|
+
sumResultsMutation((m) =>
|
|
560
563
|
m.mutationTime && m.statusTime ? m.statusTime - m.mutationTime : 0
|
|
561
564
|
)
|
|
562
|
-
)}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
+
)}** |`
|
|
566
|
+
);
|
|
567
|
+
appendBody(
|
|
568
|
+
`**${formatTime(
|
|
569
|
+
sumResultsMutation((m) =>
|
|
565
570
|
m.statusTime && m.signedTime ? m.signedTime - m.statusTime : 0
|
|
566
571
|
)
|
|
567
|
-
)}
|
|
568
|
-
|
|
569
|
-
|
|
572
|
+
)}** |`
|
|
573
|
+
);
|
|
574
|
+
appendBody(
|
|
575
|
+
`**${formatTime(
|
|
576
|
+
sumResultsMutation((m) =>
|
|
570
577
|
m.signedTime && m.broadcastedTime ? m.broadcastedTime - m.signedTime : 0
|
|
571
578
|
)
|
|
572
|
-
)}
|
|
573
|
-
|
|
574
|
-
|
|
579
|
+
)}** |`
|
|
580
|
+
);
|
|
581
|
+
appendBody(
|
|
582
|
+
`**${formatTime(
|
|
583
|
+
sumResultsMutation((m) =>
|
|
575
584
|
m.broadcastedTime && m.confirmedTime
|
|
576
585
|
? m.confirmedTime - m.broadcastedTime
|
|
577
586
|
: 0
|
|
578
587
|
)
|
|
579
|
-
)} |\n
|
|
588
|
+
)}** |\n`
|
|
589
|
+
);
|
|
590
|
+
|
|
591
|
+
results.forEach((r) => {
|
|
592
|
+
appendBody(
|
|
593
|
+
`| ${r.spec.name} (${
|
|
594
|
+
(r.accountsBefore || []).filter((a) => a.used).length
|
|
595
|
+
}) |`
|
|
596
|
+
);
|
|
597
|
+
appendBody(`${formatTime(r.preloadDuration || 0)} |`);
|
|
598
|
+
appendBody(`${formatTime(r.scanDuration || 0)} |`);
|
|
599
|
+
appendBody(
|
|
600
|
+
`${formatTime(
|
|
601
|
+
sumMutation(r.mutations, (m) => m.resyncAccountsDuration || 0)
|
|
602
|
+
)} |`
|
|
603
|
+
);
|
|
604
|
+
appendBody(
|
|
605
|
+
`${formatTime(
|
|
606
|
+
sumMutation(r.mutations, (m) =>
|
|
607
|
+
m.mutationTime && m.statusTime ? m.statusTime - m.mutationTime : 0
|
|
608
|
+
)
|
|
609
|
+
)} |`
|
|
610
|
+
);
|
|
611
|
+
appendBody(
|
|
612
|
+
`${formatTime(
|
|
613
|
+
sumMutation(r.mutations, (m) =>
|
|
614
|
+
m.statusTime && m.signedTime ? m.signedTime - m.statusTime : 0
|
|
615
|
+
)
|
|
616
|
+
)} |`
|
|
617
|
+
);
|
|
618
|
+
appendBody(
|
|
619
|
+
`${formatTime(
|
|
620
|
+
sumMutation(r.mutations, (m) =>
|
|
621
|
+
m.signedTime && m.broadcastedTime
|
|
622
|
+
? m.broadcastedTime - m.signedTime
|
|
623
|
+
: 0
|
|
624
|
+
)
|
|
625
|
+
)} |`
|
|
626
|
+
);
|
|
627
|
+
appendBody(
|
|
628
|
+
`${formatTime(
|
|
629
|
+
sumMutation(r.mutations, (m) =>
|
|
630
|
+
m.broadcastedTime && m.confirmedTime
|
|
631
|
+
? m.confirmedTime - m.broadcastedTime
|
|
632
|
+
: 0
|
|
633
|
+
)
|
|
634
|
+
)} |\n`
|
|
635
|
+
);
|
|
580
636
|
});
|
|
581
637
|
|
|
582
|
-
|
|
638
|
+
appendBody("\n</details>\n\n");
|
|
583
639
|
|
|
584
640
|
const { BOT_REPORT_FOLDER } = process.env;
|
|
585
641
|
|
|
@@ -589,6 +645,11 @@ export async function bot({
|
|
|
589
645
|
|
|
590
646
|
if (BOT_REPORT_FOLDER) {
|
|
591
647
|
await Promise.all([
|
|
648
|
+
fs.promises.writeFile(
|
|
649
|
+
path.join(BOT_REPORT_FOLDER, "github-report.md"),
|
|
650
|
+
githubBody,
|
|
651
|
+
"utf-8"
|
|
652
|
+
),
|
|
592
653
|
fs.promises.writeFile(
|
|
593
654
|
path.join(BOT_REPORT_FOLDER, "full-report.md"),
|
|
594
655
|
body,
|
package/src/bot/specs.ts
CHANGED
|
@@ -19,7 +19,14 @@ export function pickSiblings(siblings: Account[], maxAccount = 5): Account {
|
|
|
19
19
|
|
|
20
20
|
if (siblings.length > maxAccount) {
|
|
21
21
|
// we are no longer creating accounts
|
|
22
|
-
|
|
22
|
+
const maybeAccount = sample(withoutEmpties);
|
|
23
|
+
if (!maybeAccount) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
"at least one non-empty sibling account exists. maxAccount=" +
|
|
26
|
+
maxAccount
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return maybeAccount;
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
// we are only keeping empty account that have smaller index to favorize creation of non created derivation modes
|
|
@@ -30,8 +37,15 @@ export function pickSiblings(siblings: Account[], maxAccount = 5): Account {
|
|
|
30
37
|
empties = empties.filter((e) => e.index === empties[0].index);
|
|
31
38
|
}
|
|
32
39
|
|
|
33
|
-
|
|
40
|
+
const maybeAccount = sample(withoutEmpties.concat(empties));
|
|
41
|
+
if (!maybeAccount) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
"at least one sibling account exists. maxAccount=" + maxAccount
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return maybeAccount;
|
|
34
47
|
}
|
|
48
|
+
|
|
35
49
|
type State<T extends Transaction> = {
|
|
36
50
|
finalState: boolean;
|
|
37
51
|
stepTitle: string;
|
|
@@ -4,6 +4,7 @@ import type { GetKYCStatus } from "./types";
|
|
|
4
4
|
import { SwapCheckKYCStatusFailed } from "../../errors";
|
|
5
5
|
import { getEnv } from "../../env";
|
|
6
6
|
import { mockGetKYCStatus } from "./mock";
|
|
7
|
+
|
|
7
8
|
export const getKYCStatus: GetKYCStatus = async (
|
|
8
9
|
provider: string,
|
|
9
10
|
id: string
|
|
@@ -17,7 +18,7 @@ export const getKYCStatus: GetKYCStatus = async (
|
|
|
17
18
|
});
|
|
18
19
|
|
|
19
20
|
if (!res.data?.status) {
|
|
20
|
-
|
|
21
|
+
throw new SwapCheckKYCStatusFailed(id);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
const { status } = res.data;
|
|
@@ -26,4 +27,5 @@ export const getKYCStatus: GetKYCStatus = async (
|
|
|
26
27
|
status,
|
|
27
28
|
};
|
|
28
29
|
};
|
|
30
|
+
|
|
29
31
|
export default getKYCStatus;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Btc from "@ledgerhq/hw-app-btc";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SignMessage } from "../../hw/signMessage/types";
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const signMessage: SignMessage = async (transport, { path, message }) => {
|
|
5
5
|
const btc = new Btc(transport);
|
|
6
6
|
const hexMessage = Buffer.from(message).toString("hex");
|
|
7
7
|
const result = await btc.signMessageNew(path, hexMessage);
|
|
@@ -16,4 +16,4 @@ const resolver: Resolver = async (transport, { path, message }) => {
|
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export default
|
|
19
|
+
export default { signMessage };
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { getAccountBannerState } from "./banner";
|
|
2
2
|
import * as preloadedData from "./preloadedData";
|
|
3
|
-
import * as
|
|
3
|
+
import * as logic from "./logic";
|
|
4
4
|
import type { CosmosAccount, CosmosValidatorItem } from "./types";
|
|
5
5
|
import data from "./preloadedData.mock";
|
|
6
6
|
import { LEDGER_VALIDATOR_ADDRESS } from "./utils";
|
|
7
7
|
import { BigNumber } from "bignumber.js";
|
|
8
8
|
|
|
9
|
+
jest.mock("./js-prepareTransaction", () => ({
|
|
10
|
+
calculateFees: jest.fn(() => Promise.resolve({})),
|
|
11
|
+
}));
|
|
12
|
+
|
|
9
13
|
const ledgerValidator: CosmosValidatorItem | undefined = data.validators.find(
|
|
10
14
|
(x) => x.validatorAddress === LEDGER_VALIDATOR_ADDRESS
|
|
11
15
|
);
|
|
@@ -103,12 +107,9 @@ describe("cosmos/banner", () => {
|
|
|
103
107
|
.mockReturnValue({ validators } as {
|
|
104
108
|
validators: CosmosValidatorItem[];
|
|
105
109
|
});
|
|
106
|
-
|
|
107
|
-
jest.spyOn(
|
|
108
|
-
|
|
109
|
-
} as any);
|
|
110
|
-
const result = await getAccountBannerState(account);
|
|
111
|
-
expect(1 + 1).toBe(2);
|
|
110
|
+
jest.spyOn(logic, "canDelegate").mockReturnValue(false);
|
|
111
|
+
jest.spyOn(logic, "canRedelegate").mockReturnValue(false);
|
|
112
|
+
const result = getAccountBannerState(account);
|
|
112
113
|
expect(result).toStrictEqual({
|
|
113
114
|
display: false,
|
|
114
115
|
redelegate: false,
|
|
@@ -122,10 +123,9 @@ describe("cosmos/banner", () => {
|
|
|
122
123
|
.mockReturnValue({ validators } as {
|
|
123
124
|
validators: CosmosValidatorItem[];
|
|
124
125
|
});
|
|
125
|
-
jest.spyOn(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const result = await getAccountBannerState(account);
|
|
126
|
+
jest.spyOn(logic, "canDelegate").mockReturnValue(true);
|
|
127
|
+
jest.spyOn(logic, "canRedelegate").mockReturnValue(false);
|
|
128
|
+
const result = getAccountBannerState(account);
|
|
129
129
|
expect(result).toStrictEqual({
|
|
130
130
|
display: true,
|
|
131
131
|
redelegate: false,
|
|
@@ -139,16 +139,19 @@ describe("cosmos/banner", () => {
|
|
|
139
139
|
.mockReturnValue({ validators } as {
|
|
140
140
|
validators: CosmosValidatorItem[];
|
|
141
141
|
});
|
|
142
|
-
jest.spyOn(
|
|
143
|
-
|
|
144
|
-
} as any);
|
|
142
|
+
jest.spyOn(logic, "canDelegate").mockReturnValue(false);
|
|
143
|
+
jest.spyOn(logic, "canRedelegate").mockReturnValue(true);
|
|
145
144
|
account.cosmosResources.redelegations.push({
|
|
146
145
|
validatorSrcAddress: "xxxx",
|
|
147
146
|
validatorDstAddress: expensiveValidator?.validatorAddress as string,
|
|
148
147
|
amount: new BigNumber(1000),
|
|
149
148
|
completionDate: new Date(),
|
|
150
149
|
});
|
|
151
|
-
const
|
|
150
|
+
const accountWithSpendable5000 = {
|
|
151
|
+
...account,
|
|
152
|
+
spendableBalance: new BigNumber(5000),
|
|
153
|
+
};
|
|
154
|
+
const result = getAccountBannerState(accountWithSpendable5000);
|
|
152
155
|
expect(result).toStrictEqual({
|
|
153
156
|
display: true,
|
|
154
157
|
redelegate: true,
|
|
@@ -156,5 +159,27 @@ describe("cosmos/banner", () => {
|
|
|
156
159
|
ledgerValidator,
|
|
157
160
|
});
|
|
158
161
|
});
|
|
162
|
+
it("should return not display redelegate mode", async () => {
|
|
163
|
+
jest
|
|
164
|
+
.spyOn(preloadedData, "getCurrentCosmosPreloadData")
|
|
165
|
+
.mockReturnValue({ validators } as {
|
|
166
|
+
validators: CosmosValidatorItem[];
|
|
167
|
+
});
|
|
168
|
+
jest.spyOn(logic, "canDelegate").mockReturnValue(false);
|
|
169
|
+
jest.spyOn(logic, "canRedelegate").mockReturnValue(false);
|
|
170
|
+
account.cosmosResources.redelegations.push({
|
|
171
|
+
validatorSrcAddress: "xxxx",
|
|
172
|
+
validatorDstAddress: expensiveValidator?.validatorAddress as string,
|
|
173
|
+
amount: new BigNumber(1000),
|
|
174
|
+
completionDate: new Date(),
|
|
175
|
+
});
|
|
176
|
+
const result = getAccountBannerState(account);
|
|
177
|
+
expect(result).toStrictEqual({
|
|
178
|
+
display: false,
|
|
179
|
+
redelegate: false,
|
|
180
|
+
validatorSrcAddress: "",
|
|
181
|
+
ledgerValidator,
|
|
182
|
+
});
|
|
183
|
+
});
|
|
159
184
|
});
|
|
160
185
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getCurrentCosmosPreloadData } from "./preloadedData";
|
|
2
|
-
import { getAccountBridge } from "../../bridge";
|
|
3
2
|
import { LEDGER_VALIDATOR_ADDRESS } from "./utils";
|
|
3
|
+
import { canDelegate, canRedelegate } from "./logic";
|
|
4
4
|
import type { CosmosAccount, CosmosValidatorItem } from "./types";
|
|
5
5
|
|
|
6
6
|
interface AccountBannerState {
|
|
@@ -10,9 +10,9 @@ interface AccountBannerState {
|
|
|
10
10
|
ledgerValidator: CosmosValidatorItem | undefined;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export
|
|
13
|
+
export function getAccountBannerState(
|
|
14
14
|
account: CosmosAccount
|
|
15
|
-
):
|
|
15
|
+
): AccountBannerState {
|
|
16
16
|
// Group current validator
|
|
17
17
|
const cosmosResources = account.cosmosResources
|
|
18
18
|
? account.cosmosResources
|
|
@@ -43,7 +43,8 @@ export async function getAccountBannerState(
|
|
|
43
43
|
if (
|
|
44
44
|
worstValidator &&
|
|
45
45
|
validator &&
|
|
46
|
-
worstValidator.commission < validator.commission
|
|
46
|
+
worstValidator.commission < validator.commission &&
|
|
47
|
+
canRedelegate(account, validator)
|
|
47
48
|
) {
|
|
48
49
|
worstValidator = validator;
|
|
49
50
|
}
|
|
@@ -58,15 +59,7 @@ export async function getAccountBannerState(
|
|
|
58
59
|
worstValidator?.validatorAddress === ledgerValidator?.validatorAddress
|
|
59
60
|
) {
|
|
60
61
|
// Not found worst validator than ledger
|
|
61
|
-
|
|
62
|
-
account,
|
|
63
|
-
undefined
|
|
64
|
-
).estimateMaxSpendable({
|
|
65
|
-
account,
|
|
66
|
-
parentAccount: undefined,
|
|
67
|
-
transaction: undefined,
|
|
68
|
-
});
|
|
69
|
-
if (maxSpendable.gt(0)) {
|
|
62
|
+
if (canDelegate(account)) {
|
|
70
63
|
// Delegate remaining ATOM (not staked)
|
|
71
64
|
display = true;
|
|
72
65
|
}
|
|
@@ -184,7 +184,7 @@ export function canDelegate(account: CosmosAccount): boolean {
|
|
|
184
184
|
|
|
185
185
|
export function canRedelegate(
|
|
186
186
|
account: CosmosAccount,
|
|
187
|
-
delegation: CosmosDelegation
|
|
187
|
+
delegation: CosmosDelegation | CosmosValidatorItem
|
|
188
188
|
): boolean {
|
|
189
189
|
const { cosmosResources } = account;
|
|
190
190
|
invariant(cosmosResources, "cosmosResources should exist");
|