From 0db3c352805f69e8debd6d101708144a93839c58 Mon Sep 17 00:00:00 2001 From: cakesoft-vaibhav Date: Wed, 14 Aug 2024 18:55:54 +0530 Subject: [PATCH 01/61] fix: crash/ setSelectedWallet onDeleteWithFunds --- src/screens/AppSettings/ManageWallets.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/screens/AppSettings/ManageWallets.tsx b/src/screens/AppSettings/ManageWallets.tsx index d4db7f72e..77601c7fd 100644 --- a/src/screens/AppSettings/ManageWallets.tsx +++ b/src/screens/AppSettings/ManageWallets.tsx @@ -334,6 +334,7 @@ function ManageWallets() { }} onDelete={() => { if (item.specs.balances.confirmed + item.specs.balances.unconfirmed > 0) { + setSelectedWallet(item); setShowDeleteVaultBalanceAlert(true); } else { setSelectedWallet(item); From 59fe15116ebf648728317f30cb5f7fd453085eaf Mon Sep 17 00:00:00 2001 From: cakesoft-vaibhav Date: Mon, 19 Aug 2024 10:50:03 +0530 Subject: [PATCH 02/61] fix: Delete Vault with funds --- src/context/Localization/language/en.json | 8 ++++++- src/context/Localization/language/es.json | 8 ++++++- src/screens/AppSettings/ManageWallets.tsx | 26 +++++++++++++---------- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/context/Localization/language/en.json b/src/context/Localization/language/en.json index eef60ca37..885a85d0c 100644 --- a/src/context/Localization/language/en.json +++ b/src/context/Localization/language/en.json @@ -848,7 +848,13 @@ "SingerSettingsTitle": "Advanced Options", "SingerSettingsSubtitle": "For all keys", "ManageWalletsEmptyTitle": "Hide Unhide Wallets", - "ManageWalletsEmptySubtitle": "Avoid clutter on the homescreen and keep wallets away from prying eyes." + "ManageWalletsEmptySubtitle": "Avoid clutter on the homescreen and keep wallets away from prying eyes.", + "DeleteWalletModalTitle": "You have funds in your wallet", + "DeleteVaultModalTitle": "Delete vault with funds?", + "DeleteWalletModalSubTitle": "You have sats in your wallet. Are you sure you want to delete it?", + "DeleteVaultModalSubTitle": "You are about to delete a vault with sats in it. Please ensure that you have backed-up your keys and vault descriptor to retrieve the vault later.", + "DeleteWalletModalDesc": "To delete this wallet, please transfer your funds to another wallet or vault first.", + "DeleteVaultModalDesc": "This action is irreversible without the keys and descriptor backed-up. Proceed to delete vault?" }, "onboarding": { "Comprehensive": "Comprehensive", diff --git a/src/context/Localization/language/es.json b/src/context/Localization/language/es.json index 5ba82c16d..df53d911c 100644 --- a/src/context/Localization/language/es.json +++ b/src/context/Localization/language/es.json @@ -843,7 +843,13 @@ "SingerSettingsTitle": "Advanced Options", "SingerSettingsSubtitle": "For all keys", "ManageWalletsEmptyTitle": "Hide Unhide Wallets", - "ManageWalletsEmptySubtitle": "Avoid clutter on the homescreen and keep wallets away from prying eyes." + "ManageWalletsEmptySubtitle": "Avoid clutter on the homescreen and keep wallets away from prying eyes.", + "DeleteWalletModalTitle": "You have funds in your wallet", + "DeleteVaultModalTitle": "Delete vault with funds?", + "DeleteWalletModalSubTitle": "You have sats in your wallet. Are you sure you want to delete it?", + "DeleteVaultModalSubTitle": "You are about to delete a vault with sats in it. Please ensure that you have backed-up your keys and vault descriptor to retrieve the vault later.", + "DeleteWalletModalDesc": "To delete this wallet, please transfer your funds to another wallet or vault first.", + "DeleteVaultModalDesc": "This action is irreversible without the keys and descriptor backed-up. Proceed to delete vault?" }, "onboarding": { "Comprehensive": "Comprehensive", diff --git a/src/screens/AppSettings/ManageWallets.tsx b/src/screens/AppSettings/ManageWallets.tsx index 77601c7fd..7974b79a4 100644 --- a/src/screens/AppSettings/ManageWallets.tsx +++ b/src/screens/AppSettings/ManageWallets.tsx @@ -254,21 +254,26 @@ function ManageWallets() { return ( - {`To delete this ${ - isWallet ? 'wallet' : 'vault' - }, please transfer your funds to another wallet or vault first.`} + {isWallet ? settings.DeleteWalletModalDesc : settings.DeleteVaultModalDesc} { - updateWalletVisibility(selectedWallet, true, false); - setShowDeleteVaultBalanceAlert(false); + if (isWallet) { + // Cancel action + updateWalletVisibility(selectedWallet, true, false); + setShowDeleteVaultBalanceAlert(false); + } else { + // Delete Vault action + setShowDeleteVaultBalanceAlert(false); + setConfirmPasscodeVisible(true); + } }} activeOpacity={0.5} > - Cancel + {isWallet ? 'Cancel' : 'Continue'} @@ -394,19 +399,18 @@ function ManageWallets() { dismissible close={() => { setShowDeleteVaultBalanceAlert(false); + !isWallet && updateWalletVisibility(selectedWallet, true, false); }} visible={showDeleteVaultBalanceAlert} - title={`You have funds in your ${isWallet ? 'wallet' : 'vault'}`} - subTitle={`You have sats in your ${ - isWallet ? 'wallet' : 'vault' - }. Are you sure you want to delete it?`} + title={isWallet ? settings.DeleteWalletModalTitle : settings.DeleteVaultModalTitle} + subTitle={isWallet ? settings.DeleteWalletModalSubTitle : settings.DeleteVaultModalSubTitle} textColor={`${colorMode}.primaryText`} modalBackground={`${colorMode}.modalWhiteBackground`} Content={DeleteVaultBalanceAlertModalContent} subTitleColor={`${colorMode}.secondaryText`} buttonTextColor={`${colorMode}.white`} subTitleWidth={wp(240)} - closeOnOverlayClick={false} + closeOnOverlayClick={isWallet ? false : true} showButtons showCloseIcon={false} /> From e4ff6f62f49c163edc92a8509e9ab2231321e02e Mon Sep 17 00:00:00 2001 From: cakesoft-vaibhav Date: Mon, 19 Aug 2024 11:57:57 +0530 Subject: [PATCH 03/61] feat: hideDeleteOption - NonEmptyWallets --- src/screens/AppSettings/ManageWallets.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/screens/AppSettings/ManageWallets.tsx b/src/screens/AppSettings/ManageWallets.tsx index 7974b79a4..c80b813ae 100644 --- a/src/screens/AppSettings/ManageWallets.tsx +++ b/src/screens/AppSettings/ManageWallets.tsx @@ -46,8 +46,7 @@ enum PasswordMode { DEFAULT = 'DEFAULT', SHOWALL = 'SHOWALL', } - -function ListItem({ title, subtitle, balance, visibilityToggle, isHidden, onDelete, icon }) { +function ListItem({ title, subtitle, balance, visibilityToggle, isHidden, onDelete, icon, type }) { const { colorMode } = useColorMode(); const { getSatUnit, getBalance, getCurrencyIcon } = useBalance(); @@ -77,7 +76,9 @@ function ListItem({ title, subtitle, balance, visibilityToggle, isHidden, onDele - {isHidden && } />} + {isHidden && (type == 'VAULT' || (type == 'WALLET' && balance === 0)) && ( + } /> + )} ( Date: Wed, 21 Aug 2024 14:06:55 +0530 Subject: [PATCH 04/61] fix: AutoTransferModal HideHiddenVaults --- src/components/NotificationStack.tsx | 3 +++ src/components/SelectWalletModal.tsx | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/NotificationStack.tsx b/src/components/NotificationStack.tsx index f26adb127..9bcf80cc7 100644 --- a/src/components/NotificationStack.tsx +++ b/src/components/NotificationStack.tsx @@ -98,6 +98,7 @@ interface uaiDefinationInterface { cta: any; }; }; + hideHiddenVaults?: boolean; }; } @@ -246,6 +247,7 @@ const Card = memo(({ uai, index, totalLength, activeIndex, skipUaiHandler }: Car cta: () => skipUaiHandler(uai), }, }, + hideHiddenVaults: true, }, }; case uaiType.IKS_REQUEST: @@ -564,6 +566,7 @@ const Card = memo(({ uai, index, totalLength, activeIndex, skipUaiHandler }: Car setShowModal={setShowSelectVault} onlyVaults={true} onlyWallets={false} + hideHiddenVaults={uaiConfig?.modalDetails?.hideHiddenVaults} buttonCallback={(vault) => { const entityWallet = allWallets.find((wallet) => wallet.id === uai.entityId); navigtaion.navigate('AddSendAmount', { diff --git a/src/components/SelectWalletModal.tsx b/src/components/SelectWalletModal.tsx index 3bb583855..15aec19b7 100644 --- a/src/components/SelectWalletModal.tsx +++ b/src/components/SelectWalletModal.tsx @@ -6,7 +6,7 @@ import { wp, hp } from 'src/constants/responsive'; import { LocalizationContext } from 'src/context/Localization/LocContext'; import useWallets from 'src/hooks/useWallets'; import SignerCard from 'src/screens/AddSigner/SignerCard'; -import { EntityKind, VaultType } from 'src/services/wallets/enums'; +import { EntityKind, VaultType, VisibilityType } from 'src/services/wallets/enums'; import CollaborativeIcon from 'src/assets/images/collaborative_vault_white.svg'; import WalletIcon from 'src/assets/images/daily_wallet.svg'; import VaultIcon from 'src/assets/images/vault_icon.svg'; @@ -68,6 +68,7 @@ const SelectWalletModal = ({ subTitle = 'Please select vault to which you want to transfer your funds', buttonText = 'Transfer', secondaryButtonText = 'Skip', + hideHiddenVaults = false, }) => { const { colorMode } = useColorMode(); const { translations } = useContext(LocalizationContext); @@ -79,7 +80,13 @@ const SelectWalletModal = ({ const walletsData = useMemo(() => { if (onlyWallets) return wallets; - if (onlyVaults) return allVaults; + if (onlyVaults) { + if (hideHiddenVaults) + return allVaults.filter( + (vault) => vault.presentationData.visibility !== VisibilityType.HIDDEN // To hide vaults which are hidden + ); + return allVaults; + } return [...wallets, ...allVaults]; }, [wallets, allVaults, onlyWallets, onlyVaults]); From 885670b582c1bc1219bb459162c5c667b9c4e0fc Mon Sep 17 00:00:00 2001 From: cakesoft-vaibhav Date: Wed, 21 Aug 2024 14:23:31 +0530 Subject: [PATCH 05/61] feat: AutoTransfer SendConfirmationUI TransferCard TnxPriorityCard FooterCTA/ TransactionPriorityTimeCalculation/ DisableChangePriorityForAutoTransfer/ sendMaxFeeEstimatedBlocksSaga --- src/screens/Send/SendConfirmation.tsx | 166 ++++++++++++------------- src/store/reducers/send_and_receive.ts | 6 + src/store/sagas/send_and_receive.ts | 4 +- 3 files changed, 91 insertions(+), 85 deletions(-) diff --git a/src/screens/Send/SendConfirmation.tsx b/src/screens/Send/SendConfirmation.tsx index 4013e86e7..e6f8fb569 100644 --- a/src/screens/Send/SendConfirmation.tsx +++ b/src/screens/Send/SendConfirmation.tsx @@ -253,37 +253,33 @@ function SendingCard({ ); } -function TransferCard({ preTitle = '', title, subTitle = '', isVault = false, icon = null }) { +function TransferCard({ + transferFrom = false, + preTitle = '', + title, + subTitle = '', + isVault = false, + currentCurrency, + currencyCode, +}) { + const getCurrencyIcon = () => { + if (currentCurrency === CurrencyKind.BITCOIN) { + return '₿'; + } + return currencyCode; + }; const { colorMode } = useColorMode(); return ( - - - {isVault ? ( - - ) : ( - } - /> - )} - {preTitle} - - - - - {title} - - - {icon} {subTitle} - - + + + {transferFrom ? 'Transfer From' : 'Transfer To'} + + ); } @@ -533,6 +529,9 @@ function TransactionPriorityDetails({ getBalance, getCurrencyIcon, getSatUnit, + isAutoTransfer, + sendMaxFee, + sendMaxFeeEstimatedBlocks, }) { const { colorMode } = useColorMode(); const { translations } = useContext(LocalizationContext); @@ -556,8 +555,10 @@ function TransactionPriorityDetails({ {transactionPriority.toUpperCase()} ~{' '} - {txFeeInfo[transactionPriority?.toLowerCase()]?.estimatedBlocksBeforeConfirmation * - 10}{' '} + {(isAutoTransfer + ? sendMaxFeeEstimatedBlocks + : txFeeInfo[transactionPriority?.toLowerCase()] + ?.estimatedBlocksBeforeConfirmation) * 10}{' '} mins @@ -565,9 +566,11 @@ function TransactionPriorityDetails({ {getCurrencyIcon(BTC, 'dark')}   - {`${getBalance( - txFeeInfo[transactionPriority?.toLowerCase()]?.amount - )} ${getSatUnit()}`} + {isAutoTransfer + ? sendMaxFee + : `${getBalance( + txFeeInfo[transactionPriority?.toLowerCase()]?.amount + )} ${getSatUnit()}`} @@ -788,6 +791,9 @@ function SendConfirmation({ route }) { transferType === TransferType.WALLET_TO_ADDRESS; const txFeeInfo = useAppSelector((state) => state.sendAndReceive.transactionFeeInfo); const sendMaxFee = useAppSelector((state) => state.sendAndReceive.sendMaxFee); + const sendMaxFeeEstimatedBlocks = useAppSelector( + (state) => state.sendAndReceive.setSendMaxFeeEstimatedBlocks + ); const averageTxFees = useAppSelector((state) => state.network.averageTxFees); const { isSuccessful: crossTransferSuccess } = useAppSelector( (state) => state.sendAndReceive.crossTransfer @@ -1210,51 +1216,44 @@ function SendConfirmation({ route }) { /> ) : ( - - - Transfer From - - - - Transfer To - - - + <> + + + )} {/* Custom priority diabled for auto transfer */} - {!isAutoTransferFlow ? ( - setTransPriorityModalVisible(true)} - > - - - ) : null} + + setTransPriorityModalVisible(true)} + disabled={isAutoTransfer} // disable change priority for AutoTransfers + > + + + {OneDayHistoricalFee.length > 0 && ( Fee stats @@ -1316,7 +1315,13 @@ function SendConfirmation({ route }) { primaryLoading={inProgress} /> ) : ( -