@ledgerhq/live-common 21.13.2 → 21.16.0

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 (221) hide show
  1. package/lib/__tests__/derivation.js +1 -1
  2. package/lib/__tests__/derivation.js.map +1 -1
  3. package/lib/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.js +2 -2
  4. package/lib/account/groupOperations.js +1 -1
  5. package/lib/account/groupOperations.js.map +1 -1
  6. package/lib/account/pending.d.ts +1 -0
  7. package/lib/account/pending.d.ts.map +1 -1
  8. package/lib/account/serialization.d.ts +6 -4
  9. package/lib/account/serialization.d.ts.map +1 -1
  10. package/lib/account/serialization.js +47 -9
  11. package/lib/account/serialization.js.map +1 -1
  12. package/lib/api/Ethereum.d.ts +22 -1
  13. package/lib/api/Ethereum.d.ts.map +1 -1
  14. package/lib/api/Ethereum.js +21 -1
  15. package/lib/api/Ethereum.js.map +1 -1
  16. package/lib/apps/polyfill.d.ts.map +1 -1
  17. package/lib/apps/polyfill.js +1 -0
  18. package/lib/apps/polyfill.js.map +1 -1
  19. package/lib/bridge/jsHelpers.d.ts +2 -1
  20. package/lib/bridge/jsHelpers.d.ts.map +1 -1
  21. package/lib/bridge/jsHelpers.js +27 -1
  22. package/lib/bridge/jsHelpers.js.map +1 -1
  23. package/lib/csvExport.d.ts.map +1 -1
  24. package/lib/csvExport.js +3 -1
  25. package/lib/csvExport.js.map +1 -1
  26. package/lib/currencies/sortByMarketcap.d.ts.map +1 -1
  27. package/lib/currencies/sortByMarketcap.js +8 -1
  28. package/lib/currencies/sortByMarketcap.js.map +1 -1
  29. package/lib/derivation.js +1 -1
  30. package/lib/derivation.js.map +1 -1
  31. package/lib/env.d.ts +15 -5
  32. package/lib/env.d.ts.map +1 -1
  33. package/lib/env.js +12 -1
  34. package/lib/env.js.map +1 -1
  35. package/lib/env.react.d.ts +1 -1
  36. package/lib/env.react.d.ts.map +1 -1
  37. package/lib/families/bitcoin/cache.d.ts +1 -0
  38. package/lib/families/bitcoin/cache.d.ts.map +1 -1
  39. package/lib/families/bitcoin/cache.js +7 -1
  40. package/lib/families/bitcoin/cache.js.map +1 -1
  41. package/lib/families/bitcoin/errors.d.ts +4 -0
  42. package/lib/families/bitcoin/errors.d.ts.map +1 -0
  43. package/lib/families/bitcoin/errors.js +6 -0
  44. package/lib/families/bitcoin/errors.js.map +1 -0
  45. package/lib/families/bitcoin/js-getTransactionStatus.d.ts.map +1 -1
  46. package/lib/families/bitcoin/js-getTransactionStatus.js +24 -11
  47. package/lib/families/bitcoin/js-getTransactionStatus.js.map +1 -1
  48. package/lib/families/bitcoin/js-synchronisation.d.ts.map +1 -1
  49. package/lib/families/bitcoin/js-synchronisation.js +8 -19
  50. package/lib/families/bitcoin/js-synchronisation.js.map +1 -1
  51. package/lib/families/bitcoin/logic.d.ts +1 -1
  52. package/lib/families/bitcoin/logic.d.ts.map +1 -1
  53. package/lib/families/bitcoin/logic.js +6 -0
  54. package/lib/families/bitcoin/logic.js.map +1 -1
  55. package/lib/families/bitcoin/specs.d.ts.map +1 -1
  56. package/lib/families/bitcoin/specs.js +2 -1
  57. package/lib/families/bitcoin/specs.js.map +1 -1
  58. package/lib/families/bitcoin/test-dataset.js +2 -2
  59. package/lib/families/bitcoin/test-dataset.js.map +1 -1
  60. package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts +4 -0
  61. package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts.map +1 -1
  62. package/lib/families/bitcoin/wallet-btc/crypto/base.js +36 -5
  63. package/lib/families/bitcoin/wallet-btc/crypto/base.js.map +1 -1
  64. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.d.ts +1 -0
  65. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.d.ts.map +1 -1
  66. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js +19 -1
  67. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js.map +1 -1
  68. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.d.ts +1 -0
  69. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.d.ts.map +1 -1
  70. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js +4 -0
  71. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js.map +1 -1
  72. package/lib/families/bitcoin/wallet-btc/crypto/types.d.ts +1 -0
  73. package/lib/families/bitcoin/wallet-btc/crypto/types.d.ts.map +1 -1
  74. package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts +1 -0
  75. package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts.map +1 -1
  76. package/lib/families/bitcoin/wallet-btc/crypto/zec.js +4 -0
  77. package/lib/families/bitcoin/wallet-btc/crypto/zec.js.map +1 -1
  78. package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts +1 -0
  79. package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts.map +1 -1
  80. package/lib/families/bitcoin/wallet-btc/crypto/zen.js +4 -0
  81. package/lib/families/bitcoin/wallet-btc/crypto/zen.js.map +1 -1
  82. package/lib/families/bitcoin/wallet-btc/explorer/index.d.ts.map +1 -1
  83. package/lib/families/bitcoin/wallet-btc/explorer/index.js +0 -3
  84. package/lib/families/bitcoin/wallet-btc/explorer/index.js.map +1 -1
  85. package/lib/families/bitcoin/wallet-btc/index.d.ts +2 -2
  86. package/lib/families/bitcoin/wallet-btc/index.d.ts.map +1 -1
  87. package/lib/families/bitcoin/wallet-btc/index.js +4 -5
  88. package/lib/families/bitcoin/wallet-btc/index.js.map +1 -1
  89. package/lib/families/bitcoin/wallet-btc/pickingstrategies/CoinSelect.js +3 -3
  90. package/lib/families/bitcoin/wallet-btc/pickingstrategies/DeepFirst.js +5 -5
  91. package/lib/families/bitcoin/wallet-btc/pickingstrategies/Merge.js +5 -5
  92. package/lib/families/bitcoin/wallet-btc/utils.d.ts +3 -1
  93. package/lib/families/bitcoin/wallet-btc/utils.d.ts.map +1 -1
  94. package/lib/families/bitcoin/wallet-btc/utils.js +30 -10
  95. package/lib/families/bitcoin/wallet-btc/utils.js.map +1 -1
  96. package/lib/families/bitcoin/wallet-btc/wallet.d.ts.map +1 -1
  97. package/lib/families/bitcoin/wallet-btc/wallet.js +5 -3
  98. package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
  99. package/lib/families/bitcoin/wallet-btc/xpub.d.ts +2 -6
  100. package/lib/families/bitcoin/wallet-btc/xpub.d.ts.map +1 -1
  101. package/lib/families/bitcoin/wallet-btc/xpub.js +62 -52
  102. package/lib/families/bitcoin/wallet-btc/xpub.js.map +1 -1
  103. package/lib/families/elrond/js-getTransactionStatus.d.ts.map +1 -1
  104. package/lib/families/elrond/js-getTransactionStatus.js +3 -0
  105. package/lib/families/elrond/js-getTransactionStatus.js.map +1 -1
  106. package/lib/families/elrond/js-signOperation.d.ts.map +1 -1
  107. package/lib/families/elrond/js-signOperation.js +3 -1
  108. package/lib/families/elrond/js-signOperation.js.map +1 -1
  109. package/lib/families/ethereum/signOperation.d.ts.map +1 -1
  110. package/lib/families/ethereum/signOperation.js +7 -0
  111. package/lib/families/ethereum/signOperation.js.map +1 -1
  112. package/lib/families/ethereum/specs.d.ts +1 -0
  113. package/lib/families/ethereum/specs.d.ts.map +1 -1
  114. package/lib/families/ethereum/specs.js +41 -0
  115. package/lib/families/ethereum/specs.js.map +1 -1
  116. package/lib/families/ethereum/synchronisation.d.ts.map +1 -1
  117. package/lib/families/ethereum/synchronisation.js +175 -15
  118. package/lib/families/ethereum/synchronisation.js.map +1 -1
  119. package/lib/families/ethereum/versions.d.ts +2 -0
  120. package/lib/families/ethereum/versions.d.ts.map +1 -0
  121. package/lib/families/ethereum/versions.js +5 -0
  122. package/lib/families/ethereum/versions.js.map +1 -0
  123. package/lib/generated/specs.d.ts +1 -0
  124. package/lib/generated/specs.d.ts.map +1 -1
  125. package/lib/nft/NftMetadataProvider/index.d.ts +10 -0
  126. package/lib/nft/NftMetadataProvider/index.d.ts.map +1 -0
  127. package/lib/nft/NftMetadataProvider/index.js +244 -0
  128. package/lib/nft/NftMetadataProvider/index.js.map +1 -0
  129. package/lib/nft/NftMetadataProvider/logic.d.ts +3 -0
  130. package/lib/nft/NftMetadataProvider/logic.d.ts.map +1 -0
  131. package/lib/nft/NftMetadataProvider/logic.js +22 -0
  132. package/lib/nft/NftMetadataProvider/logic.js.map +1 -0
  133. package/lib/nft/NftMetadataProvider/types.d.ts +44 -0
  134. package/lib/nft/NftMetadataProvider/types.d.ts.map +1 -0
  135. package/lib/nft/NftMetadataProvider/types.js +3 -0
  136. package/lib/nft/NftMetadataProvider/types.js.map +1 -0
  137. package/lib/nft/helpers.d.ts +10 -0
  138. package/lib/nft/helpers.d.ts.map +1 -0
  139. package/lib/nft/helpers.js +85 -0
  140. package/lib/nft/helpers.js.map +1 -0
  141. package/lib/nft/index.d.ts +4 -0
  142. package/lib/nft/index.d.ts.map +1 -0
  143. package/lib/nft/index.js +16 -0
  144. package/lib/nft/index.js.map +1 -0
  145. package/lib/nft/nftId.d.ts +3 -0
  146. package/lib/nft/nftId.d.ts.map +1 -0
  147. package/lib/nft/nftId.js +33 -0
  148. package/lib/nft/nftId.js.map +1 -0
  149. package/lib/operation.d.ts +1 -1
  150. package/lib/operation.d.ts.map +1 -1
  151. package/lib/operation.js +19 -5
  152. package/lib/operation.js.map +1 -1
  153. package/lib/reconciliation.d.ts.map +1 -1
  154. package/lib/reconciliation.js +6 -0
  155. package/lib/reconciliation.js.map +1 -1
  156. package/lib/types/account.d.ts +3 -0
  157. package/lib/types/account.d.ts.map +1 -1
  158. package/lib/types/index.d.ts +1 -0
  159. package/lib/types/index.d.ts.map +1 -1
  160. package/lib/types/index.js +1 -0
  161. package/lib/types/index.js.map +1 -1
  162. package/lib/types/nft.d.ts +29 -0
  163. package/lib/types/nft.d.ts.map +1 -0
  164. package/lib/types/nft.js +3 -0
  165. package/lib/types/nft.js.map +1 -0
  166. package/lib/types/operation.d.ts +12 -1
  167. package/lib/types/operation.d.ts.map +1 -1
  168. package/package.json +13 -13
  169. package/src/__tests__/__snapshots__/all.libcore.ts.snap +64428 -57815
  170. package/src/__tests__/derivation.ts +1 -1
  171. package/src/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.ts +2 -2
  172. package/src/account/groupOperations.ts +2 -2
  173. package/src/account/serialization.ts +52 -0
  174. package/src/api/Ethereum.ts +40 -2
  175. package/src/apps/polyfill.ts +1 -0
  176. package/src/bridge/jsHelpers.ts +35 -0
  177. package/src/csvExport.ts +3 -2
  178. package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +1361 -1
  179. package/src/currencies/sortByMarketcap.ts +9 -1
  180. package/src/derivation.ts +1 -1
  181. package/src/env.ts +12 -1
  182. package/src/families/bitcoin/cache.ts +12 -0
  183. package/src/families/bitcoin/errors.ts +5 -0
  184. package/src/families/bitcoin/js-getTransactionStatus.ts +15 -1
  185. package/src/families/bitcoin/js-synchronisation.ts +11 -25
  186. package/src/families/bitcoin/logic.ts +7 -2
  187. package/src/families/bitcoin/specs.ts +6 -1
  188. package/src/families/bitcoin/test-dataset.ts +2 -2
  189. package/src/families/bitcoin/wallet-btc/crypto/base.ts +40 -5
  190. package/src/families/bitcoin/wallet-btc/crypto/bitcoin.ts +21 -1
  191. package/src/families/bitcoin/wallet-btc/crypto/bitcoincash.ts +5 -0
  192. package/src/families/bitcoin/wallet-btc/crypto/types.ts +1 -0
  193. package/src/families/bitcoin/wallet-btc/crypto/zec.ts +5 -0
  194. package/src/families/bitcoin/wallet-btc/crypto/zen.ts +5 -0
  195. package/src/families/bitcoin/wallet-btc/explorer/index.ts +0 -5
  196. package/src/families/bitcoin/wallet-btc/index.ts +4 -4
  197. package/src/families/bitcoin/wallet-btc/pickingstrategies/CoinSelect.ts +3 -3
  198. package/src/families/bitcoin/wallet-btc/pickingstrategies/DeepFirst.ts +5 -5
  199. package/src/families/bitcoin/wallet-btc/pickingstrategies/Merge.ts +5 -5
  200. package/src/families/bitcoin/wallet-btc/utils.ts +34 -9
  201. package/src/families/bitcoin/wallet-btc/wallet.ts +4 -2
  202. package/src/families/bitcoin/wallet-btc/xpub.ts +37 -53
  203. package/src/families/elrond/js-getTransactionStatus.ts +4 -0
  204. package/src/families/elrond/js-signOperation.ts +3 -1
  205. package/src/families/ethereum/modules/__snapshots__/compound.resilience.test.ts.snap +2876 -0
  206. package/src/families/ethereum/signOperation.ts +8 -0
  207. package/src/families/ethereum/specs.ts +47 -0
  208. package/src/families/ethereum/synchronisation.ts +185 -6
  209. package/src/families/ethereum/versions.ts +1 -0
  210. package/src/nft/NftMetadataProvider/index.tsx +205 -0
  211. package/src/nft/NftMetadataProvider/logic.ts +20 -0
  212. package/src/nft/NftMetadataProvider/types.ts +60 -0
  213. package/src/nft/helpers.ts +78 -0
  214. package/src/nft/index.ts +3 -0
  215. package/src/nft/nftId.ts +17 -0
  216. package/src/operation.ts +22 -3
  217. package/src/reconciliation.ts +7 -0
  218. package/src/types/account.ts +4 -0
  219. package/src/types/index.ts +1 -0
  220. package/src/types/nft.ts +38 -0
  221. package/src/types/operation.ts +23 -1
@@ -0,0 +1,78 @@
1
+ import eip55 from "eip55";
2
+ import BigNumber from "bignumber.js";
3
+ import { NFT, Operation } from "../types";
4
+
5
+ type Collection = NFT["collection"];
6
+
7
+ type CollectionMap<C> = Record<string, C>;
8
+
9
+ export type CollectionWithNFT = Collection & {
10
+ nfts: Array<Omit<NFT, "collection">>;
11
+ };
12
+
13
+ export const nftsFromOperations = (ops: Operation[]): NFT[] => {
14
+ const nftsMap = ops
15
+ // if ops are Operations get the prop nftOperations, else ops are considered nftOperations already
16
+ .flatMap((op) => (op?.nftOperations?.length ? op.nftOperations : op))
17
+ .reduce((acc: Record<string, NFT>, nftOp: Operation) => {
18
+ if (!nftOp?.contract) {
19
+ return acc;
20
+ }
21
+
22
+ // Creating a "token for a contract" unique key
23
+ const contract = eip55.encode(nftOp.contract!);
24
+ const nftKey = contract + nftOp.tokenId!;
25
+ const { tokenId, standard, id } = nftOp;
26
+
27
+ const nft = (acc[nftKey] ?? {
28
+ id,
29
+ tokenId: tokenId!,
30
+ amount: new BigNumber(0),
31
+ collection: {
32
+ contract,
33
+ standard: standard!,
34
+ },
35
+ }) as NFT;
36
+
37
+ if (nftOp.type === "NFT_IN") {
38
+ nft.amount = nft.amount.plus(nftOp.value);
39
+ } else if (nftOp.type === "NFT_OUT") {
40
+ nft.amount = nft.amount.minus(nftOp.value);
41
+ }
42
+
43
+ acc[nftKey] = nft;
44
+
45
+ return acc;
46
+ }, {});
47
+
48
+ return Object.values(nftsMap);
49
+ };
50
+
51
+ export const nftsByCollections = (
52
+ nfts: NFT[] = [],
53
+ collectionAddress?: string
54
+ ): CollectionWithNFT[] => {
55
+ const filteredNfts = collectionAddress
56
+ ? nfts.filter((n) => n.collection.contract === collectionAddress)
57
+ : nfts;
58
+
59
+ const collectionMap = filteredNfts.reduce(
60
+ (acc: CollectionMap<CollectionWithNFT>, nft: NFT) => {
61
+ const { collection, ...nftWithoutCollection } = nft;
62
+
63
+ if (!acc[collection.contract]) {
64
+ acc[collection.contract] = { ...collection, nfts: [] };
65
+ }
66
+ acc[collection.contract].nfts.push(nftWithoutCollection);
67
+
68
+ return acc;
69
+ },
70
+ {} as CollectionMap<CollectionWithNFT>
71
+ );
72
+
73
+ return Object.values(collectionMap);
74
+ };
75
+
76
+ export const getNftKey = (contract: string, tokenId: string): string => {
77
+ return `${contract}-${tokenId}`;
78
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./nftId";
2
+ export * from "./helpers";
3
+ export * from "./NftMetadataProvider";
@@ -0,0 +1,17 @@
1
+ export const encodeNftId = (
2
+ accountId: string,
3
+ contract: string,
4
+ tokenId: string
5
+ ): string => {
6
+ return `${accountId}+${contract}+${tokenId.toString()}`;
7
+ };
8
+
9
+ export const decodeNftId = (id: string): unknown => {
10
+ const [accountId, contract, tokenId] = id.split("+");
11
+
12
+ return {
13
+ accountId,
14
+ contract,
15
+ tokenId,
16
+ };
17
+ };
package/src/operation.ts CHANGED
@@ -17,6 +17,16 @@ export function findOperationInAccount(
17
17
  if (internalOp.id === operationId) return internalOp;
18
18
  }
19
19
  }
20
+
21
+ if (op.nftOperations) {
22
+ const nftOps = op.nftOperations;
23
+
24
+ for (let j = 0; j < nftOps.length; j++) {
25
+ const nftOp = nftOps[j];
26
+
27
+ if (nftOp.id === operationId) return nftOp;
28
+ }
29
+ }
20
30
  }
21
31
 
22
32
  for (let i = 0; i < pendingOperations.length; i++) {
@@ -66,7 +76,9 @@ export function patchOperationWithHash(
66
76
  };
67
77
  }
68
78
 
69
- export function flattenOperationWithInternals(op: Operation): Operation[] {
79
+ export function flattenOperationWithInternalsAndNfts(
80
+ op: Operation
81
+ ): Operation[] {
70
82
  let ops: Operation[] = [];
71
83
 
72
84
  // ops of type NONE does not appear in lists
@@ -79,6 +91,11 @@ export function flattenOperationWithInternals(op: Operation): Operation[] {
79
91
  ops = ops.concat(op.internalOperations);
80
92
  }
81
93
 
94
+ // all nfts operations are expanded after the main op
95
+ if (op.nftOperations) {
96
+ ops = ops.concat(op.nftOperations);
97
+ }
98
+
82
99
  return ops;
83
100
  }
84
101
 
@@ -88,6 +105,7 @@ export function getOperationAmountNumber(op: Operation): BigNumber {
88
105
  case "REWARD":
89
106
  case "REWARD_PAYOUT":
90
107
  case "SUPPLY":
108
+ case "NFT_IN":
91
109
  return op.value;
92
110
 
93
111
  case "OUT":
@@ -101,6 +119,7 @@ export function getOperationAmountNumber(op: Operation): BigNumber {
101
119
  case "OPT_OUT":
102
120
  case "REDEEM":
103
121
  case "SLASH":
122
+ case "NFT_OUT":
104
123
  return op.value.negated();
105
124
 
106
125
  case "FREEZE":
@@ -122,7 +141,7 @@ export function getOperationAmountNumber(op: Operation): BigNumber {
122
141
  export function getOperationAmountNumberWithInternals(
123
142
  op: Operation
124
143
  ): BigNumber {
125
- return flattenOperationWithInternals(op).reduce(
144
+ return flattenOperationWithInternalsAndNfts(op).reduce(
126
145
  (amount: BigNumber, op) => amount.plus(getOperationAmountNumber(op)),
127
146
  new BigNumber(0)
128
147
  );
@@ -148,5 +167,5 @@ export const isConfirmedOperation = (
148
167
  confirmationsNb: number
149
168
  ): boolean =>
150
169
  operation.blockHeight
151
- ? account.blockHeight - operation.blockHeight > confirmationsNb
170
+ ? account.blockHeight - operation.blockHeight + 1 > confirmationsNb
152
171
  : false;
@@ -27,6 +27,7 @@ import {
27
27
  fromTezosResourcesRaw,
28
28
  fromElrondResourcesRaw,
29
29
  fromCryptoOrgResourcesRaw,
30
+ fromNFTRaw,
30
31
  } from "./account";
31
32
  import consoleWarnExpectToEqual from "./consoleWarnExpectToEqual";
32
33
 
@@ -382,6 +383,12 @@ export function patchAccount(
382
383
  changed = true;
383
384
  }
384
385
 
386
+ const nfts = updatedRaw?.nfts?.map(fromNFTRaw);
387
+ if (updatedRaw.nfts && !isEqual(account.nfts, nfts)) {
388
+ next.nfts = nfts;
389
+ changed = true;
390
+ }
391
+
385
392
  if (!changed) return account; // nothing changed at all
386
393
 
387
394
  return next;
@@ -37,6 +37,7 @@ import type {
37
37
  PortfolioRange,
38
38
  } from "./portfolio";
39
39
  import type { SwapOperation, SwapOperationRaw } from "../exchange/swap/types";
40
+ import type { NFT, NFTRaw } from "./nft";
40
41
  // This is the old cache and now DEPRECATED (pre v2 portfoli)
41
42
  export type BalanceHistoryMap = Partial<Record<PortfolioRange, BalanceHistory>>;
42
43
  export type BalanceHistoryRawMap = Record<PortfolioRange, BalanceHistoryRaw>;
@@ -214,6 +215,8 @@ export type Account = {
214
215
  swapHistory: SwapOperation[];
215
216
  // Hash used to discard tx history on sync
216
217
  syncHash?: string;
218
+ // Array of NFTs computed by diffing NFTOperations
219
+ nfts?: NFT[];
217
220
  };
218
221
  export type SubAccount = TokenAccount | ChildAccount;
219
222
  export type AccountLike = Account | SubAccount;
@@ -299,6 +302,7 @@ export type AccountRaw = {
299
302
  cryptoOrgResources?: CryptoOrgResourcesRaw;
300
303
  swapHistory?: SwapOperationRaw[];
301
304
  syncHash?: string;
305
+ nfts?: NFTRaw[];
302
306
  };
303
307
  export type SubAccountRaw = TokenAccountRaw | ChildAccountRaw;
304
308
  export type AccountRawLike = AccountRaw | SubAccountRaw;
@@ -9,3 +9,4 @@ export * from "./transaction";
9
9
  export * from "../generated/types";
10
10
  export * from "./bridge";
11
11
  export * from "./pagination";
12
+ export * from "./nft";
@@ -0,0 +1,38 @@
1
+ import type BigNumber from "bignumber.js";
2
+
3
+ export type NFTStandards = "ERC721" | "ERC1155";
4
+
5
+ export type NFT = {
6
+ // id crafted by live
7
+ id: string;
8
+ // id on chain
9
+ tokenId: string;
10
+ amount: BigNumber;
11
+ collection: {
12
+ // contract address. Careful 1 contract address != 1 collection as some collections are off-chain
13
+ // So 1 contract address from OpenSea for example can reprensent an infinity of collections
14
+ contract: string;
15
+ // Carefull to non spec compliant NFTs (cryptopunks, cryptokitties, ethrock, and others?)
16
+ standard: NFTStandards | string;
17
+ };
18
+ };
19
+
20
+ export type NFTRaw = Omit<NFT, "amount"> & {
21
+ amount: string;
22
+ };
23
+
24
+ export type NFTMetadataLinksProviders = "opensea" | "rarible" | "etherscan";
25
+
26
+ export type NFTMetadataResponse = {
27
+ status: 200 | 404 | 500;
28
+ result?: {
29
+ contract: string;
30
+ tokenId: string;
31
+ tokenName: string | null;
32
+ nftName: string | null;
33
+ media: string | null;
34
+ description: string | null;
35
+ properties: Array<Record<"key" | "value", string>>;
36
+ links: Record<NFTMetadataLinksProviders, string>;
37
+ } | null;
38
+ };
@@ -1,4 +1,6 @@
1
1
  import type { BigNumber } from "bignumber.js";
2
+ import { NFTStandards } from "./nft";
3
+
2
4
  export type OperationType =
3
5
  | "IN"
4
6
  | "OUT"
@@ -26,7 +28,9 @@ export type OperationType =
26
28
  | "APPROVE"
27
29
  | "OPT_IN"
28
30
  | "OPT_OUT"
29
- | "CLOSE_ACCOUNT";
31
+ | "CLOSE_ACCOUNT"
32
+ | "NFT_IN"
33
+ | "NFT_OUT";
30
34
  export type Operation = {
31
35
  // unique identifier (usually hash)
32
36
  id: string;
@@ -54,6 +58,15 @@ export type Operation = {
54
58
  transactionSequenceNumber?: number;
55
59
  // the account id. available for convenient reason
56
60
  accountId: string;
61
+ // --------------------------------------------- properties related to NFTs
62
+ // the specification used for the transaction's event
63
+ standard?: NFTStandards | string;
64
+ // address of an account/contract that is approved to make the transfer
65
+ operator?: string;
66
+ // address of the contract/collection containing an NFT (tokenId)
67
+ contract?: string;
68
+ // Id of an NFT inside its collection/contract
69
+ tokenId?: string;
57
70
  // --------------------------------------------- specific operation raw fields
58
71
  // transaction date
59
72
  date: Date;
@@ -67,6 +80,8 @@ export type Operation = {
67
80
  // in context of accounts that have internal transactions that belong to a parent transaction
68
81
  // we have internal operations. Those are not included in the top level operations but can be presented to UI at that same level
69
82
  internalOperations?: Operation[];
83
+ // Operations related to ERC721 | ERC1155 tokens
84
+ nftOperations?: Operation[];
70
85
  };
71
86
  export type OperationRaw = {
72
87
  id: string;
@@ -81,6 +96,11 @@ export type OperationRaw = {
81
96
  transactionSequenceNumber?: number;
82
97
  accountId: string;
83
98
  hasFailed?: boolean;
99
+ // --------------------------------------------- properties related to NFTs
100
+ standard?: NFTStandards | string;
101
+ operator?: string;
102
+ contract?: string;
103
+ tokenId?: string;
84
104
  // --------------------------------------------- specific operation raw fields
85
105
  date: string;
86
106
  extra: Record<string, any>;
@@ -89,4 +109,6 @@ export type OperationRaw = {
89
109
  // in context of accounts that have internal transactions that belong to a parent transaction
90
110
  // we have internal operations. Those are not included in the top level operations but can be presented to UI at that same level
91
111
  internalOperations?: OperationRaw[];
112
+ // Operations related to ERC721 | ERC1155 tokens
113
+ nftOperations?: OperationRaw[];
92
114
  };