From f8cc81518c562ce4c2859a3dffee1cdd8ab26ff8 Mon Sep 17 00:00:00 2001 From: Viktor Vasas Date: Thu, 31 Oct 2024 16:15:11 +0100 Subject: [PATCH] fix: identify x and p address without prefix --- src/pages/Send/hooks/useIdentifyAddress.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pages/Send/hooks/useIdentifyAddress.ts b/src/pages/Send/hooks/useIdentifyAddress.ts index ca12b0e2..236309b2 100644 --- a/src/pages/Send/hooks/useIdentifyAddress.ts +++ b/src/pages/Send/hooks/useIdentifyAddress.ts @@ -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: '', @@ -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: '' } @@ -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: '' }