@ledgerhq/live-common 21.18.0 → 21.19.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 (118) hide show
  1. package/lib/__tests__/test-helpers/setup.js +1 -0
  2. package/lib/__tests__/test-helpers/setup.js.map +1 -1
  3. package/lib/account/addAccounts.d.ts.map +1 -1
  4. package/lib/account/addAccounts.js +3 -2
  5. package/lib/account/addAccounts.js.map +1 -1
  6. package/lib/account/helpers.d.ts.map +1 -1
  7. package/lib/account/helpers.js +1 -0
  8. package/lib/account/helpers.js.map +1 -1
  9. package/lib/api/Ethereum.d.ts.map +1 -1
  10. package/lib/api/Ethereum.js +2 -1
  11. package/lib/api/Ethereum.js.map +1 -1
  12. package/lib/api/explorerConfig/index.d.ts.map +1 -1
  13. package/lib/api/explorerConfig/index.js +0 -4
  14. package/lib/api/explorerConfig/index.js.map +1 -1
  15. package/lib/bridge/jsHelpers.d.ts.map +1 -1
  16. package/lib/bridge/jsHelpers.js +9 -8
  17. package/lib/bridge/jsHelpers.js.map +1 -1
  18. package/lib/env.d.ts +10 -5
  19. package/lib/env.d.ts.map +1 -1
  20. package/lib/env.js +5 -0
  21. package/lib/env.js.map +1 -1
  22. package/lib/env.react.d.ts +1 -1
  23. package/lib/env.react.d.ts.map +1 -1
  24. package/lib/families/bitcoin/getAccountNetworkInfo.d.ts.map +1 -1
  25. package/lib/families/bitcoin/getAccountNetworkInfo.js +12 -2
  26. package/lib/families/bitcoin/getAccountNetworkInfo.js.map +1 -1
  27. package/lib/families/bitcoin/test-dataset.js +2 -2
  28. package/lib/families/bitcoin/test-dataset.js.map +1 -1
  29. package/lib/families/bitcoin/types.d.ts +1 -0
  30. package/lib/families/bitcoin/types.d.ts.map +1 -1
  31. package/lib/families/bitcoin/types.js.map +1 -1
  32. package/lib/families/bitcoin/wallet-btc/explorer/index.d.ts +1 -0
  33. package/lib/families/bitcoin/wallet-btc/explorer/index.d.ts.map +1 -1
  34. package/lib/families/bitcoin/wallet-btc/explorer/index.js +19 -0
  35. package/lib/families/bitcoin/wallet-btc/explorer/index.js.map +1 -1
  36. package/lib/families/bitcoin/wallet-btc/explorer/types.d.ts +1 -0
  37. package/lib/families/bitcoin/wallet-btc/explorer/types.d.ts.map +1 -1
  38. package/lib/families/ethereum/bridge/js.d.ts.map +1 -1
  39. package/lib/families/ethereum/bridge/js.js +3 -0
  40. package/lib/families/ethereum/bridge/js.js.map +1 -1
  41. package/lib/families/ethereum/modules/erc1155.d.ts.map +1 -1
  42. package/lib/families/ethereum/modules/erc1155.js +21 -9
  43. package/lib/families/ethereum/modules/erc1155.js.map +1 -1
  44. package/lib/families/ethereum/modules/erc721.d.ts +3 -1
  45. package/lib/families/ethereum/modules/erc721.d.ts.map +1 -1
  46. package/lib/families/ethereum/modules/erc721.js +101 -7
  47. package/lib/families/ethereum/modules/erc721.js.map +1 -1
  48. package/lib/families/ethereum/modules/index.d.ts +5 -0
  49. package/lib/families/ethereum/modules/index.d.ts.map +1 -1
  50. package/lib/families/ethereum/modules/index.js +9 -1
  51. package/lib/families/ethereum/modules/index.js.map +1 -1
  52. package/lib/families/ethereum/nft.test.d.ts +2 -0
  53. package/lib/families/ethereum/nft.test.d.ts.map +1 -0
  54. package/lib/families/ethereum/nft.test.js +360 -0
  55. package/lib/families/ethereum/nft.test.js.map +1 -0
  56. package/lib/families/ethereum/signOperation.d.ts.map +1 -1
  57. package/lib/families/ethereum/signOperation.js +3 -12
  58. package/lib/families/ethereum/signOperation.js.map +1 -1
  59. package/lib/families/ethereum/synchronisation.d.ts.map +1 -1
  60. package/lib/families/ethereum/synchronisation.js +21 -38
  61. package/lib/families/ethereum/synchronisation.js.map +1 -1
  62. package/lib/families/ethereum/synchronisation.test.js.map +1 -1
  63. package/lib/families/ethereum/transaction.d.ts.map +1 -1
  64. package/lib/families/ethereum/transaction.js +4 -4
  65. package/lib/families/ethereum/transaction.js.map +1 -1
  66. package/lib/families/ethereum/types.d.ts +2 -0
  67. package/lib/families/ethereum/types.d.ts.map +1 -1
  68. package/lib/families/ethereum/types.js.map +1 -1
  69. package/lib/hw/uninstallApp.d.ts.map +1 -1
  70. package/lib/hw/uninstallApp.js +1 -1
  71. package/lib/hw/uninstallApp.js.map +1 -1
  72. package/lib/nft/helpers.js +2 -3
  73. package/lib/nft/helpers.js.map +1 -1
  74. package/lib/nft/index.d.ts +1 -0
  75. package/lib/nft/index.d.ts.map +1 -1
  76. package/lib/nft/index.js +1 -0
  77. package/lib/nft/index.js.map +1 -1
  78. package/lib/nft/support.d.ts +4 -0
  79. package/lib/nft/support.d.ts.map +1 -0
  80. package/lib/nft/support.js +16 -0
  81. package/lib/nft/support.js.map +1 -0
  82. package/lib/reconciliation.d.ts.map +1 -1
  83. package/lib/reconciliation.js +5 -1
  84. package/lib/reconciliation.js.map +1 -1
  85. package/package.json +4 -4
  86. package/src/.DS_Store +0 -0
  87. package/src/__tests__/.DS_Store +0 -0
  88. package/src/__tests__/__snapshots__/all.libcore.ts.snap +10 -49
  89. package/src/__tests__/test-helpers/setup.ts +1 -0
  90. package/src/account/addAccounts.ts +3 -2
  91. package/src/account/helpers.ts +1 -0
  92. package/src/api/Ethereum.ts +4 -4
  93. package/src/api/explorerConfig/index.ts +0 -4
  94. package/src/bridge/jsHelpers.ts +9 -8
  95. package/src/currencies/{.DS_Store → __snapshots__/.DS_Store} +0 -0
  96. package/src/env.ts +5 -0
  97. package/src/families/bitcoin/getAccountNetworkInfo.ts +8 -1
  98. package/src/families/bitcoin/test-dataset.ts +2 -2
  99. package/src/families/bitcoin/types.ts +1 -0
  100. package/src/families/bitcoin/wallet-btc/explorer/index.ts +7 -0
  101. package/src/families/bitcoin/wallet-btc/explorer/types.ts +1 -0
  102. package/src/families/ethereum/bridge/js.ts +8 -1
  103. package/src/families/ethereum/modules/erc1155.ts +22 -7
  104. package/src/families/ethereum/modules/erc721.ts +42 -4
  105. package/src/families/ethereum/modules/index.ts +20 -0
  106. package/src/families/ethereum/nft.test.ts +263 -0
  107. package/src/families/ethereum/signOperation.ts +3 -16
  108. package/src/families/ethereum/synchronisation.test.ts +1 -0
  109. package/src/families/ethereum/synchronisation.ts +104 -113
  110. package/src/families/ethereum/transaction.ts +8 -4
  111. package/src/families/ethereum/types.ts +2 -0
  112. package/src/hw/uninstallApp.ts +13 -8
  113. package/src/nft/helpers.ts +2 -2
  114. package/src/nft/index.ts +1 -0
  115. package/src/nft/support.ts +16 -0
  116. package/src/reconciliation.ts +4 -1
  117. package/src/types/account.ts +1 -1
  118. package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +0 -6152
@@ -9,14 +9,19 @@ export default function uninstallApp(
9
9
  targetId: string | number,
10
10
  app: ApplicationVersion | App
11
11
  ): Observable<any> {
12
- return ManagerAPI.install(transport, "uninstall-app", {
13
- targetId,
14
- perso: app.perso,
15
- deleteKey: app.delete_key,
16
- firmware: app.delete,
17
- firmwareKey: app.delete_key,
18
- hash: app.hash,
19
- }).pipe(
12
+ return ManagerAPI.install(
13
+ transport,
14
+ "uninstall-app",
15
+ {
16
+ targetId,
17
+ perso: app.perso,
18
+ deleteKey: app.delete_key,
19
+ firmware: app.delete,
20
+ firmwareKey: app.delete_key,
21
+ hash: app.hash,
22
+ },
23
+ true
24
+ ).pipe(
20
25
  ignoreElements(),
21
26
  catchError((e: Error) => {
22
27
  if (!e || !e.message) return throwError(e);
@@ -24,7 +24,7 @@ export const nftsFromOperations = (ops: Operation[]): NFT[] => {
24
24
  const nftKey = contract + nftOp.tokenId!;
25
25
  const { tokenId, standard, id } = nftOp;
26
26
 
27
- const nft = (acc[nftKey] ?? {
27
+ const nft = (acc[nftKey] || {
28
28
  id,
29
29
  tokenId: tokenId!,
30
30
  amount: new BigNumber(0),
@@ -45,7 +45,7 @@ export const nftsFromOperations = (ops: Operation[]): NFT[] => {
45
45
  return acc;
46
46
  }, {});
47
47
 
48
- return Object.values(nftsMap);
48
+ return Object.values(nftsMap).filter((n) => n.amount.gt(0));
49
49
  };
50
50
 
51
51
  export const nftsByCollections = (
package/src/nft/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./nftId";
2
2
  export * from "./helpers";
3
+ export * from "./support";
3
4
  export * from "./NftMetadataProvider";
@@ -0,0 +1,16 @@
1
+ import { Transaction, CryptoCurrency } from "../types";
2
+ import { getEnv } from "../env";
3
+
4
+ export const isNftTransaction = (transaction: Transaction): boolean => {
5
+ if (transaction.family === "ethereum") {
6
+ return ["erc721.transfer", "erc1155.transfer"].includes(transaction.mode);
7
+ }
8
+
9
+ return false;
10
+ };
11
+
12
+ export function isNFTActive(currency: CryptoCurrency): boolean {
13
+ return (
14
+ getEnv("NFT") && getEnv("NFT_CURRENCIES").split(",").includes(currency.id)
15
+ );
16
+ }
@@ -384,7 +384,10 @@ export function patchAccount(
384
384
  }
385
385
 
386
386
  const nfts = updatedRaw?.nfts?.map(fromNFTRaw);
387
- if (updatedRaw.nfts && !isEqual(account.nfts, nfts)) {
387
+ if (!updatedRaw.nfts && account.nfts) {
388
+ delete next.nfts;
389
+ changed = true;
390
+ } else if (!isEqual(account.nfts, nfts)) {
388
391
  next.nfts = nfts;
389
392
  changed = true;
390
393
  }
@@ -215,7 +215,7 @@ export type Account = {
215
215
  swapHistory: SwapOperation[];
216
216
  // Hash used to discard tx history on sync
217
217
  syncHash?: string;
218
- // Array of NFTs computed by diffing NFTOperations
218
+ // Array of NFTs computed by diffing NFTOperations ordered from newest to oldest
219
219
  nfts?: NFT[];
220
220
  };
221
221
  export type SubAccount = TokenAccount | ChildAccount;