Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui-ux): cfp valid address warning #4150

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function AddressRow({
onAddressType,
showQrButton = true,
onlyLocalAddress,
restrictedJellyfishAddressType,
matchedAddress,
setMatchedAddress,
setAddressLabel,
Expand All @@ -63,6 +64,7 @@ export function AddressRow({
onAddressType?: (addressType?: AddressType) => void;
showQrButton?: boolean;
onlyLocalAddress?: boolean;
restrictedJellyfishAddressType?: JellyfishAddressType[];
matchedAddress?: LocalAddress | WhitelistedAddress | undefined;
setMatchedAddress?: (address?: LocalAddress | WhitelistedAddress) => void;
setAddressLabel?: React.Dispatch<React.SetStateAction<string | undefined>>;
Expand All @@ -86,14 +88,24 @@ export function AddressRow({
const [validEvmAddress, setValidEvmAddress] = useState<boolean>(false);

const validLocalAddress = useMemo(() => {
if (
restrictedJellyfishAddressType?.some(
(addressType) => addressType === getAddressType(address, networkName),
)
) {
return false;
}

if (address === "") {
return true;
}

if (onlyLocalAddress) {
return addressType === AddressType.WalletAddress;
}

return true;
}, [onlyLocalAddress, addressType, address]);
}, [onlyLocalAddress, addressType, address, networkName]);

const addressObj = jellyfishWalletAddress.find(
(e: WalletAddressI) => e.dvm === address || e.evm === address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
} from "@hooks/wallet/Conversion";
import { useSelector } from "react-redux";
import { RootState } from "@store";
import { LocalAddress, WhitelistedAddress } from "@store/userPreferences";
import {
DFITokenSelector,
DFIUtxoSelector,
Expand All @@ -34,6 +35,7 @@ import { AddressRow } from "@screens/AppNavigator/screens/Portfolio/components/A
import { ButtonGroupTabKey } from "@screens/AppNavigator/screens/Portfolio/screens/AddressBookScreen";
import { DomainType } from "@contexts/DomainContext";
import { ConvertDirection } from "@screens/enum";
import { AddressType as JellyfishAddressType } from "@waveshq/walletkit-core";

export function CFPDetailScreen(): JSX.Element {
const logger = useLogger();
Expand All @@ -47,6 +49,9 @@ export function CFPDetailScreen(): JSX.Element {
const proposalFee = getCFPFee(BigNumber(amount ?? 0));
const navigation = useNavigation<NavigationProp<PortfolioParamList>>();
const [isUrlValid, setUrlValid] = useState<boolean>(false);
const [matchedAddress, setMatchedAddress] = useState<
LocalAddress | WhitelistedAddress
>();

const DFIToken = useSelector((state: RootState) =>
DFITokenSelector(state.wallet),
Expand Down Expand Up @@ -268,7 +273,11 @@ export function CFPDetailScreen(): JSX.Element {
await trigger("address");
}}
address={address}
onMatchedAddress={setMatchedAddress}
setMatchedAddress={setMatchedAddress}
matchedAddress={matchedAddress}
onlyLocalAddress
restrictedJellyfishAddressType={[JellyfishAddressType.ETH]}
/>
</View>
)}
Expand Down
Loading