@ledgerhq/live-common 21.17.2 → 21.19.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 (119) 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/cli-transaction.d.ts.map +1 -1
  42. package/lib/families/ethereum/cli-transaction.js +10 -0
  43. package/lib/families/ethereum/cli-transaction.js.map +1 -1
  44. package/lib/families/ethereum/modules/erc1155.d.ts +4 -0
  45. package/lib/families/ethereum/modules/erc1155.d.ts.map +1 -0
  46. package/lib/families/ethereum/modules/erc1155.js +129 -0
  47. package/lib/families/ethereum/modules/erc1155.js.map +1 -0
  48. package/lib/families/ethereum/modules/erc721.d.ts +6 -0
  49. package/lib/families/ethereum/modules/erc721.d.ts.map +1 -0
  50. package/lib/families/ethereum/modules/erc721.js +189 -0
  51. package/lib/families/ethereum/modules/erc721.js.map +1 -0
  52. package/lib/families/ethereum/modules/index.d.ts +8 -1
  53. package/lib/families/ethereum/modules/index.d.ts.map +1 -1
  54. package/lib/families/ethereum/modules/index.js +14 -2
  55. package/lib/families/ethereum/modules/index.js.map +1 -1
  56. package/lib/families/ethereum/nft.test.d.ts +2 -0
  57. package/lib/families/ethereum/nft.test.d.ts.map +1 -0
  58. package/lib/families/ethereum/nft.test.js +353 -0
  59. package/lib/families/ethereum/nft.test.js.map +1 -0
  60. package/lib/families/ethereum/signOperation.d.ts.map +1 -1
  61. package/lib/families/ethereum/signOperation.js +3 -12
  62. package/lib/families/ethereum/signOperation.js.map +1 -1
  63. package/lib/families/ethereum/synchronisation.d.ts.map +1 -1
  64. package/lib/families/ethereum/synchronisation.js +21 -38
  65. package/lib/families/ethereum/synchronisation.js.map +1 -1
  66. package/lib/families/ethereum/synchronisation.test.js.map +1 -1
  67. package/lib/families/ethereum/transaction.d.ts.map +1 -1
  68. package/lib/families/ethereum/transaction.js +25 -8
  69. package/lib/families/ethereum/transaction.js.map +1 -1
  70. package/lib/families/ethereum/types.d.ts +8 -0
  71. package/lib/families/ethereum/types.d.ts.map +1 -1
  72. package/lib/families/ethereum/types.js.map +1 -1
  73. package/lib/hw/uninstallApp.d.ts.map +1 -1
  74. package/lib/hw/uninstallApp.js +1 -1
  75. package/lib/hw/uninstallApp.js.map +1 -1
  76. package/lib/nft/helpers.js +1 -2
  77. package/lib/nft/helpers.js.map +1 -1
  78. package/lib/nft/index.d.ts +1 -0
  79. package/lib/nft/index.d.ts.map +1 -1
  80. package/lib/nft/index.js +1 -0
  81. package/lib/nft/index.js.map +1 -1
  82. package/lib/nft/support.d.ts +4 -0
  83. package/lib/nft/support.d.ts.map +1 -0
  84. package/lib/nft/support.js +16 -0
  85. package/lib/nft/support.js.map +1 -0
  86. package/package.json +4 -4
  87. package/src/.DS_Store +0 -0
  88. package/src/__tests__/.DS_Store +0 -0
  89. package/src/__tests__/__snapshots__/all.libcore.ts.snap +10 -49
  90. package/src/__tests__/test-helpers/setup.ts +1 -0
  91. package/src/account/addAccounts.ts +3 -2
  92. package/src/account/helpers.ts +1 -0
  93. package/src/api/Ethereum.ts +4 -4
  94. package/src/api/explorerConfig/index.ts +0 -4
  95. package/src/bridge/jsHelpers.ts +9 -8
  96. package/src/currencies/{.DS_Store → __snapshots__/.DS_Store} +0 -0
  97. package/src/env.ts +5 -0
  98. package/src/families/bitcoin/getAccountNetworkInfo.ts +8 -1
  99. package/src/families/bitcoin/test-dataset.ts +2 -2
  100. package/src/families/bitcoin/types.ts +1 -0
  101. package/src/families/bitcoin/wallet-btc/explorer/index.ts +7 -0
  102. package/src/families/bitcoin/wallet-btc/explorer/types.ts +1 -0
  103. package/src/families/ethereum/bridge/js.ts +8 -1
  104. package/src/families/ethereum/cli-transaction.ts +10 -0
  105. package/src/families/ethereum/modules/erc1155.ts +157 -0
  106. package/src/families/ethereum/modules/erc721.ts +146 -0
  107. package/src/families/ethereum/modules/index.ts +32 -1
  108. package/src/families/ethereum/nft.test.ts +259 -0
  109. package/src/families/ethereum/signOperation.ts +3 -16
  110. package/src/families/ethereum/synchronisation.test.ts +1 -0
  111. package/src/families/ethereum/synchronisation.ts +104 -113
  112. package/src/families/ethereum/transaction.ts +42 -8
  113. package/src/families/ethereum/types.ts +8 -0
  114. package/src/hw/uninstallApp.ts +13 -8
  115. package/src/nft/helpers.ts +1 -1
  116. package/src/nft/index.ts +1 -0
  117. package/src/nft/support.ts +16 -0
  118. package/src/types/account.ts +1 -1
  119. package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +0 -6150
@@ -15,13 +15,12 @@ import {
15
15
  } from "../../account";
16
16
  import { listTokensForCryptoCurrency } from "../../currencies";
17
17
  import { encodeAccountId } from "../../account";
18
- import type { Operation, TokenAccount, Account, NFT } from "../../types";
18
+ import type { Operation, TokenAccount, Account } from "../../types";
19
19
  import { API, apiForCurrency, Tx } from "../../api/Ethereum";
20
20
  import { digestTokenAccounts, prepareTokenAccounts } from "./modules";
21
21
  import { findTokenByAddressInCurrency } from "@ledgerhq/cryptoassets";
22
- import { encodeNftId, nftsFromOperations } from "../../nft";
22
+ import { encodeNftId, isNFTActive, nftsFromOperations } from "../../nft";
23
23
  import { NFT_VERSION } from "./versions";
24
- import { getEnv } from "../../env";
25
24
 
26
25
  export const getAccountShape: GetAccountShape = async (
27
26
  infoInput,
@@ -41,24 +40,24 @@ export const getAccountShape: GetAccountShape = async (
41
40
  const initialStableOperations = initialAccount
42
41
  ? stableOperations(initialAccount)
43
42
  : [];
43
+ const shouldNFTBeActive = isNFTActive(currency);
44
44
  // fetch transactions, incrementally if possible
45
45
  const mostRecentStableOperation = initialStableOperations[0];
46
46
  // when new tokens are added / blacklist changes, we need to sync again because we need to go through all operations again
47
47
  const syncHash =
48
48
  JSON.stringify(blacklistedTokenIds || []) +
49
49
  "_" +
50
+ shouldNFTBeActive +
51
+ "_" +
50
52
  listTokensForCryptoCurrency(currency, {
51
53
  withDelisted: true,
52
54
  }).length;
53
- const outdatedBlacklist = initialAccount?.syncHash !== syncHash;
54
- const firstNftSync =
55
- getEnv("NFT") && typeof initialAccount?.nfts === "undefined";
55
+ const outdatedSyncHash = initialAccount?.syncHash !== syncHash;
56
56
  const pullFromBlockHash =
57
57
  initialAccount &&
58
58
  areAllOperationsLoaded(initialAccount) &&
59
59
  mostRecentStableOperation &&
60
- !outdatedBlacklist &&
61
- !firstNftSync &&
60
+ !outdatedSyncHash &&
62
61
  NFT_VERSION
63
62
  ? mostRecentStableOperation.blockHash
64
63
  : undefined;
@@ -83,10 +82,8 @@ export const getAccountShape: GetAccountShape = async (
83
82
  let newOps = flatMap(txs, txToOps({ address, id: accountId, currency }));
84
83
  // extracting out the sub operations by token account
85
84
  const perTokenAccountIdOperations = {};
86
- // extracting and concat all nft operations for an account
87
- const flatNftOps: Operation[] = [];
88
85
  newOps.forEach((op) => {
89
- const { subOperations, nftOperations } = op;
86
+ const { subOperations } = op;
90
87
 
91
88
  if (subOperations?.length) {
92
89
  subOperations.forEach((sop) => {
@@ -97,10 +94,6 @@ export const getAccountShape: GetAccountShape = async (
97
94
  perTokenAccountIdOperations[sop.accountId].push(sop);
98
95
  });
99
96
  }
100
-
101
- if (nftOperations?.length) {
102
- nftOperations.forEach((nop) => flatNftOps.push(nop));
103
- }
104
97
  });
105
98
  const subAccountsExisting = {};
106
99
  initialAccount?.subAccounts?.forEach((a) => {
@@ -173,8 +166,8 @@ export const getAccountShape: GetAccountShape = async (
173
166
  }));
174
167
  const operations = mergeOps(initialStableOperations, newOps);
175
168
 
176
- const nfts = getEnv("NFT")
177
- ? mergeNfts(initialAccount?.nfts, await getNfts(flatNftOps))
169
+ const nfts = isNFTActive(currency)
170
+ ? mergeNfts(initialAccount?.nfts, nftsFromOperations(operations))
178
171
  : undefined;
179
172
 
180
173
  const accountShape: Partial<Account> = {
@@ -334,91 +327,23 @@ const txToOps =
334
327
  });
335
328
 
336
329
  // Creating NFTOps from transfer events related to ERC721 only
337
- const erc721Operations = !erc721_transfer_events
338
- ? []
339
- : flatMap(erc721_transfer_events, (event) => {
340
- const sender = safeEncodeEIP55(event.sender);
341
- const receiver = safeEncodeEIP55(event.receiver);
342
- const contract = safeEncodeEIP55(event.contract);
343
- const tokenId = event.token_id;
344
- const nftId = encodeNftId(id, event.contract, tokenId);
345
- const sending = addr === sender;
346
- const receiving = addr === receiver;
347
-
348
- if (!sending && !receiving) {
349
- return [];
350
- }
351
-
352
- const all: Operation[] = [];
353
-
354
- if (sending) {
355
- const type = "NFT_OUT";
356
- all.push({
357
- id: `${nftId}-${hash}-${type}`,
358
- senders: [sender],
359
- recipients: [receiver],
360
- contract,
361
- fee,
362
- standard: "ERC721",
363
- tokenId,
364
- value: new BigNumber(1),
365
- hash,
366
- type,
367
- blockHeight,
368
- blockHash,
369
- date,
370
- transactionSequenceNumber,
371
- accountId: id,
372
- extra: {},
373
- });
374
- }
375
-
376
- if (receiving) {
377
- const type = "NFT_IN";
378
- all.push({
379
- id: `${nftId}-${hash}-${type}`,
380
- senders: [sender],
381
- recipients: [receiver],
382
- contract,
383
- fee,
384
- standard: "ERC721",
385
- tokenId,
386
- value: new BigNumber(1),
387
- hash,
388
- type,
389
- blockHeight,
390
- blockHash,
391
- date,
392
- transactionSequenceNumber,
393
- accountId: id,
394
- extra: {},
395
- });
396
- }
397
-
398
- return all;
399
- });
400
-
401
- // Creating NFTOps from transfer events related to ERC1155 only
402
- const erc1155Operations = !erc1155_transfer_events
403
- ? []
404
- : flatMap(erc1155_transfer_events, (event) => {
405
- const sender = safeEncodeEIP55(event.sender);
406
- const receiver = safeEncodeEIP55(event.receiver);
407
- const contract = safeEncodeEIP55(event.contract);
408
- const operator = safeEncodeEIP55(event.operator);
409
- const sending = addr === sender;
410
- const receiving = addr === receiver;
411
-
412
- if (!sending && !receiving) {
413
- return [];
414
- }
330
+ const erc721Operations =
331
+ !erc721_transfer_events || !isNFTActive(currency)
332
+ ? []
333
+ : flatMap(erc721_transfer_events, (event) => {
334
+ const sender = safeEncodeEIP55(event.sender);
335
+ const receiver = safeEncodeEIP55(event.receiver);
336
+ const contract = safeEncodeEIP55(event.contract);
337
+ const tokenId = event.token_id;
338
+ const nftId = encodeNftId(id, event.contract, tokenId);
339
+ const sending = addr === sender;
340
+ const receiving = addr === receiver;
415
341
 
416
- const all: Operation[] = [];
342
+ if (!sending && !receiving) {
343
+ return [];
344
+ }
417
345
 
418
- event.transfers.forEach((transfer) => {
419
- const tokenId = transfer.id;
420
- const value = new BigNumber(transfer.value);
421
- const nftId = encodeNftId(id, event.contract, tokenId);
346
+ const all: Operation[] = [];
422
347
 
423
348
  if (sending) {
424
349
  const type = "NFT_OUT";
@@ -428,10 +353,9 @@ const txToOps =
428
353
  recipients: [receiver],
429
354
  contract,
430
355
  fee,
431
- operator,
432
- standard: "ERC1155",
356
+ standard: "ERC721",
433
357
  tokenId,
434
- value,
358
+ value: new BigNumber(1),
435
359
  hash,
436
360
  type,
437
361
  blockHeight,
@@ -451,10 +375,9 @@ const txToOps =
451
375
  recipients: [receiver],
452
376
  contract,
453
377
  fee,
454
- operator,
455
- standard: "ERC1155",
378
+ standard: "ERC721",
456
379
  tokenId,
457
- value,
380
+ value: new BigNumber(1),
458
381
  hash,
459
382
  type,
460
383
  blockHeight,
@@ -465,15 +388,88 @@ const txToOps =
465
388
  extra: {},
466
389
  });
467
390
  }
391
+
392
+ return all;
468
393
  });
469
394
 
470
- return all;
471
- });
395
+ // Creating NFTOps from transfer events related to ERC1155 only
396
+ const erc1155Operations =
397
+ !erc1155_transfer_events || !isNFTActive(currency)
398
+ ? []
399
+ : flatMap(erc1155_transfer_events, (event) => {
400
+ const sender = safeEncodeEIP55(event.sender);
401
+ const receiver = safeEncodeEIP55(event.receiver);
402
+ const contract = safeEncodeEIP55(event.contract);
403
+ const operator = safeEncodeEIP55(event.operator);
404
+ const sending = addr === sender;
405
+ const receiving = addr === receiver;
406
+
407
+ if (!sending && !receiving) {
408
+ return [];
409
+ }
410
+
411
+ const all: Operation[] = [];
412
+
413
+ event.transfers.forEach((transfer) => {
414
+ const tokenId = transfer.id;
415
+ const value = new BigNumber(transfer.value);
416
+ const nftId = encodeNftId(id, event.contract, tokenId);
417
+
418
+ if (sending) {
419
+ const type = "NFT_OUT";
420
+ all.push({
421
+ id: `${nftId}-${hash}-${type}`,
422
+ senders: [sender],
423
+ recipients: [receiver],
424
+ contract,
425
+ fee,
426
+ operator,
427
+ standard: "ERC1155",
428
+ tokenId,
429
+ value,
430
+ hash,
431
+ type,
432
+ blockHeight,
433
+ blockHash,
434
+ date,
435
+ transactionSequenceNumber,
436
+ accountId: id,
437
+ extra: {},
438
+ });
439
+ }
440
+
441
+ if (receiving) {
442
+ const type = "NFT_IN";
443
+ all.push({
444
+ id: `${nftId}-${hash}-${type}`,
445
+ senders: [sender],
446
+ recipients: [receiver],
447
+ contract,
448
+ fee,
449
+ operator,
450
+ standard: "ERC1155",
451
+ tokenId,
452
+ value,
453
+ hash,
454
+ type,
455
+ blockHeight,
456
+ blockHash,
457
+ date,
458
+ transactionSequenceNumber,
459
+ accountId: id,
460
+ extra: {},
461
+ });
462
+ }
463
+ });
464
+
465
+ return all;
466
+ });
472
467
 
473
468
  const nftOperations = erc721Operations
474
469
  .concat(erc1155Operations)
475
470
  /** @warning is this necessary ? Do we need the operations to be chronologically organised for LLD/LLM ? */
476
471
  .sort((a, b) => b.date.getTime() - a.date.getTime());
472
+
477
473
  const ops: Operation[] = [];
478
474
 
479
475
  if (sending) {
@@ -619,11 +615,6 @@ async function loadERC20Balances(tokenAccounts, address, api) {
619
615
  .filter(Boolean);
620
616
  }
621
617
 
622
- function getNfts(nftOperations: Operation[]): NFT[] {
623
- const nfts: NFT[] = nftsFromOperations(nftOperations);
624
- return nfts.filter((nft) => nft.amount.gt(0));
625
- }
626
-
627
618
  const SAFE_REORG_THRESHOLD = 80;
628
619
 
629
620
  function stableOperations(a) {
@@ -86,15 +86,40 @@ export const formatTransaction = (
86
86
  (t.subAccountId &&
87
87
  (mainAccount.subAccounts || []).find((a) => a.id === t.subAccountId)) ||
88
88
  mainAccount;
89
+
90
+ const header = (() => {
91
+ switch (t.mode) {
92
+ case "erc721.transfer":
93
+ return `${t.mode.toUpperCase()} Collection: ${t.collection} (${
94
+ t.collectionName || ""
95
+ }) TokenId: ${t.tokenIds?.[0]}`;
96
+ case "erc1155.transfer":
97
+ return (
98
+ `${t.mode.toUpperCase()} Collection: ${t.collection} (${
99
+ t.collectionName || ""
100
+ })` +
101
+ t.tokenIds
102
+ ?.map((tokenId, index) => {
103
+ return `\n - TokenId: ${tokenId} Quantity: ${
104
+ t.quantities?.[index]?.toFixed() ?? 0
105
+ }`;
106
+ })
107
+ .join(",")
108
+ );
109
+ default:
110
+ return `${t.mode.toUpperCase()} ${
111
+ t.useAllAmount
112
+ ? "MAX"
113
+ : formatCurrencyUnit(getAccountUnit(account), t.amount, {
114
+ showCode: true,
115
+ disableRounding: true,
116
+ })
117
+ }`;
118
+ }
119
+ })();
120
+
89
121
  return `
90
- ${t.mode.toUpperCase()} ${
91
- t.useAllAmount
92
- ? "MAX"
93
- : formatCurrencyUnit(getAccountUnit(account), t.amount, {
94
- showCode: true,
95
- disableRounding: true,
96
- })
97
- }
122
+ ${header}
98
123
  TO ${t.recipient}
99
124
  with gasPrice=${formatCurrencyUnit(
100
125
  mainAccount.currency.units[1] || mainAccount.currency.units[0],
@@ -102,6 +127,7 @@ with gasPrice=${formatCurrencyUnit(
102
127
  )}
103
128
  with gasLimit=${gasLimit.toString()}`;
104
129
  };
130
+
105
131
  const defaultGasLimit = new BigNumber(0x5208);
106
132
  export const getGasLimit = (t: Transaction): BigNumber =>
107
133
  t.userGasLimit || t.estimatedGasLimit || defaultGasLimit;
@@ -127,6 +153,10 @@ export const fromTransactionRaw = (tr: TransactionRaw): Transaction => {
127
153
  },
128
154
  allowZeroAmount: tr.allowZeroAmount,
129
155
  feesStrategy: tr.feesStrategy,
156
+ tokenIds: tr.tokenIds,
157
+ collection: tr.collection,
158
+ collectionName: tr.collectionName,
159
+ quantities: tr.quantities?.map((q) => new BigNumber(q)),
130
160
  };
131
161
  };
132
162
  export const toTransactionRaw = (t: Transaction): TransactionRaw => {
@@ -151,6 +181,10 @@ export const toTransactionRaw = (t: Transaction): TransactionRaw => {
151
181
  },
152
182
  allowZeroAmount: t.allowZeroAmount,
153
183
  feesStrategy: t.feesStrategy,
184
+ tokenIds: t.tokenIds,
185
+ collection: t.collection,
186
+ collectionName: t.collectionName,
187
+ quantities: t.quantities?.map((q) => q.toString()),
154
188
  };
155
189
  };
156
190
 
@@ -37,6 +37,10 @@ export type Transaction = TransactionCommon & {
37
37
  feeCustomUnit: Unit | null | undefined;
38
38
  networkInfo: NetworkInfo | null | undefined;
39
39
  allowZeroAmount?: boolean;
40
+ collection?: string;
41
+ collectionName?: string;
42
+ tokenIds?: string[];
43
+ quantities?: BigNumber[];
40
44
  };
41
45
  export type TransactionRaw = TransactionCommonRaw & {
42
46
  family: "ethereum";
@@ -49,6 +53,10 @@ export type TransactionRaw = TransactionCommonRaw & {
49
53
  feeCustomUnit: Unit | null | undefined;
50
54
  networkInfo: NetworkInfoRaw | null | undefined;
51
55
  allowZeroAmount?: boolean;
56
+ tokenIds?: string[];
57
+ collection?: string;
58
+ collectionName?: string;
59
+ quantities?: string[];
52
60
  };
53
61
  export type TypedMessage = {
54
62
  types: {
@@ -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),
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
+ }
@@ -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;