@ledgerhq/live-common 25.0.0 → 25.1.0-next.2

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.
Files changed (53) hide show
  1. package/lib/__tests__/test-helpers/bridge.d.ts.map +1 -1
  2. package/lib/__tests__/test-helpers/bridge.js +16 -0
  3. package/lib/__tests__/test-helpers/bridge.js.map +1 -1
  4. package/lib/apps/react.js +1 -1
  5. package/lib/apps/react.test.js +1 -1
  6. package/lib/apps/support.js +1 -1
  7. package/lib/bot/index.d.ts.map +1 -1
  8. package/lib/bot/index.js +24 -4
  9. package/lib/bot/index.js.map +1 -1
  10. package/lib/env.d.ts +10 -5
  11. package/lib/env.d.ts.map +1 -1
  12. package/lib/env.js +5 -0
  13. package/lib/env.js.map +1 -1
  14. package/lib/env.react.d.ts +1 -1
  15. package/lib/env.react.d.ts.map +1 -1
  16. package/lib/families/ethereum/hw-signMessage.d.ts +5 -4
  17. package/lib/families/ethereum/hw-signMessage.d.ts.map +1 -1
  18. package/lib/families/ethereum/hw-signMessage.js +26 -17
  19. package/lib/families/ethereum/hw-signMessage.js.map +1 -1
  20. package/lib/families/ethereum/hw-signMessage.test.d.ts +2 -0
  21. package/lib/families/ethereum/hw-signMessage.test.d.ts.map +1 -0
  22. package/lib/families/ethereum/hw-signMessage.test.js +185 -0
  23. package/lib/families/ethereum/hw-signMessage.test.js.map +1 -0
  24. package/lib/families/ethereum/types.d.ts +2 -24
  25. package/lib/families/ethereum/types.d.ts.map +1 -1
  26. package/lib/families/stellar/js-getTransactionStatus.js +3 -3
  27. package/lib/families/stellar/js-getTransactionStatus.js.map +1 -1
  28. package/lib/families/tezos/synchronisation.d.ts +2 -0
  29. package/lib/families/tezos/synchronisation.d.ts.map +1 -1
  30. package/lib/families/tezos/synchronisation.integration.test.d.ts +2 -0
  31. package/lib/families/tezos/synchronisation.integration.test.d.ts.map +1 -0
  32. package/lib/families/tezos/synchronisation.integration.test.js +79 -0
  33. package/lib/families/tezos/synchronisation.integration.test.js.map +1 -0
  34. package/lib/families/tezos/synchronisation.js +5 -3
  35. package/lib/families/tezos/synchronisation.js.map +1 -1
  36. package/lib/featureFlags/types.d.ts +7 -0
  37. package/lib/featureFlags/types.d.ts.map +1 -1
  38. package/lib/generated/hw-signMessage.d.ts +1 -1
  39. package/package.json +3 -3
  40. package/src/__tests__/test-helpers/bridge.ts +12 -1
  41. package/src/apps/react.test.ts +1 -1
  42. package/src/apps/react.ts +1 -1
  43. package/src/apps/support.ts +1 -1
  44. package/src/bot/index.ts +34 -5
  45. package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +38 -4
  46. package/src/env.ts +5 -0
  47. package/src/families/ethereum/hw-signMessage.test.ts +110 -0
  48. package/src/families/ethereum/hw-signMessage.ts +28 -20
  49. package/src/families/ethereum/types.ts +2 -24
  50. package/src/families/stellar/js-getTransactionStatus.ts +3 -3
  51. package/src/families/tezos/synchronisation.integration.test.ts +22 -0
  52. package/src/families/tezos/synchronisation.ts +3 -3
  53. package/src/featureFlags/types.ts +7 -0
@@ -3,7 +3,11 @@ import { BigNumber } from "bignumber.js";
3
3
  import { reduce, filter, map } from "rxjs/operators";
4
4
  import flatMap from "lodash/flatMap";
5
5
  import omit from "lodash/omit";
6
- import { InvalidAddress, RecipientRequired } from "@ledgerhq/errors";
6
+ import {
7
+ InvalidAddress,
8
+ RecipientRequired,
9
+ AmountRequired,
10
+ } from "@ledgerhq/errors";
7
11
  import type {
8
12
  Account,
9
13
  Transaction,
@@ -618,6 +622,13 @@ export function testBridge<T extends Transaction>(data: DatasetTest<T>): void {
618
622
  const status = await bridge.getTransactionStatus(account, t);
619
623
  expect(status.errors.recipient).toBeInstanceOf(InvalidAddress);
620
624
  });
625
+ makeTest("Default empty amount has an amount error", async () => {
626
+ const account = await getSynced();
627
+ const t = { ...bridge.createTransaction(account) };
628
+ const status = await bridge.getTransactionStatus(account, t);
629
+ expect(status.errors.amount).toBeInstanceOf(AmountRequired);
630
+ });
631
+
621
632
  const accountDataTest = accountData.test;
622
633
 
623
634
  if (accountDataTest) {
@@ -57,7 +57,7 @@ test("Apps hooks - useAppInstallProgress - Queued or unknown app", () => {
57
57
  const { result } = renderHook(() =>
58
58
  useAppInstallProgress(mockedState, "not_in_queue")
59
59
  );
60
- expect(result.current).toBe(1);
60
+ expect(result.current).toBe(0);
61
61
  });
62
62
  test("Apps hooks - useAppInstallProgress - Current app", () => {
63
63
  const currentProgressSubject: Subject<number> = new Subject();
package/src/apps/react.ts CHANGED
@@ -151,7 +151,7 @@ export function useAppInstallProgress(state: State, name: string): number {
151
151
  return progress;
152
152
  }
153
153
 
154
- return 1;
154
+ return 0;
155
155
  }
156
156
 
157
157
  // if the app needs deps to be installed, we want to display a modal
@@ -31,7 +31,7 @@ export function shouldUpgrade(
31
31
  const appVersionsRequired = {
32
32
  Cosmos: ">= 2.34.4",
33
33
  Algorand: ">= 1.2.9",
34
- Polkadot: ">= 12.9180.0",
34
+ Polkadot: ">= 13.9250.0",
35
35
  Elrond: ">= 1.0.11",
36
36
  Ethereum: ">= 1.9.17",
37
37
  Solana: ">= 1.2.0",
package/src/bot/index.ts CHANGED
@@ -194,14 +194,33 @@ export async function bot({ currency, family, mutation }: Arg = {}) {
194
194
  );
195
195
  }
196
196
 
197
- const withoutFunds = results
197
+ const specsWithoutFunds = results.filter(
198
+ (s) =>
199
+ !s.fatalError &&
200
+ ((s.accountsBefore && s.accountsBefore.every(isAccountEmpty)) ||
201
+ (s.mutations && s.mutations.every((r) => !r.mutation)))
202
+ );
203
+
204
+ const specsWithoutOperations = results.filter(
205
+ (s) =>
206
+ !s.fatalError &&
207
+ !specsWithoutFunds.includes(s) &&
208
+ s.mutations &&
209
+ s.mutations.every((r) => !r.operation)
210
+ );
211
+
212
+ const withoutFunds = specsWithoutFunds
198
213
  .filter(
199
214
  (s) =>
200
- !s.fatalError &&
201
- ((s.accountsBefore && s.accountsBefore.every(isAccountEmpty)) ||
202
- (s.mutations && s.mutations.every((r) => !r.mutation)))
215
+ // ignore coin that are backed by testnet that have funds
216
+ !results.some(
217
+ (o) =>
218
+ o.spec.currency.isTestnetFor === s.spec.currency.id &&
219
+ !specsWithoutFunds.includes(o)
220
+ )
203
221
  )
204
222
  .map((s) => s.spec.name);
223
+
205
224
  const { GITHUB_RUN_ID, GITHUB_WORKFLOW } = process.env;
206
225
 
207
226
  let body = "";
@@ -326,11 +345,21 @@ export async function bot({ currency, family, mutation }: Arg = {}) {
326
345
  if (withoutFunds.length) {
327
346
  const missingFundsWarn = `> ⚠️ ${
328
347
  withoutFunds.length
329
- } specs don't have enough funds! (${withoutFunds.join(", ")})\n`;
348
+ } specs may miss funds: **${withoutFunds.join(", ")}**\n`;
330
349
  body += missingFundsWarn;
331
350
  slackBody += missingFundsWarn;
332
351
  }
333
352
 
353
+ if (specsWithoutOperations.length) {
354
+ const warn = `> ⚠️ ${
355
+ specsWithoutOperations.length
356
+ } specs may have issues: **${specsWithoutOperations
357
+ .map((o) => o.spec.name)
358
+ .join(", ")}**\n`;
359
+ body += warn;
360
+ slackBody += warn;
361
+ }
362
+
334
363
  body += "<details>\n";
335
364
  body += `<summary>Details of the ${results.length} currencies</summary>\n\n`;
336
365
  body += "| Spec (accounts) | Operations | Balance | funds? |\n";
@@ -155,7 +155,7 @@ Array [
155
155
  "ethereum/erc20/ela_coin",
156
156
  "ethereum/erc20/playfuel",
157
157
  "ethereum/erc20/thorecoin",
158
- "ethereum/erc20/husd_stablecoin ",
158
+ "ethereum/erc20/husd_stablecoin",
159
159
  "ethereum/erc20/insight_chain",
160
160
  "ethereum/erc20/flexacoin",
161
161
  "ethereum/erc20/cofinex",
@@ -516,6 +516,7 @@ Array [
516
516
  "ethereum/erc20/asian_fintech",
517
517
  "ethereum/erc20/abyss",
518
518
  "ethereum/erc20/linkeye_token",
519
+ "ethereum/erc20/atomic_wallet_token",
519
520
  "ethereum/erc20/likecoin",
520
521
  "ethereum/erc20/noia_token",
521
522
  "ethereum/erc20/czr",
@@ -791,6 +792,7 @@ Array [
791
792
  "ethereum/erc20/eristica",
792
793
  "ethereum/erc20/hoqu_token",
793
794
  "ethereum/erc20/kubo_coin",
795
+ "ethereum/erc20/sparkpoint",
794
796
  "ethereum/erc20/eszcoin",
795
797
  "ethereum/erc20/ipsx",
796
798
  "ethereum/erc20/pla_token",
@@ -1550,6 +1552,7 @@ Array [
1550
1552
  "ethereum/erc20/ammbr",
1551
1553
  "ethereum/erc20/amp",
1552
1554
  "ethereum/erc20/ampleforth_governance",
1555
+ "ethereum/erc20/amplify_token",
1553
1556
  "ethereum/erc20/ampnet_apx_token",
1554
1557
  "ethereum/erc20/amun_defi_index",
1555
1558
  "ethereum/erc20/amun_defi_momentum_index",
@@ -1576,11 +1579,13 @@ Array [
1576
1579
  "ethereum/erc20/apecoin_dev",
1577
1580
  "ethereum/erc20/apehaven",
1578
1581
  "ethereum/erc20/apenft",
1582
+ "ethereum/erc20/apenftio",
1579
1583
  "ethereum/erc20/api3",
1580
1584
  "ethereum/erc20/apiary_fund_coin",
1581
1585
  "ethereum/erc20/apis",
1582
1586
  "ethereum/erc20/apollo",
1583
1587
  "ethereum/erc20/apollo18",
1588
+ "ethereum/erc20/apollo_inu",
1584
1589
  "ethereum/erc20/apot",
1585
1590
  "ethereum/erc20/app_alliance_association",
1586
1591
  "ethereum/erc20/apple_protocol_token",
@@ -2226,6 +2231,7 @@ Array [
2226
2231
  "ethereum/erc20/covalent_query_token",
2227
2232
  "ethereum/erc20/cover_protocol_governance_token",
2228
2233
  "ethereum/erc20/covir",
2234
+ "ethereum/erc20/cow_protocol_token",
2229
2235
  "ethereum/erc20/cowboy_finance",
2230
2236
  "ethereum/erc20/coweye",
2231
2237
  "ethereum/erc20/cp3rtoken",
@@ -2327,6 +2333,7 @@ Array [
2327
2333
  "ethereum/erc20/curve_fi_eursseur",
2328
2334
  "ethereum/erc20/curve_fi_renbtcwbtc",
2329
2335
  "ethereum/erc20/curve_fi_renbtcwbtcsbtc",
2336
+ "ethereum/erc20/curve_fi_usd-btc-eth",
2330
2337
  "ethereum/erc20/curve_fi_usdk_3crv",
2331
2338
  "ethereum/erc20/cute_coin",
2332
2339
  "ethereum/erc20/cvault_finance",
@@ -2422,6 +2429,7 @@ Array [
2422
2429
  "ethereum/erc20/degenvc",
2423
2430
  "ethereum/erc20/dego_finance",
2424
2431
  "ethereum/erc20/degov",
2432
+ "ethereum/erc20/degrain",
2425
2433
  "ethereum/erc20/dehive_finance",
2426
2434
  "ethereum/erc20/deipool",
2427
2435
  "ethereum/erc20/delphi_tech_token",
@@ -2576,6 +2584,7 @@ Array [
2576
2584
  "ethereum/erc20/dreamcatcher",
2577
2585
  "ethereum/erc20/dripcoin",
2578
2586
  "ethereum/erc20/dripper_finance",
2587
+ "ethereum/erc20/dripto",
2579
2588
  "ethereum/erc20/driveholic_token",
2580
2589
  "ethereum/erc20/dronefly",
2581
2590
  "ethereum/erc20/droplex",
@@ -2612,6 +2621,7 @@ Array [
2612
2621
  "ethereum/erc20/easticoin",
2613
2622
  "ethereum/erc20/easy",
2614
2623
  "ethereum/erc20/easy_v2",
2624
+ "ethereum/erc20/easy_v2_",
2615
2625
  "ethereum/erc20/easyhomes",
2616
2626
  "ethereum/erc20/easyswap",
2617
2627
  "ethereum/erc20/eauric",
@@ -2916,6 +2926,7 @@ Array [
2916
2926
  "ethereum/erc20/freq_set_dollar",
2917
2927
  "ethereum/erc20/friends_with_benefits",
2918
2928
  "ethereum/erc20/friends_with_benefits_pro",
2929
+ "ethereum/erc20/fringe",
2919
2930
  "ethereum/erc20/frmx_token",
2920
2931
  "ethereum/erc20/frogdao_dime",
2921
2932
  "ethereum/erc20/froge_finance_old",
@@ -2951,6 +2962,7 @@ Array [
2951
2962
  "ethereum/erc20/gambler_shiba",
2952
2963
  "ethereum/erc20/game_coin",
2953
2964
  "ethereum/erc20/game_of_bitcoins",
2965
+ "ethereum/erc20/game_on_players",
2954
2966
  "ethereum/erc20/game_x_coin",
2955
2967
  "ethereum/erc20/gamecity",
2956
2968
  "ethereum/erc20/gamee",
@@ -3239,6 +3251,7 @@ Array [
3239
3251
  "ethereum/erc20/idledai",
3240
3252
  "ethereum/erc20/idleusdc",
3241
3253
  "ethereum/erc20/idltoken",
3254
+ "ethereum/erc20/idna",
3242
3255
  "ethereum/erc20/idol",
3243
3256
  "ethereum/erc20/iearn_busd",
3244
3257
  "ethereum/erc20/iearn_tusd",
@@ -3940,7 +3953,6 @@ Array [
3940
3953
  "ethereum/erc20/orao_network",
3941
3954
  "ethereum/erc20/orbicularv2",
3942
3955
  "ethereum/erc20/orbit_chain",
3943
- "ethereum/erc20/orca_token",
3944
3956
  "ethereum/erc20/orica",
3945
3957
  "ethereum/erc20/orient",
3946
3958
  "ethereum/erc20/orientum_plus",
@@ -4180,6 +4192,7 @@ Array [
4180
4192
  "ethereum/erc20/public_mint",
4181
4193
  "ethereum/erc20/puglife",
4182
4194
  "ethereum/erc20/pulltherug_finance",
4195
+ "ethereum/erc20/pulsedogecoin",
4183
4196
  "ethereum/erc20/pundi_x_token",
4184
4197
  "ethereum/erc20/pundi_x_token_old",
4185
4198
  "ethereum/erc20/punk",
@@ -4313,6 +4326,7 @@ Array [
4313
4326
  "ethereum/erc20/ri_token",
4314
4327
  "ethereum/erc20/rice",
4315
4328
  "ethereum/erc20/ridertoken",
4329
+ "ethereum/erc20/ridotto",
4316
4330
  "ethereum/erc20/rigel_finance",
4317
4331
  "ethereum/erc20/rigeltoken",
4318
4332
  "ethereum/erc20/rigo_token",
@@ -4740,8 +4754,8 @@ Array [
4740
4754
  "ethereum/erc20/swtcoin",
4741
4755
  "ethereum/erc20/sybc_coin",
4742
4756
  "ethereum/erc20/sylo",
4743
- "ethereum/erc20/synapse",
4744
4757
  "ethereum/erc20/synapse_network",
4758
+ "ethereum/erc20/synapse_protocol",
4745
4759
  "ethereum/erc20/sync",
4746
4760
  "ethereum/erc20/synchrocoin",
4747
4761
  "ethereum/erc20/synlev",
@@ -4954,6 +4968,7 @@ Array [
4954
4968
  "ethereum/erc20/tower",
4955
4969
  "ethereum/erc20/tozex",
4956
4970
  "ethereum/erc20/tr3zor",
4971
+ "ethereum/erc20/trace_network",
4957
4972
  "ethereum/erc20/traceability_chain_coin",
4958
4973
  "ethereum/erc20/tradcoin",
4959
4974
  "ethereum/erc20/trade_butler_bot",
@@ -5284,6 +5299,7 @@ Array [
5284
5299
  "ethereum/erc20/wrapped_etho",
5285
5300
  "ethereum/erc20/wrapped_fct",
5286
5301
  "ethereum/erc20/wrapped_filecoin",
5302
+ "ethereum/erc20/wrapped_flow",
5287
5303
  "ethereum/erc20/wrapped_gen_0",
5288
5304
  "ethereum/erc20/wrapped_hns",
5289
5305
  "ethereum/erc20/wrapped_ilcoin",
@@ -5591,6 +5607,7 @@ Array [
5591
5607
  "polygon/erc20/amp",
5592
5608
  "polygon/erc20/ampleforth_governance",
5593
5609
  "polygon/erc20/ankr_eth2_reward_bearing_certificate",
5610
+ "polygon/erc20/apwine_token_(pos)",
5594
5611
  "polygon/erc20/armor",
5595
5612
  "polygon/erc20/augury_finance",
5596
5613
  "polygon/erc20/aurusgold",
@@ -5631,6 +5648,9 @@ Array [
5631
5648
  "polygon/erc20/crv_(pos)",
5632
5649
  "polygon/erc20/cryption_network_token",
5633
5650
  "polygon/erc20/crypto_development_services",
5651
+ "polygon/erc20/curve.fi_amdaiamusdcamusdt",
5652
+ "polygon/erc20/curve.fi_factory_plain_pool_2jpy",
5653
+ "polygon/erc20/curve.fi_factory_plain_pool_4eur",
5634
5654
  "polygon/erc20/dappradar",
5635
5655
  "polygon/erc20/data_economy_index_(pos)",
5636
5656
  "polygon/erc20/decentr",
@@ -5665,6 +5685,7 @@ Array [
5665
5685
  "polygon/erc20/fish",
5666
5686
  "polygon/erc20/flare_token",
5667
5687
  "polygon/erc20/foam_token",
5688
+ "polygon/erc20/foodchain_global",
5668
5689
  "polygon/erc20/fox",
5669
5690
  "polygon/erc20/fractal_protocol_token",
5670
5691
  "polygon/erc20/frax",
@@ -5708,6 +5729,7 @@ Array [
5708
5729
  "polygon/erc20/jarvis_reward_token",
5709
5730
  "polygon/erc20/jarvis_synthetic_canadian_dollar",
5710
5731
  "polygon/erc20/jarvis_synthetic_euro",
5732
+ "polygon/erc20/jarvis_synthetic_swiss_franc",
5711
5733
  "polygon/erc20/kart_racing_league",
5712
5734
  "polygon/erc20/kastatoken",
5713
5735
  "polygon/erc20/keep_token",
@@ -5731,7 +5753,9 @@ Array [
5731
5753
  "polygon/erc20/meta",
5732
5754
  "polygon/erc20/metaverse_index_(pos)",
5733
5755
  "polygon/erc20/mimatic",
5734
- "polygon/erc20/moonwolf.io",
5756
+ "polygon/erc20/moo_curve_atricrypto3",
5757
+ "polygon/erc20/moo_mai_usdc-mimatic",
5758
+ "polygon/erc20/moonwolf_io",
5735
5759
  "polygon/erc20/mover",
5736
5760
  "polygon/erc20/mysterium_(pos)",
5737
5761
  "polygon/erc20/nakamoto.games",
@@ -5795,6 +5819,7 @@ Array [
5795
5819
  "polygon/erc20/sekuritance_(pos)",
5796
5820
  "polygon/erc20/sentinel",
5797
5821
  "polygon/erc20/serum",
5822
+ "polygon/erc20/shiba_inu_(pos)",
5798
5823
  "polygon/erc20/shopping.io",
5799
5824
  "polygon/erc20/singularitynet_token",
5800
5825
  "polygon/erc20/spacerat",
@@ -5837,6 +5862,7 @@ Array [
5837
5862
  "polygon/erc20/voyager",
5838
5863
  "polygon/erc20/waultswap_polygon",
5839
5864
  "polygon/erc20/wepower",
5865
+ "polygon/erc20/wlitidao",
5840
5866
  "polygon/erc20/woofy",
5841
5867
  "polygon/erc20/wootrade_network",
5842
5868
  "polygon/erc20/wrapped_celo",
@@ -6074,6 +6100,7 @@ Array [
6074
6100
  "bsc/bep20/faracrystal",
6075
6101
  "bsc/bep20/fegtoken",
6076
6102
  "bsc/bep20/ferrum_network_token",
6103
+ "bsc/bep20/fibo_token",
6077
6104
  "bsc/bep20/finnexus",
6078
6105
  "bsc/bep20/firo",
6079
6106
  "bsc/bep20/flash_token",
@@ -6106,6 +6133,7 @@ Array [
6106
6133
  "bsc/bep20/gourmetgalaxy",
6107
6134
  "bsc/bep20/green_metaverse_token",
6108
6135
  "bsc/bep20/gummy_bull_token",
6136
+ "bsc/bep20/hachiro_inu",
6109
6137
  "bsc/bep20/hacken_token",
6110
6138
  "bsc/bep20/hakka_finance_on_xdai_on_bsc",
6111
6139
  "bsc/bep20/happinesstoken",
@@ -6123,6 +6151,7 @@ Array [
6123
6151
  "bsc/bep20/hunny_token",
6124
6152
  "bsc/bep20/hyfi",
6125
6153
  "bsc/bep20/iassets",
6154
+ "bsc/bep20/immutable",
6126
6155
  "bsc/bep20/impossible_finance",
6127
6156
  "bsc/bep20/injective_protocol",
6128
6157
  "bsc/bep20/innovativebioresearchcoin",
@@ -6142,6 +6171,7 @@ Array [
6142
6171
  "bsc/bep20/kindcow_finance",
6143
6172
  "bsc/bep20/kiwi_token",
6144
6173
  "bsc/bep20/kmoncoin",
6174
+ "bsc/bep20/kunci_coin",
6145
6175
  "bsc/bep20/lamden",
6146
6176
  "bsc/bep20/lien_on_xdai_from_xdai",
6147
6177
  "bsc/bep20/linear_token",
@@ -6196,6 +6226,7 @@ Array [
6196
6226
  "bsc/bep20/nftb",
6197
6227
  "bsc/bep20/nftbooks",
6198
6228
  "bsc/bep20/nobility",
6229
+ "bsc/bep20/noe_crypto_bank",
6199
6230
  "bsc/bep20/nominex",
6200
6231
  "bsc/bep20/num_token_[via_chainport.io]",
6201
6232
  "bsc/bep20/nyanswop_token",
@@ -6264,7 +6295,9 @@ Array [
6264
6295
  "bsc/bep20/revv",
6265
6296
  "bsc/bep20/rfox",
6266
6297
  "bsc/bep20/rigeltoken",
6298
+ "bsc/bep20/right_side",
6267
6299
  "bsc/bep20/roobee",
6300
+ "bsc/bep20/rubic",
6268
6301
  "bsc/bep20/rusd",
6269
6302
  "bsc/bep20/safemoon",
6270
6303
  "bsc/bep20/safemoon_",
@@ -6401,6 +6434,7 @@ Array [
6401
6434
  "bsc/bep20/yield_guild_games_token",
6402
6435
  "bsc/bep20/yieldwatch",
6403
6436
  "bsc/bep20/yourkiss",
6437
+ "bsc/bep20/yummy",
6404
6438
  "bsc/bep20/zeroswaptoken",
6405
6439
  "bsc/bep20/zilliqa",
6406
6440
  "bsc/bep20/zmine_token",
package/src/env.ts CHANGED
@@ -554,6 +554,11 @@ const envDefinitions = {
554
554
  parser: intParser,
555
555
  desc: "version used for ledger status api",
556
556
  },
557
+ TEZOS_MAX_TX_QUERIES: {
558
+ def: 100,
559
+ parser: intParser,
560
+ desc: "safe max on maximum number of queries to synchronize a tezos account",
561
+ },
557
562
  PLATFORM_DEBUG: {
558
563
  def: false,
559
564
  parser: boolParser,
@@ -0,0 +1,110 @@
1
+ import "../../__tests__/test-helpers/setup";
2
+
3
+ import EIP712Message from "@ledgerhq/hw-app-eth/tests/sample-messages/0.json";
4
+ import hwSignMessage from "./hw-signMessage";
5
+ import { setEnv } from "../../env";
6
+
7
+ const signPersonalMessage = jest.fn(() =>
8
+ Promise.resolve({
9
+ r: "r",
10
+ s: "s",
11
+ v: 28,
12
+ })
13
+ );
14
+ const signEIP712HashedMessage = jest.fn(() =>
15
+ Promise.resolve({
16
+ r: "r",
17
+ s: "s",
18
+ v: 28,
19
+ })
20
+ );
21
+ const signEIP712Message = jest.fn(() =>
22
+ Promise.resolve({
23
+ r: "r",
24
+ s: "s",
25
+ v: 28,
26
+ })
27
+ );
28
+ jest.mock("@ledgerhq/hw-app-eth", () => {
29
+ return class {
30
+ signPersonalMessage = signPersonalMessage;
31
+ signEIP712HashedMessage = signEIP712HashedMessage;
32
+ signEIP712Message = signEIP712Message;
33
+ };
34
+ });
35
+
36
+ describe("Eth hw-signMessage", () => {
37
+ beforeEach(() => {
38
+ jest.clearAllMocks();
39
+ });
40
+
41
+ describe("parsing", () => {
42
+ it("should be using the signPersonalMessage method with string message", async () => {
43
+ await hwSignMessage({} as any, {
44
+ path: "",
45
+ message: "test",
46
+ rawMessage: "0xtest",
47
+ });
48
+
49
+ expect(signPersonalMessage).toHaveBeenCalledTimes(1);
50
+ });
51
+
52
+ it("should be using the signEIP712HashedMessage method with stringified message", async () => {
53
+ await hwSignMessage({} as any, {
54
+ path: "",
55
+ message: JSON.stringify(EIP712Message),
56
+ rawMessage: "0xtest",
57
+ });
58
+
59
+ expect(signEIP712HashedMessage).toHaveBeenCalledTimes(1);
60
+ });
61
+
62
+ it("should be using the signEIP712Message method with stringified message", async () => {
63
+ setEnv("EXPERIMENTAL_EIP712", true);
64
+
65
+ await hwSignMessage({} as any, {
66
+ path: "",
67
+ message: EIP712Message,
68
+ rawMessage: "0xtest",
69
+ });
70
+
71
+ expect(signEIP712Message).toHaveBeenCalledTimes(1);
72
+ setEnv("EXPERIMENTAL_EIP712", false);
73
+ });
74
+ });
75
+
76
+ describe("value of v", () => {
77
+ it("should returning parity for signPersonalMessage", async () => {
78
+ const { rsv } = await hwSignMessage({} as any, {
79
+ path: "",
80
+ message: "test",
81
+ rawMessage: "0xtest",
82
+ });
83
+
84
+ expect(rsv.v).toBe(1);
85
+ });
86
+
87
+ it("should not be returning parity for signEIP712HashedMessage", async () => {
88
+ const { rsv } = await hwSignMessage({} as any, {
89
+ path: "",
90
+ message: JSON.stringify(EIP712Message),
91
+ rawMessage: "0xtest",
92
+ });
93
+
94
+ expect(rsv.v).toBe(28);
95
+ });
96
+
97
+ it("should not be returning parity for signEIP712Message", async () => {
98
+ setEnv("EXPERIMENTAL_EIP712", true);
99
+
100
+ const { rsv } = await hwSignMessage({} as any, {
101
+ path: "",
102
+ message: EIP712Message,
103
+ rawMessage: "0xtest",
104
+ });
105
+
106
+ expect(rsv.v).toBe(28);
107
+ setEnv("EXPERIMENTAL_EIP712", false);
108
+ });
109
+ });
110
+ });
@@ -1,15 +1,18 @@
1
+ import { EIP712Message } from "@ledgerhq/hw-app-eth/lib/modules/EIP712/EIP712.types";
1
2
  import Eth from "@ledgerhq/hw-app-eth";
2
3
  import Transport from "@ledgerhq/hw-transport";
3
4
  import { TypedDataUtils } from "eth-sig-util";
4
5
  import { bufferToHex } from "ethereumjs-util";
5
6
  import { getEnv } from "../../env";
6
7
  import type { MessageData, Result } from "../../hw/signMessage/types";
7
- import type { TypedMessageData, TypedMessage } from "./types";
8
+ import type { TypedMessageData } from "./types";
8
9
  type EthResolver = (
9
10
  arg0: Transport,
10
- arg1: MessageData | TypedMessageData
11
+ arg1: Pick<MessageData | TypedMessageData, "path" | "message"> &
12
+ Partial<Pick<MessageData, "rawMessage">>
11
13
  ) => Promise<Result>;
12
- export const domainHash = (message: TypedMessage) => {
14
+
15
+ export const domainHash = (message: EIP712Message): Buffer => {
13
16
  return TypedDataUtils.hashStruct(
14
17
  "EIP712Domain",
15
18
  message.domain,
@@ -17,7 +20,7 @@ export const domainHash = (message: TypedMessage) => {
17
20
  true
18
21
  );
19
22
  };
20
- export const messageHash = (message: TypedMessage) => {
23
+ export const messageHash = (message: EIP712Message): Buffer => {
21
24
  return TypedDataUtils.hashStruct(
22
25
  message.primaryType,
23
26
  message.message,
@@ -28,29 +31,34 @@ export const messageHash = (message: TypedMessage) => {
28
31
 
29
32
  const resolver: EthResolver = async (
30
33
  transport,
31
- // @ts-expect-error only available on MessageData. (type guard)
32
34
  { path, message, rawMessage }
33
35
  ) => {
34
36
  const eth = new Eth(transport);
35
- let result;
37
+ const parsedMessage = (() => {
38
+ try {
39
+ return JSON.parse(message as string);
40
+ } catch (e) {
41
+ return message;
42
+ }
43
+ })();
36
44
 
37
- if (typeof message === "string") {
38
- result = await eth.signPersonalMessage(path, rawMessage.slice(2));
45
+ let result: Awaited<ReturnType<typeof eth.signPersonalMessage>>;
46
+ if (typeof parsedMessage === "string") {
47
+ result = await eth.signPersonalMessage(path, rawMessage?.slice(2) || "");
48
+ result.v -= 27;
49
+ // here the expected v is the parity/recoveryId, so we need to remove 27 (v is either 27 or 28)
39
50
  } else {
40
- if (getEnv("EXPERIMENTAL_EIP712")) {
41
- result = await eth.signEIP712Message(path, message);
42
- } else {
43
- result = await eth.signEIP712HashedMessage(
44
- path,
45
- bufferToHex(domainHash(message)),
46
- bufferToHex(messageHash(message))
47
- );
48
- }
51
+ result = getEnv("EXPERIMENTAL_EIP712")
52
+ ? await eth.signEIP712Message(path, parsedMessage)
53
+ : await eth.signEIP712HashedMessage(
54
+ path,
55
+ bufferToHex(domainHash(parsedMessage)),
56
+ bufferToHex(messageHash(parsedMessage))
57
+ );
58
+ // result.v stays untouched for EIP712 as the expected v is already good (27 or 28)
49
59
  }
50
60
 
51
- let v: string | number = result["v"] - 27;
52
- v = v.toString(16);
53
-
61
+ let v = result.v.toString(16);
54
62
  if (v.length < 2) {
55
63
  v = "0" + v;
56
64
  }
@@ -1,3 +1,4 @@
1
+ import { EIP712Message } from "@ledgerhq/hw-app-eth/lib/modules/EIP712/EIP712.types";
1
2
  import type { BigNumber } from "bignumber.js";
2
3
  import type { Unit } from "../../types";
3
4
  import type {
@@ -59,35 +60,12 @@ export type TransactionRaw = TransactionCommonRaw & {
59
60
  collectionName?: string;
60
61
  quantities?: string[];
61
62
  };
62
- export type TypedMessage = {
63
- types: {
64
- EIP712Domain: [
65
- {
66
- type: string;
67
- name: string;
68
- }
69
- ];
70
- [key: string]: [
71
- {
72
- type: string;
73
- name: string;
74
- }
75
- ];
76
- };
77
- primaryType: string;
78
- domain: any;
79
- message: any;
80
- hashes: {
81
- domainHash: string;
82
- messageHash: string;
83
- };
84
- };
85
63
  export type TypedMessageData = {
86
64
  currency: CryptoCurrency;
87
65
  path: string;
88
66
  verify?: boolean;
89
67
  derivationMode: DerivationMode;
90
- message: TypedMessage;
68
+ message: EIP712Message;
91
69
  hashes: {
92
70
  stringHash: string;
93
71
  };
@@ -196,10 +196,10 @@ const getTransactionStatus = async (
196
196
  totalSpent = new BigNumber(0);
197
197
  amount = new BigNumber(0);
198
198
  }
199
+ }
199
200
 
200
- if (!errors.amount && amount.eq(0)) {
201
- errors.amount = new AmountRequired();
202
- }
201
+ if (!errors.amount && amount.eq(0)) {
202
+ errors.amount = new AmountRequired();
203
203
  }
204
204
  }
205
205
 
@@ -0,0 +1,22 @@
1
+ import { getEnv, setEnv } from "../../env";
2
+ import { fetchAllTransactions } from "./synchronisation";
3
+
4
+ jest.setTimeout(2 * 60 * 1000);
5
+
6
+ describe("TEZOS_MAX_TX_QUERIES", () => {
7
+ const bigAccount = "tz1boBHAVpwcvKkNFAQHYr7mjxAz1PpVgKq7";
8
+ test("default have more than 100 txs", async () => {
9
+ const txs = await fetchAllTransactions(bigAccount);
10
+ expect(txs.length).toBeGreaterThan(100);
11
+ });
12
+ test("lowering it to 1 will only fetch a few txs", async () => {
13
+ const cur = getEnv("TEZOS_MAX_TX_QUERIES");
14
+ setEnv("TEZOS_MAX_TX_QUERIES", 1);
15
+ try {
16
+ const txs = await fetchAllTransactions(bigAccount);
17
+ expect(txs.length).toBeLessThanOrEqual(100);
18
+ } finally {
19
+ setEnv("TEZOS_MAX_TX_QUERIES", cur);
20
+ }
21
+ });
22
+ });