Skip to content

Commit 68af75c

Browse files
authored
feat: add more info into migration logs (#89)
* feat: add more info into migration logs * feat: add more info into migration logs * fix: format * refactor: prepareMigrationLog * fix: prepare migration log * fix: reset migration log after each migration
1 parent e0d7299 commit 68af75c

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

packages/shared/lib/migration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ export const prepareMigrationLog = (bundleHash: string, trytes: string[], balanc
430430
spentAddresses: bundle?.inputs?.filter((input) => input.spent === true).map((input) => input.address) || [],
431431
mine: bundle?.miningRuns > 0,
432432
crackability: bundle?.crackability || null,
433+
depositAddress: get(migrationAddress)?.bech32 ?? '',
433434
},
434435
])
435436
}
@@ -1355,6 +1356,7 @@ export const resetMigrationState = (): void => {
13551356
bundles.set([])
13561357
migrationAddress.set(null)
13571358
accounts.set([])
1359+
migrationLog.set([])
13581360
}
13591361

13601362
/**

packages/shared/lib/typings/migration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ export interface MigrationLog {
6464
spentBundleHashes: string[]
6565
mine: boolean
6666
crackability: number | null
67+
depositAddress?: string
68+
requestId?: string
6769
}
6870

6971
export interface Bundle {

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
hasSingleBundle,
1515
migration,
1616
migrationAddress,
17+
migrationLog,
1718
prepareMigrationLog,
1819
sendOffLedgerMigrationRequest,
1920
unselectedInputs,
@@ -93,7 +94,12 @@
9394
return sendOffLedgerMigrationRequest(reverseTrytesLedger, 0)
9495
})
9596
.then((receipt) => {
96-
// todo: handle receipt data
97+
migrationLog.update((_migrationLog) =>
98+
_migrationLog.map((log) => ({
99+
...log,
100+
requestId: receipt?.request?.requestId || '',
101+
}))
102+
)
97103
loading = false
98104
if ($newProfile) {
99105
// Save profile
@@ -127,7 +133,12 @@
127133
return sendOffLedgerMigrationRequest(reverseTrytesSoftware, 0)
128134
})
129135
.then((receipt) => {
130-
// todo: handle receipt data
136+
migrationLog.update((_migrationLog) =>
137+
_migrationLog.map((log) => ({
138+
...log,
139+
requestId: receipt?.request?.requestId || '',
140+
}))
141+
)
131142
loading = false
132143
if ($newProfile) {
133144
// Save profile

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
hasMigratedAnyBundle,
2121
migration,
2222
migrationAddress,
23+
migrationLog,
2324
prepareMigrationLog,
2425
sendOffLedgerMigrationRequest,
2526
unmigratedBundles,
@@ -234,7 +235,14 @@
234235
return sendOffLedgerMigrationRequest(reverseTrytesLedger, transaction.index)
235236
})
236237
.then((receipt) => {
237-
// todo: handle receipt
238+
migrationLog.update((_migrationLog) => [
239+
..._migrationLog,
240+
(_migrationLog[idx] = {
241+
..._migrationLog[idx],
242+
requestId: receipt?.request?.requestId || '',
243+
}),
244+
])
245+
238246
if (!hasBroadcastAnyBundle) {
239247
hasBroadcastAnyBundle = true
240248
persistProfile()
@@ -250,6 +258,13 @@
250258
return sendOffLedgerMigrationRequest(reverseTrytesSoftware, transaction.index)
251259
})
252260
.then((receipt) => {
261+
migrationLog.update((_migrationLog) => [
262+
..._migrationLog,
263+
(_migrationLog[idx] = {
264+
..._migrationLog[idx],
265+
requestId: receipt?.request?.requestId || '',
266+
}),
267+
])
253268
// todo: handle receipt data
254269
// is this needed?
255270
if (!hasBroadcastAnyBundle) {
@@ -330,6 +345,10 @@
330345
<Spinner {busy} message={migratingFundsMessage} classes="justify-center" />
331346
{/if}
332347
</Button>
348+
{:else if fullSuccess}
349+
<Button classes="w-full py-3 mt-2" onClick={() => handleContinueClick()}
350+
>{locale('actions.continue')}</Button
351+
>
333352
{:else if someSuccess}
334353
<div class="flex flex-row justify-center items-center py-3 mt-2 w-full space-x-2">
335354
<Button classes="w-1/2 {$popupState.active && 'opacity-20'}" onClick={() => handleRerunClick()}>
@@ -339,10 +358,6 @@
339358
{locale('actions.continue')}
340359
</Button>
341360
</div>
342-
{:else if fullSuccess}
343-
<Button classes="w-full py-3 mt-2" onClick={() => handleContinueClick()}
344-
>{locale('actions.continue')}</Button
345-
>
346361
{:else}
347362
<Button classes="w-full py-3 mt-2 {$popupState.active && 'opacity-20'}" onClick={() => handleRerunClick()}>
348363
{locale('views.transferFragmentedFunds.rerun')}

0 commit comments

Comments
 (0)