diff --git a/packages/shared/src/lib/core/utils/crypto/utils/validateBech32Address.ts b/packages/shared/src/lib/core/utils/crypto/utils/validateBech32Address.ts index 65c64d6eef..96d78d4287 100644 --- a/packages/shared/src/lib/core/utils/crypto/utils/validateBech32Address.ts +++ b/packages/shared/src/lib/core/utils/crypto/utils/validateBech32Address.ts @@ -5,7 +5,6 @@ import { ADDRESS_TYPE_MAP } from '@core/wallet/constants' import { AddressType } from '@iota/sdk/out/types' export function validateBech32Address(prefix: string, addr: string, addressType?: AddressType): void { - const addressTypeLetter = addressType ? ADDRESS_TYPE_MAP[addressType] ?? undefined : undefined if (!addr || !addr.startsWith(prefix)) { throw new Error( localize('error.send.wrongAddressPrefix', { @@ -19,6 +18,7 @@ export function validateBech32Address(prefix: string, addr: string, addressType? throw new Error(localize('error.send.wrongAddressFormat')) } + const addressTypeLetter = addressType === undefined ? undefined : ADDRESS_TYPE_MAP[addressType] ?? undefined if (addressTypeLetter && !new RegExp(`^${prefix}1${addressTypeLetter}[02-9ac-hj-np-z]{58}$`).test(addr)) { throw new Error(localize('error.address.wrongAddressType')) }