Skip to content

Commit 0c19459

Browse files
authored
fix: remove keplr requirement to receive to an IBC address (#2328)
1 parent 96b6c35 commit 0c19459

File tree

5 files changed

+11
-43
lines changed

5 files changed

+11
-43
lines changed

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

Lines changed: 2 additions & 6 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 { NamadaTransferTopHeader } from "App/NamadaTransfer/NamadaTransferTopHeader";
43
import { TransferModule } from "App/Transfer/TransferModule";
54
import { OnSubmitTransferParams } from "App/Transfer/types";
65
import { allDefaultAccountsAtom } from "atoms/accounts";
@@ -148,11 +147,8 @@ export const MaspShield = ({
148147

149148
return (
150149
<Panel className="rounded-sm flex flex-col flex-1 py-9">
151-
<header className="flex flex-col items-center text-center mb-8 gap-6">
152-
<NamadaTransferTopHeader
153-
isSourceShielded={false}
154-
isDestinationShielded={true}
155-
/>
150+
<header className="flex flex-col text-yellow items-center text-center mb-8 gap-6">
151+
Shield Assets
156152
</header>
157153
<TransferModule
158154
source={{

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Panel } from "@namada/components";
22
import { MaspSyncCover } from "App/Common/MaspSyncCover";
3-
import { NamadaTransferTopHeader } from "App/NamadaTransfer/NamadaTransferTopHeader";
43
import { TransferModule } from "App/Transfer/TransferModule";
54
import { OnSubmitTransferParams } from "App/Transfer/types";
65
import { lastCompletedShieldedSyncAtom } from "atoms/balance/atoms";
@@ -133,11 +132,8 @@ export const MaspUnshield = ({
133132

134133
return (
135134
<Panel className="relative rounded-sm flex flex-col flex-1 pt-9">
136-
<header className="flex flex-col items-center text-center mb-8 gap-6">
137-
<NamadaTransferTopHeader
138-
isSourceShielded={true}
139-
isDestinationShielded={false}
140-
/>
135+
<header className="flex flex-col text-yellow items-center text-center mb-8 gap-6">
136+
Unshield Assets
141137
</header>
142138
<TransferModule
143139
source={{

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { createTransferDataFromNamada } from "lib/transactions";
1818
import { useMemo, useState } from "react";
1919
import { useSearchParams } from "react-router-dom";
2020
import { AssetWithAmountAndChain } from "types";
21-
import { NamadaTransferTopHeader } from "./NamadaTransferTopHeader";
2221

2322
interface NamadaTransferProps {
2423
sourceAddress: string;
@@ -165,13 +164,8 @@ export const NamadaTransfer = ({
165164

166165
return (
167166
<Panel className="min-h-[600px] rounded-sm flex flex-col flex-1 py-9">
168-
<header className="flex flex-col items-center text-center mb-8 gap-6">
169-
<NamadaTransferTopHeader
170-
isSourceShielded={isSourceShielded}
171-
isDestinationShielded={
172-
destinationAddress ? isTargetShielded : undefined
173-
}
174-
/>
167+
<header className="flex flex-col text-yellow items-center text-center mb-8 gap-6">
168+
{`${isSourceShielded ? "Shielded" : "Transparent"} Transfer Assets`}
175169
</header>
176170
<TransferModule
177171
source={{

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

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ import {
1212
isTransparentAddress,
1313
} from "App/Transfer/common";
1414
import { allDefaultAccountsAtom } from "atoms/accounts";
15-
import { connectedWalletsAtom } from "atoms/integrations";
1615
import { getAddressLabel } from "atoms/transfer/functions";
1716
import BigNumber from "bignumber.js";
1817
import clsx from "clsx";
1918
import { TransactionFeeProps } from "hooks/useTransactionFee";
2019
import { wallets } from "integrations";
21-
import { KeplrWalletManager } from "integrations/Keplr";
2220
import { getChainFromAddress, getChainImageUrl } from "integrations/utils";
2321
import { useAtomValue } from "jotai";
2422
import { useCallback, useEffect, useState } from "react";
@@ -51,7 +49,6 @@ type TransferDestinationProps = {
5149
sourceAsset: Asset | undefined;
5250
onChangeAddress?: (address: Address) => void;
5351
onChangeMemo?: (address: string) => void;
54-
setDestinationAddress?: (address: string) => void;
5552
};
5653

5754
export const TransferDestination = ({
@@ -67,14 +64,12 @@ export const TransferDestination = ({
6764
sourceAddress,
6865
memo,
6966
sourceAsset,
70-
setDestinationAddress,
67+
onChangeAddress,
7168
onChangeMemo,
7269
}: TransferDestinationProps): JSX.Element => {
7370
const { data: accounts } = useAtomValue(allDefaultAccountsAtom);
7471
const [isModalOpen, setIsModalOpen] = useState(false);
7572
const location = useLocation();
76-
const connectedWallets = useAtomValue(connectedWalletsAtom);
77-
const keplr = new KeplrWalletManager();
7873

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

10196
const handleSelectAddress = useCallback(
102-
async (selectedAddress: Address): Promise<void> => {
103-
const isIbcAsset = !isNamadaAddress(selectedAddress);
104-
if (isIbcAsset) {
105-
await keplr.connectAllKeplrChains();
106-
}
107-
setDestinationAddress?.(selectedAddress);
108-
},
109-
[keplr, setDestinationAddress]
97+
(selectedAddress: Address): void => onChangeAddress?.(selectedAddress),
98+
[onChangeAddress]
11099
);
111100

112101
const isShieldingTransaction =
113102
routes.shield === location.pathname || routes.ibc === location.pathname;
114103

115-
// Make sure destination address isnt ibc if keplr is not connected
116-
useEffect(() => {
117-
if (isIbcAddress(destinationAddress ?? "") && !connectedWallets.keplr)
118-
setDestinationAddress?.("");
119-
}, [connectedWallets.keplr, destinationAddress, setDestinationAddress]);
120-
121104
// Make sure destination address is pre-filled if it's a shielding transaction
122105
useEffect(() => {
123106
if (destinationAddress) return;
124107
if (isShieldingTransaction && shieldedAccount?.address) {
125-
setDestinationAddress?.(shieldedAccount?.address ?? "");
108+
onChangeAddress?.(shieldedAccount?.address ?? "");
126109
}
127110
}, [
128111
isShieldingTransaction,
129112
shieldedAccount?.address,
130113
destinationAddress,
131-
setDestinationAddress,
114+
onChangeAddress,
132115
]);
133116

134117
// Write a customAddress variable that checks if the address doesn't come from our transparent or shielded accounts

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ export const TransferModule = ({
213213
/>
214214
</i>
215215
<TransferDestination
216-
setDestinationAddress={destination.onChangeAddress}
217216
isShieldedAddress={isShieldedAddress(destinationAddress)}
218217
isShieldedTx={isShieldedTx}
219218
destinationAddress={destinationAddress}

0 commit comments

Comments
 (0)