diff --git a/apps/extension/src/Approvals/ConfirmSignLedgerTx.tsx b/apps/extension/src/Approvals/ConfirmSignLedgerTx.tsx index 81a346637..1a57a74e9 100644 --- a/apps/extension/src/Approvals/ConfirmSignLedgerTx.tsx +++ b/apps/extension/src/Approvals/ConfirmSignLedgerTx.tsx @@ -188,8 +188,6 @@ export const ConfirmSignLedgerTx: React.FC = ({ details }) => { setStepTwoDescription("Preparing transaction..."); try { - // TODO: we have to check if the signer is disposable or not - const accountDetails = await requester.sendMessage( Ports.Background, new QueryAccountDetailsMsg(signer) @@ -235,6 +233,11 @@ export const ConfirmSignLedgerTx: React.FC = ({ details }) => { .type ) ); + const disposableSigner = txDetails.reduce((acc, curr) => { + console.log("www", curr.wrapperFeePayer, accountDetails.address); + return acc || curr.wrapperFeePayer !== accountDetails.address; + }, false); + // For now we work under the assumption that we can't batch transfers from masp with other tx types const fromMasp = transferTypes.includes("Shielded") || @@ -257,7 +260,9 @@ export const ConfirmSignLedgerTx: React.FC = ({ details }) => { }); // Adds new signature to the collection await handleMaspSignTx(ledger, tx, zip32Path, maspSignatures); - } else { + } + + if (!disposableSigner) { const bip44Path = makeBip44Path(chains.namada.bip44.coinType, path); // Adds new signature to the collection await handleSignTx(ledger, tx, bip44Path, signatures); @@ -273,10 +278,18 @@ export const ConfirmSignLedgerTx: React.FC = ({ details }) => { Ports.Background, new ReplaceMaspSignaturesMsg(msgId, maspSignatures) ); - await requester.sendMessage( - Ports.Background, - new SubmitApprovedSignTxMsg(msgId, signer) - ); + + if (disposableSigner) { + await requester.sendMessage( + Ports.Background, + new SubmitApprovedSignTxMsg(msgId, signer) + ); + } else { + await requester.sendMessage( + Ports.Background, + new SubmitApprovedSignLedgerTxMsg(msgId, signatures) + ); + } } else { await requester.sendMessage( Ports.Background, diff --git a/apps/extension/src/background/keyring/keyring.ts b/apps/extension/src/background/keyring/keyring.ts index 9dc26aa2f..c27cfc475 100644 --- a/apps/extension/src/background/keyring/keyring.ts +++ b/apps/extension/src/background/keyring/keyring.ts @@ -796,7 +796,7 @@ export class KeyRing { const realAddress = disposableKey?.realAddress || signer; // If disposable key is provided, use it to map real address to spending key - const xsks = [await this.getSpendingKey(realAddress)]; + const xsks = [await this.getSpendingKey(disposableKey ? realAddress : signer)]; const { signing } = this.sdkService.getSdk(); diff --git a/apps/namadillo/src/App/Common/GasFeeModal.tsx b/apps/namadillo/src/App/Common/GasFeeModal.tsx index 3bbb5bf20..dee46ebd6 100644 --- a/apps/namadillo/src/App/Common/GasFeeModal.tsx +++ b/apps/namadillo/src/App/Common/GasFeeModal.tsx @@ -3,7 +3,10 @@ import { ActionButton, AmountInput, Modal, + Stack, StyledSelectBox, + Text, + ToggleButton, } from "@namada/components"; import { transparentBalanceAtom } from "atoms/accounts"; import { shieldedBalanceAtom } from "atoms/balance"; @@ -95,7 +98,6 @@ const useBuildGasOption = ({ export const GasFeeModal = ({ feeProps, onClose, - isShielded = false, }: { feeProps: TransactionFeeProps; onClose: () => void; @@ -105,8 +107,11 @@ export const GasFeeModal = ({ gasConfig, gasEstimate, gasPriceTable, + gasSource, + gasSourceSwitch, onChangeGasLimit, onChangeGasToken, + onChangeGasSource, } = feeProps; const sortByNativeToken = useSortByNativeToken(); @@ -118,7 +123,7 @@ export const GasFeeModal = ({ const findUserBalanceByTokenAddress = (tokenAddres: string): BigNumber => { // TODO: we need to refactor userShieldedBalances to return Balance[] type instead const balances = - isShielded ? + gasSource === "shielded" ? shieldedAmount.data?.map((balance) => ({ minDenomAmount: balance.minDenomAmount, tokenAddress: balance.address, @@ -207,6 +212,39 @@ export const GasFeeModal = ({ Balance Fee + {gasSourceSwitch && gasSource !== "shielded" && ( + + Warning! Using fees from your transparent account will reveal data. +
+ To keep your data protected we recommend moving assets to the +
+ shield pool to pay fees. +
+ )} + +
Fee Token
+ {gasSourceSwitch && ( + + onChangeGasSource( + gasSource === "shielded" ? "transparent" : "shielded" + ) + } + containerProps={{ className: "gap-3 text-xs" }} + /> + )} +
{ const [modalOpen, setModalOpen] = useState(false); const chainAssetsMap = useAtomValue(chainAssetsMapAtom); @@ -54,11 +52,7 @@ export const TransactionFeeButton = ({ {modalOpen && ( - setModalOpen(false)} - isShielded={isShieldedTransfer} - /> + setModalOpen(false)} /> )} ); diff --git a/apps/namadillo/src/App/Masp/MaspUnshield.tsx b/apps/namadillo/src/App/Masp/MaspUnshield.tsx index 803cec80b..0608417dc 100644 --- a/apps/namadillo/src/App/Masp/MaspUnshield.tsx +++ b/apps/namadillo/src/App/Masp/MaspUnshield.tsx @@ -162,7 +162,6 @@ export const MaspUnshield: React.FC = () => { isShieldedAddress: false, }} feeProps={feeProps} - isShieldedTx={true} isSubmitting={isPerformingTransfer || isSuccess} errorMessage={generalErrorMessage} onSubmitTransfer={onSubmitTransfer} diff --git a/apps/namadillo/src/App/NamadaTransfer/NamadaTransfer.tsx b/apps/namadillo/src/App/NamadaTransfer/NamadaTransfer.tsx index 33233a536..5d4742f38 100644 --- a/apps/namadillo/src/App/NamadaTransfer/NamadaTransfer.tsx +++ b/apps/namadillo/src/App/NamadaTransfer/NamadaTransfer.tsx @@ -202,7 +202,6 @@ export const NamadaTransfer: React.FC = () => { feeProps={feeProps} currentStatus={currentStatus} currentStatusExplanation={currentStatusExplanation} - isShieldedTx={isSourceShielded} isSubmitting={ isPerformingTransfer || isTransferSuccessful || Boolean(completedAt) } diff --git a/apps/namadillo/src/App/Transfer/TransferDestination.tsx b/apps/namadillo/src/App/Transfer/TransferDestination.tsx index 54efd5f08..4764fb576 100644 --- a/apps/namadillo/src/App/Transfer/TransferDestination.tsx +++ b/apps/namadillo/src/App/Transfer/TransferDestination.tsx @@ -15,7 +15,6 @@ import { TokenAmountCard } from "./TokenAmountCard"; type TransferDestinationProps = { isShieldedAddress?: boolean; - isShieldedTx?: boolean; onChangeShielded?: (isShielded: boolean) => void; chain?: Chain; wallet?: WalletProvider; @@ -43,7 +42,6 @@ export const TransferDestination = ({ wallet, walletAddress, isShieldedAddress, - isShieldedTx = false, onChangeShielded, gasDisplayAmount, gasAsset, @@ -173,12 +171,7 @@ export const TransferDestination = ({ {!isSubmitting && (