@ledgerhq/cryptoassets 13.31.1-nightly.0 → 13.32.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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @ledgerhq/cryptoassets@13.31.0 build /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/cryptoassets
2
+ > @ledgerhq/cryptoassets@13.31.1-nightly.0 build /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/cryptoassets
3
3
  > tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @ledgerhq/cryptoassets
2
2
 
3
+ ## 13.32.0-nightly.1
4
+
5
+ ### Minor Changes
6
+
7
+ - [#12321](https://github.com/LedgerHQ/ledger-live/pull/12321) [`63e8f34`](https://github.com/LedgerHQ/ledger-live/commit/63e8f342f6b951ab77bb710b9971f033c05e579e) Thanks [@mcayuelas-ledger](https://github.com/mcayuelas-ledger)! - Bump axios version to 1.12.2
8
+
9
+ - [#12382](https://github.com/LedgerHQ/ledger-live/pull/12382) [`3d4188a`](https://github.com/LedgerHQ/ledger-live/commit/3d4188a26021d33b950129d82cb55d2c2e8d4358) Thanks [@gre-ledger](https://github.com/gre-ledger)! - Introduce CryptoAssetStore#getTokensSyncHash function
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [[`3d4188a`](https://github.com/LedgerHQ/ledger-live/commit/3d4188a26021d33b950129d82cb55d2c2e8d4358)]:
14
+ - @ledgerhq/types-live@6.88.0-nightly.1
15
+
3
16
  ## 13.31.1-nightly.0
4
17
 
5
18
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-store.d.ts","sourceRoot":"","sources":["../../src/legacy/legacy-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAc9D;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,iBAGrC,CAAC"}
1
+ {"version":3,"file":"legacy-store.d.ts","sourceRoot":"","sources":["../../src/legacy/legacy-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAmB9D;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,iBAIrC,CAAC"}
@@ -8,6 +8,10 @@ function findTokenById(id) {
8
8
  function findTokenByAddressInCurrency(address, currencyId) {
9
9
  return legacy_state_1.tokensByCurrencyAddress[currencyId + ":" + address.toLowerCase()];
10
10
  }
11
+ function getTokensSyncHash(currencyId) {
12
+ const tokens = legacy_state_1.tokensByCryptoCurrency[currencyId];
13
+ return Promise.resolve("legacy_" + tokens?.length);
14
+ }
11
15
  /**
12
16
  * Legacy CryptoAssetsStore adapter that wraps the legacy token lookup functions
13
17
  * and provides the CryptoAssetsStore interface expected by the rest of the codebase.
@@ -15,5 +19,6 @@ function findTokenByAddressInCurrency(address, currencyId) {
15
19
  exports.legacyCryptoAssetsStore = {
16
20
  findTokenById,
17
21
  findTokenByAddressInCurrency,
22
+ getTokensSyncHash,
18
23
  };
19
24
  //# sourceMappingURL=legacy-store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-store.js","sourceRoot":"","sources":["../../src/legacy/legacy-store.ts"],"names":[],"mappings":";;;AAEA,iDAAqE;AAErE,SAAS,aAAa,CAAC,EAAU;IAC/B,OAAO,yBAAU,CAAC,EAAE,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,4BAA4B,CACnC,OAAe,EACf,UAAkB;IAElB,OAAO,sCAAuB,CAAC,UAAU,GAAG,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED;;;GAGG;AACU,QAAA,uBAAuB,GAAsB;IACxD,aAAa;IACb,4BAA4B;CAC7B,CAAC"}
1
+ {"version":3,"file":"legacy-store.js","sourceRoot":"","sources":["../../src/legacy/legacy-store.ts"],"names":[],"mappings":";;;AAEA,iDAA6F;AAE7F,SAAS,aAAa,CAAC,EAAU;IAC/B,OAAO,yBAAU,CAAC,EAAE,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,4BAA4B,CACnC,OAAe,EACf,UAAkB;IAElB,OAAO,sCAAuB,CAAC,UAAU,GAAG,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,iBAAiB,CAAC,UAAkB;IAC3C,MAAM,MAAM,GAAG,qCAAsB,CAAC,UAAU,CAAC,CAAC;IAClD,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACU,QAAA,uBAAuB,GAAsB;IACxD,aAAa;IACb,4BAA4B;IAC5B,iBAAiB;CAClB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-store.d.ts","sourceRoot":"","sources":["../../src/legacy/legacy-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAc9D;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,iBAGrC,CAAC"}
1
+ {"version":3,"file":"legacy-store.d.ts","sourceRoot":"","sources":["../../src/legacy/legacy-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAmB9D;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,iBAIrC,CAAC"}
@@ -1,10 +1,14 @@
1
- import { tokensById, tokensByCurrencyAddress } from "./legacy-state";
1
+ import { tokensById, tokensByCurrencyAddress, tokensByCryptoCurrency } from "./legacy-state";
2
2
  function findTokenById(id) {
3
3
  return tokensById[id];
4
4
  }
5
5
  function findTokenByAddressInCurrency(address, currencyId) {
6
6
  return tokensByCurrencyAddress[currencyId + ":" + address.toLowerCase()];
7
7
  }
8
+ function getTokensSyncHash(currencyId) {
9
+ const tokens = tokensByCryptoCurrency[currencyId];
10
+ return Promise.resolve("legacy_" + tokens?.length);
11
+ }
8
12
  /**
9
13
  * Legacy CryptoAssetsStore adapter that wraps the legacy token lookup functions
10
14
  * and provides the CryptoAssetsStore interface expected by the rest of the codebase.
@@ -12,5 +16,6 @@ function findTokenByAddressInCurrency(address, currencyId) {
12
16
  export const legacyCryptoAssetsStore = {
13
17
  findTokenById,
14
18
  findTokenByAddressInCurrency,
19
+ getTokensSyncHash,
15
20
  };
16
21
  //# sourceMappingURL=legacy-store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"legacy-store.js","sourceRoot":"","sources":["../../src/legacy/legacy-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAErE,SAAS,aAAa,CAAC,EAAU;IAC/B,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,4BAA4B,CACnC,OAAe,EACf,UAAkB;IAElB,OAAO,uBAAuB,CAAC,UAAU,GAAG,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAsB;IACxD,aAAa;IACb,4BAA4B;CAC7B,CAAC"}
1
+ {"version":3,"file":"legacy-store.js","sourceRoot":"","sources":["../../src/legacy/legacy-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7F,SAAS,aAAa,CAAC,EAAU;IAC/B,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,4BAA4B,CACnC,OAAe,EACf,UAAkB;IAElB,OAAO,uBAAuB,CAAC,UAAU,GAAG,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,iBAAiB,CAAC,UAAkB;IAC3C,MAAM,MAAM,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;IAClD,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAsB;IACxD,aAAa;IACb,4BAA4B;IAC5B,iBAAiB;CAClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/cryptoassets",
3
- "version": "13.31.1-nightly.0",
3
+ "version": "13.32.0-nightly.1",
4
4
  "description": "Ledger crypto-assets list",
5
5
  "keywords": [
6
6
  "Ledger"
@@ -20,11 +20,11 @@
20
20
  "module": "lib-es/index.js",
21
21
  "types": "lib/index.d.ts",
22
22
  "dependencies": {
23
- "axios": "1.11.0",
23
+ "axios": "1.12.2",
24
24
  "bs58check": "^2.1.2",
25
25
  "invariant": "2",
26
26
  "@ledgerhq/live-env": "^2.19.0",
27
- "@ledgerhq/types-live": "^6.88.0-nightly.0"
27
+ "@ledgerhq/types-live": "^6.88.0-nightly.1"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@testing-library/react": "14.2.2",
@@ -1,6 +1,6 @@
1
1
  import type { TokenCurrency } from "@ledgerhq/types-cryptoassets";
2
2
  import type { CryptoAssetsStore } from "@ledgerhq/types-live";
3
- import { tokensById, tokensByCurrencyAddress } from "./legacy-state";
3
+ import { tokensById, tokensByCurrencyAddress, tokensByCryptoCurrency } from "./legacy-state";
4
4
 
5
5
  function findTokenById(id: string): TokenCurrency | undefined {
6
6
  return tokensById[id];
@@ -13,6 +13,11 @@ function findTokenByAddressInCurrency(
13
13
  return tokensByCurrencyAddress[currencyId + ":" + address.toLowerCase()];
14
14
  }
15
15
 
16
+ function getTokensSyncHash(currencyId: string): Promise<string> {
17
+ const tokens = tokensByCryptoCurrency[currencyId];
18
+ return Promise.resolve("legacy_" + tokens?.length);
19
+ }
20
+
16
21
  /**
17
22
  * Legacy CryptoAssetsStore adapter that wraps the legacy token lookup functions
18
23
  * and provides the CryptoAssetsStore interface expected by the rest of the codebase.
@@ -20,4 +25,5 @@ function findTokenByAddressInCurrency(
20
25
  export const legacyCryptoAssetsStore: CryptoAssetsStore = {
21
26
  findTokenById,
22
27
  findTokenByAddressInCurrency,
28
+ getTokensSyncHash,
23
29
  };
@@ -30,6 +30,7 @@ import {
30
30
  tokensByCurrencyAddress,
31
31
  tokenListHashes,
32
32
  } from "./legacy-state";
33
+ import { legacyCryptoAssetsStore } from "./legacy-store";
33
34
  import type { TokenCurrency } from "@ledgerhq/types-cryptoassets";
34
35
  import type {
35
36
  ERC20Token,
@@ -567,6 +568,98 @@ describe("Legacy Data", () => {
567
568
  });
568
569
  });
569
570
 
571
+ describe("legacyCryptoAssetsStore", () => {
572
+ beforeEach(() => {
573
+ __clearAllLists();
574
+ });
575
+
576
+ it("should find token by id", () => {
577
+ const erc20Token: ERC20Token = [
578
+ "ethereum",
579
+ "test_token",
580
+ "TEST",
581
+ 18,
582
+ "Test Token",
583
+ "signature",
584
+ "0x123",
585
+ false,
586
+ false,
587
+ ];
588
+
589
+ addTokens([convertERC20(erc20Token)].filter(Boolean) as TokenCurrency[]);
590
+
591
+ const token = legacyCryptoAssetsStore.findTokenById("ethereum/erc20/test_token");
592
+
593
+ expect(token).toMatchObject({ ticker: "TEST" });
594
+ });
595
+
596
+ it("should find token by address in currency", () => {
597
+ const erc20Token: ERC20Token = [
598
+ "ethereum",
599
+ "test_token",
600
+ "TEST",
601
+ 18,
602
+ "Test Token",
603
+ "signature",
604
+ "0xABC123",
605
+ false,
606
+ false,
607
+ ];
608
+
609
+ addTokens([convertERC20(erc20Token)].filter(Boolean) as TokenCurrency[]);
610
+
611
+ const token = legacyCryptoAssetsStore.findTokenByAddressInCurrency("0xabc123", "ethereum");
612
+
613
+ expect(token).toMatchObject({ ticker: "TEST" });
614
+ });
615
+
616
+ it("should return undefined for non-existent token by address", () => {
617
+ const token = legacyCryptoAssetsStore.findTokenByAddressInCurrency("0xnonexistent", "ethereum");
618
+
619
+ expect(token).toBeUndefined();
620
+ });
621
+
622
+ it("should return sync hash for currency with tokens", async () => {
623
+ const erc20Token1: ERC20Token = [
624
+ "ethereum",
625
+ "test_token1",
626
+ "TEST1",
627
+ 18,
628
+ "Test Token 1",
629
+ "signature1",
630
+ "0x123",
631
+ false,
632
+ false,
633
+ ];
634
+
635
+ const erc20Token2: ERC20Token = [
636
+ "ethereum",
637
+ "test_token2",
638
+ "TEST2",
639
+ 18,
640
+ "Test Token 2",
641
+ "signature2",
642
+ "0x456",
643
+ false,
644
+ false,
645
+ ];
646
+
647
+ addTokens(
648
+ [convertERC20(erc20Token1), convertERC20(erc20Token2)].filter(Boolean) as TokenCurrency[],
649
+ );
650
+
651
+ const hash = await legacyCryptoAssetsStore.getTokensSyncHash("ethereum");
652
+
653
+ expect(hash).toBe("legacy_2");
654
+ });
655
+
656
+ it("should return sync hash for currency with no tokens", async () => {
657
+ const hash = await legacyCryptoAssetsStore.getTokensSyncHash("bitcoin");
658
+
659
+ expect(hash).toBe("legacy_undefined");
660
+ });
661
+ });
662
+
570
663
  describe("Legacy State", () => {
571
664
  it("should export all state objects", () => {
572
665
  expect(tokensArray).toBeDefined();