Skip to content

Commit

Permalink
fix: handling the case where chain swapping happens right after transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Nov 24, 2023
1 parent f44492b commit e5dd659
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/components/layout/account/sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
function onSelect(session: SessionLike) {
activate(session).then(() => {
fetchBalances($activeSession!)
setTimeout(() => {
fetchBalances($activeSession!, true)
}, 1000)
})
open = false
}
Expand Down
18 changes: 12 additions & 6 deletions src/pages/transfer/form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
fromOptions = []
const fromOptionsBeingSet: Token[] = []
await Promise.all(
Object.values(transferManagers).map(async (transferManagerData) => {
const TransferManagerClass = transferManagerData.transferClass
Expand All @@ -98,10 +100,12 @@
return
}
fromOptions.push(token)
fromOptionsBeingSet.push(token)
})
)
fromOptions = [...fromOptionsBeingSet]
generatingOptions = false
}
Expand All @@ -116,11 +120,13 @@
}
$: {
const fromInOptions = fromOptions.find(
(token) => from?.symbol.equals(token.symbol) && token.name !== from?.name
)
if (!fromInOptions) {
toOptions = []
if (from) {
const fromInOptions = fromOptions.find(
(token) => from?.symbol.equals(token.symbol) && token.name !== from?.name
)
if (!fromInOptions) {
toOptions = []
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/pages/transfer/success.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import type {TransferManager} from './managers/transferManager'
import {updateBalances} from '~/stores/balances-provider'
import {activeSession} from '~/store'
import { get } from 'svelte/store'
export let transferManager: TransferManager
export let transactResult: TransactResult | ethers.providers.TransactionResponse
Expand Down Expand Up @@ -41,9 +42,10 @@
) {
clearInterval(refreshInterval)
}
// Fetch the balances
updateBalances($activeSession!)
}, 1000)
updateBalances(get(activeSession)!)
}, 2000)
// Timeout after 30 seconds
setTimeout(() => {
Expand Down

0 comments on commit e5dd659

Please sign in to comment.