Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wallet): Prevent Double Account Creation on Buy Screen #26954

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ import { Column, Row, Text } from '../../../../../components/shared/style'
interface Props extends DialogProps {
isOpen: boolean
token?: MeldCryptoCurrency
onSelectToken: (asset: MeldCryptoCurrency) => void
onSelectToken: (
asset: MeldCryptoCurrency,
account?: BraveWallet.AccountInfo
) => void
onClose: () => void
}

Expand Down Expand Up @@ -92,7 +95,7 @@ export const CreateAccount = (props: Props) => {
}).unwrap()

if (account) {
onSelectToken(token)
onSelectToken(token, account)
}
} catch (error) {
console.log(error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,12 @@ export const useBuy = () => {
)

const onSelectToken = useCallback(
async (asset: MeldCryptoCurrency) => {
async (asset: MeldCryptoCurrency, account?: BraveWallet.AccountInfo) => {
const incomingAssetsCoinType = getMeldTokensCoinType(asset)
const accountToUse =
selectedAccount.accountId.coin !== incomingAssetsCoinType
account !== undefined
? account
: selectedAccount.accountId.coin !== incomingAssetsCoinType
? getFirstAccountByCoinType(incomingAssetsCoinType, accounts)
: selectedAccount
if (!accountToUse) {
Expand Down
Loading