Skip to content

Commit

Permalink
fix: identify x and p address without prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
vvava committed Oct 31, 2024
1 parent 5a4af6f commit f8cc815
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/pages/Send/hooks/useIdentifyAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useCallback } from 'react';
import { isBitcoin } from '@src/utils/isBitcoin';
import { isPchainNetwork } from '@src/background/services/network/utils/isAvalanchePchainNetwork';
import { isXchainNetwork } from '@src/background/services/network/utils/isAvalancheXchainNetwork';
import { correctAddressByPrefix } from '../utils/correctAddressByPrefix';

const UNSAVED_CONTACT_BASE = {
id: '',
Expand Down Expand Up @@ -35,8 +36,10 @@ export const useIdentifyAddress = () => {
if (
contact.address.toLowerCase() === addressLowerCase ||
contact.addressBTC?.toLowerCase() === addressLowerCase ||
`p-${contact.addressXP?.toLowerCase()}` === addressLowerCase ||
`x-${contact.addressXP?.toLowerCase()}` === addressLowerCase
`p-${contact.addressXP?.toLowerCase()}` ===
correctAddressByPrefix(addressLowerCase, 'p-') ||
`x-${contact.addressXP?.toLowerCase()}` ===
correctAddressByPrefix(addressLowerCase, 'x-')
) {
const addressToUse = isBitcoin(network)
? { addressBTC: address, address: '', addressPVM: '' }
Expand All @@ -55,8 +58,10 @@ export const useIdentifyAddress = () => {
if (
account.addressC.toLowerCase() === addressLowerCase ||
account.addressBTC?.toLocaleLowerCase() === addressLowerCase ||
account.addressPVM?.toLocaleLowerCase() === addressLowerCase ||
account.addressAVM?.toLowerCase() === addressLowerCase
account.addressPVM?.toLocaleLowerCase() ===
correctAddressByPrefix(addressLowerCase, 'p-') ||
account.addressAVM?.toLowerCase() ===
correctAddressByPrefix(addressLowerCase, 'x-')
) {
const addressToUse = isBitcoin(network)
? { addressBTC: account.addressBTC, address: '' }
Expand Down

0 comments on commit f8cc815

Please sign in to comment.