Skip to content

Commit 93b5e1f

Browse files
committed
feat: enable gas source switch only for unshielding and shielded
transfers
1 parent 00d9c02 commit 93b5e1f

File tree

2 files changed

+35
-17
lines changed

2 files changed

+35
-17
lines changed

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

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
Modal,
55
Stack,
66
StyledSelectBox,
7+
Text,
78
ToggleButton,
89
} from "@namada/components";
910
import { chainAssetsMapAtom, nativeTokenAddressAtom } from "atoms/chain";
@@ -95,6 +96,7 @@ export const GasFeeModal = ({
9596
gasEstimate,
9697
gasPriceTable,
9798
gasSource,
99+
gasSourceSwitch,
98100
onChangeGasLimit,
99101
onChangeGasToken,
100102
onChangeGasSource,
@@ -168,28 +170,38 @@ export const GasFeeModal = ({
168170
);
169171
})}
170172
</div>
171-
173+
{gasSourceSwitch && gasSource !== "shielded" && (
174+
<Text className="text-red-600 text-sm">
175+
Warning! Using fees from your transparent account will reveal data.
176+
<br />
177+
To keep your data protected we recommend moving assets to the
178+
<br />
179+
shield pool to pay fees.
180+
</Text>
181+
)}
172182
<Stack
173183
direction="horizontal"
174184
className="justify-between align-middle mt-4 mb-1"
175185
>
176186
<div className="text-sm">Fee Token</div>
177-
<ToggleButton
178-
label={
179-
gasSource === "shielded" ? "Shielded Balance" : (
180-
"Transparent Balance"
181-
)
182-
}
183-
color="white"
184-
activeColor="yellow"
185-
checked={gasSource === "shielded"}
186-
onChange={() =>
187-
onChangeGasSource(
188-
gasSource === "shielded" ? "transparent" : "shielded"
189-
)
190-
}
191-
containerProps={{ className: "gap-3 text-xs" }}
192-
/>
187+
{gasSourceSwitch && (
188+
<ToggleButton
189+
label={
190+
gasSource === "shielded" ? "Shielded Balance" : (
191+
"Transparent Balance"
192+
)
193+
}
194+
color="white"
195+
activeColor="yellow"
196+
checked={gasSource === "shielded"}
197+
onChange={() =>
198+
onChangeGasSource(
199+
gasSource === "shielded" ? "transparent" : "shielded"
200+
)
201+
}
202+
containerProps={{ className: "gap-3 text-xs" }}
203+
/>
204+
)}
193205
</Stack>
194206
<StyledSelectBox
195207
id="fee-token-select"

apps/namadillo/src/hooks/useTransactionFee.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export type TransactionFeeProps = {
1818
gasEstimate: GasEstimate | undefined;
1919
gasPriceTable: GasPriceTable | undefined;
2020
gasSource: "shielded" | "transparent";
21+
gasSourceSwitch: boolean;
2122
onChangeGasLimit: (value: BigNumber) => void;
2223
onChangeGasToken: (value: string) => void;
2324
onChangeGasSource: (value: "shielded" | "transparent") => void;
@@ -57,12 +58,17 @@ export const useTransactionFee = (txKinds: TxKind[]): TransactionFeeProps => {
5758
const isLoading =
5859
isLoadingNativeToken || isLoadingGasEstimate || isLoadingGasPriceTable;
5960

61+
const gasSourceSwitch =
62+
txKinds.includes("ShieldedTransfer") ||
63+
txKinds.includes("UnshieldingTransfer");
64+
6065
return {
6166
gasConfig,
6267
isLoading,
6368
gasEstimate,
6469
gasPriceTable,
6570
gasSource,
71+
gasSourceSwitch,
6672
onChangeGasLimit: setGasLimitValue,
6773
onChangeGasToken: setGasTokenValue,
6874
onChangeGasSource: setGasSource,

0 commit comments

Comments
 (0)