Skip to content

Commit

Permalink
Merge pull request #177 from greymass/dev
Browse files Browse the repository at this point in the history
Transfer + Send/Receive fixes
  • Loading branch information
aaroncox authored Oct 17, 2023
2 parents af1b621 + 3973bb5 commit 6d9ba7f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/components/elements/input/token/selector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import {activeBlockchain} from '~/store'
import type {Token} from '~/stores/tokens'
import {tokens} from '~/stores/tokens'
import {balances} from '~/stores/balances'
import Form from '~/components/elements/form.svelte'
import Input from '~/components/elements/input.svelte'
Expand All @@ -16,6 +17,13 @@
export let selectedToken: Token | undefined = undefined
export let tokenOptions: Token[] | undefined = undefined
export let onTokenSelect: (token: Token) => void
export let showTokensWithoutBalance: boolean = false
$: {
if (defaultToken) {
selectedToken = defaultToken
}
}
let displayModal = writable<boolean>(false)
let query: string = ''
Expand All @@ -42,11 +50,22 @@
($tokens &&
$tokens.filter((token) => {
const blockchainMatches = token.chainId.equals($activeBlockchain.chainId)
let balanceExists
if (!showTokensWithoutBalance) {
balanceExists = !!(
token.balance ||
$balances.find((balance) => balance.tokenKey === token.key)
)
}
const queryExists = query.length === 0
const queryMatches = String(token.name)
.toLowerCase()
.includes(query.toLowerCase())
return blockchainMatches && (queryExists || queryMatches)
return (
blockchainMatches &&
(queryExists || queryMatches) &&
(showTokensWithoutBalance || balanceExists)
)
})) ||
[]
}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/transfer/form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
onTokenSelect={handleFromChange}
selectedToken={from}
tokenOptions={fromOptions}
showTokensWithoutBalance
/>
</div>
<Label align="left">Amount</Label>
Expand All @@ -257,6 +258,7 @@
onTokenSelect={handleToChange}
selectedToken={to}
tokenOptions={toOptions}
showTokensWithoutBalance
/>
</div>
{#if receivedAmount && receivedAmount.value > 0 && feeAmount && feeAmount.value > 0}
Expand Down

0 comments on commit 6d9ba7f

Please sign in to comment.