Skip to content

Commit

Permalink
Merge branch 'main' into chloe/save-tx
Browse files Browse the repository at this point in the history
  • Loading branch information
chloezxyy authored Jan 24, 2024
2 parents fd633c0 + b2d55e5 commit eec0f90
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export function PortfolioScreen({ navigation }: Props): JSX.Element {
const dispatch = useAppDispatch();
const [refreshing, setRefreshing] = useState(false);
const [isZeroBalance, setIsZeroBalance] = useState(true);
const [isEvmZeroBalance, setIsEvmZeroBalance] = useState(true);
const { hasFetchedToken, allTokens } = useSelector(
(state: RootState) => state.wallet,
);
Expand Down Expand Up @@ -455,7 +456,10 @@ export function PortfolioScreen({ navigation }: Props): JSX.Element {
setIsZeroBalance(
!tokens.some((token) => new BigNumber(token.amount).isGreaterThan(0)),
);
}, [tokens]);
setIsEvmZeroBalance(
!evmTokens.some((token) => new BigNumber(token.amount).isGreaterThan(0)),
);
}, [tokens, evmTokens]);

const assetSortBottomSheetScreen = useMemo(() => {
return [
Expand Down Expand Up @@ -695,6 +699,7 @@ export function PortfolioScreen({ navigation }: Props): JSX.Element {
) : (
<PortfolioCard
isZeroBalance={isZeroBalance}
isEvmZeroBalance={isEvmZeroBalance}
filteredTokens={sortTokensAssetOnType(assetSortType)}
navigation={navigation}
buttonGroupOptions={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { EmptyEvmPortfolioIcon } from "../assets/EmptyEvmPortfolioIcon";

interface PortfolioCardProps {
isZeroBalance: boolean;
isEvmZeroBalance: boolean;
filteredTokens: PortfolioRowToken[];
navigation: StackNavigationProp<PortfolioParamList>;
buttonGroupOptions?: {
Expand All @@ -35,6 +36,7 @@ interface PortfolioCardProps {

export function PortfolioCard({
isZeroBalance,
isEvmZeroBalance,
filteredTokens,
navigation,
buttonGroupOptions,
Expand All @@ -44,7 +46,7 @@ export function PortfolioCard({
const { hasFetchedToken } = useSelector((state: RootState) => state.wallet);
const { domain } = useDomainContext();
// return empty portfolio if no DFI and other tokens
if (isZeroBalance) {
if ((isZeroBalance && !isEvmDomain) || (isEvmZeroBalance && isEvmDomain)) {
const screenDetails = getEmptyScreenDetails(
ButtonGroupTabKey.AllTokens,
domain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function StepThree(): JSX.Element {
dark={tailwind("bg-mono-dark-v2-00 border-mono-dark-v2-200")}
light={tailwind("bg-mono-light-v2-00 border-mono-light-v2-200")}
>
<View>
<View style={tailwind("flex flex-col items-center")}>
<ThemedViewV2
style={tailwind(
"w-15 h-15 flex flex-row justify-around items-center rounded-full",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export function ServiceProviderScreen({ navigation }: Props): JSX.Element {
url: dvmUrl,
defaultUrl: defaultDvmUrl,
setUrl: setDvmUrl,
isCustomUrl,
} = useServiceProviderContext();
const { evmUrl, ethRpcUrl, defaultEvmUrl, defaultEthRpcUrl, setCustomUrl } =
useCustomServiceProviderContext();
Expand Down Expand Up @@ -191,41 +192,43 @@ export function ServiceProviderScreen({ navigation }: Props): JSX.Element {
/>
))}
</View>
{showActionButtons && (
<View
style={tailwind("mt-48", {
"mt-36": isSmallScreen,
"mt-10": customProviders.length > 1,
})}
>
<View style={tailwind("mt-2 px-5 mb-5")}>
<Text
style={tailwind(
"text-orange-v2 font-normal-v2 text-xs text-center",
)}
>
{translate(
"screens/ServiceProviderScreen",
"Only add URLs that are fully trusted and secured. Adding malicious service providers may result in irrecoverable funds. Proceed at your own risk.",
)}
</Text>
</View>
<ButtonV2
styleProps="mx-7 mt-2"
label={translate("screens/ServiceProviderScreen", "Save changes")}
testID="button_submit"
onPress={async () => await submitCustomServiceProvider()}
disabled={
!(
urlInputValues.DVM.isValid &&
urlInputValues.EVM.isValid &&
urlInputValues.ETHRPC.isValid
)
}
/>
<ResetButton />
</View>
)}
<View
style={tailwind("mt-48", {
"mt-36": isSmallScreen,
"mt-10": customProviders.length > 1,
})}
>
{showActionButtons && (
<>
<View style={tailwind("mt-2 px-5 mb-5")}>
<Text
style={tailwind(
"text-orange-v2 font-normal-v2 text-xs text-center",
)}
>
{translate(
"screens/ServiceProviderScreen",
"Only add URLs that are fully trusted and secured. Adding malicious service providers may result in irrecoverable funds. Proceed at your own risk.",
)}
</Text>
</View>
<ButtonV2
styleProps="mx-7 mt-2"
label={translate("screens/ServiceProviderScreen", "Save changes")}
testID="button_submit"
onPress={async () => await submitCustomServiceProvider()}
disabled={
!(
urlInputValues.DVM.isValid &&
urlInputValues.EVM.isValid &&
urlInputValues.ETHRPC.isValid
)
}
/>
</>
)}
{(showActionButtons || isCustomUrl) && <ResetButton />}
</View>
</ThemedScrollViewV2>
);
}

0 comments on commit eec0f90

Please sign in to comment.