@ledgerhq/cryptoassets 13.31.0-nightly.0 → 13.31.0-nightly.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +24 -0
  3. package/lib/api-token-converter.js +1 -1
  4. package/lib/api-token-converter.js.map +1 -1
  5. package/lib/crypto-assets-importer/importers/sui/index.d.ts.map +1 -1
  6. package/lib/crypto-assets-importer/importers/sui/index.js +4 -1
  7. package/lib/crypto-assets-importer/importers/sui/index.js.map +1 -1
  8. package/lib/crypto-assets-importer/importers/sui/sui.test.js +14 -3
  9. package/lib/crypto-assets-importer/importers/sui/sui.test.js.map +1 -1
  10. package/lib/data/sui.d.ts +2 -1
  11. package/lib/data/sui.d.ts.map +1 -1
  12. package/lib/data/sui.js.map +1 -1
  13. package/lib/legacy/legacy-state.d.ts +0 -2
  14. package/lib/legacy/legacy-state.d.ts.map +1 -1
  15. package/lib/legacy/legacy-state.js +1 -3
  16. package/lib/legacy/legacy-state.js.map +1 -1
  17. package/lib/legacy/legacy-utils.d.ts +1 -1
  18. package/lib/legacy/legacy-utils.d.ts.map +1 -1
  19. package/lib/legacy/legacy-utils.js +4 -11
  20. package/lib/legacy/legacy-utils.js.map +1 -1
  21. package/lib/legacy/legacy.test.js +4 -8
  22. package/lib/legacy/legacy.test.js.map +1 -1
  23. package/lib/tokens.d.ts +0 -8
  24. package/lib/tokens.d.ts.map +1 -1
  25. package/lib/tokens.js +1 -20
  26. package/lib/tokens.js.map +1 -1
  27. package/lib-es/api-token-converter.js +1 -1
  28. package/lib-es/api-token-converter.js.map +1 -1
  29. package/lib-es/crypto-assets-importer/importers/sui/index.d.ts.map +1 -1
  30. package/lib-es/crypto-assets-importer/importers/sui/index.js +4 -1
  31. package/lib-es/crypto-assets-importer/importers/sui/index.js.map +1 -1
  32. package/lib-es/crypto-assets-importer/importers/sui/sui.test.js +14 -3
  33. package/lib-es/crypto-assets-importer/importers/sui/sui.test.js.map +1 -1
  34. package/lib-es/data/sui.d.ts +2 -1
  35. package/lib-es/data/sui.d.ts.map +1 -1
  36. package/lib-es/data/sui.js.map +1 -1
  37. package/lib-es/legacy/legacy-state.d.ts +0 -2
  38. package/lib-es/legacy/legacy-state.d.ts.map +1 -1
  39. package/lib-es/legacy/legacy-state.js +0 -2
  40. package/lib-es/legacy/legacy-state.js.map +1 -1
  41. package/lib-es/legacy/legacy-utils.d.ts +1 -1
  42. package/lib-es/legacy/legacy-utils.d.ts.map +1 -1
  43. package/lib-es/legacy/legacy-utils.js +5 -12
  44. package/lib-es/legacy/legacy-utils.js.map +1 -1
  45. package/lib-es/legacy/legacy.test.js +5 -9
  46. package/lib-es/legacy/legacy.test.js.map +1 -1
  47. package/lib-es/tokens.d.ts +0 -8
  48. package/lib-es/tokens.d.ts.map +1 -1
  49. package/lib-es/tokens.js +1 -18
  50. package/lib-es/tokens.js.map +1 -1
  51. package/package.json +2 -2
  52. package/src/api-token-converter.ts +1 -1
  53. package/src/crypto-assets-importer/importers/sui/index.ts +6 -2
  54. package/src/crypto-assets-importer/importers/sui/sui.test.ts +15 -3
  55. package/src/data/sui.ts +2 -1
  56. package/src/legacy/legacy-state.ts +0 -2
  57. package/src/legacy/legacy-utils.ts +11 -14
  58. package/src/legacy/legacy.test.ts +4 -10
  59. package/src/tokens.ts +1 -25
package/src/data/sui.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  export type SuiToken = [
2
- string, // CAL id
2
+ string, // id
3
3
  string, // name
4
4
  string, // ticker
5
5
  string, // address
6
6
  number, // decimals
7
+ string, // live_signature
7
8
  ];
8
9
 
9
10
  import tokens from "./sui.json";
@@ -1,8 +1,6 @@
1
1
  import type { TokenCurrency } from "@ledgerhq/types-cryptoassets";
2
2
 
3
3
  // Legacy state variables that are used for the legacy implementation of CryptoAssetsStore contract
4
- export const tokensByTicker: Record<string, TokenCurrency> = {};
5
- export const tokensByAddress: Record<string, TokenCurrency> = {};
6
4
  export const tokensArray: TokenCurrency[] = [];
7
5
  export const tokensArrayWithDelisted: TokenCurrency[] = [];
8
6
  export const tokensByCryptoCurrency: Record<string, TokenCurrency[]> = {};
@@ -7,8 +7,6 @@ import {
7
7
  tokensByCryptoCurrencyWithDelisted,
8
8
  tokensById,
9
9
  tokensByCurrencyAddress,
10
- tokensByTicker,
11
- tokensByAddress,
12
10
  tokenListHashes,
13
11
  } from "./legacy-state";
14
12
  import {
@@ -276,13 +274,21 @@ export function convertAptFaTokens(token: AptosFAToken): TokenCurrency {
276
274
  /**
277
275
  * @deprecated
278
276
  */
279
- export function convertSuiTokens([id, name, ticker, address, decimals]: SuiToken): TokenCurrency {
277
+ export function convertSuiTokens([
278
+ id,
279
+ name,
280
+ ticker,
281
+ address,
282
+ decimals,
283
+ ledgerSignature,
284
+ ]: SuiToken): TokenCurrency {
280
285
  return {
281
286
  type: "TokenCurrency",
282
287
  id,
283
288
  contractAddress: address,
284
289
  parentCurrency: getCryptoCurrencyById("sui"),
285
290
  name,
291
+ ledgerSignature,
286
292
  tokenType: "sui",
287
293
  ticker,
288
294
  disableCountervalue: false,
@@ -461,8 +467,6 @@ export function __clearAllLists(): void {
461
467
  __clearObject(tokensByCryptoCurrency);
462
468
  __clearObject(tokensByCryptoCurrencyWithDelisted);
463
469
  __clearObject(tokensById);
464
- __clearObject(tokensByTicker);
465
- __clearObject(tokensByAddress);
466
470
  __clearObject(tokensByCurrencyAddress);
467
471
  tokenListHashes.clear();
468
472
  }
@@ -485,13 +489,11 @@ function removeTokenFromRecord(record: Record<string, TokenCurrency>, key: strin
485
489
  * @param token
486
490
  */
487
491
  function removeTokenFromAllLists(token: TokenCurrency) {
488
- const { id, contractAddress, parentCurrency, ticker } = token;
492
+ const { id, contractAddress, parentCurrency } = token;
489
493
  const lowCaseContract = contractAddress.toLowerCase();
490
494
 
491
495
  removeTokenFromRecord(tokensById, id);
492
496
  removeTokenFromRecord(tokensByCurrencyAddress, parentCurrency.id + ":" + lowCaseContract);
493
- removeTokenFromRecord(tokensByAddress, lowCaseContract);
494
- removeTokenFromRecord(tokensByTicker, ticker);
495
497
  removeTokenFromArray(tokensArray, id);
496
498
  removeTokenFromArray(tokensArrayWithDelisted, id);
497
499
  removeTokenFromArray(tokensByCryptoCurrency[parentCurrency.id], id);
@@ -512,7 +514,7 @@ export function addTokens(list: (TokenCurrency | undefined)[]): void {
512
514
  * Like this we can update any change from a already added token coming from Dynamic CAL
513
515
  * and maintain it up to date without having to release a new version of LLD or LLM
514
516
  */
515
- const { id, contractAddress, parentCurrency, delisted, ticker } = token;
517
+ const { id, contractAddress, parentCurrency, delisted } = token;
516
518
  if (tokensById[id]) removeTokenFromAllLists(token);
517
519
  const lowCaseContract = contractAddress.toLowerCase();
518
520
 
@@ -520,11 +522,6 @@ export function addTokens(list: (TokenCurrency | undefined)[]): void {
520
522
  tokensArrayWithDelisted.push(token);
521
523
  tokensById[id] = token;
522
524
 
523
- if (!tokensByTicker[ticker]) {
524
- tokensByTicker[ticker] = token;
525
- }
526
-
527
- tokensByAddress[lowCaseContract] = token;
528
525
  tokensByCurrencyAddress[parentCurrency.id + ":" + lowCaseContract] = token;
529
526
 
530
527
  if (!(parentCurrency.id in tokensByCryptoCurrency)) {
@@ -22,8 +22,6 @@ import {
22
22
  import { initializeLegacyTokens } from "./legacy-data";
23
23
  import { getEnv } from "@ledgerhq/live-env";
24
24
  import {
25
- tokensByTicker,
26
- tokensByAddress,
27
25
  tokensArray,
28
26
  tokensArrayWithDelisted,
29
27
  tokensByCryptoCurrency,
@@ -179,7 +177,7 @@ describe("Legacy Utils", () => {
179
177
  });
180
178
 
181
179
  it("should convert Sui token", () => {
182
- const suiToken: SuiToken = ["sui/test", "Test Token", "TEST", "0x123", 9];
180
+ const suiToken: SuiToken = ["sui/test", "Test Token", "TEST", "0x123", 9, "signature"];
183
181
  const result = convertSuiTokens(suiToken);
184
182
  expect(result.type).toBe("TokenCurrency");
185
183
  expect(result.tokenType).toBe("sui");
@@ -282,8 +280,6 @@ describe("Legacy Utils", () => {
282
280
  expect(tokensArray).toContain(token);
283
281
  expect(tokensArrayWithDelisted).toContain(token);
284
282
  expect(tokensById[token.id]).toBe(token);
285
- expect(tokensByTicker["TEST"]).toBe(token);
286
- expect(tokensByAddress["0x123"]).toBe(token);
287
283
  expect(tokensByCurrencyAddress["ethereum:0x123"]).toBe(token);
288
284
  expect(tokensByCryptoCurrency["ethereum"]).toContain(token);
289
285
  });
@@ -352,7 +348,9 @@ describe("Legacy Utils", () => {
352
348
 
353
349
  addTokens([token1, token2]);
354
350
 
355
- expect(tokensByTicker["TEST"]).toBe(token1); // First one wins
351
+ // Both tokens should be added successfully
352
+ expect(tokensById[token1.id]).toBe(token1);
353
+ expect(tokensById[token2.id]).toBe(token2);
356
354
  });
357
355
 
358
356
  it("should handle undefined tokens", () => {
@@ -513,8 +511,6 @@ describe("Legacy Utils", () => {
513
511
  expect(Object.keys(tokensByCryptoCurrency).length).toBe(0);
514
512
  expect(Object.keys(tokensByCryptoCurrencyWithDelisted).length).toBe(0);
515
513
  expect(Object.keys(tokensById).length).toBe(0);
516
- expect(Object.keys(tokensByTicker).length).toBe(0);
517
- expect(Object.keys(tokensByAddress).length).toBe(0);
518
514
  expect(Object.keys(tokensByCurrencyAddress).length).toBe(0);
519
515
  expect(tokenListHashes.size).toBe(0);
520
516
  });
@@ -573,8 +569,6 @@ describe("Legacy Data", () => {
573
569
 
574
570
  describe("Legacy State", () => {
575
571
  it("should export all state objects", () => {
576
- expect(tokensByTicker).toBeDefined();
577
- expect(tokensByAddress).toBeDefined();
578
572
  expect(tokensArray).toBeDefined();
579
573
  expect(tokensArrayWithDelisted).toBeDefined();
580
574
  expect(tokensByCryptoCurrency).toBeDefined();
package/src/tokens.ts CHANGED
@@ -23,12 +23,7 @@ import {
23
23
  convertAptFaTokens,
24
24
  convertHederaTokens,
25
25
  } from "./legacy/legacy-utils";
26
- import {
27
- tokensByAddress,
28
- tokensByCurrencyAddress,
29
- tokensById,
30
- tokensByTicker,
31
- } from "./legacy/legacy-state";
26
+ import { tokensByCurrencyAddress, tokensById } from "./legacy/legacy-state";
32
27
  import { initializeLegacyTokens } from "./legacy/legacy-data";
33
28
 
34
29
  export {
@@ -51,13 +46,6 @@ export {
51
46
 
52
47
  initializeLegacyTokens(addTokens);
53
48
 
54
- /**
55
- * @deprecated this function must not be used and will be replaced by `getCryptoAssetsStore().findTokenById(id)` in https://github.com/LedgerHQ/ledger-live/pull/11905
56
- */
57
- export function findTokenByTicker(ticker: string): TokenCurrency | undefined {
58
- return tokensByTicker[ticker];
59
- }
60
-
61
49
  /**
62
50
  * @deprecated Please do `await getCryptoAssetsStore().findTokenById(id)` instead to anticipate https://github.com/LedgerHQ/ledger-live/pull/11905
63
51
  */
@@ -65,18 +53,6 @@ export function findTokenById(id: string): TokenCurrency | undefined {
65
53
  return tokensById[id];
66
54
  }
67
55
 
68
- let deprecatedDisplayed = false;
69
- /**
70
- * @deprecated This function will be removed when https://github.com/LedgerHQ/ledger-live/pull/11905 lands
71
- */
72
- export function findTokenByAddress(address: string): TokenCurrency | undefined {
73
- if (!deprecatedDisplayed) {
74
- deprecatedDisplayed = true;
75
- console.warn("findTokenByAddress is deprecated. use findTokenByAddressInCurrency");
76
- }
77
- return tokensByAddress[address.toLowerCase()];
78
- }
79
-
80
56
  /**
81
57
  * @deprecated Please do `await getCryptoAssetsStore().findTokenByAddress(address, currencyId)` instead to anticipate https://github.com/LedgerHQ/ledger-live/pull/11905
82
58
  */