Skip to content

Commit b4f915d

Browse files
authored
fix: add logs for canceled transaction & improve notifications for ledger devices (#116)
1 parent f9a3416 commit b4f915d

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

packages/shared/routes/setup/migrate/views/Migrate.svelte

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
.selectSeed($hardwareIndexes.accountIndex, $hardwareIndexes.pageIndex, ADDRESS_SECURITY_LEVEL)
8686
.then(({ iota, callback }) => {
8787
closeTransport = callback
88+
prepareMigrationLog([], migratableBalance)
8889
return createLedgerMigrationBundle(
8990
0,
9091
get(migrationAddress),
@@ -96,7 +97,10 @@
9697
closePopup(true) // close transaction popup
9798
singleMigrationBundleHash = bundleHash
9899
const reverseTrytesLedger = trytes.reverse()
99-
prepareMigrationLog(reverseTrytesLedger, migratableBalance, bundleHash)
100+
updateMigrationLog(get(migrationLog).length - 1, {
101+
trytes: reverseTrytesLedger,
102+
bundleHash,
103+
})
100104
return sendOffLedgerMigrationRequest(reverseTrytesLedger, 0)
101105
})
102106
.then((receipt) => {
@@ -114,7 +118,7 @@
114118
}
115119
})
116120
.catch((err) => {
117-
const error = err?.message ? err.message : err?.toString()
121+
const error = err?.message ?? err?.toString()
118122
loading = false
119123
closePopup(true) // close transaction popup
120124
closeTransport()
@@ -154,7 +158,7 @@
154158
}
155159
})
156160
.catch((err) => {
157-
const error = err?.message ? err.message : err.toString()
161+
const error = err?.message ?? err?.toString()
158162
loading = false
159163
showAppNotification({
160164
type: 'error',

packages/shared/routes/setup/migrate/views/TransferFragmentedFunds.svelte

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import { Platform } from 'shared/lib/platform'
66
import {
77
displayNotificationForLedgerProfile,
8+
getLegacyErrorMessage,
89
ledgerDeviceState,
910
promptUserToConnectLedger,
1011
} from 'shared/lib/ledger'
@@ -218,6 +219,7 @@
218219
)
219220
.then(({ iota, callback }) => {
220221
closeTransport = callback
222+
prepareMigrationLog([], transaction.balance)
221223
return createLedgerMigrationBundle(
222224
transaction.index,
223225
get(migrationAddress),
@@ -235,7 +237,10 @@
235237
return _transaction
236238
})
237239
const reverseTrytesLedger = trytes.reverse()
238-
prepareMigrationLog(reverseTrytesLedger, transaction.balance, bundleHash)
240+
updateMigrationLog(get(migrationLog).length - 1, {
241+
trytes: reverseTrytesLedger,
242+
bundleHash,
243+
})
239244
return sendOffLedgerMigrationRequest(reverseTrytesLedger, transaction.index)
240245
})
241246
.then((receipt) => {
@@ -250,10 +255,20 @@
250255
}
251256
})
252257
.catch((err) => {
253-
const error = err?.message ? err.message : err?.toString()
258+
const error = err?.message ?? err?.toString()
254259
updateMigrationLog(get(migrationLog).length - 1, { errorMessage: error })
255260
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+
)
257272
})
258273
} else {
259274
setMigratingTransaction(transaction, 1)
@@ -276,7 +291,7 @@
276291
}
277292
})
278293
.catch((err) => {
279-
const error = err?.message ? err.message : err?.toString()
294+
const error = err?.message ?? err?.toString()
280295
updateMigrationLog(get(migrationLog).length - 1, { errorMessage: error })
281296
addMigrationError(error)
282297
throw new Error(err)
@@ -286,11 +301,6 @@
286301
.catch((error) => {
287302
console.error(error)
288303
289-
if (legacyLedger) {
290-
closePopup(true) // close transaction popup
291-
closeTransport()
292-
displayNotificationForLedgerProfile('error', false, true, false, true, error)
293-
}
294304
showAppNotification({
295305
type: 'error',
296306
message: error.message || 'Failed to prepare transfers',

0 commit comments

Comments
 (0)