Skip to content

Commit

Permalink
fix(ui-ux): fully disable send to evm (#4138)
Browse files Browse the repository at this point in the history
* fix(ui-ux): fully disable send to evm

* change error message for evm address

* change error message for evm address
  • Loading branch information
pierregee authored Nov 21, 2023
1 parent 5b63897 commit e0d2511
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function AddressRow({
setAddressLabel?: React.Dispatch<React.SetStateAction<string | undefined>>;
}): JSX.Element {
const { fetchWalletAddresses } = useWalletAddress();
const { domain } = useDomainContext();
const { domain, isEvmFeatureEnabled } = useDomainContext();

const defaultValue = "";

Expand Down Expand Up @@ -134,6 +134,7 @@ export function AddressRow({
if (onlyLocalAddress) {
setAddressType(undefined);
} else if (
isEvmFeatureEnabled &&
getAddressType(address, networkName) === JellyfishAddressType.ETH
) {
// Unsaved and valid EVM address
Expand Down Expand Up @@ -267,14 +268,27 @@ export function AddressRow({
rules={{
required: true,
validate: {
isValidAddress: (address) =>
// Check if its either a valid EVM/DVM address &&
!!getAddressType(address, networkName) &&
// EVM -> EVM domain transfer is not allowed
!(
getAddressType(address, networkName) ===
JellyfishAddressType.ETH && domain === DomainType.EVM
),
isValidAddress: (address) => {
const addressType = getAddressType(address, networkName);

// Check if address is EVM and feature flag is enabled
if (
!isEvmFeatureEnabled &&
addressType === JellyfishAddressType.ETH
) {
return false;
}

return (
// Check if its either a valid EVM/DVM address &&
!!addressType &&
// EVM -> EVM domain transfer is not allowed
!(
addressType === JellyfishAddressType.ETH &&
domain === DomainType.EVM
)
);
},
},
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,8 @@ export function SendScreen({ route, navigation }: Props): JSX.Element {
!formState.isValid ||
hasPendingJob ||
hasPendingBroadcastJob ||
token === undefined
token === undefined ||
(isEvmAddress && !isEvmFeatureEnabled)
}
label={translate("screens/SendScreen", "Continue")}
onSubmit={onSubmit}
Expand Down

0 comments on commit e0d2511

Please sign in to comment.