Skip to content

Commit

Permalink
Merge pull request #26954 from brave/fix-wallet-prevent-double-accoun…
Browse files Browse the repository at this point in the history
…t-creation-on-buy-screen

fix(wallet): Prevent Double Account Creation on Buy Screen
  • Loading branch information
Douglashdaniel authored Dec 12, 2024
2 parents 1ce9c73 + 9170120 commit 059a437
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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

0 comments on commit 059a437

Please sign in to comment.