@ledgerhq/live-common 27.2.0-nightly.3 → 27.2.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 (100) hide show
  1. package/lib/bot/specs.d.ts +0 -8
  2. package/lib/bot/specs.d.ts.map +1 -1
  3. package/lib/bot/specs.js +1 -45
  4. package/lib/bot/specs.js.map +1 -1
  5. package/lib/env.js +1 -1
  6. package/lib/exchange/swap/getExchangeRates.d.ts.map +1 -1
  7. package/lib/exchange/swap/getExchangeRates.js +1 -1
  8. package/lib/exchange/swap/getExchangeRates.js.map +1 -1
  9. package/lib/exchange/swap/getProviders.d.ts.map +1 -1
  10. package/lib/exchange/swap/getProviders.js +5 -45
  11. package/lib/exchange/swap/getProviders.js.map +1 -1
  12. package/lib/exchange/swap/index.d.ts +1 -2
  13. package/lib/exchange/swap/index.d.ts.map +1 -1
  14. package/lib/exchange/swap/index.js +1 -11
  15. package/lib/exchange/swap/index.js.map +1 -1
  16. package/lib/exchange/swap/index.test.js +0 -22
  17. package/lib/exchange/swap/index.test.js.map +1 -1
  18. package/lib/exchange/swap/mock.js +1 -1
  19. package/lib/exchange/swap/mock.js.map +1 -1
  20. package/lib/exchange/swap/types.d.ts +0 -14
  21. package/lib/exchange/swap/types.d.ts.map +1 -1
  22. package/lib/families/algorand/speculos-deviceActions.d.ts.map +1 -1
  23. package/lib/families/algorand/speculos-deviceActions.js +29 -2
  24. package/lib/families/algorand/speculos-deviceActions.js.map +1 -1
  25. package/lib/families/bitcoin/speculos-deviceActions.d.ts.map +1 -1
  26. package/lib/families/bitcoin/speculos-deviceActions.js +22 -2
  27. package/lib/families/bitcoin/speculos-deviceActions.js.map +1 -1
  28. package/lib/families/cardano/speculos-deviceActions.d.ts.map +1 -1
  29. package/lib/families/cardano/speculos-deviceActions.js +10 -2
  30. package/lib/families/cardano/speculos-deviceActions.js.map +1 -1
  31. package/lib/families/celo/speculos-deviceActions.d.ts.map +1 -1
  32. package/lib/families/celo/speculos-deviceActions.js +10 -3
  33. package/lib/families/celo/speculos-deviceActions.js.map +1 -1
  34. package/lib/families/elrond/speculos-deviceActions.d.ts.map +1 -1
  35. package/lib/families/elrond/speculos-deviceActions.js +8 -3
  36. package/lib/families/elrond/speculos-deviceActions.js.map +1 -1
  37. package/lib/families/ethereum/speculos-deviceActions.d.ts.map +1 -1
  38. package/lib/families/ethereum/speculos-deviceActions.js +33 -10
  39. package/lib/families/ethereum/speculos-deviceActions.js.map +1 -1
  40. package/lib/families/evm/specs.d.ts.map +1 -1
  41. package/lib/families/evm/specs.js +3 -7
  42. package/lib/families/evm/specs.js.map +1 -1
  43. package/lib/families/evm/speculos-deviceActions.d.ts.map +1 -1
  44. package/lib/families/evm/speculos-deviceActions.js +25 -5
  45. package/lib/families/evm/speculos-deviceActions.js.map +1 -1
  46. package/lib/families/filecoin/speculos-deviceActions.d.ts.map +1 -1
  47. package/lib/families/filecoin/speculos-deviceActions.js +10 -6
  48. package/lib/families/filecoin/speculos-deviceActions.js.map +1 -1
  49. package/lib/families/polkadot/speculos-deviceActions.d.ts.map +1 -1
  50. package/lib/families/polkadot/speculos-deviceActions.js +10 -3
  51. package/lib/families/polkadot/speculos-deviceActions.js.map +1 -1
  52. package/lib/families/ripple/speculos-deviceActions.d.ts.map +1 -1
  53. package/lib/families/ripple/speculos-deviceActions.js +22 -2
  54. package/lib/families/ripple/speculos-deviceActions.js.map +1 -1
  55. package/lib/families/solana/speculos-deviceActions.d.ts.map +1 -1
  56. package/lib/families/solana/speculos-deviceActions.js +7 -5
  57. package/lib/families/solana/speculos-deviceActions.js.map +1 -1
  58. package/lib/families/stellar/api/horizon.d.ts.map +1 -1
  59. package/lib/families/stellar/api/horizon.js +10 -15
  60. package/lib/families/stellar/api/horizon.js.map +1 -1
  61. package/lib/families/stellar/speculos-deviceActions.d.ts.map +1 -1
  62. package/lib/families/stellar/speculos-deviceActions.js +8 -4
  63. package/lib/families/stellar/speculos-deviceActions.js.map +1 -1
  64. package/lib/families/tezos/speculos-deviceActions.d.ts.map +1 -1
  65. package/lib/families/tezos/speculos-deviceActions.js +11 -6
  66. package/lib/families/tezos/speculos-deviceActions.js.map +1 -1
  67. package/lib/families/tron/speculos-deviceActions.d.ts.map +1 -1
  68. package/lib/families/tron/speculos-deviceActions.js +14 -2
  69. package/lib/families/tron/speculos-deviceActions.js.map +1 -1
  70. package/package.json +17 -17
  71. package/src/bot/specs.ts +0 -39
  72. package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +35 -1
  73. package/src/env.ts +1 -1
  74. package/src/exchange/swap/getExchangeRates.ts +3 -7
  75. package/src/exchange/swap/getProviders.ts +8 -31
  76. package/src/exchange/swap/index.test.ts +1 -36
  77. package/src/exchange/swap/index.ts +0 -15
  78. package/src/exchange/swap/mock.ts +2 -2
  79. package/src/exchange/swap/types.ts +0 -11
  80. package/src/families/algorand/speculos-deviceActions.ts +35 -4
  81. package/src/families/bitcoin/speculos-deviceActions.ts +26 -3
  82. package/src/families/cardano/speculos-deviceActions.ts +14 -3
  83. package/src/families/celo/speculos-deviceActions.ts +14 -6
  84. package/src/families/elrond/speculos-deviceActions.ts +9 -4
  85. package/src/families/ethereum/speculos-deviceActions.ts +46 -16
  86. package/src/families/evm/specs.ts +6 -10
  87. package/src/families/evm/speculos-deviceActions.ts +35 -7
  88. package/src/families/filecoin/speculos-deviceActions.ts +11 -7
  89. package/src/families/polkadot/speculos-deviceActions.ts +16 -5
  90. package/src/families/ripple/speculos-deviceActions.ts +28 -3
  91. package/src/families/solana/speculos-deviceActions.ts +8 -6
  92. package/src/families/stellar/api/horizon.ts +6 -10
  93. package/src/families/stellar/speculos-deviceActions.ts +11 -5
  94. package/src/families/tezos/speculos-deviceActions.ts +16 -9
  95. package/src/families/tron/speculos-deviceActions.ts +12 -4
  96. package/lib/exchange/swap/getProviders.test.d.ts +0 -2
  97. package/lib/exchange/swap/getProviders.test.d.ts.map +0 -1
  98. package/lib/exchange/swap/getProviders.test.js +0 -519
  99. package/lib/exchange/swap/getProviders.test.js.map +0 -1
  100. package/src/exchange/swap/getProviders.test.ts +0 -450
@@ -1,450 +0,0 @@
1
- import axios from "axios";
2
- import getProviders from "./getProviders";
3
- import { getEnv, setEnv } from "../../env";
4
-
5
- const EXPECTED_RESULT_V4 = [
6
- {
7
- provider: "changelly",
8
- pairs: [
9
- {
10
- from: "bitcoin",
11
- to: "ethereum",
12
- tradeMethod: "float",
13
- },
14
- {
15
- from: "bitcoin",
16
- to: "zcash",
17
- tradeMethod: "float",
18
- },
19
- {
20
- from: "bitcoin",
21
- to: "ethereum_classic",
22
- tradeMethod: "float",
23
- },
24
- {
25
- from: "ethereum",
26
- to: "bitcoin",
27
- tradeMethod: "float",
28
- },
29
- {
30
- from: "ethereum",
31
- to: "zcash",
32
- tradeMethod: "float",
33
- },
34
- {
35
- from: "ethereum",
36
- to: "ethereum_classic",
37
- tradeMethod: "float",
38
- },
39
- {
40
- from: "bitcoin",
41
- to: "ethereum",
42
- tradeMethod: "float",
43
- },
44
- {
45
- from: "bitcoin",
46
- to: "zcash",
47
- tradeMethod: "float",
48
- },
49
- {
50
- from: "bitcoin",
51
- to: "ethereum_classic",
52
- tradeMethod: "float",
53
- },
54
- {
55
- from: "ethereum",
56
- to: "bitcoin",
57
- tradeMethod: "float",
58
- },
59
- {
60
- from: "ethereum",
61
- to: "zcash",
62
- tradeMethod: "float",
63
- },
64
- {
65
- from: "ethereum",
66
- to: "ethereum_classic",
67
- tradeMethod: "float",
68
- },
69
- {
70
- from: "zcash",
71
- to: "bitcoin",
72
- tradeMethod: "float",
73
- },
74
- {
75
- from: "zcash",
76
- to: "ethereum_classic",
77
- tradeMethod: "float",
78
- },
79
- {
80
- from: "ethereum_classic",
81
- to: "bitcoin",
82
- tradeMethod: "float",
83
- },
84
- {
85
- from: "ethereum_classic",
86
- to: "ethereum",
87
- tradeMethod: "float",
88
- },
89
- {
90
- from: "bitcoin",
91
- to: "ethereum",
92
- tradeMethod: "fixed",
93
- },
94
- {
95
- from: "bitcoin",
96
- to: "zcash",
97
- tradeMethod: "fixed",
98
- },
99
- {
100
- from: "bitcoin",
101
- to: "ethereum_classic",
102
- tradeMethod: "fixed",
103
- },
104
- {
105
- from: "ethereum",
106
- to: "bitcoin",
107
- tradeMethod: "fixed",
108
- },
109
- {
110
- from: "ethereum",
111
- to: "zcash",
112
- tradeMethod: "fixed",
113
- },
114
- {
115
- from: "ethereum",
116
- to: "ethereum_classic",
117
- tradeMethod: "fixed",
118
- },
119
- {
120
- from: "zcash",
121
- to: "bitcoin",
122
- tradeMethod: "fixed",
123
- },
124
- {
125
- from: "zcash",
126
- to: "ethereum_classic",
127
- tradeMethod: "fixed",
128
- },
129
- {
130
- from: "ethereum_classic",
131
- to: "bitcoin",
132
- tradeMethod: "fixed",
133
- },
134
- {
135
- from: "ethereum_classic",
136
- to: "ethereum",
137
- tradeMethod: "fixed",
138
- },
139
- {
140
- from: "zcash",
141
- to: "bitcoin",
142
- tradeMethod: "fixed",
143
- },
144
- {
145
- from: "zcash",
146
- to: "ethereum_classic",
147
- tradeMethod: "fixed",
148
- },
149
- {
150
- from: "ethereum_classic",
151
- to: "bitcoin",
152
- tradeMethod: "fixed",
153
- },
154
- {
155
- from: "ethereum_classic",
156
- to: "ethereum",
157
- tradeMethod: "fixed",
158
- },
159
- ],
160
- },
161
- {
162
- provider: "ftx",
163
- pairs: [
164
- {
165
- from: "bitcoin",
166
- to: "ethereum",
167
- tradeMethod: "float",
168
- },
169
- {
170
- from: "bitcoin",
171
- to: "zcash",
172
- tradeMethod: "float",
173
- },
174
- {
175
- from: "bitcoin",
176
- to: "ethereum_classic",
177
- tradeMethod: "float",
178
- },
179
- {
180
- from: "ethereum",
181
- to: "bitcoin",
182
- tradeMethod: "float",
183
- },
184
- {
185
- from: "ethereum",
186
- to: "zcash",
187
- tradeMethod: "float",
188
- },
189
- {
190
- from: "ethereum",
191
- to: "ethereum_classic",
192
- tradeMethod: "float",
193
- },
194
- {
195
- from: "zcash",
196
- to: "bitcoin",
197
- tradeMethod: "float",
198
- },
199
- {
200
- from: "zcash",
201
- to: "ethereum",
202
- tradeMethod: "float",
203
- },
204
- {
205
- from: "zcash",
206
- to: "ethereum_classic",
207
- tradeMethod: "float",
208
- },
209
- {
210
- from: "ethereum_classic",
211
- to: "bitcoin",
212
- tradeMethod: "float",
213
- },
214
- {
215
- from: "ethereum_classic",
216
- to: "ethereum",
217
- tradeMethod: "float",
218
- },
219
- {
220
- from: "ethereum_classic",
221
- to: "zcash",
222
- tradeMethod: "float",
223
- },
224
- ],
225
- },
226
- ];
227
-
228
- jest.mock("axios");
229
- const mockedAxios = jest.mocked(axios);
230
-
231
- describe("swap/getProviders", () => {
232
- const DEFAULT_SWAP_API_BASE = getEnv("SWAP_API_BASE");
233
-
234
- afterAll(() => {
235
- // Restore DEFAULT_SWAP_API_BASE
236
- setEnv("SWAP_API_BASE", DEFAULT_SWAP_API_BASE);
237
- });
238
-
239
- describe("version 2", () => {
240
- const data = [
241
- {
242
- provider: "changelly",
243
- pairs: [
244
- {
245
- from: "bitcoin",
246
- to: "ethereum",
247
- tradeMethod: ["float", "fixed"],
248
- },
249
- {
250
- from: "bitcoin",
251
- to: "ethereum_classic",
252
- tradeMethod: ["float", "fixed"],
253
- },
254
- ],
255
- },
256
- ];
257
- const resp = {
258
- data,
259
- status: 200,
260
- statusText: "",
261
- headers: {},
262
- config: {},
263
- };
264
-
265
- beforeAll(() => {
266
- // set SWAP_API_BASE
267
- setEnv("SWAP_API_BASE", "https://swap.ledger.com/v2");
268
- });
269
-
270
- beforeEach(() => {
271
- mockedAxios.mockResolvedValue(Promise.resolve(resp));
272
- });
273
-
274
- afterEach(() => {
275
- mockedAxios.mockClear();
276
- });
277
-
278
- test("should not be called with whitelist", async () => {
279
- await getProviders();
280
-
281
- expect(mockedAxios).toBeCalledWith(
282
- expect.objectContaining({
283
- params: undefined,
284
- })
285
- );
286
- });
287
- });
288
-
289
- describe("version 3", () => {
290
- const data = [
291
- {
292
- provider: "changelly",
293
- pairs: [
294
- {
295
- from: "bitcoin",
296
- to: "ethereum",
297
- tradeMethod: ["float", "fixed"],
298
- },
299
- {
300
- from: "bitcoin",
301
- to: "ethereum_classic",
302
- tradeMethod: ["float", "fixed"],
303
- },
304
- ],
305
- },
306
- ];
307
- const resp = {
308
- data,
309
- status: 200,
310
- statusText: "",
311
- headers: {},
312
- config: {},
313
- };
314
-
315
- beforeAll(() => {
316
- // set SWAP_API_BASE
317
- setEnv("SWAP_API_BASE", "https://swap.ledger.com/v3");
318
- });
319
-
320
- beforeEach(() => {
321
- mockedAxios.mockResolvedValue(Promise.resolve(resp));
322
- });
323
-
324
- afterEach(() => {
325
- mockedAxios.mockClear();
326
- });
327
-
328
- test("should be called with whitelist", async () => {
329
- await getProviders();
330
-
331
- expect(mockedAxios).toBeCalledWith(
332
- expect.objectContaining({
333
- params: expect.objectContaining({
334
- whitelist: expect.any(Array),
335
- }),
336
- })
337
- );
338
- });
339
-
340
- test("should throw error if no data", async () => {
341
- const emptyResp = { ...resp, data: [] };
342
-
343
- mockedAxios.mockResolvedValue(Promise.resolve(emptyResp));
344
-
345
- await expect(getProviders).rejects.toThrow("SwapNoAvailableProviders");
346
- });
347
-
348
- test("should return list of providers with pairs", async () => {
349
- const res = await getProviders();
350
-
351
- expect(res).toEqual(data);
352
- });
353
- });
354
-
355
- describe("version 4", () => {
356
- const data = {
357
- currencies: {
358
- "1": "bitcoin",
359
- "2": "ethereum",
360
- "3": "zcash",
361
- "4": "ethereum_classic",
362
- },
363
- providers: {
364
- changelly: [
365
- {
366
- methods: ["float"],
367
- pairs: {
368
- "1": [2, 3, 4],
369
- "2": [1, 3, 4],
370
- },
371
- },
372
- {
373
- methods: ["float", "fixed"],
374
- pairs: {
375
- "1": [2, 3, 4],
376
- "2": [1, 3, 4],
377
- "3": [1, 4],
378
- "4": [1, 2],
379
- },
380
- },
381
- {
382
- methods: ["fixed"],
383
- pairs: {
384
- "3": [1, 4],
385
- "4": [1, 2],
386
- },
387
- },
388
- ],
389
- ftx: [
390
- {
391
- methods: ["float"],
392
- pairs: {
393
- "1": [2, 3, 4],
394
- "2": [1, 3, 4],
395
- "3": [1, 2, 4],
396
- "4": [1, 2, 3],
397
- },
398
- },
399
- ],
400
- },
401
- };
402
-
403
- const resp = {
404
- data,
405
- status: 200,
406
- statusText: "",
407
- headers: {},
408
- config: {},
409
- };
410
-
411
- beforeAll(() => {
412
- // set SWAP_API_BASE
413
- setEnv("SWAP_API_BASE", "https://swap.ledger.com/v4");
414
- });
415
-
416
- beforeEach(() => {
417
- mockedAxios.mockResolvedValue(Promise.resolve(resp));
418
- });
419
-
420
- afterEach(() => {
421
- mockedAxios.mockClear();
422
- });
423
-
424
- test("should be called with whitelist", async () => {
425
- await getProviders();
426
-
427
- expect(mockedAxios).toBeCalledWith(
428
- expect.objectContaining({
429
- params: expect.objectContaining({
430
- whitelist: expect.any(Array),
431
- }),
432
- })
433
- );
434
- });
435
-
436
- test("should throw error if no providers", async () => {
437
- const emptyResp = { ...resp, data: { ...data, providers: {} } };
438
-
439
- mockedAxios.mockResolvedValue(Promise.resolve(emptyResp));
440
-
441
- await expect(getProviders).rejects.toThrow("SwapNoAvailableProviders");
442
- });
443
-
444
- test("should return list of providers with pairs", async () => {
445
- const res = await getProviders();
446
-
447
- expect(res).toEqual(EXPECTED_RESULT_V4);
448
- });
449
- });
450
- });