@ledgerhq/live-common 21.19.7 → 21.20.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__/svg.d.ts +9 -0
- package/lib/__tests__/svg.d.ts.map +1 -0
- package/lib/__tests__/svg.js +105 -0
- package/lib/__tests__/svg.js.map +1 -0
- package/lib/bridge/jsHelpers.d.ts +1 -1
- package/lib/bridge/jsHelpers.d.ts.map +1 -1
- package/lib/bridge/jsHelpers.js +7 -8
- package/lib/bridge/jsHelpers.js.map +1 -1
- package/lib/data/icons/react/index.d.ts +0 -2
- package/lib/data/icons/react/index.d.ts.map +1 -1
- package/lib/data/icons/react/index.js +8 -12
- package/lib/data/icons/react/index.js.map +1 -1
- package/lib/data/icons/react/matic.js +2 -2
- package/lib/data/icons/react/matic.js.map +1 -1
- package/lib/data/icons/reactNative/index.d.ts +0 -2
- package/lib/data/icons/reactNative/index.d.ts.map +1 -1
- package/lib/data/icons/reactNative/index.js +8 -12
- package/lib/data/icons/reactNative/index.js.map +1 -1
- package/lib/data/icons/reactNative/matic.js +2 -2
- package/lib/data/icons/reactNative/matic.js.map +1 -1
- package/lib/families/ethereum/modules/compound.resilience.test.js +2 -18
- package/lib/families/ethereum/modules/compound.resilience.test.js.map +1 -1
- package/lib/families/ethereum/modules/erc20.d.ts.map +1 -1
- package/lib/families/ethereum/modules/erc20.js +0 -12
- package/lib/families/ethereum/modules/erc20.js.map +1 -1
- package/lib/families/ethereum/modules/erc721.d.ts.map +1 -1
- package/lib/families/ethereum/modules/erc721.js +0 -1
- package/lib/families/ethereum/modules/erc721.js.map +1 -1
- package/lib/families/ethereum/nft.integration.test.d.ts +2 -0
- package/lib/families/ethereum/nft.integration.test.d.ts.map +1 -0
- package/lib/families/ethereum/nft.integration.test.js +264 -0
- package/lib/families/ethereum/nft.integration.test.js.map +1 -0
- package/lib/families/ethereum/nft.merging.unit.test.d.ts +2 -0
- package/lib/families/ethereum/nft.merging.unit.test.d.ts.map +1 -0
- package/lib/families/ethereum/nft.merging.unit.test.js +72 -0
- package/lib/families/ethereum/nft.merging.unit.test.js.map +1 -0
- package/lib/families/ethereum/synchronisation.js +5 -5
- package/lib/families/ethereum/synchronisation.js.map +1 -1
- package/lib/nft/NftMetadataProvider/index.d.ts +3 -2
- package/lib/nft/NftMetadataProvider/index.d.ts.map +1 -1
- package/lib/nft/NftMetadataProvider/index.js +9 -2
- package/lib/nft/NftMetadataProvider/index.js.map +1 -1
- package/lib/operation.d.ts.map +1 -1
- package/lib/operation.js +0 -2
- package/lib/operation.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/svg.ts +78 -0
- package/src/bridge/jsHelpers.ts +9 -15
- package/src/data/icons/react/index.tsx +0 -2
- package/src/data/icons/react/matic.tsx +1 -1
- package/src/data/icons/reactNative/index.tsx +0 -2
- package/src/data/icons/reactNative/matic.tsx +1 -1
- package/src/data/icons/svg/MATIC.svg +2 -2
- package/src/families/ethereum/modules/compound.resilience.test.ts +2 -18
- package/src/families/ethereum/modules/erc20.ts +0 -4
- package/src/families/ethereum/modules/erc721.ts +0 -4
- package/src/families/ethereum/nft.integration.test.ts +168 -0
- package/src/families/ethereum/nft.merging.unit.test.ts +78 -0
- package/src/families/ethereum/synchronisation.ts +5 -5
- package/src/nft/NftMetadataProvider/index.tsx +12 -3
- package/src/operation.ts +0 -2
- package/lib/data/icons/react/cro.d.ts +0 -8
- package/lib/data/icons/react/cro.d.ts.map +0 -1
- package/lib/data/icons/react/cro.js +0 -30
- package/lib/data/icons/react/cro.js.map +0 -1
- package/lib/data/icons/react/grs.d.ts +0 -8
- package/lib/data/icons/react/grs.d.ts.map +0 -1
- package/lib/data/icons/react/grs.js +0 -34
- package/lib/data/icons/react/grs.js.map +0 -1
- package/lib/data/icons/reactNative/cro.d.ts +0 -8
- package/lib/data/icons/reactNative/cro.d.ts.map +0 -1
- package/lib/data/icons/reactNative/cro.js +0 -31
- package/lib/data/icons/reactNative/cro.js.map +0 -1
- package/lib/data/icons/reactNative/grs.d.ts +0 -8
- package/lib/data/icons/reactNative/grs.d.ts.map +0 -1
- package/lib/data/icons/reactNative/grs.js +0 -35
- package/lib/data/icons/reactNative/grs.js.map +0 -1
- package/lib/families/ethereum/nft.test.d.ts +0 -2
- package/lib/families/ethereum/nft.test.d.ts.map +0 -1
- package/lib/families/ethereum/nft.test.js +0 -360
- package/lib/families/ethereum/nft.test.js.map +0 -1
- package/src/data/icons/react/cro.tsx +0 -12
- package/src/data/icons/react/grs.tsx +0 -12
- package/src/data/icons/reactNative/cro.tsx +0 -13
- package/src/data/icons/reactNative/grs.tsx +0 -13
- package/src/data/icons/svg/CRO.svg +0 -3
- package/src/data/icons/svg/GRS.svg +0 -10
- package/src/families/ethereum/modules/__snapshots__/compound.resilience.test.ts.snap +0 -15991
- package/src/families/ethereum/nft.test.ts +0 -263
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import "../../__tests__/test-helpers/setup";
|
|
2
|
-
import BigNumber from "bignumber.js";
|
|
3
|
-
import { reduce } from "rxjs/operators";
|
|
4
|
-
import { fromAccountRaw, toAccountRaw, toNFTRaw } from "../../account";
|
|
5
|
-
import type { Account, AccountRaw, NFT } from "../../types";
|
|
6
|
-
import { getAccountBridge } from "../../bridge";
|
|
7
|
-
import { makeBridgeCacheSystem } from "../../bridge/cache";
|
|
8
|
-
import { patchAccount } from "../../reconciliation";
|
|
9
|
-
import { setEnv } from "../../env";
|
|
10
|
-
import { mergeNfts } from "../../bridge/jsHelpers";
|
|
11
|
-
import { encodeNftId } from "../../nft";
|
|
12
|
-
|
|
13
|
-
jest.setTimeout(120000);
|
|
14
|
-
|
|
15
|
-
const gaspardAccount: AccountRaw = {
|
|
16
|
-
id: "js:1:ethereum:0xb98d10d9f6d07ba283bfd21b2dfec050f9ae282a:",
|
|
17
|
-
seedIdentifier: "0xb98d10d9f6d07ba283bfd21b2dfec050f9ae282a",
|
|
18
|
-
name: "G4sp4rd",
|
|
19
|
-
derivationMode: "",
|
|
20
|
-
index: 0,
|
|
21
|
-
freshAddress: "0xb98d10d9f6d07ba283bfd21b2dfec050f9ae282a",
|
|
22
|
-
freshAddressPath: "44'/60'/0'/0/0",
|
|
23
|
-
freshAddresses: [],
|
|
24
|
-
pendingOperations: [],
|
|
25
|
-
operations: [],
|
|
26
|
-
currencyId: "ethereum",
|
|
27
|
-
unitMagnitude: 18,
|
|
28
|
-
balance: "",
|
|
29
|
-
blockHeight: 0,
|
|
30
|
-
lastSyncDate: "",
|
|
31
|
-
xpub: "",
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/*
|
|
35
|
-
const gaspardPolygonAccount: AccountRaw = {
|
|
36
|
-
id: "js:1:polygon:0xb98d10d9f6d07ba283bfd21b2dfec050f9ae282a:",
|
|
37
|
-
seedIdentifier: "0xb98d10d9f6d07ba283bfd21b2dfec050f9ae282a",
|
|
38
|
-
name: "G4sp4rd",
|
|
39
|
-
derivationMode: "",
|
|
40
|
-
index: 0,
|
|
41
|
-
freshAddress: "0xb98d10d9f6d07ba283bfd21b2dfec050f9ae282a",
|
|
42
|
-
freshAddressPath: "44'/60'/0'/0/0",
|
|
43
|
-
freshAddresses: [],
|
|
44
|
-
pendingOperations: [],
|
|
45
|
-
operations: [],
|
|
46
|
-
currencyId: "polygon",
|
|
47
|
-
unitMagnitude: 18,
|
|
48
|
-
balance: "",
|
|
49
|
-
blockHeight: 0,
|
|
50
|
-
lastSyncDate: "",
|
|
51
|
-
xpub: "",
|
|
52
|
-
};
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
const gaspardBscAccount: AccountRaw = {
|
|
56
|
-
id: "js:1:bsc:0xb98d10d9f6d07ba283bfd21b2dfec050f9ae282a:",
|
|
57
|
-
seedIdentifier: "0xb98d10d9f6d07ba283bfd21b2dfec050f9ae282a",
|
|
58
|
-
name: "G4sp4rd",
|
|
59
|
-
derivationMode: "",
|
|
60
|
-
index: 0,
|
|
61
|
-
freshAddress: "0xb98d10d9f6d07ba283bfd21b2dfec050f9ae282a",
|
|
62
|
-
freshAddressPath: "44'/60'/0'/0/0",
|
|
63
|
-
freshAddresses: [],
|
|
64
|
-
pendingOperations: [],
|
|
65
|
-
operations: [],
|
|
66
|
-
currencyId: "bsc",
|
|
67
|
-
unitMagnitude: 18,
|
|
68
|
-
balance: "",
|
|
69
|
-
blockHeight: 0,
|
|
70
|
-
lastSyncDate: "",
|
|
71
|
-
xpub: "",
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
async function sync(account, withNFT = true) {
|
|
75
|
-
const bridge = getAccountBridge(account);
|
|
76
|
-
const blacklistedTokenIds = [];
|
|
77
|
-
setEnv("NFT", withNFT);
|
|
78
|
-
const r = await bridge
|
|
79
|
-
.sync(account, {
|
|
80
|
-
paginationConfig: {},
|
|
81
|
-
blacklistedTokenIds,
|
|
82
|
-
})
|
|
83
|
-
.pipe(reduce((a, f: (arg0: Account) => Account) => f(a), account))
|
|
84
|
-
.toPromise();
|
|
85
|
-
setEnv("NFT", false);
|
|
86
|
-
return r;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const localCache = {};
|
|
90
|
-
const cache = makeBridgeCacheSystem({
|
|
91
|
-
saveData(c, d) {
|
|
92
|
-
localCache[c.id] = d;
|
|
93
|
-
return Promise.resolve();
|
|
94
|
-
},
|
|
95
|
-
getData(c) {
|
|
96
|
-
return Promise.resolve(localCache[c.id]);
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe("nft merging", () => {
|
|
101
|
-
const makeNFT = (tokenId: string, contract: string, amount: number): NFT => ({
|
|
102
|
-
id: encodeNftId("test", contract, tokenId),
|
|
103
|
-
tokenId,
|
|
104
|
-
amount: new BigNumber(amount),
|
|
105
|
-
collection: {
|
|
106
|
-
contract,
|
|
107
|
-
standard: "erc721",
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
const oldNfts = [
|
|
111
|
-
makeNFT("1", "contract1", 10),
|
|
112
|
-
makeNFT("2", "contract1", 1),
|
|
113
|
-
makeNFT("3", "contract2", 6),
|
|
114
|
-
];
|
|
115
|
-
|
|
116
|
-
test("should remove first NFT and return new array with same refs", () => {
|
|
117
|
-
const nfts = [makeNFT("2", "contract1", 1), makeNFT("3", "contract2", 6)];
|
|
118
|
-
const newNfts = mergeNfts(oldNfts, nfts);
|
|
119
|
-
|
|
120
|
-
expect(newNfts.map(toNFTRaw)).toEqual(nfts.map(toNFTRaw));
|
|
121
|
-
expect(oldNfts[1]).toBe(newNfts[0]);
|
|
122
|
-
expect(oldNfts[2]).toBe(newNfts[1]);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test("should remove any NFT and return new array with same refs", () => {
|
|
126
|
-
const nfts = [makeNFT("1", "contract1", 10), makeNFT("3", "contract2", 6)];
|
|
127
|
-
const newNfts = mergeNfts(oldNfts, nfts);
|
|
128
|
-
|
|
129
|
-
expect(newNfts.map(toNFTRaw)).toEqual(nfts.map(toNFTRaw));
|
|
130
|
-
expect(oldNfts[0]).toBe(newNfts[0]);
|
|
131
|
-
expect(oldNfts[2]).toBe(newNfts[1]);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
test("should change NFT amount and return new array with new ref", () => {
|
|
135
|
-
const nfts = [
|
|
136
|
-
makeNFT("1", "contract1", 10),
|
|
137
|
-
makeNFT("2", "contract1", 5),
|
|
138
|
-
makeNFT("3", "contract2", 6),
|
|
139
|
-
];
|
|
140
|
-
const addToNft1 = mergeNfts(oldNfts, nfts);
|
|
141
|
-
|
|
142
|
-
expect(addToNft1.map(toNFTRaw)).toEqual(nfts.map(toNFTRaw));
|
|
143
|
-
expect(oldNfts[0]).toBe(addToNft1[0]);
|
|
144
|
-
expect(oldNfts[1]).not.toBe(addToNft1[1]);
|
|
145
|
-
expect(oldNfts[2]).toBe(addToNft1[2]);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
test("should add NFT and return new array with new ref", () => {
|
|
149
|
-
const nfts = [
|
|
150
|
-
makeNFT("1", "contract1", 10),
|
|
151
|
-
makeNFT("2", "contract1", 1),
|
|
152
|
-
makeNFT("3", "contract2", 6),
|
|
153
|
-
makeNFT("4", "contract2", 4),
|
|
154
|
-
];
|
|
155
|
-
const addToNft1 = mergeNfts(oldNfts, nfts);
|
|
156
|
-
|
|
157
|
-
expect(addToNft1.map(toNFTRaw)).toEqual(
|
|
158
|
-
[
|
|
159
|
-
makeNFT("4", "contract2", 4),
|
|
160
|
-
makeNFT("1", "contract1", 10),
|
|
161
|
-
makeNFT("2", "contract1", 1),
|
|
162
|
-
makeNFT("3", "contract2", 6),
|
|
163
|
-
].map(toNFTRaw)
|
|
164
|
-
);
|
|
165
|
-
expect(oldNfts[0]).toBe(addToNft1[1]);
|
|
166
|
-
expect(oldNfts[1]).toBe(addToNft1[2]);
|
|
167
|
-
expect(oldNfts[2]).toBe(addToNft1[3]);
|
|
168
|
-
expect(addToNft1[0]).toBe(nfts[3]);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
describe("gaspard NFT on ethereum", () => {
|
|
173
|
-
let account = fromAccountRaw(gaspardAccount);
|
|
174
|
-
|
|
175
|
-
test("first sync & have nfts", async () => {
|
|
176
|
-
await cache.prepareCurrency(account.currency);
|
|
177
|
-
account = await sync(account);
|
|
178
|
-
expect(account.nfts?.length || 0).not.toBe(0);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
test("remove half NFTs will restore them with operations still here", async () => {
|
|
182
|
-
const copy = {
|
|
183
|
-
...account,
|
|
184
|
-
nfts: account.nfts?.slice(Math.ceil((account.nfts?.length || 0) / 2)),
|
|
185
|
-
};
|
|
186
|
-
const resync = await sync(copy);
|
|
187
|
-
expect(resync.nfts).toEqual(account.nfts);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
test("remove half NFTs will restore them with missing operations too", async () => {
|
|
191
|
-
const copy = {
|
|
192
|
-
...account,
|
|
193
|
-
operations: [],
|
|
194
|
-
nfts: account.nfts?.slice(Math.ceil((account.nfts?.length || 0) / 2)),
|
|
195
|
-
};
|
|
196
|
-
const resync = await sync(copy);
|
|
197
|
-
expect(resync.nfts).toEqual(account.nfts);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
test("remove half NFTs will restore them with half operations", async () => {
|
|
201
|
-
const halfOps = Math.ceil(account.operations.length / 2);
|
|
202
|
-
const copy = {
|
|
203
|
-
...account,
|
|
204
|
-
operations: account.operations.slice(halfOps),
|
|
205
|
-
nfts: account.nfts?.slice(Math.ceil((account.nfts?.length || 0) / 2)),
|
|
206
|
-
};
|
|
207
|
-
const resync = await sync(copy);
|
|
208
|
-
expect(resync.nfts).toEqual(account.nfts);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
test("patchAccount restore new NFTs correctly", async () => {
|
|
212
|
-
const copy = {
|
|
213
|
-
...account,
|
|
214
|
-
operations: [],
|
|
215
|
-
nfts: account.nfts?.slice(Math.ceil((account.nfts?.length || 0) / 2)),
|
|
216
|
-
};
|
|
217
|
-
const newAccount = patchAccount(copy, toAccountRaw(account));
|
|
218
|
-
expect(newAccount.nfts).toEqual(account.nfts);
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
test("start account with .nfts and disable the NFT flag should make it disappear", async () => {
|
|
222
|
-
expect(account.nfts).not.toBeFalsy();
|
|
223
|
-
const resync = await sync(account, false);
|
|
224
|
-
expect(resync.nfts).toBeFalsy();
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
test("start account without .nfts and enable the NFT flag should make it appear", async () => {
|
|
228
|
-
const first = await sync(account, false);
|
|
229
|
-
expect(first.nfts).toBeFalsy();
|
|
230
|
-
const second = await sync(first, true);
|
|
231
|
-
expect(second.nfts).not.toBeFalsy();
|
|
232
|
-
expect(second.nfts).toEqual(account.nfts);
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
test("no nft should be on quantity 0 or negative", async () => {
|
|
236
|
-
expect(account.nfts?.find((n) => !n.amount.gt(0))).toEqual(undefined);
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
/*
|
|
241
|
-
// this is never ending here... have to disable this test... (backend issue)
|
|
242
|
-
describe("gaspard NFT on polygon", () => {
|
|
243
|
-
let account = fromAccountRaw(gaspardPolygonAccount);
|
|
244
|
-
test("first sync", async () => {
|
|
245
|
-
await cache.prepareCurrency(account.currency);
|
|
246
|
-
account = await sync(account);
|
|
247
|
-
});
|
|
248
|
-
test(".nfts shouldn't be visible", () => {
|
|
249
|
-
expect(account.nfts).toBeFalsy();
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
*/
|
|
253
|
-
|
|
254
|
-
describe("gaspard NFT on bsc", () => {
|
|
255
|
-
let account = fromAccountRaw(gaspardBscAccount);
|
|
256
|
-
test("first sync", async () => {
|
|
257
|
-
await cache.prepareCurrency(account.currency);
|
|
258
|
-
account = await sync(account);
|
|
259
|
-
});
|
|
260
|
-
test(".nfts shouldn't be visible", () => {
|
|
261
|
-
expect(account.nfts).toBeFalsy();
|
|
262
|
-
});
|
|
263
|
-
});
|