@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.
- package/lib/__tests__/derivation.js +1 -1
- package/lib/__tests__/derivation.js.map +1 -1
- package/lib/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.js +2 -2
- package/lib/account/groupOperations.js +1 -1
- package/lib/account/groupOperations.js.map +1 -1
- package/lib/account/pending.d.ts +1 -0
- package/lib/account/pending.d.ts.map +1 -1
- package/lib/account/serialization.d.ts +6 -4
- package/lib/account/serialization.d.ts.map +1 -1
- package/lib/account/serialization.js +47 -9
- package/lib/account/serialization.js.map +1 -1
- package/lib/api/Ethereum.d.ts +22 -1
- package/lib/api/Ethereum.d.ts.map +1 -1
- package/lib/api/Ethereum.js +21 -1
- package/lib/api/Ethereum.js.map +1 -1
- package/lib/apps/polyfill.d.ts.map +1 -1
- package/lib/apps/polyfill.js +1 -0
- package/lib/apps/polyfill.js.map +1 -1
- package/lib/bridge/jsHelpers.d.ts +2 -1
- package/lib/bridge/jsHelpers.d.ts.map +1 -1
- package/lib/bridge/jsHelpers.js +27 -1
- package/lib/bridge/jsHelpers.js.map +1 -1
- package/lib/csvExport.d.ts.map +1 -1
- package/lib/csvExport.js +3 -1
- package/lib/csvExport.js.map +1 -1
- package/lib/currencies/sortByMarketcap.d.ts.map +1 -1
- package/lib/currencies/sortByMarketcap.js +8 -1
- package/lib/currencies/sortByMarketcap.js.map +1 -1
- package/lib/derivation.js +1 -1
- package/lib/derivation.js.map +1 -1
- package/lib/env.d.ts +15 -5
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +12 -1
- package/lib/env.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/families/bitcoin/cache.d.ts +1 -0
- package/lib/families/bitcoin/cache.d.ts.map +1 -1
- package/lib/families/bitcoin/cache.js +7 -1
- package/lib/families/bitcoin/cache.js.map +1 -1
- package/lib/families/bitcoin/errors.d.ts +4 -0
- package/lib/families/bitcoin/errors.d.ts.map +1 -0
- package/lib/families/bitcoin/errors.js +6 -0
- package/lib/families/bitcoin/errors.js.map +1 -0
- package/lib/families/bitcoin/js-getTransactionStatus.d.ts.map +1 -1
- package/lib/families/bitcoin/js-getTransactionStatus.js +24 -11
- package/lib/families/bitcoin/js-getTransactionStatus.js.map +1 -1
- package/lib/families/bitcoin/js-synchronisation.d.ts.map +1 -1
- package/lib/families/bitcoin/js-synchronisation.js +8 -19
- package/lib/families/bitcoin/js-synchronisation.js.map +1 -1
- package/lib/families/bitcoin/logic.d.ts +1 -1
- package/lib/families/bitcoin/logic.d.ts.map +1 -1
- package/lib/families/bitcoin/logic.js +6 -0
- package/lib/families/bitcoin/logic.js.map +1 -1
- package/lib/families/bitcoin/specs.d.ts.map +1 -1
- package/lib/families/bitcoin/specs.js +2 -1
- package/lib/families/bitcoin/specs.js.map +1 -1
- package/lib/families/bitcoin/test-dataset.js +2 -2
- package/lib/families/bitcoin/test-dataset.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts +4 -0
- package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/base.js +36 -5
- package/lib/families/bitcoin/wallet-btc/crypto/base.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.d.ts +1 -0
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js +19 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.d.ts +1 -0
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js +4 -0
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/types.d.ts +1 -0
- package/lib/families/bitcoin/wallet-btc/crypto/types.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts +1 -0
- package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zec.js +4 -0
- package/lib/families/bitcoin/wallet-btc/crypto/zec.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts +1 -0
- package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zen.js +4 -0
- package/lib/families/bitcoin/wallet-btc/crypto/zen.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/explorer/index.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/explorer/index.js +0 -3
- package/lib/families/bitcoin/wallet-btc/explorer/index.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/index.d.ts +2 -2
- package/lib/families/bitcoin/wallet-btc/index.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/index.js +4 -5
- package/lib/families/bitcoin/wallet-btc/index.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/pickingstrategies/CoinSelect.js +3 -3
- package/lib/families/bitcoin/wallet-btc/pickingstrategies/DeepFirst.js +5 -5
- package/lib/families/bitcoin/wallet-btc/pickingstrategies/Merge.js +5 -5
- package/lib/families/bitcoin/wallet-btc/utils.d.ts +3 -1
- package/lib/families/bitcoin/wallet-btc/utils.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/utils.js +30 -10
- package/lib/families/bitcoin/wallet-btc/utils.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/wallet.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/wallet.js +5 -3
- package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/xpub.d.ts +2 -6
- package/lib/families/bitcoin/wallet-btc/xpub.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/xpub.js +62 -52
- package/lib/families/bitcoin/wallet-btc/xpub.js.map +1 -1
- package/lib/families/elrond/js-getTransactionStatus.d.ts.map +1 -1
- package/lib/families/elrond/js-getTransactionStatus.js +3 -0
- package/lib/families/elrond/js-getTransactionStatus.js.map +1 -1
- package/lib/families/elrond/js-signOperation.d.ts.map +1 -1
- package/lib/families/elrond/js-signOperation.js +3 -1
- package/lib/families/elrond/js-signOperation.js.map +1 -1
- package/lib/families/ethereum/signOperation.d.ts.map +1 -1
- package/lib/families/ethereum/signOperation.js +7 -0
- package/lib/families/ethereum/signOperation.js.map +1 -1
- package/lib/families/ethereum/specs.d.ts +1 -0
- package/lib/families/ethereum/specs.d.ts.map +1 -1
- package/lib/families/ethereum/specs.js +41 -0
- package/lib/families/ethereum/specs.js.map +1 -1
- package/lib/families/ethereum/synchronisation.d.ts.map +1 -1
- package/lib/families/ethereum/synchronisation.js +175 -15
- package/lib/families/ethereum/synchronisation.js.map +1 -1
- package/lib/families/ethereum/versions.d.ts +2 -0
- package/lib/families/ethereum/versions.d.ts.map +1 -0
- package/lib/families/ethereum/versions.js +5 -0
- package/lib/families/ethereum/versions.js.map +1 -0
- package/lib/generated/specs.d.ts +1 -0
- package/lib/generated/specs.d.ts.map +1 -1
- package/lib/nft/NftMetadataProvider/index.d.ts +10 -0
- package/lib/nft/NftMetadataProvider/index.d.ts.map +1 -0
- package/lib/nft/NftMetadataProvider/index.js +244 -0
- package/lib/nft/NftMetadataProvider/index.js.map +1 -0
- package/lib/nft/NftMetadataProvider/logic.d.ts +3 -0
- package/lib/nft/NftMetadataProvider/logic.d.ts.map +1 -0
- package/lib/nft/NftMetadataProvider/logic.js +22 -0
- package/lib/nft/NftMetadataProvider/logic.js.map +1 -0
- package/lib/nft/NftMetadataProvider/types.d.ts +44 -0
- package/lib/nft/NftMetadataProvider/types.d.ts.map +1 -0
- package/lib/nft/NftMetadataProvider/types.js +3 -0
- package/lib/nft/NftMetadataProvider/types.js.map +1 -0
- package/lib/nft/helpers.d.ts +10 -0
- package/lib/nft/helpers.d.ts.map +1 -0
- package/lib/nft/helpers.js +85 -0
- package/lib/nft/helpers.js.map +1 -0
- package/lib/nft/index.d.ts +4 -0
- package/lib/nft/index.d.ts.map +1 -0
- package/lib/nft/index.js +16 -0
- package/lib/nft/index.js.map +1 -0
- package/lib/nft/nftId.d.ts +3 -0
- package/lib/nft/nftId.d.ts.map +1 -0
- package/lib/nft/nftId.js +33 -0
- package/lib/nft/nftId.js.map +1 -0
- package/lib/operation.d.ts +1 -1
- package/lib/operation.d.ts.map +1 -1
- package/lib/operation.js +19 -5
- package/lib/operation.js.map +1 -1
- package/lib/reconciliation.d.ts.map +1 -1
- package/lib/reconciliation.js +6 -0
- package/lib/reconciliation.js.map +1 -1
- package/lib/types/account.d.ts +3 -0
- package/lib/types/account.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +1 -0
- package/lib/types/index.js.map +1 -1
- package/lib/types/nft.d.ts +29 -0
- package/lib/types/nft.d.ts.map +1 -0
- package/lib/types/nft.js +3 -0
- package/lib/types/nft.js.map +1 -0
- package/lib/types/operation.d.ts +12 -1
- package/lib/types/operation.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/__tests__/__snapshots__/all.libcore.ts.snap +64428 -57815
- package/src/__tests__/derivation.ts +1 -1
- package/src/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.ts +2 -2
- package/src/account/groupOperations.ts +2 -2
- package/src/account/serialization.ts +52 -0
- package/src/api/Ethereum.ts +40 -2
- package/src/apps/polyfill.ts +1 -0
- package/src/bridge/jsHelpers.ts +35 -0
- package/src/csvExport.ts +3 -2
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +1361 -1
- package/src/currencies/sortByMarketcap.ts +9 -1
- package/src/derivation.ts +1 -1
- package/src/env.ts +12 -1
- package/src/families/bitcoin/cache.ts +12 -0
- package/src/families/bitcoin/errors.ts +5 -0
- package/src/families/bitcoin/js-getTransactionStatus.ts +15 -1
- package/src/families/bitcoin/js-synchronisation.ts +11 -25
- package/src/families/bitcoin/logic.ts +7 -2
- package/src/families/bitcoin/specs.ts +6 -1
- package/src/families/bitcoin/test-dataset.ts +2 -2
- package/src/families/bitcoin/wallet-btc/crypto/base.ts +40 -5
- package/src/families/bitcoin/wallet-btc/crypto/bitcoin.ts +21 -1
- package/src/families/bitcoin/wallet-btc/crypto/bitcoincash.ts +5 -0
- package/src/families/bitcoin/wallet-btc/crypto/types.ts +1 -0
- package/src/families/bitcoin/wallet-btc/crypto/zec.ts +5 -0
- package/src/families/bitcoin/wallet-btc/crypto/zen.ts +5 -0
- package/src/families/bitcoin/wallet-btc/explorer/index.ts +0 -5
- package/src/families/bitcoin/wallet-btc/index.ts +4 -4
- package/src/families/bitcoin/wallet-btc/pickingstrategies/CoinSelect.ts +3 -3
- package/src/families/bitcoin/wallet-btc/pickingstrategies/DeepFirst.ts +5 -5
- package/src/families/bitcoin/wallet-btc/pickingstrategies/Merge.ts +5 -5
- package/src/families/bitcoin/wallet-btc/utils.ts +34 -9
- package/src/families/bitcoin/wallet-btc/wallet.ts +4 -2
- package/src/families/bitcoin/wallet-btc/xpub.ts +37 -53
- package/src/families/elrond/js-getTransactionStatus.ts +4 -0
- package/src/families/elrond/js-signOperation.ts +3 -1
- package/src/families/ethereum/modules/__snapshots__/compound.resilience.test.ts.snap +2876 -0
- package/src/families/ethereum/signOperation.ts +8 -0
- package/src/families/ethereum/specs.ts +47 -0
- package/src/families/ethereum/synchronisation.ts +185 -6
- package/src/families/ethereum/versions.ts +1 -0
- package/src/nft/NftMetadataProvider/index.tsx +205 -0
- package/src/nft/NftMetadataProvider/logic.ts +20 -0
- package/src/nft/NftMetadataProvider/types.ts +60 -0
- package/src/nft/helpers.ts +78 -0
- package/src/nft/index.ts +3 -0
- package/src/nft/nftId.ts +17 -0
- package/src/operation.ts +22 -3
- package/src/reconciliation.ts +7 -0
- package/src/types/account.ts +4 -0
- package/src/types/index.ts +1 -0
- package/src/types/nft.ts +38 -0
- 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
|
+
};
|
package/src/nft/index.ts
ADDED
package/src/nft/nftId.ts
ADDED
|
@@ -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
|
|
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
|
|
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;
|
package/src/reconciliation.ts
CHANGED
|
@@ -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;
|
package/src/types/account.ts
CHANGED
|
@@ -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;
|
package/src/types/index.ts
CHANGED
package/src/types/nft.ts
ADDED
|
@@ -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
|
+
};
|
package/src/types/operation.ts
CHANGED
|
@@ -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
|
};
|