Skip to content

Commit b1e4304

Browse files
chore: prepare swaps for transfer v2 release (#2339)
1 parent 4ac55e2 commit b1e4304

File tree

6 files changed

+37
-25
lines changed

6 files changed

+37
-25
lines changed

apps/namadillo/src/App/AppRoutes.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import { StakingOverview } from "./Staking/StakingOverview";
3636
import { StakingRewards } from "./Staking/StakingRewards";
3737
import { StakingWithdrawModal } from "./Staking/StakingWithdrawModal";
3838
import { Unstake } from "./Staking/Unstake";
39-
import { SwapModule } from "./Swap/SwapModule";
4039
import { SwitchAccountPanel } from "./SwitchAccount/SwitchAccountPanel";
4140
import { TransactionDetails } from "./Transactions/TransactionDetails";
4241
import { TransactionHistory } from "./Transactions/TransactionHistory";
@@ -101,7 +100,8 @@ export const MainRoutes = (): JSX.Element => {
101100
</Route>
102101

103102
{/* Swapping */}
104-
<Route path={routes.swap} element={<SwapModule />} />
103+
{/* TODO: Re-enable swaps after v2 release */}
104+
{/* <Route path={routes.swap} element={<SwapModule />} /> */}
105105

106106
{/* Transaction History */}
107107
{(features.namTransfersEnabled || features.ibcTransfersEnabled) && (

apps/namadillo/src/App/Layout/Navigation.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { SidebarMenuItem } from "App/Common/SidebarMenuItem";
22
import { ShieldIcon } from "App/Icons/ShieldIcon";
3-
import { SwapIcon } from "App/Icons/SwapIcon";
43
import { routes } from "App/routes";
54
import { applicationFeaturesAtom } from "atoms/settings";
65
import { useAtomValue } from "jotai";
@@ -41,11 +40,12 @@ export const Navigation = (): JSX.Element => {
4140
icon: <LuArrowDownToLine />,
4241
url: routes.receive,
4342
},
44-
{
45-
label: "Swap",
46-
icon: <SwapIcon className="w-[18px]" />,
47-
url: routes.swap,
48-
},
43+
// TODO: Re-enable swaps after v2 release
44+
// {
45+
// label: "Swap",
46+
// icon: <SwapIcon className="w-[18px]" />,
47+
// url: routes.swap,
48+
// },
4949
{
5050
label: "Staking",
5151
icon: <GoStack />,

apps/namadillo/src/App/Swap/SwapCalculations.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ActionButton, Stack } from "@namada/components";
22
import { mapUndefined } from "@namada/utils";
33
import { ConnectProviderButton } from "App/Common/ConnectProviderButton";
4-
import { SelectAssetModal } from "App/Common/SelectAssetModal";
54
import { SelectWalletModal } from "App/Common/SelectWalletModal";
65
import { TransactionFeeButton } from "App/Common/TransactionFeeButton";
76
import { SwapArrowsIcon } from "App/Icons/SwapArrowsIcon";
@@ -21,7 +20,6 @@ import { getChainFromAddress } from "integrations/utils";
2120
import { useAtom, useAtomValue, useSetAtom } from "jotai";
2221
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2322
import { toDisplayAmount } from "utils";
24-
import { SwapSource } from "./SwapSource";
2523
import {
2624
useSwapBuyAmount,
2725
useSwapSellAmount,
@@ -34,6 +32,8 @@ import {
3432
swapStateAtom,
3533
swapStatusAtom,
3634
} from "./state/atoms";
35+
import { SwapSelectAssetModal } from "./SwapSelectAssetModal";
36+
import { SwapSource } from "./SwapSource";
3737

3838
const ValidationMessages: Record<string, string> = {
3939
NoSellAssetSelected: "Select a token to sell",
@@ -272,7 +272,7 @@ export const SwapCalculations = (): JSX.Element => {
272272
</Stack>
273273

274274
{sellAssetSelectorModalOpen && shieldedAccountAddress && (
275-
<SelectAssetModal
275+
<SwapSelectAssetModal
276276
onClose={() => setSellAssetSelectorModalOpen(false)}
277277
assets={sortedAssets}
278278
balances={balances}
@@ -281,7 +281,7 @@ export const SwapCalculations = (): JSX.Element => {
281281
/>
282282
)}
283283
{buyAssetSelectorModalOpen && shieldedAccountAddress && (
284-
<SelectAssetModal
284+
<SwapSelectAssetModal
285285
onClose={() => setBuyAssetSelectorModalOpen(false)}
286286
assets={sortedAssets}
287287
balances={balances}

apps/namadillo/src/App/Common/SelectAssetModal.tsx renamed to apps/namadillo/src/App/Swap/SwapSelectAssetModal.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type SelectWalletModalProps = {
2323
balances?: Record<Address, [DisplayAmount, FiatAmount?]>;
2424
};
2525

26-
export const SelectAssetModal = ({
26+
export const SwapSelectAssetModal = ({
2727
onClose,
2828
onSelect,
2929
assets,
@@ -37,11 +37,20 @@ export const SelectAssetModal = ({
3737
const [filter, setFilter] = useState("");
3838

3939
const { assetsWithBalance, assetsWithoutBalance } = useMemo(() => {
40-
const filtered = assets.filter(
41-
(asset) =>
42-
asset.name.toLowerCase().indexOf(filter.toLowerCase()) >= 0 ||
43-
asset.symbol.toLowerCase().indexOf(filter.toLowerCase()) >= 0
44-
);
40+
const filtered = assets
41+
.filter(
42+
(asset) =>
43+
asset.name.toLowerCase().indexOf(filter.toLowerCase()) >= 0 ||
44+
asset.symbol.toLowerCase().indexOf(filter.toLowerCase()) >= 0
45+
)
46+
// We temporarily hide stride assets until we support them fully
47+
.filter(
48+
(asset) =>
49+
!asset.traces?.find(
50+
(trace) =>
51+
trace.type === "ibc" && trace.counterparty.chain_name === "stride"
52+
)
53+
);
4554

4655
const withBalance: Asset[] = [];
4756
const withoutBalance: Asset[] = [];

apps/namadillo/src/App/Common/__tests__/SelectAssetModal.test.tsx renamed to apps/namadillo/src/App/Swap/__tests__/SelectAssetModal.test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
2-
import { assetMockList } from "../__mocks__/assets";
3-
import { SelectAssetModal } from "../SelectAssetModal";
2+
import { assetMockList } from "App/Common/__mocks__/assets";
3+
import { SwapSelectAssetModal } from "../SwapSelectAssetModal";
44

55
jest.mock("hooks/useIsChannelInactive", () => ({
66
useIsChannelInactive: jest.fn(() => ({
@@ -9,14 +9,14 @@ jest.mock("hooks/useIsChannelInactive", () => ({
99
})),
1010
}));
1111

12-
describe("SelectAssetModal", () => {
12+
describe("SwapSelectAssetModal", () => {
1313
const onCloseMock = jest.fn();
1414
const onSelectMock = jest.fn();
1515
const mockAddress = "cosmos1xnu3p06fkke8hnl7t83hzhggrca59syf0wjqgh";
1616

1717
it("should render the modal title", () => {
1818
render(
19-
<SelectAssetModal
19+
<SwapSelectAssetModal
2020
onClose={onCloseMock}
2121
onSelect={onSelectMock}
2222
assets={assetMockList}
@@ -28,7 +28,7 @@ describe("SelectAssetModal", () => {
2828

2929
it("should render all assets", () => {
3030
render(
31-
<SelectAssetModal
31+
<SwapSelectAssetModal
3232
onClose={onCloseMock}
3333
onSelect={onSelectMock}
3434
assets={assetMockList}
@@ -41,7 +41,7 @@ describe("SelectAssetModal", () => {
4141

4242
it("should filter assets based on search input", async () => {
4343
render(
44-
<SelectAssetModal
44+
<SwapSelectAssetModal
4545
onClose={onCloseMock}
4646
onSelect={onSelectMock}
4747
assets={assetMockList}
@@ -61,7 +61,7 @@ describe("SelectAssetModal", () => {
6161

6262
it("should call onSelect and onClose when an asset is selected", () => {
6363
render(
64-
<SelectAssetModal
64+
<SwapSelectAssetModal
6565
onClose={onCloseMock}
6666
onSelect={onSelectMock}
6767
assets={assetMockList}

apps/namadillo/src/hooks/useTransactionCallbacks.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ export const useTransactionCallback = (): void => {
5555
shouldUpdateBalance(true);
5656
refetchBalances();
5757
refetchShieldedBalance();
58+
59+
const timePolling = 6 * 1000;
60+
setTimeout(() => shouldUpdateBalance(false), timePolling);
5861
};
5962

6063
const onTransferError = (e: CustomEvent<TransferTransactionData>): void => {

0 commit comments

Comments
 (0)