|
5 | 5 | import { Platform } from 'shared/lib/platform' |
6 | 6 | import { |
7 | 7 | displayNotificationForLedgerProfile, |
| 8 | + getLegacyErrorMessage, |
8 | 9 | ledgerDeviceState, |
9 | 10 | promptUserToConnectLedger, |
10 | 11 | } from 'shared/lib/ledger' |
|
218 | 219 | ) |
219 | 220 | .then(({ iota, callback }) => { |
220 | 221 | closeTransport = callback |
| 222 | + prepareMigrationLog([], transaction.balance) |
221 | 223 | return createLedgerMigrationBundle( |
222 | 224 | transaction.index, |
223 | 225 | get(migrationAddress), |
|
235 | 237 | return _transaction |
236 | 238 | }) |
237 | 239 | const reverseTrytesLedger = trytes.reverse() |
238 | | - prepareMigrationLog(reverseTrytesLedger, transaction.balance, bundleHash) |
| 240 | + updateMigrationLog(get(migrationLog).length - 1, { |
| 241 | + trytes: reverseTrytesLedger, |
| 242 | + bundleHash, |
| 243 | + }) |
239 | 244 | return sendOffLedgerMigrationRequest(reverseTrytesLedger, transaction.index) |
240 | 245 | }) |
241 | 246 | .then((receipt) => { |
|
250 | 255 | } |
251 | 256 | }) |
252 | 257 | .catch((err) => { |
253 | | - const error = err?.message ? err.message : err?.toString() |
| 258 | + const error = err?.message ?? err?.toString() |
254 | 259 | updateMigrationLog(get(migrationLog).length - 1, { errorMessage: error }) |
255 | 260 | addMigrationError(error) |
256 | | - throw new Error(err) |
| 261 | +
|
| 262 | + closePopup(true) // close transaction popup |
| 263 | + closeTransport() |
| 264 | + displayNotificationForLedgerProfile('error', false, true, false, true, err) |
| 265 | +
|
| 266 | + const legacyErrorMessage = getLegacyErrorMessage(err) |
| 267 | + throw new Error( |
| 268 | + legacyErrorMessage === 'error.global.generic' |
| 269 | + ? error |
| 270 | + : locale(legacyErrorMessage) |
| 271 | + ) |
257 | 272 | }) |
258 | 273 | } else { |
259 | 274 | setMigratingTransaction(transaction, 1) |
|
276 | 291 | } |
277 | 292 | }) |
278 | 293 | .catch((err) => { |
279 | | - const error = err?.message ? err.message : err?.toString() |
| 294 | + const error = err?.message ?? err?.toString() |
280 | 295 | updateMigrationLog(get(migrationLog).length - 1, { errorMessage: error }) |
281 | 296 | addMigrationError(error) |
282 | 297 | throw new Error(err) |
|
286 | 301 | .catch((error) => { |
287 | 302 | console.error(error) |
288 | 303 |
|
289 | | - if (legacyLedger) { |
290 | | - closePopup(true) // close transaction popup |
291 | | - closeTransport() |
292 | | - displayNotificationForLedgerProfile('error', false, true, false, true, error) |
293 | | - } |
294 | 304 | showAppNotification({ |
295 | 305 | type: 'error', |
296 | 306 | message: error.message || 'Failed to prepare transfers', |
|
0 commit comments