Skip to content
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
41 changes: 23 additions & 18 deletions components/Card/CardDepositInternalForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ type AmountInputProps = {
onAmountEntry?: () => void;
/** Symbol for Wallet source (e.g. USDC.e or rUSD). */
walletTokenSymbol: string;
/** Optional override for the right-hand token cell (e.g. WalletTokenButton). */
rightSlot?: React.ReactNode;
};

function AmountInput({
Expand All @@ -314,6 +316,7 @@ function AmountInput({
from,
onAmountEntry,
walletTokenSymbol,
rightSlot,
}: AmountInputProps) {
const getTokenImage = () => {
if (from === CardDepositSource.WALLET) return getAsset('images/usdc-4x.png');
Expand Down Expand Up @@ -358,14 +361,18 @@ function AmountInput({
/>
)}
/>
<View className="native:shrink-0 flex-row items-center gap-2">
<Image
source={getTokenImage()}
alt={getTokenSymbol()}
style={{ width: 34, height: 34 }}
/>
<Text className="text-lg font-semibold text-white">{getTokenSymbol()}</Text>
</View>
{rightSlot ? (
rightSlot
) : (
<View className="native:shrink-0 flex-row items-center gap-2">
<Image
source={getTokenImage()}
alt={getTokenSymbol()}
style={{ width: 34, height: 34 }}
/>
<Text className="text-lg font-semibold text-white">{getTokenSymbol()}</Text>
</View>
)}
</View>
</View>
);
Expand Down Expand Up @@ -1198,16 +1205,6 @@ export default function CardDepositInternalForm() {
walletTokenSymbol={walletTokenSymbol}
/>

{isWalletSourceGaslessGated && (
<View className="gap-2">
<Text className="font-medium opacity-50">Token</Text>
<WalletTokenButton
selectedToken={selectedCardWalletToken}
onPress={() => setModal(CARD_DEPOSIT_MODAL.OPEN_TOKEN_SELECTOR)}
/>
</View>
)}

{watchedFrom === CardDepositSource.BORROW ? (
<View className="gap-4 px-2">
<BorrowSlider
Expand All @@ -1225,6 +1222,14 @@ export default function CardDepositInternalForm() {
from={watchedFrom}
onAmountEntry={trackAmountEntry}
walletTokenSymbol={walletTokenSymbol}
rightSlot={
isWalletSourceGaslessGated ? (
<WalletTokenButton
selectedToken={selectedCardWalletToken}
onPress={() => setModal(CARD_DEPOSIT_MODAL.OPEN_TOKEN_SELECTOR)}
/>
) : undefined
}
/>
<BalanceDisplay
balanceAmount={balanceAmount}
Expand Down
7 changes: 6 additions & 1 deletion components/Card/CardDepositModalProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { track } from '@/lib/analytics';
import getTokenIcon from '@/lib/getTokenIcon';
import { useCardDepositStore } from '@/store/useCardDepositStore';

import { CardDepositSource } from '@/store/useCardDepositStore';

import CardDepositExternal from './CardDepositExternal';
import CardDepositInternalForm from './CardDepositInternalForm';
import CardDepositOptions from './CardDepositOptions';
Expand Down Expand Up @@ -151,11 +153,14 @@ const CardDepositModalProvider = () => {

const handleBackPress = useCallback(() => {
if (isTokenSelector) {
// Preserve the Wallet source so the internal form re-mounts on the
// wallet option (the only path that opens the token selector).
setSource(CardDepositSource.WALLET);
setModal(CARD_DEPOSIT_MODAL.OPEN_INTERNAL_FORM);
return;
}
setModal(CARD_DEPOSIT_MODAL.CLOSE);
}, [isTokenSelector, setModal]);
}, [isTokenSelector, setSource, setModal]);

return (
<ResponsiveModal
Expand Down
11 changes: 9 additions & 2 deletions components/Card/CardDepositTokenSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useShallow } from 'zustand/react/shallow';
import { WalletTokenSelectorScreen } from '@/components/WalletTokenSelector';
import { CARD_DEPOSIT_MODAL } from '@/constants/modals';
import { TokenBalance } from '@/lib/types';
import { useCardDepositStore, CardDepositSource } from '@/store/useCardDepositStore';
import { useDepositStore } from '@/store/useDepositStore';

const SUPPORTED_CHAIN_IDS = [mainnet.id, polygon.id, base.id, arbitrum.id, fuse.id];
Expand All @@ -17,21 +18,27 @@ const SUPPORTED_TOKEN_SYMBOLS = ['USDC'];
* deposit internal form on selection.
*/
const CardDepositTokenSelector: React.FC = () => {
const { setSrcChainId, setPrincipalToken, setModal } = useDepositStore(
const { setSrcChainId, setPrincipalToken } = useDepositStore(
useShallow(state => ({
setSrcChainId: state.setSrcChainId,
setPrincipalToken: state.setPrincipalToken,
})),
);
const { setModal, setSource } = useCardDepositStore(
useShallow(state => ({
setModal: state.setModal,
setSource: state.setSource,
})),
);

const handleTokenSelect = useCallback(
(token: TokenBalance) => {
setSrcChainId(token.chainId);
setPrincipalToken(token.contractTickerSymbol?.toUpperCase() || 'USDC');
setSource(CardDepositSource.WALLET);
setModal(CARD_DEPOSIT_MODAL.OPEN_INTERNAL_FORM);
},
[setSrcChainId, setPrincipalToken, setModal],
[setSrcChainId, setPrincipalToken, setSource, setModal],
);

const supportedChainIds = useMemo(() => SUPPORTED_CHAIN_IDS, []);
Expand Down
Loading