@ledgerhq/live-common 34.35.0-nightly.0 → 34.35.0-nightly.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.
- package/lib/e2e/enum/Device.d.ts +8 -0
- package/lib/e2e/enum/Device.d.ts.map +1 -0
- package/lib/e2e/enum/Device.js +14 -0
- package/lib/e2e/enum/Device.js.map +1 -0
- package/lib/e2e/enum/Swap.d.ts +2 -1
- package/lib/e2e/enum/Swap.d.ts.map +1 -1
- package/lib/e2e/enum/Swap.js +12 -10
- package/lib/e2e/enum/Swap.js.map +1 -1
- package/lib/e2e/families/cardano.d.ts.map +1 -1
- package/lib/e2e/families/cardano.js +55 -26
- package/lib/e2e/families/cardano.js.map +1 -1
- package/lib/e2e/families/evm.d.ts.map +1 -1
- package/lib/e2e/families/evm.js +2 -1
- package/lib/e2e/families/evm.js.map +1 -1
- package/lib/e2e/families/solana.d.ts.map +1 -1
- package/lib/e2e/families/solana.js +5 -2
- package/lib/e2e/families/solana.js.map +1 -1
- package/lib/e2e/speculos.d.ts +2 -0
- package/lib/e2e/speculos.d.ts.map +1 -1
- package/lib/e2e/speculos.js +48 -32
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/exchange/swap/getCompleteSwapHistory.d.ts.map +1 -1
- package/lib/exchange/swap/getCompleteSwapHistory.js +2 -2
- package/lib/exchange/swap/getCompleteSwapHistory.js.map +1 -1
- package/lib-es/e2e/enum/Device.d.ts +8 -0
- package/lib-es/e2e/enum/Device.d.ts.map +1 -0
- package/lib-es/e2e/enum/Device.js +10 -0
- package/lib-es/e2e/enum/Device.js.map +1 -0
- package/lib-es/e2e/enum/Swap.d.ts +2 -1
- package/lib-es/e2e/enum/Swap.d.ts.map +1 -1
- package/lib-es/e2e/enum/Swap.js +12 -10
- package/lib-es/e2e/enum/Swap.js.map +1 -1
- package/lib-es/e2e/families/cardano.d.ts.map +1 -1
- package/lib-es/e2e/families/cardano.js +56 -27
- package/lib-es/e2e/families/cardano.js.map +1 -1
- package/lib-es/e2e/families/evm.d.ts.map +1 -1
- package/lib-es/e2e/families/evm.js +2 -1
- package/lib-es/e2e/families/evm.js.map +1 -1
- package/lib-es/e2e/families/solana.d.ts.map +1 -1
- package/lib-es/e2e/families/solana.js +5 -2
- package/lib-es/e2e/families/solana.js.map +1 -1
- package/lib-es/e2e/speculos.d.ts +2 -0
- package/lib-es/e2e/speculos.d.ts.map +1 -1
- package/lib-es/e2e/speculos.js +45 -31
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/exchange/swap/getCompleteSwapHistory.d.ts.map +1 -1
- package/lib-es/exchange/swap/getCompleteSwapHistory.js +2 -2
- package/lib-es/exchange/swap/getCompleteSwapHistory.js.map +1 -1
- package/package.json +12 -12
- package/src/e2e/enum/Device.ts +7 -0
- package/src/e2e/enum/Swap.ts +10 -9
- package/src/e2e/families/cardano.ts +63 -28
- package/src/e2e/families/evm.ts +2 -1
- package/src/e2e/families/solana.ts +5 -2
- package/src/e2e/speculos.ts +46 -31
- package/src/exchange/swap/getCompleteSwapHistory.ts +4 -2
package/src/e2e/families/evm.ts
CHANGED
@@ -2,12 +2,13 @@ import expect from "expect";
|
|
2
2
|
import { NFTTransaction, Transaction } from "../models/Transaction";
|
3
3
|
import { pressBoth, pressUntilTextFound, containsSubstringInEvent, waitFor } from "../speculos";
|
4
4
|
import { DeviceLabels } from "../enum/DeviceLabels";
|
5
|
+
import { Device } from "../enum/Device";
|
5
6
|
|
6
7
|
export async function sendEVM(tx: Transaction) {
|
7
8
|
const events = await pressUntilTextFound(DeviceLabels.ACCEPT);
|
8
9
|
const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
|
9
10
|
expect(isAmountCorrect).toBeTruthy();
|
10
|
-
if (tx.accountToCredit.ensName) {
|
11
|
+
if (tx.accountToCredit.ensName && process.env.SPECULOS_DEVICE !== Device.LNS) {
|
11
12
|
const isENSNameCorrect = containsSubstringInEvent(tx.accountToCredit.ensName, events);
|
12
13
|
expect(isENSNameCorrect).toBeTruthy();
|
13
14
|
} else {
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import expect from "expect";
|
2
2
|
import { pressBoth, pressUntilTextFound, waitFor, containsSubstringInEvent } from "../speculos";
|
3
3
|
import { DeviceLabels } from "../enum/DeviceLabels";
|
4
|
+
import { Device } from "../enum/Device";
|
4
5
|
import { Transaction } from "../models/Transaction";
|
5
6
|
|
6
7
|
export async function delegateSolana() {
|
@@ -13,8 +14,10 @@ export async function sendSolana(tx: Transaction) {
|
|
13
14
|
const events = await pressUntilTextFound(DeviceLabels.APPROVE);
|
14
15
|
const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
|
15
16
|
expect(isAmountCorrect).toBeTruthy();
|
16
|
-
|
17
|
-
|
17
|
+
if (process.env.SPECULOS_DEVICE !== Device.LNS) {
|
18
|
+
const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
|
19
|
+
expect(isAddressCorrect).toBeTruthy();
|
20
|
+
}
|
18
21
|
|
19
22
|
await pressBoth();
|
20
23
|
}
|
package/src/e2e/speculos.ts
CHANGED
@@ -16,6 +16,7 @@ import { getEnv } from "@ledgerhq/live-env";
|
|
16
16
|
import { getCryptoCurrencyById } from "../currencies";
|
17
17
|
import { DeviceLabels } from "../e2e/enum/DeviceLabels";
|
18
18
|
import { Account } from "./enum/Account";
|
19
|
+
import { Device as CryptoWallet } from "./enum/Device";
|
19
20
|
import { Currency } from "./enum/Currency";
|
20
21
|
import expect from "expect";
|
21
22
|
import { sendBTCBasedCoin } from "./families/bitcoin";
|
@@ -61,6 +62,19 @@ export function setExchangeDependencies(dependencies: Dependency[]) {
|
|
61
62
|
specs["Exchange"].dependencies = Array.from(map.values());
|
62
63
|
}
|
63
64
|
|
65
|
+
export function getSpeculosModel() {
|
66
|
+
const speculosDevice = process.env.SPECULOS_DEVICE;
|
67
|
+
switch (speculosDevice) {
|
68
|
+
case CryptoWallet.LNS:
|
69
|
+
return DeviceModelId.nanoS;
|
70
|
+
case CryptoWallet.LNX:
|
71
|
+
return DeviceModelId.nanoX;
|
72
|
+
case CryptoWallet.LNSP:
|
73
|
+
default:
|
74
|
+
return DeviceModelId.nanoSP;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
64
78
|
type Specs = {
|
65
79
|
[key: string]: Spec;
|
66
80
|
};
|
@@ -75,7 +89,7 @@ export const specs: Specs = {
|
|
75
89
|
Bitcoin: {
|
76
90
|
currency: getCryptoCurrencyById("bitcoin"),
|
77
91
|
appQuery: {
|
78
|
-
model:
|
92
|
+
model: getSpeculosModel(),
|
79
93
|
appName: "Bitcoin",
|
80
94
|
},
|
81
95
|
dependency: "",
|
@@ -83,21 +97,21 @@ export const specs: Specs = {
|
|
83
97
|
Aptos: {
|
84
98
|
currency: getCryptoCurrencyById("aptos"),
|
85
99
|
appQuery: {
|
86
|
-
model:
|
100
|
+
model: getSpeculosModel(),
|
87
101
|
appName: "Aptos",
|
88
102
|
},
|
89
103
|
dependency: "",
|
90
104
|
},
|
91
105
|
Exchange: {
|
92
106
|
appQuery: {
|
93
|
-
model:
|
107
|
+
model: getSpeculosModel(),
|
94
108
|
appName: "Exchange",
|
95
109
|
},
|
96
110
|
dependencies: [],
|
97
111
|
},
|
98
112
|
LedgerSync: {
|
99
113
|
appQuery: {
|
100
|
-
model:
|
114
|
+
model: getSpeculosModel(),
|
101
115
|
appName: "Ledger Sync",
|
102
116
|
},
|
103
117
|
dependency: "",
|
@@ -105,7 +119,7 @@ export const specs: Specs = {
|
|
105
119
|
Dogecoin: {
|
106
120
|
currency: getCryptoCurrencyById("dogecoin"),
|
107
121
|
appQuery: {
|
108
|
-
model:
|
122
|
+
model: getSpeculosModel(),
|
109
123
|
appName: "Dogecoin",
|
110
124
|
},
|
111
125
|
dependency: "",
|
@@ -113,7 +127,7 @@ export const specs: Specs = {
|
|
113
127
|
Ethereum: {
|
114
128
|
currency: getCryptoCurrencyById("ethereum"),
|
115
129
|
appQuery: {
|
116
|
-
model:
|
130
|
+
model: getSpeculosModel(),
|
117
131
|
appName: "Ethereum",
|
118
132
|
},
|
119
133
|
dependency: "",
|
@@ -121,7 +135,7 @@ export const specs: Specs = {
|
|
121
135
|
Ethereum_Holesky: {
|
122
136
|
currency: getCryptoCurrencyById("ethereum_holesky"),
|
123
137
|
appQuery: {
|
124
|
-
model:
|
138
|
+
model: getSpeculosModel(),
|
125
139
|
appName: "Ethereum",
|
126
140
|
},
|
127
141
|
dependency: "",
|
@@ -129,7 +143,7 @@ export const specs: Specs = {
|
|
129
143
|
Ethereum_Sepolia: {
|
130
144
|
currency: getCryptoCurrencyById("ethereum_sepolia"),
|
131
145
|
appQuery: {
|
132
|
-
model:
|
146
|
+
model: getSpeculosModel(),
|
133
147
|
appName: "Ethereum",
|
134
148
|
},
|
135
149
|
dependency: "",
|
@@ -137,7 +151,7 @@ export const specs: Specs = {
|
|
137
151
|
Ethereum_Classic: {
|
138
152
|
currency: getCryptoCurrencyById("ethereum_classic"),
|
139
153
|
appQuery: {
|
140
|
-
model:
|
154
|
+
model: getSpeculosModel(),
|
141
155
|
appName: "Ethereum Classic",
|
142
156
|
},
|
143
157
|
dependency: "Ethereum",
|
@@ -145,7 +159,7 @@ export const specs: Specs = {
|
|
145
159
|
Bitcoin_Testnet: {
|
146
160
|
currency: getCryptoCurrencyById("bitcoin_testnet"),
|
147
161
|
appQuery: {
|
148
|
-
model:
|
162
|
+
model: getSpeculosModel(),
|
149
163
|
appName: "Bitcoin Test",
|
150
164
|
},
|
151
165
|
dependency: "",
|
@@ -153,7 +167,7 @@ export const specs: Specs = {
|
|
153
167
|
Solana: {
|
154
168
|
currency: getCryptoCurrencyById("solana"),
|
155
169
|
appQuery: {
|
156
|
-
model:
|
170
|
+
model: getSpeculosModel(),
|
157
171
|
appName: "Solana",
|
158
172
|
},
|
159
173
|
dependency: "",
|
@@ -161,7 +175,7 @@ export const specs: Specs = {
|
|
161
175
|
Cardano: {
|
162
176
|
currency: getCryptoCurrencyById("cardano"),
|
163
177
|
appQuery: {
|
164
|
-
model:
|
178
|
+
model: getSpeculosModel(),
|
165
179
|
appName: "CardanoADA",
|
166
180
|
},
|
167
181
|
dependency: "",
|
@@ -169,7 +183,7 @@ export const specs: Specs = {
|
|
169
183
|
Polkadot: {
|
170
184
|
currency: getCryptoCurrencyById("polkadot"),
|
171
185
|
appQuery: {
|
172
|
-
model:
|
186
|
+
model: getSpeculosModel(),
|
173
187
|
appName: "Polkadot",
|
174
188
|
},
|
175
189
|
dependency: "",
|
@@ -177,7 +191,7 @@ export const specs: Specs = {
|
|
177
191
|
Tron: {
|
178
192
|
currency: getCryptoCurrencyById("tron"),
|
179
193
|
appQuery: {
|
180
|
-
model:
|
194
|
+
model: getSpeculosModel(),
|
181
195
|
appName: "Tron",
|
182
196
|
},
|
183
197
|
dependency: "",
|
@@ -185,7 +199,7 @@ export const specs: Specs = {
|
|
185
199
|
XRP: {
|
186
200
|
currency: getCryptoCurrencyById("ripple"),
|
187
201
|
appQuery: {
|
188
|
-
model:
|
202
|
+
model: getSpeculosModel(),
|
189
203
|
appName: "XRP",
|
190
204
|
},
|
191
205
|
dependency: "",
|
@@ -193,7 +207,7 @@ export const specs: Specs = {
|
|
193
207
|
Stellar: {
|
194
208
|
currency: getCryptoCurrencyById("stellar"),
|
195
209
|
appQuery: {
|
196
|
-
model:
|
210
|
+
model: getSpeculosModel(),
|
197
211
|
appName: "Stellar",
|
198
212
|
},
|
199
213
|
dependency: "",
|
@@ -201,7 +215,7 @@ export const specs: Specs = {
|
|
201
215
|
Bitcoin_Cash: {
|
202
216
|
currency: getCryptoCurrencyById("bitcoin_cash"),
|
203
217
|
appQuery: {
|
204
|
-
model:
|
218
|
+
model: getSpeculosModel(),
|
205
219
|
appName: "Bitcoin Cash",
|
206
220
|
},
|
207
221
|
dependency: "",
|
@@ -209,7 +223,7 @@ export const specs: Specs = {
|
|
209
223
|
Algorand: {
|
210
224
|
currency: getCryptoCurrencyById("algorand"),
|
211
225
|
appQuery: {
|
212
|
-
model:
|
226
|
+
model: getSpeculosModel(),
|
213
227
|
appName: "Algorand",
|
214
228
|
},
|
215
229
|
dependency: "",
|
@@ -217,7 +231,7 @@ export const specs: Specs = {
|
|
217
231
|
Cosmos: {
|
218
232
|
currency: getCryptoCurrencyById("cosmos"),
|
219
233
|
appQuery: {
|
220
|
-
model:
|
234
|
+
model: getSpeculosModel(),
|
221
235
|
appName: "Cosmos",
|
222
236
|
},
|
223
237
|
dependency: "",
|
@@ -225,7 +239,7 @@ export const specs: Specs = {
|
|
225
239
|
Tezos: {
|
226
240
|
currency: getCryptoCurrencyById("tezos"),
|
227
241
|
appQuery: {
|
228
|
-
model:
|
242
|
+
model: getSpeculosModel(),
|
229
243
|
appName: "TezosWallet",
|
230
244
|
},
|
231
245
|
dependency: "",
|
@@ -233,7 +247,7 @@ export const specs: Specs = {
|
|
233
247
|
Polygon: {
|
234
248
|
currency: getCryptoCurrencyById("polygon"),
|
235
249
|
appQuery: {
|
236
|
-
model:
|
250
|
+
model: getSpeculosModel(),
|
237
251
|
appName: "Ethereum",
|
238
252
|
},
|
239
253
|
dependency: "",
|
@@ -241,7 +255,7 @@ export const specs: Specs = {
|
|
241
255
|
Binance_Smart_Chain: {
|
242
256
|
currency: getCryptoCurrencyById("bsc"),
|
243
257
|
appQuery: {
|
244
|
-
model:
|
258
|
+
model: getSpeculosModel(),
|
245
259
|
appName: "Ethereum",
|
246
260
|
},
|
247
261
|
dependency: "",
|
@@ -249,7 +263,7 @@ export const specs: Specs = {
|
|
249
263
|
Ton: {
|
250
264
|
currency: getCryptoCurrencyById("ton"),
|
251
265
|
appQuery: {
|
252
|
-
model:
|
266
|
+
model: getSpeculosModel(),
|
253
267
|
appName: "TON",
|
254
268
|
},
|
255
269
|
dependency: "",
|
@@ -257,7 +271,7 @@ export const specs: Specs = {
|
|
257
271
|
Near: {
|
258
272
|
currency: getCryptoCurrencyById("near"),
|
259
273
|
appQuery: {
|
260
|
-
model:
|
274
|
+
model: getSpeculosModel(),
|
261
275
|
appName: "NEAR",
|
262
276
|
},
|
263
277
|
dependency: "",
|
@@ -265,7 +279,7 @@ export const specs: Specs = {
|
|
265
279
|
Multivers_X: {
|
266
280
|
currency: getCryptoCurrencyById("elrond"),
|
267
281
|
appQuery: {
|
268
|
-
model:
|
282
|
+
model: getSpeculosModel(),
|
269
283
|
appName: "MultiversX",
|
270
284
|
},
|
271
285
|
dependency: "",
|
@@ -273,7 +287,7 @@ export const specs: Specs = {
|
|
273
287
|
Osmosis: {
|
274
288
|
currency: getCryptoCurrencyById("osmo"),
|
275
289
|
appQuery: {
|
276
|
-
model:
|
290
|
+
model: getSpeculosModel(),
|
277
291
|
appName: "Cosmos",
|
278
292
|
},
|
279
293
|
dependency: "",
|
@@ -281,7 +295,7 @@ export const specs: Specs = {
|
|
281
295
|
Injective: {
|
282
296
|
currency: getCryptoCurrencyById("injective"),
|
283
297
|
appQuery: {
|
284
|
-
model:
|
298
|
+
model: getSpeculosModel(),
|
285
299
|
appName: "Cosmos",
|
286
300
|
},
|
287
301
|
dependency: "",
|
@@ -290,7 +304,7 @@ export const specs: Specs = {
|
|
290
304
|
Celo: {
|
291
305
|
currency: getCryptoCurrencyById("celo"),
|
292
306
|
appQuery: {
|
293
|
-
model:
|
307
|
+
model: getSpeculosModel(),
|
294
308
|
appName: "Celo",
|
295
309
|
},
|
296
310
|
dependency: "",
|
@@ -298,7 +312,7 @@ export const specs: Specs = {
|
|
298
312
|
Litecoin: {
|
299
313
|
currency: getCryptoCurrencyById("litecoin"),
|
300
314
|
appQuery: {
|
301
|
-
model:
|
315
|
+
model: getSpeculosModel(),
|
302
316
|
appName: "Litecoin",
|
303
317
|
},
|
304
318
|
dependency: "",
|
@@ -427,7 +441,7 @@ export async function pressUntilTextFound(
|
|
427
441
|
return await fetchAllEvents(speculosApiPort);
|
428
442
|
}
|
429
443
|
|
430
|
-
await pressRightButton(
|
444
|
+
await pressRightButton();
|
431
445
|
await waitForTimeOut(200);
|
432
446
|
}
|
433
447
|
|
@@ -450,7 +464,8 @@ async function fetchAllEvents(speculosApiPort: number): Promise<string[]> {
|
|
450
464
|
return response.data.events.map(event => event.text);
|
451
465
|
}
|
452
466
|
|
453
|
-
async function pressRightButton(
|
467
|
+
export async function pressRightButton(): Promise<void> {
|
468
|
+
const speculosApiPort = getEnv("SPECULOS_API_PORT");
|
454
469
|
await axios.post(`http://127.0.0.1:${speculosApiPort}/button/right`, {
|
455
470
|
action: "press-and-release",
|
456
471
|
});
|
@@ -17,9 +17,11 @@ const getSwapOperationMap =
|
|
17
17
|
tokenId,
|
18
18
|
} = swapOperation;
|
19
19
|
// Find operation by matching its hash which is embedded in the operationId
|
20
|
-
const operation = account.operations.find(
|
20
|
+
const operation = account.operations.find(
|
21
|
+
o => operationId.includes(o.hash) || o.id === operationId,
|
22
|
+
);
|
21
23
|
const optimisticOperation = !operation
|
22
|
-
? account.pendingOperations.find(o => o.id === operationId)
|
24
|
+
? account.pendingOperations.find(o => operationId.includes(o.hash) || o.id === operationId)
|
23
25
|
: null;
|
24
26
|
const op = operation || optimisticOperation;
|
25
27
|
|