Skip to content

Commit bd1f95b

Browse files
authored
fix: review fixes v2 (#2348)
1 parent c530763 commit bd1f95b

File tree

16 files changed

+178
-51
lines changed

16 files changed

+178
-51
lines changed

apps/namadillo/src/App/AccountOverview/ShieldedAssetsOverview.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { ActionButton, Panel } from "@namada/components";
22
import { MaspSyncCover } from "App/Common/MaspSyncCover";
33
import { ShieldedAssetTable } from "App/Masp/ShieldedAssetTable";
4-
import { routes } from "App/routes";
4+
import { params, routes } from "App/routes";
5+
import { defaultShieldedAccountAtom } from "atoms/accounts";
56
import { applicationFeaturesAtom } from "atoms/settings";
67
import clsx from "clsx";
78
import { useAmountsInFiat } from "hooks/useAmountsInFiat";
@@ -16,6 +17,7 @@ export const ShieldedAssetsOverview = (): JSX.Element => {
1617
useAmountsInFiat();
1718
const textContainerClassList = `flex h-full gap-1 items-center justify-center`;
1819
const requiresNewShieldedSync = useRequiresNewShieldedSync();
20+
const shieldedAccount = useAtomValue(defaultShieldedAccountAtom);
1921

2022
// Hide TotalBalanceCard if shielded fiat amount is 0 but shielded assets exist
2123
const shouldHideBalanceCard =
@@ -31,7 +33,7 @@ export const ShieldedAssetsOverview = (): JSX.Element => {
3133
footerButtons={
3234
<>
3335
<ActionButton
34-
href={routes.transfer}
36+
href={`${routes.transfer}?${params.source}=${shieldedAccount?.address || ""}`}
3537
outlineColor="yellow"
3638
size="xs"
3739
className="w-auto px-4"

apps/namadillo/src/App/Common/Search.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ type SearchProps = Omit<
1010
"onChange" | "onFocus" | "onBlur" | "type"
1111
> & {
1212
onChange?: (search: string) => void;
13+
debounceTime?: number;
1314
};
1415

1516
export const Search = ({
1617
onChange,
1718
className,
1819
placeholder,
20+
debounceTime = 300,
1921
...rest
2022
}: SearchProps): JSX.Element => {
2123
const [displaySearchIcon, setDisplaySearchIcon] = useState(true);
2224
const debouncedSearch = useRef(
23-
debounce((value: string) => onChange?.(value), 300)
25+
debounce((value: string) => onChange?.(value), debounceTime)
2426
);
2527

2628
// Hideous hack to add padding to placeholder in Firefox.

apps/namadillo/src/App/Masp/MaspShield.tsx

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Panel } from "@namada/components";
22
import { AccountType } from "@namada/types";
3-
import { params, routes } from "App/routes";
43
import { TransferModule } from "App/Transfer/TransferModule";
54
import { OnSubmitTransferParams } from "App/Transfer/types";
65
import { allDefaultAccountsAtom } from "atoms/accounts";
@@ -15,7 +14,6 @@ import invariant from "invariant";
1514
import { useAtom, useAtomValue } from "jotai";
1615
import { createTransferDataFromNamada } from "lib/transactions";
1716
import { useEffect, useState } from "react";
18-
import { Link, useLocation } from "react-router-dom";
1917
import { AssetWithAmountAndChain } from "types";
2018
interface MaspShieldProps {
2119
sourceAddress: string;
@@ -50,14 +48,10 @@ export const MaspShield = ({
5048
const chainParameters = useAtomValue(chainParametersAtom);
5149
const defaultAccounts = useAtomValue(allDefaultAccountsAtom);
5250
const [ledgerStatus, setLedgerStatusStop] = useAtom(ledgerStatusDataAtom);
53-
const { pathname } = useLocation();
5451
// DERIVED VALUES
5552
const transparentAddress = defaultAccounts.data?.find(
5653
(account) => account.type !== AccountType.ShieldedKeys
5754
)?.address;
58-
const shieldedAddress = defaultAccounts.data?.find(
59-
(account) => account.type === AccountType.ShieldedKeys
60-
)?.address;
6155
const ledgerAccountInfo = ledgerStatus && {
6256
deviceConnected: ledgerStatus.connected,
6357
errorMessage: ledgerStatus.errorMessage,
@@ -170,7 +164,7 @@ export const MaspShield = ({
170164
isShieldedAddress: true,
171165
onChangeAddress: setDestinationAddress,
172166
memo,
173-
onChangeMemo: pathname !== routes.shield ? setMemo : undefined,
167+
onChangeMemo: setMemo,
174168
}}
175169
feeProps={feeProps}
176170
isSubmitting={isPerformingTransfer || isSuccess}
@@ -183,16 +177,6 @@ export const MaspShield = ({
183177
assetSelectorModalOpen={assetSelectorModalOpen}
184178
setAssetSelectorModalOpen={setAssetSelectorModalOpen}
185179
/>
186-
<div className="flex flex-row font-normal justify-center mt-10 gap-2">
187-
<h4>Looking to Unshield tokens?</h4>
188-
<Link
189-
className="text-yellow underline"
190-
to={`${routes.transfer}?${params.source}=${shieldedAddress || ""}&${params.destination}=${transparentAddress}`}
191-
title={`View pending transactions`}
192-
>
193-
Click here.
194-
</Link>
195-
</div>
196180
</Panel>
197181
);
198182
};

apps/namadillo/src/App/Masp/ShieldedFungibleTable.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ const initialPage = 0;
2929

3030
// Minimum thresholds to earn rewards for each asset
3131
const REWARD_THRESHOLDS: Record<string, BigNumber> = {
32-
statom: new BigNumber(10),
33-
stosmo: new BigNumber(100),
34-
sttia: new BigNumber(20),
35-
osmo: new BigNumber(100),
36-
atom: new BigNumber(10),
37-
tia: new BigNumber(20),
3832
usdc: new BigNumber(50),
3933
};
4034

apps/namadillo/src/App/NamadaTransfer/NamadaTransfer.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Panel } from "@namada/components";
22
import { params } from "App/routes";
3-
import { isShieldedAddress } from "App/Transfer/common";
3+
import { isShieldedAddress, isTransparentAddress } from "App/Transfer/common";
44
import { TransferModule } from "App/Transfer/TransferModule";
55
import { OnSubmitTransferParams } from "App/Transfer/types";
66
import { chainParametersAtom } from "atoms/chain/atoms";
@@ -108,6 +108,7 @@ export const NamadaTransfer = ({
108108
});
109109

110110
const isSourceShielded = isShieldedAddress(sourceAddress ?? "");
111+
const isSourceTransparent = isTransparentAddress(sourceAddress ?? "");
111112
const isTargetShielded = isShieldedAddress(destinationAddress ?? "");
112113

113114
const onSubmitTransfer = async ({
@@ -165,7 +166,11 @@ export const NamadaTransfer = ({
165166
return (
166167
<Panel className="min-h-[600px] rounded-sm flex flex-col flex-1 py-9">
167168
<header className="text-yellow text-center mb-8 gap-6">
168-
{`${isSourceShielded ? "Shielded" : "Transparent"} Transfer`}
169+
{`${
170+
isSourceShielded && !!destinationAddress ? "Shielded"
171+
: isSourceTransparent && !!destinationAddress ? "Transparent"
172+
: ""
173+
} Transfer`}
169174
</header>
170175
<TransferModule
171176
source={{

apps/namadillo/src/App/Transactions/TransactionDetails.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export const TransactionDetails = (): JSX.Element => {
1515

1616
return (
1717
<Panel className="flex-1 h-full">
18-
<h1 className="mb-12">Transactions</h1>
1918
<TransactionReceipt transaction={transaction} />
2019
</Panel>
2120
);

apps/namadillo/src/App/Transfer/AddressDropdown.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ export const AddressDropdown = ({
163163
}
164164
};
165165

166+
const disconnectKeplr = async (): Promise<void> => {
167+
setConnectedWallets((obj) => ({ ...obj, [keplr.key]: false }));
168+
const keplrInstance = await keplr.get();
169+
if (keplrInstance) await keplrInstance.disable();
170+
};
171+
166172
const handleConnectKeplr = useCallback(async (): Promise<void> => {
167173
try {
168174
setIsConnectingKeplr(true);
@@ -185,9 +191,11 @@ export const AddressDropdown = ({
185191
onSelectAddress?.(key.bech32Address);
186192
} catch (error) {
187193
console.error("Failed to fetch Keplr address after connection:", error);
194+
disconnectKeplr();
188195
}
189196
} catch (error) {
190197
console.error("Failed to connect to Keplr:", error);
198+
disconnectKeplr();
191199
} finally {
192200
setIsConnectingKeplr(false);
193201
}

apps/namadillo/src/App/Transfer/DestinationAddressModal.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { getChainFromAddress, getChainImageUrl } from "integrations/utils";
1313
import { useAtom, useAtomValue } from "jotai";
1414
import { useCallback, useState } from "react";
1515
import { Address, Asset } from "types";
16+
import { timestampToRelativeTime } from "utils/dates";
1617
import namadaShieldedIcon from "./assets/namada-shielded.svg";
1718
import namadaTransparentIcon from "./assets/namada-transparent.svg";
1819
import {
@@ -38,6 +39,7 @@ type AddressOption = {
3839
address: string;
3940
icon: string;
4041
type: "transparent" | "shielded" | "ibc" | "keplr";
42+
timestamp?: number;
4143
};
4244

4345
type DestinationAddressModalProps = {
@@ -120,7 +122,7 @@ export const DestinationAddressModal = ({
120122

121123
// Build recent addresses options
122124
const filteredRecentAddresses = filterNonIbcIfSourceIbc(recentAddresses);
123-
const recentAddressOptions: AddressOption[] = filteredRecentAddresses
125+
const recentAddressOptions = filteredRecentAddresses
124126
.filter((addresses) => !addressOptionsAddresses.includes(addresses.address))
125127
.filter((addresses) => addresses.address !== sourceAddress)
126128
.map((recent) => ({
@@ -132,6 +134,7 @@ export const DestinationAddressModal = ({
132134
: recent.type === "transparent" ? namadaTransparentIcon
133135
: getChainImageUrl(getChainFromAddress(recent.address ?? "")), // fallback for IBC
134136
type: recent.type,
137+
timestamp: recent.timestamp,
135138
}));
136139

137140
const validateAddress = (address: string): ValidationResult => {
@@ -376,6 +379,13 @@ export const DestinationAddressModal = ({
376379
</span>
377380
</div>
378381
</div>
382+
{option.timestamp && (
383+
<div className="flex flex-col items-end">
384+
<span className="text-xs text-neutral-500">
385+
{timestampToRelativeTime(option.timestamp)}
386+
</span>
387+
</div>
388+
)}
379389
</button>
380390
))}
381391
</Stack>

apps/namadillo/src/App/Transfer/SelectToken.tsx

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,25 +92,31 @@ export const SelectToken = ({
9292
const filteredTokens = useMemo(() => {
9393
return assetsWithAmounts
9494
.filter((assetWithAmount) => {
95-
if (assetWithAmount.amount.eq(0)) return false;
96-
97-
// Filter by search term
95+
// Filter by search term (if provided)
9896
const matchesSearch =
99-
!!filter &&
97+
!filter ||
10098
assetWithAmount.asset.name
10199
.toLowerCase()
102100
.includes(filter.toLowerCase());
103101

102+
// Filter by network (if provided)
104103
const matchesNetwork =
104+
!selectedNetwork ||
105105
selectedNetwork ===
106-
assetWithAmount.asset.traces?.[0]?.counterparty?.chain_name;
107-
return !selectedNetwork ? true : matchesSearch || matchesNetwork;
106+
assetWithAmount.asset.traces?.[0]?.counterparty?.chain_name;
107+
108+
// Filter out zero balances
109+
const hasBalance = !assetWithAmount.amount.eq(0);
110+
111+
// All conditions must be true
112+
return matchesSearch && matchesNetwork && hasBalance;
108113
})
109114
.sort((a, b) => Number(b.amount) - Number(a.amount));
110115
}, [assetsWithAmounts, filter, selectedNetwork, assetToNetworkMap]);
111116

112117
const handleNetworkSelect = (networkName: string): void => {
113118
setSelectedNetwork(selectedNetwork === networkName ? null : networkName);
119+
setFilter(""); // Clear search input when network is selected
114120
};
115121

116122
const handleWalletAddressChange = (address: string): void => {
@@ -119,6 +125,7 @@ export const SelectToken = ({
119125
};
120126

121127
const handleClose = (): void => {
128+
setFilter("");
122129
onClose();
123130
};
124131

@@ -224,7 +231,10 @@ export const SelectToken = ({
224231
>
225232
<li>
226233
<button
227-
onClick={() => setSelectedNetwork(null)}
234+
onClick={() => {
235+
setFilter(""); // Clear search input when "All Networks" is selected
236+
setSelectedNetwork(null);
237+
}}
228238
className={`flex items-center gap-3 p-2 w-full rounded-sm transition-colors ${
229239
selectedNetwork === null ?
230240
"bg-white/5 border border-white/20"
@@ -240,9 +250,10 @@ export const SelectToken = ({
240250
{allNetworks.map((network) => (
241251
<li key={network.chain_name}>
242252
<button
243-
onClick={() =>
244-
handleNetworkSelect(network.chain_name.toLowerCase())
245-
}
253+
onClick={() => {
254+
setFilter("");
255+
handleNetworkSelect(network.chain_name.toLowerCase());
256+
}}
246257
className={`flex items-center gap-3 p-2 w-full rounded-sm transition-colors ${
247258
selectedNetwork === network.chain_name ?
248259
"bg-white/5 border border-white/20"
@@ -277,6 +288,8 @@ export const SelectToken = ({
277288
<Search
278289
placeholder="Insert token name or symbol"
279290
onChange={setFilter}
291+
value={filter}
292+
debounceTime={0}
280293
/>
281294
</div>
282295

apps/namadillo/src/App/Transfer/TransferDestination.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,7 @@ export const TransferDestination = ({
211211
</div>
212212
: <button
213213
type="button"
214-
disabled={
215-
isShieldingTransaction || isSubmitting || !sourceAsset
216-
}
214+
disabled={isShieldingTransaction || isSubmitting}
217215
onClick={handleOpenModal}
218216
className={clsx(
219217
"flex justify-between items-center bg-neutral-900 p-2 rounded-sm w-full",

0 commit comments

Comments
 (0)