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
8 changes: 2 additions & 6 deletions apps/namadillo/src/App/Masp/MaspShield.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Panel } from "@namada/components";
import { AccountType } from "@namada/types";
import { NamadaTransferTopHeader } from "App/NamadaTransfer/NamadaTransferTopHeader";
import { TransferModule } from "App/Transfer/TransferModule";
import { OnSubmitTransferParams } from "App/Transfer/types";
import { allDefaultAccountsAtom } from "atoms/accounts";
Expand Down Expand Up @@ -148,11 +147,8 @@ export const MaspShield = ({

return (
<Panel className="rounded-sm flex flex-col flex-1 py-9">
<header className="flex flex-col items-center text-center mb-8 gap-6">
<NamadaTransferTopHeader
isSourceShielded={false}
isDestinationShielded={true}
/>
<header className="flex flex-col text-yellow items-center text-center mb-8 gap-6">
Shield Assets
</header>
<TransferModule
source={{
Expand Down
8 changes: 2 additions & 6 deletions apps/namadillo/src/App/Masp/MaspUnshield.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Panel } from "@namada/components";
import { MaspSyncCover } from "App/Common/MaspSyncCover";
import { NamadaTransferTopHeader } from "App/NamadaTransfer/NamadaTransferTopHeader";
import { TransferModule } from "App/Transfer/TransferModule";
import { OnSubmitTransferParams } from "App/Transfer/types";
import { lastCompletedShieldedSyncAtom } from "atoms/balance/atoms";
Expand Down Expand Up @@ -133,11 +132,8 @@ export const MaspUnshield = ({

return (
<Panel className="relative rounded-sm flex flex-col flex-1 pt-9">
<header className="flex flex-col items-center text-center mb-8 gap-6">
<NamadaTransferTopHeader
isSourceShielded={true}
isDestinationShielded={false}
/>
<header className="flex flex-col text-yellow items-center text-center mb-8 gap-6">
Unshield Assets
</header>
<TransferModule
source={{
Expand Down
10 changes: 2 additions & 8 deletions apps/namadillo/src/App/NamadaTransfer/NamadaTransfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { createTransferDataFromNamada } from "lib/transactions";
import { useMemo, useState } from "react";
import { useSearchParams } from "react-router-dom";
import { AssetWithAmountAndChain } from "types";
import { NamadaTransferTopHeader } from "./NamadaTransferTopHeader";

interface NamadaTransferProps {
sourceAddress: string;
Expand Down Expand Up @@ -165,13 +164,8 @@ export const NamadaTransfer = ({

return (
<Panel className="min-h-[600px] rounded-sm flex flex-col flex-1 py-9">
<header className="flex flex-col items-center text-center mb-8 gap-6">
<NamadaTransferTopHeader
isSourceShielded={isSourceShielded}
isDestinationShielded={
destinationAddress ? isTargetShielded : undefined
}
/>
<header className="flex flex-col text-yellow items-center text-center mb-8 gap-6">
{`${isSourceShielded ? "Shielded" : "Transparent"} Transfer Assets`}
</header>
<TransferModule
source={{
Expand Down
27 changes: 5 additions & 22 deletions apps/namadillo/src/App/Transfer/TransferDestination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ import {
isTransparentAddress,
} from "App/Transfer/common";
import { allDefaultAccountsAtom } from "atoms/accounts";
import { connectedWalletsAtom } from "atoms/integrations";
import { getAddressLabel } from "atoms/transfer/functions";
import BigNumber from "bignumber.js";
import clsx from "clsx";
import { TransactionFeeProps } from "hooks/useTransactionFee";
import { wallets } from "integrations";
import { KeplrWalletManager } from "integrations/Keplr";
import { getChainFromAddress, getChainImageUrl } from "integrations/utils";
import { useAtomValue } from "jotai";
import { useCallback, useEffect, useState } from "react";
Expand Down Expand Up @@ -51,7 +49,6 @@ type TransferDestinationProps = {
sourceAsset: Asset | undefined;
onChangeAddress?: (address: Address) => void;
onChangeMemo?: (address: string) => void;
setDestinationAddress?: (address: string) => void;
};

export const TransferDestination = ({
Expand All @@ -67,14 +64,12 @@ export const TransferDestination = ({
sourceAddress,
memo,
sourceAsset,
setDestinationAddress,
onChangeAddress,
onChangeMemo,
}: TransferDestinationProps): JSX.Element => {
const { data: accounts } = useAtomValue(allDefaultAccountsAtom);
const [isModalOpen, setIsModalOpen] = useState(false);
const location = useLocation();
const connectedWallets = useAtomValue(connectedWalletsAtom);
const keplr = new KeplrWalletManager();

const isIbcTransfer = isIbcAddress(sourceAddress ?? "");
const changeFeeEnabled = !isIbcTransfer;
Expand All @@ -99,36 +94,24 @@ export const TransferDestination = ({
};

const handleSelectAddress = useCallback(
async (selectedAddress: Address): Promise<void> => {
const isIbcAsset = !isNamadaAddress(selectedAddress);
if (isIbcAsset) {
await keplr.connectAllKeplrChains();
}
setDestinationAddress?.(selectedAddress);
},
[keplr, setDestinationAddress]
(selectedAddress: Address): void => onChangeAddress?.(selectedAddress),
[onChangeAddress]
);

const isShieldingTransaction =
routes.shield === location.pathname || routes.ibc === location.pathname;

// Make sure destination address isnt ibc if keplr is not connected
useEffect(() => {
if (isIbcAddress(destinationAddress ?? "") && !connectedWallets.keplr)
setDestinationAddress?.("");
}, [connectedWallets.keplr, destinationAddress, setDestinationAddress]);

// Make sure destination address is pre-filled if it's a shielding transaction
useEffect(() => {
if (destinationAddress) return;
if (isShieldingTransaction && shieldedAccount?.address) {
setDestinationAddress?.(shieldedAccount?.address ?? "");
onChangeAddress?.(shieldedAccount?.address ?? "");
}
}, [
isShieldingTransaction,
shieldedAccount?.address,
destinationAddress,
setDestinationAddress,
onChangeAddress,
]);

// Write a customAddress variable that checks if the address doesn't come from our transparent or shielded accounts
Expand Down
1 change: 0 additions & 1 deletion apps/namadillo/src/App/Transfer/TransferModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ export const TransferModule = ({
/>
</i>
<TransferDestination
setDestinationAddress={destination.onChangeAddress}
isShieldedAddress={isShieldedAddress(destinationAddress)}
isShieldedTx={isShieldedTx}
destinationAddress={destinationAddress}
Expand Down