@ledgerhq/live-common 21.30.0 → 21.30.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.
@@ -75,367 +75,370 @@ const fees = (signatureCount: number) =>
75
75
 
76
76
  const zero = new BigNumber(0);
77
77
 
78
- const dataset: DatasetTest<Transaction> = {
79
- implementations: [getEnv("MOCK") ? "mock" : "js"],
80
- currencies: {
81
- solana: {
82
- scanAccounts: [scanAccounts1],
83
- accounts: [
78
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
79
+ const solana = {
80
+ scanAccounts: [scanAccounts1],
81
+ accounts: [
82
+ {
83
+ raw: makeAccount(testOnChainData.fundedSenderAddress),
84
+ /*
85
+ Solana integration is written in such a way that requires
86
+ prepareTransaction to be called before any meaningfull status
87
+ can be calculated. The general bridge tests do not run prepareTransaction
88
+ on all tests, so skip them in the general runner, but make alternatives for them.
89
+ */
90
+ FIXME_tests: [
91
+ "balance is sum of ops",
92
+ "Default empty recipient have a recipientError",
93
+ "invalid recipient have a recipientError",
94
+ "can be called on an empty transaction",
95
+ ],
96
+ transactions: [
97
+ ...recipientRequired(),
98
+ ...recipientNotValid(),
99
+ ...recipientIsSameAsSender(),
100
+ ...memoIsTooLong(),
84
101
  {
85
- raw: makeAccount(testOnChainData.fundedSenderAddress),
86
- /*
87
- Solana integration is written in such a way that requires
88
- prepareTransaction to be called before any meaningfull status
89
- can be calculated. The general bridge tests do not run prepareTransaction
90
- on all tests, so skip them in the general runner, but make alternatives for them.
91
- */
92
- FIXME_tests: [
93
- "balance is sum of ops",
94
- "Default empty recipient have a recipientError",
95
- "invalid recipient have a recipientError",
96
- "can be called on an empty transaction",
97
- ],
98
- transactions: [
99
- ...recipientRequired(),
100
- ...recipientNotValid(),
101
- ...recipientIsSameAsSender(),
102
- ...memoIsTooLong(),
103
- {
104
- name: "status is error: called on an empty transaction",
105
- transaction: createTransaction({} as any),
106
- expectedStatus: {
107
- errors: {
108
- recipient: new RecipientRequired(),
109
- },
110
- warnings: {},
111
- estimatedFees: fees(1),
112
- amount: zero,
113
- totalSpent: fees(1),
114
- },
102
+ name: "status is error: called on an empty transaction",
103
+ transaction: createTransaction({} as any),
104
+ expectedStatus: {
105
+ errors: {
106
+ recipient: new RecipientRequired(),
115
107
  },
116
- {
117
- name: "transfer :: status is success: not all amount",
118
- transaction: {
119
- model: {
120
- kind: "transfer",
121
- uiState: {},
122
- },
123
- amount: testOnChainData.fundedSenderBalance.dividedBy(2),
124
- recipient: testOnChainData.fundedAddress,
125
- feeCalculator: testOnChainData.feeCalculator,
126
- family: "solana",
127
- },
128
- expectedStatus: {
129
- errors: {},
130
- warnings: {},
131
- estimatedFees: fees(1),
132
- amount: testOnChainData.fundedSenderBalance.dividedBy(2),
133
- totalSpent: testOnChainData.fundedSenderBalance
134
- .dividedBy(2)
135
- .plus(fees(1)),
136
- },
108
+ warnings: {},
109
+ estimatedFees: fees(1),
110
+ amount: zero,
111
+ totalSpent: fees(1),
112
+ },
113
+ },
114
+ {
115
+ name: "transfer :: status is success: not all amount",
116
+ transaction: {
117
+ model: {
118
+ kind: "transfer",
119
+ uiState: {},
137
120
  },
138
- {
139
- name: "transfer :: status is success: all amount",
140
- transaction: {
141
- model: {
142
- kind: "transfer",
143
- uiState: {},
144
- },
145
- useAllAmount: true,
146
- amount: zero,
147
- recipient: testOnChainData.fundedAddress,
148
- feeCalculator: testOnChainData.feeCalculator,
149
- family: "solana",
150
- },
151
- expectedStatus: {
152
- errors: {},
153
- warnings: {},
154
- estimatedFees: fees(1),
155
- amount: testOnChainData.fundedSenderBalance.minus(fees(1)),
156
- totalSpent: testOnChainData.fundedSenderBalance,
157
- },
121
+ amount: testOnChainData.fundedSenderBalance.dividedBy(2),
122
+ recipient: testOnChainData.fundedAddress,
123
+ feeCalculator: testOnChainData.feeCalculator,
124
+ family: "solana",
125
+ },
126
+ expectedStatus: {
127
+ errors: {},
128
+ warnings: {},
129
+ estimatedFees: fees(1),
130
+ amount: testOnChainData.fundedSenderBalance.dividedBy(2),
131
+ totalSpent: testOnChainData.fundedSenderBalance
132
+ .dividedBy(2)
133
+ .plus(fees(1)),
134
+ },
135
+ },
136
+ {
137
+ name: "transfer :: status is success: all amount",
138
+ transaction: {
139
+ model: {
140
+ kind: "transfer",
141
+ uiState: {},
158
142
  },
159
- {
160
- name: "transfer :: status is error: not enough balance, not all amount",
161
- transaction: {
162
- model: {
163
- kind: "transfer",
164
- uiState: {},
165
- },
166
- amount: testOnChainData.fundedSenderBalance,
167
- recipient: testOnChainData.fundedAddress,
168
- feeCalculator: testOnChainData.feeCalculator,
169
- family: "solana",
170
- },
171
- expectedStatus: {
172
- errors: {
173
- amount: new NotEnoughBalance(),
174
- },
175
- warnings: {},
176
- estimatedFees: fees(1),
177
- amount: testOnChainData.fundedSenderBalance,
178
- totalSpent: testOnChainData.fundedSenderBalance.plus(fees(1)),
179
- },
143
+ useAllAmount: true,
144
+ amount: zero,
145
+ recipient: testOnChainData.fundedAddress,
146
+ feeCalculator: testOnChainData.feeCalculator,
147
+ family: "solana",
148
+ },
149
+ expectedStatus: {
150
+ errors: {},
151
+ warnings: {},
152
+ estimatedFees: fees(1),
153
+ amount: testOnChainData.fundedSenderBalance.minus(fees(1)),
154
+ totalSpent: testOnChainData.fundedSenderBalance,
155
+ },
156
+ },
157
+ {
158
+ name: "transfer :: status is error: not enough balance, not all amount",
159
+ transaction: {
160
+ model: {
161
+ kind: "transfer",
162
+ uiState: {},
180
163
  },
181
- {
182
- name: "transfer :: status is error: not enough balance, all amount",
183
- transaction: {
184
- model: {
185
- kind: "transfer",
186
- uiState: {
187
- memo: "a memo",
188
- },
189
- },
190
- useAllAmount: true,
191
- amount: zero,
192
- recipient: testOnChainData.fundedAddress,
193
- feeCalculator: {
194
- lamportsPerSignature: testOnChainData.fundedSenderBalance
195
- .plus(1)
196
- .toNumber(),
197
- },
198
- family: "solana",
199
- },
200
- expectedStatus: {
201
- errors: {
202
- amount: new NotEnoughBalance(),
203
- },
204
- warnings: {},
205
- estimatedFees: testOnChainData.fundedSenderBalance.plus(1),
206
- amount: zero,
207
- totalSpent: testOnChainData.fundedSenderBalance.plus(1),
208
- },
164
+ amount: testOnChainData.fundedSenderBalance,
165
+ recipient: testOnChainData.fundedAddress,
166
+ feeCalculator: testOnChainData.feeCalculator,
167
+ family: "solana",
168
+ },
169
+ expectedStatus: {
170
+ errors: {
171
+ amount: new NotEnoughBalance(),
209
172
  },
210
- {
211
- name: "transfer :: status is error: amount is 0",
212
- transaction: {
213
- model: {
214
- kind: "transfer",
215
- uiState: {},
216
- },
217
- amount: zero,
218
- recipient: testOnChainData.fundedAddress,
219
- feeCalculator: testOnChainData.feeCalculator,
220
- family: "solana",
221
- },
222
- expectedStatus: {
223
- errors: {
224
- amount: new AmountRequired(),
225
- },
226
- warnings: {},
227
- estimatedFees: fees(1),
228
- amount: zero,
229
- totalSpent: fees(1),
173
+ warnings: {},
174
+ estimatedFees: fees(1),
175
+ amount: testOnChainData.fundedSenderBalance,
176
+ totalSpent: testOnChainData.fundedSenderBalance.plus(fees(1)),
177
+ },
178
+ },
179
+ {
180
+ name: "transfer :: status is error: not enough balance, all amount",
181
+ transaction: {
182
+ model: {
183
+ kind: "transfer",
184
+ uiState: {
185
+ memo: "a memo",
230
186
  },
231
187
  },
232
- {
233
- name: "transfer :: status is error: amount is negative",
234
- transaction: {
235
- model: {
236
- kind: "transfer",
237
- uiState: {},
238
- },
239
- amount: new BigNumber(-1),
240
- recipient: testOnChainData.fundedAddress,
241
- feeCalculator: testOnChainData.feeCalculator,
242
- family: "solana",
243
- },
244
- expectedStatus: {
245
- errors: {
246
- amount: new AmountRequired(),
247
- },
248
- warnings: {},
249
- estimatedFees: fees(1),
250
- amount: new BigNumber(-1),
251
- totalSpent: new BigNumber(-1).plus(fees(1)),
252
- },
188
+ useAllAmount: true,
189
+ amount: zero,
190
+ recipient: testOnChainData.fundedAddress,
191
+ feeCalculator: {
192
+ lamportsPerSignature: testOnChainData.fundedSenderBalance
193
+ .plus(1)
194
+ .toNumber(),
253
195
  },
254
- {
255
- name: "transfer :: status is warning: recipient wallet not funded",
256
- transaction: {
257
- model: {
258
- kind: "transfer",
259
- uiState: {},
260
- },
261
- amount: new BigNumber(1),
262
- recipient: testOnChainData.unfundedAddress,
263
- feeCalculator: testOnChainData.feeCalculator,
264
- family: "solana",
265
- },
266
- expectedStatus: {
267
- errors: {},
268
- warnings: {
269
- recipient: new SolanaAccountNotFunded(),
270
- },
271
- estimatedFees: fees(1),
272
- amount: new BigNumber(1),
273
- totalSpent: fees(1).plus(1),
274
- },
196
+ family: "solana",
197
+ },
198
+ expectedStatus: {
199
+ errors: {
200
+ amount: new NotEnoughBalance(),
275
201
  },
276
- {
277
- name: "transfer :: status is warning: recipient address is off ed25519",
278
- transaction: {
279
- model: {
280
- kind: "transfer",
281
- uiState: {},
282
- },
283
- amount: new BigNumber(1),
284
- recipient: testOnChainData.offEd25519Address,
285
- feeCalculator: testOnChainData.feeCalculator,
286
- family: "solana",
287
- },
288
- expectedStatus: {
289
- errors: {},
290
- warnings: {
291
- recipient: new SolanaAccountNotFunded(),
292
- recipientOffCurve: new SolanaAddressOffEd25519(),
293
- },
294
- estimatedFees: fees(1),
295
- amount: new BigNumber(1),
296
- totalSpent: fees(1).plus(1),
297
- },
202
+ warnings: {},
203
+ estimatedFees: testOnChainData.fundedSenderBalance.plus(1),
204
+ amount: zero,
205
+ totalSpent: testOnChainData.fundedSenderBalance.plus(1),
206
+ },
207
+ },
208
+ {
209
+ name: "transfer :: status is error: amount is 0",
210
+ transaction: {
211
+ model: {
212
+ kind: "transfer",
213
+ uiState: {},
298
214
  },
299
- // no tokens for first release
300
- /*
301
- {
302
- name: "token.transfer :: status is success: recipient is funded wallet, assoc token acc exists",
303
- transaction: {
304
- model: {
305
- kind: "token.transfer",
306
- uiState: {
307
- subAccountId: wSolSubAccId,
308
- },
309
- },
310
- amount:
311
- testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
312
- recipient: testOnChainData.fundedAddress,
313
- feeCalculator: testOnChainData.feeCalculator,
314
- family: "solana",
315
- },
316
- expectedStatus: {
317
- errors: {},
318
- warnings: {},
319
- estimatedFees: fees(1),
320
- amount:
321
- testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
322
- totalSpent:
323
- testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
324
- },
215
+ amount: zero,
216
+ recipient: testOnChainData.fundedAddress,
217
+ feeCalculator: testOnChainData.feeCalculator,
218
+ family: "solana",
219
+ },
220
+ expectedStatus: {
221
+ errors: {
222
+ amount: new AmountRequired(),
325
223
  },
326
- {
327
- name: "token.transfer :: status is success: recipient is correct mint token acc",
328
- transaction: {
329
- model: {
330
- kind: "token.transfer",
331
- uiState: {
332
- subAccountId: wSolSubAccId,
333
- },
334
- },
335
- amount:
336
- testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
337
- recipient:
338
- testOnChainData.wSolFundedAccountAssocTokenAccAddress,
339
- feeCalculator: testOnChainData.feeCalculator,
340
- family: "solana",
341
- },
342
- expectedStatus: {
343
- errors: {},
344
- warnings: {},
345
- estimatedFees: fees(1),
346
- amount:
347
- testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
348
- totalSpent:
349
- testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
350
- },
224
+ warnings: {},
225
+ estimatedFees: fees(1),
226
+ amount: zero,
227
+ totalSpent: fees(1),
228
+ },
229
+ },
230
+ {
231
+ name: "transfer :: status is error: amount is negative",
232
+ transaction: {
233
+ model: {
234
+ kind: "transfer",
235
+ uiState: {},
351
236
  },
352
- {
353
- name: "token.transfer :: status is error: recipient is another mint token acc",
354
- transaction: {
355
- model: {
356
- kind: "token.transfer",
357
- uiState: {
358
- subAccountId: wSolSubAccId,
359
- },
360
- },
361
- amount:
362
- testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
363
- recipient: testOnChainData.notWSolTokenAccAddress,
364
- feeCalculator: testOnChainData.feeCalculator,
365
- family: "solana",
366
- },
367
- expectedStatus: {
368
- errors: {
369
- recipient: new SolanaTokenAccountHoldsAnotherToken(),
370
- },
371
- warnings: {},
372
- estimatedFees: fees(1),
373
- amount:
374
- testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
375
- totalSpent: zero,
237
+ amount: new BigNumber(-1),
238
+ recipient: testOnChainData.fundedAddress,
239
+ feeCalculator: testOnChainData.feeCalculator,
240
+ family: "solana",
241
+ },
242
+ expectedStatus: {
243
+ errors: {
244
+ amount: new AmountRequired(),
245
+ },
246
+ warnings: {},
247
+ estimatedFees: fees(1),
248
+ amount: new BigNumber(-1),
249
+ totalSpent: new BigNumber(-1).plus(fees(1)),
250
+ },
251
+ },
252
+ {
253
+ name: "transfer :: status is warning: recipient wallet not funded",
254
+ transaction: {
255
+ model: {
256
+ kind: "transfer",
257
+ uiState: {},
258
+ },
259
+ amount: new BigNumber(1),
260
+ recipient: testOnChainData.unfundedAddress,
261
+ feeCalculator: testOnChainData.feeCalculator,
262
+ family: "solana",
263
+ },
264
+ expectedStatus: {
265
+ errors: {},
266
+ warnings: {
267
+ recipient: new SolanaAccountNotFunded(),
268
+ },
269
+ estimatedFees: fees(1),
270
+ amount: new BigNumber(1),
271
+ totalSpent: fees(1).plus(1),
272
+ },
273
+ },
274
+ {
275
+ name: "transfer :: status is warning: recipient address is off ed25519",
276
+ transaction: {
277
+ model: {
278
+ kind: "transfer",
279
+ uiState: {},
280
+ },
281
+ amount: new BigNumber(1),
282
+ recipient: testOnChainData.offEd25519Address,
283
+ feeCalculator: testOnChainData.feeCalculator,
284
+ family: "solana",
285
+ },
286
+ expectedStatus: {
287
+ errors: {},
288
+ warnings: {
289
+ recipient: new SolanaAccountNotFunded(),
290
+ recipientOffCurve: new SolanaAddressOffEd25519(),
291
+ },
292
+ estimatedFees: fees(1),
293
+ amount: new BigNumber(1),
294
+ totalSpent: fees(1).plus(1),
295
+ },
296
+ },
297
+ // no tokens for first release
298
+ /*
299
+ {
300
+ name: "token.transfer :: status is success: recipient is funded wallet, assoc token acc exists",
301
+ transaction: {
302
+ model: {
303
+ kind: "token.transfer",
304
+ uiState: {
305
+ subAccountId: wSolSubAccId,
376
306
  },
377
307
  },
378
- {
379
- name: "token.transfer :: status is warning: recipient is off curve",
380
- transaction: {
381
- model: {
382
- kind: "token.transfer",
383
- uiState: {
384
- subAccountId: wSolSubAccId,
385
- },
386
- },
387
- amount:
388
- testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
389
- recipient: testOnChainData.offEd25519Address,
390
- feeCalculator: testOnChainData.feeCalculator,
391
- family: "solana",
308
+ amount:
309
+ testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
310
+ recipient: testOnChainData.fundedAddress,
311
+ feeCalculator: testOnChainData.feeCalculator,
312
+ family: "solana",
313
+ },
314
+ expectedStatus: {
315
+ errors: {},
316
+ warnings: {},
317
+ estimatedFees: fees(1),
318
+ amount:
319
+ testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
320
+ totalSpent:
321
+ testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
322
+ },
323
+ },
324
+ {
325
+ name: "token.transfer :: status is success: recipient is correct mint token acc",
326
+ transaction: {
327
+ model: {
328
+ kind: "token.transfer",
329
+ uiState: {
330
+ subAccountId: wSolSubAccId,
392
331
  },
393
- expectedStatus: {
394
- errors: {
395
- recipient: new SolanaAddressOffEd25519(),
396
- },
397
- warnings: {},
398
- estimatedFees: fees(1),
399
- amount:
400
- testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
401
- totalSpent: zero,
332
+ },
333
+ amount:
334
+ testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
335
+ recipient:
336
+ testOnChainData.wSolFundedAccountAssocTokenAccAddress,
337
+ feeCalculator: testOnChainData.feeCalculator,
338
+ family: "solana",
339
+ },
340
+ expectedStatus: {
341
+ errors: {},
342
+ warnings: {},
343
+ estimatedFees: fees(1),
344
+ amount:
345
+ testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
346
+ totalSpent:
347
+ testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
348
+ },
349
+ },
350
+ {
351
+ name: "token.transfer :: status is error: recipient is another mint token acc",
352
+ transaction: {
353
+ model: {
354
+ kind: "token.transfer",
355
+ uiState: {
356
+ subAccountId: wSolSubAccId,
402
357
  },
403
358
  },
404
- {
405
- name: "token.transfer :: status is success: recipient is wallet and no assoc token acc exists (will be created)",
406
- transaction: {
407
- model: {
408
- kind: "token.transfer",
409
- uiState: {
410
- subAccountId: wSolSubAccId,
411
- },
412
- },
413
- amount:
414
- testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
415
- recipient: testOnChainData.unfundedAddress,
416
- feeCalculator: testOnChainData.feeCalculator,
417
- family: "solana",
359
+ amount:
360
+ testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
361
+ recipient: testOnChainData.notWSolTokenAccAddress,
362
+ feeCalculator: testOnChainData.feeCalculator,
363
+ family: "solana",
364
+ },
365
+ expectedStatus: {
366
+ errors: {
367
+ recipient: new SolanaTokenAccountHoldsAnotherToken(),
368
+ },
369
+ warnings: {},
370
+ estimatedFees: fees(1),
371
+ amount:
372
+ testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
373
+ totalSpent: zero,
374
+ },
375
+ },
376
+ {
377
+ name: "token.transfer :: status is warning: recipient is off curve",
378
+ transaction: {
379
+ model: {
380
+ kind: "token.transfer",
381
+ uiState: {
382
+ subAccountId: wSolSubAccId,
418
383
  },
419
- expectedStatus: {
420
- errors: {},
421
- warnings: {
422
- recipient: new SolanaAccountNotFunded(),
423
- recipientAssociatedTokenAccount:
424
- new SolanaRecipientAssociatedTokenAccountWillBeFunded(),
425
- },
426
- // this fee is dynamic, skip
427
- //estimatedFees: new BigNumber(2044280),
428
- amount:
429
- testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
430
- totalSpent:
431
- testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
384
+ },
385
+ amount:
386
+ testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
387
+ recipient: testOnChainData.offEd25519Address,
388
+ feeCalculator: testOnChainData.feeCalculator,
389
+ family: "solana",
390
+ },
391
+ expectedStatus: {
392
+ errors: {
393
+ recipient: new SolanaAddressOffEd25519(),
394
+ },
395
+ warnings: {},
396
+ estimatedFees: fees(1),
397
+ amount:
398
+ testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
399
+ totalSpent: zero,
400
+ },
401
+ },
402
+ {
403
+ name: "token.transfer :: status is success: recipient is wallet and no assoc token acc exists (will be created)",
404
+ transaction: {
405
+ model: {
406
+ kind: "token.transfer",
407
+ uiState: {
408
+ subAccountId: wSolSubAccId,
432
409
  },
433
410
  },
434
- */
435
- ],
411
+ amount:
412
+ testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
413
+ recipient: testOnChainData.unfundedAddress,
414
+ feeCalculator: testOnChainData.feeCalculator,
415
+ family: "solana",
416
+ },
417
+ expectedStatus: {
418
+ errors: {},
419
+ warnings: {
420
+ recipient: new SolanaAccountNotFunded(),
421
+ recipientAssociatedTokenAccount:
422
+ new SolanaRecipientAssociatedTokenAccountWillBeFunded(),
423
+ },
424
+ // this fee is dynamic, skip
425
+ //estimatedFees: new BigNumber(2044280),
426
+ amount:
427
+ testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
428
+ totalSpent:
429
+ testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
430
+ },
436
431
  },
432
+ */
437
433
  ],
438
434
  },
435
+ ],
436
+ };
437
+
438
+ const dataset: DatasetTest<Transaction> = {
439
+ implementations: [getEnv("MOCK") ? "mock" : "js"], // FIXME we should actually put both mock and js like other dataset do
440
+ currencies: {
441
+ // solana, // TODO re enable when it's ready
439
442
  },
440
443
  };
441
444