diff --git a/src/App.tsx b/src/App.tsx index c5455a6..72dae3b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -44,8 +44,6 @@ import { saveFileToDisk, saveSeedPhraseToDisk, } from './utils/generateWallet/generateWallet'; -import { kdf } from './deps/kdf'; -import { generateSaveWalletData } from './utils/generateWallet/storeWallet'; import { crypto, walletVersion } from './constants/decryptWallet'; import PhraseWallet from './utils/generateWallet/phrase-wallet'; import { @@ -147,21 +145,21 @@ import { useAtom, useSetAtom } from 'jotai'; import { useResetAtom } from 'jotai/utils'; type extStates = - | 'not-authenticated' | 'authenticated' - | 'send-qort' - | 'web-app-request-connection' - | 'web-app-request-payment' - | 'web-app-request-authentication' - | 'download-wallet' + | 'buy-order-submitted' | 'create-wallet' + | 'download-wallet' + | 'group' + | 'not-authenticated' + | 'send-qort' | 'transfer-success-regular' | 'transfer-success-request' | 'wallet-dropped' - | 'web-app-request-buy-order' - | 'buy-order-submitted' | 'wallets' - | 'group'; + | 'web-app-request-authentication' + | 'web-app-request-buy-order' + | 'web-app-request-connection' + | 'web-app-request-payment'; interface MyContextInterface { isShow: boolean; @@ -277,6 +275,7 @@ export const getBaseApiReactSocket = (customApi?: string) => { }; export const isMainWindow = true; + function App() { const [extState, setExtstate] = useState('not-authenticated'); const [desktopViewMode, setDesktopViewMode] = useState('home'); @@ -308,18 +307,22 @@ function App() { const [isLoading, setIsLoading] = useState(false); const [isLoadingSendCoin, setIsLoadingSendCoin] = useState(false); - const { t } = useTranslation(['auth', 'core']); + const { t } = useTranslation(['auth', 'core', 'group']); const theme = useTheme(); const [ walletToBeDownloadedPasswordConfirm, setWalletToBeDownloadedPasswordConfirm, ] = useState(''); + const [walletToBeDownloadedError, setWalletToBeDownloadedError] = useState(''); + const [walletToBeDecryptedError, setWalletToBeDecryptedError] = useState(''); + const [isFocused, setIsFocused] = useState(true); + const [hasSettingsChanged, setHasSettingsChanged] = useAtom( hasSettingsChangedAtom ); @@ -328,6 +331,7 @@ function App() { const downloadResource = useFetchResources(); const holdRefExtState = useRef('not-authenticated'); const isFocusedRef = useRef(true); + const { showTutorial, openTutorialModal, @@ -335,7 +339,9 @@ function App() { setOpenTutorialModal, hasSeenGettingStarted, } = useHandleTutorials(); + const { isShow, onCancel, onOk, show, message } = useModal(); + const { isShow: isShowUnsavedChanges, onCancel: onCancelUnsavedChanges, @@ -343,6 +349,7 @@ function App() { show: showUnsavedChanges, message: messageUnsavedChanges, } = useModal(); + const { isShow: isShowInfo, onCancel: onCancelInfo, @@ -358,6 +365,7 @@ function App() { isShow: isShowQortalRequest, message: messageQortalRequest, } = useModal(); + const { onCancel: onCancelQortalRequestExtension, onOk: onOkQortalRequestExtension, @@ -365,6 +373,7 @@ function App() { isShow: isShowQortalRequestExtension, message: messageQortalRequestExtension, } = useModal(); + const setIsRunningPublicNode = useSetAtom(isRunningPublicNodeAtom); const [infoSnack, setInfoSnack] = useState(null); @@ -375,15 +384,18 @@ function App() { const [apiKey, setApiKey] = useState(''); const [isOpenSendQort, setIsOpenSendQort] = useState(false); const [isOpenSendQortSuccess, setIsOpenSendQortSuccess] = useState(false); + const { isUserBlocked, addToBlockList, removeBlockFromList, getAllBlockedUsers, } = useBlockedAddresses(); + const [currentNode, setCurrentNode] = useState({ url: 'http://127.0.0.1:12391', }); + const [useLocalNode, setUseLocalNode] = useState(false); const [confirmRequestRead, setConfirmRequestRead] = useState(false); @@ -662,10 +674,15 @@ function App() { 'kdfThreads', ]; for (const field of requiredFields) { - if (!(field in pf)) throw new Error(field + ' not found in JSON'); + if (!(field in pf)) + throw new Error( + t('auth:message.error.field_not_found_json', { + field: field, + postProcess: 'capitalizeFirst', + }) + ); } setRawWallet(pf); - // setExtstate("authenticated"); setExtstate('wallet-dropped'); setdecryptedWallet(null); } catch (e) { @@ -958,25 +975,39 @@ function App() { const createAccountFunc = async () => { try { if (!walletToBeDownloadedPassword) { - setWalletToBeDownloadedError('Please enter a password'); + setWalletToBeDownloadedError( + t('core:message.generic.password_enter', { + postProcess: 'capitalizeFirst', + }) + ); return; } if (!walletToBeDownloadedPasswordConfirm) { - setWalletToBeDownloadedError('Please confirm your password'); + setWalletToBeDownloadedError( + t('core:message.generic.password_confirm', { + postProcess: 'capitalizeFirst', + }) + ); return; } if ( walletToBeDownloadedPasswordConfirm !== walletToBeDownloadedPassword ) { - setWalletToBeDownloadedError('Password fields do not match!'); + setWalletToBeDownloadedError( + t('core:message.error.password_not_matching', { + postProcess: 'capitalizeFirst', + }) + ); return; } setIsLoading(true); + await new Promise((res) => { setTimeout(() => { res(); }, 250); }); + const res = await createAccount(generatorRef.current.parsedString); const wallet = await res.generateSaveWalletData( walletToBeDownloadedPassword, @@ -1029,9 +1060,10 @@ function App() { const logoutFunc = useCallback(async () => { try { if (extState === 'authenticated') { - // TODO translate await showUnsavedChanges({ - message: 'Are you sure you would like to logout?', + message: t('core:question.logout', { + postProcess: 'capitalizeFirst', + }), }); } window @@ -1091,7 +1123,6 @@ function App() { setWalletToBeDownloadedPassword(''); setShowSeed(false); setCreationStep(1); - setWalletToBeDownloadedPasswordConfirm(''); setWalletToBeDownloadedError(''); setSendqortState(null); @@ -1166,7 +1197,11 @@ function App() { console.error('Failed to decrypt wallet:', error); }); } catch (error) { - setWalletToBeDecryptedError('Unable to authenticate. Wrong password'); + setWalletToBeDecryptedError( + t('core:message.error.password_wrong', { + postProcess: 'capitalizeFirst', + }) + ); } }; @@ -1242,17 +1277,18 @@ function App() { return ( + {authenticatedMode === 'qort' && ( @@ -1455,6 +1491,7 @@ function App() { > {balance?.toFixed(2)} QORT + + + )} @@ -2182,6 +2221,7 @@ function App() { {messageQortalRequest?.fee} {' QORT'} + )} @@ -2627,7 +2667,7 @@ function App() { {t('auth:wallet.password', { postProcess: 'capitalizeFirst' })} - + - Wallet Password + {t('auth:wallet.password', { + postProcess: 'capitalizeFirst', + })} @@ -2919,7 +2961,9 @@ function App() { - Confirm Wallet Password + {t('auth:wallet.password_confirmation', { + postProcess: 'capitalizeFirst', + })} diff --git a/src/components/Save/Save.tsx b/src/components/Save/Save.tsx index 70faac8..f85baee 100644 --- a/src/components/Save/Save.tsx +++ b/src/components/Save/Save.tsx @@ -155,7 +155,7 @@ export const Save = ({ isDesktop, disableWidth, myName }) => { const fee = await getFee('ARBITRARY'); await show({ - message: t('core:save_options.publish_qnd', { + message: t('core:message.generic.publish_qnd', { postProcess: 'capitalizeFirst', }), publishFee: fee.fee + ' QORT', @@ -306,7 +306,7 @@ export const Save = ({ isDesktop, disableWidth, myName }) => { fontSize: '14px', }} > - {t('core:save_options.settings', { + {t('core:message.generic.settings', { postProcess: 'capitalizeFirst', })} {' '} @@ -335,7 +335,7 @@ export const Save = ({ isDesktop, disableWidth, myName }) => { }, }} > - {t('core:save_options.qdn', { + {t('core:message.generic.qdn', { postProcess: 'capitalizeFirst', })} @@ -366,7 +366,7 @@ export const Save = ({ isDesktop, disableWidth, myName }) => { fontSize: '14px', }} > - {t('core:save_options.register_name', { + {t('core:message.generic.register_name', { postProcess: 'capitalizeFirst', })} @@ -387,7 +387,7 @@ export const Save = ({ isDesktop, disableWidth, myName }) => { fontSize: '14px', }} > - {t('core:save_options.unsaved_changes', { + {t('core:message.generic.unsaved_changes', { postProcess: 'capitalizeFirst', })} @@ -446,7 +446,7 @@ export const Save = ({ isDesktop, disableWidth, myName }) => { }, }} > - {t('core:save_options.revert_qdn', { + {t('core:message.generic.revert_qdn', { postProcess: 'capitalizeFirst', })} @@ -471,7 +471,7 @@ export const Save = ({ isDesktop, disableWidth, myName }) => { onClick={revertChanges} variant="contained" > - {t('core:save_options.revert_default', { + {t('core:message.generic.revert_default', { postProcess: 'capitalizeFirst', })} @@ -517,7 +517,7 @@ export const Save = ({ isDesktop, disableWidth, myName }) => { }, }} > - {t('core:save_options.overwrite_qdn', { + {t('core:message.generic.overwrite_qdn', { postProcess: 'capitalizeFirst', })} @@ -537,7 +537,7 @@ export const Save = ({ isDesktop, disableWidth, myName }) => { fontSize: '14px', }} > - {t('core:save_options.no_pinned_changes', { + {t('core:message.generic.no_pinned_changes', { postProcess: 'capitalizeFirst', })} diff --git a/src/i18n/locales/en/auth.json b/src/i18n/locales/en/auth.json index d43873f..5d05e66 100644 --- a/src/i18n/locales/en/auth.json +++ b/src/i18n/locales/en/auth.json @@ -31,6 +31,7 @@ "message": { "error": { "account_creation": "could not create account.", + "field_not_found_json": "{{ field }} not found in JSON", "incorrect_password": "incorrect password", "invalid_secret_key": "secretKey is not valid", "unable_reencrypt_secret_key": "unable to re-encrypt secret key" diff --git a/src/i18n/locales/en/core.json b/src/i18n/locales/en/core.json index 71afe1f..e93cdf2 100644 --- a/src/i18n/locales/en/core.json +++ b/src/i18n/locales/en/core.json @@ -128,6 +128,8 @@ "missing_fields": "missing: {{ fields }}", "navigation_timeout": "navigation timeout", "network_generic": "network error", + "password_not_matching": "password fields do not match!", + "password_wrong": "unable to authenticate. Wrong password", "publish_app": "unable to publish app", "rating_option": "cannot find rating option", "save_qdn": "unable to save to QDN", @@ -147,18 +149,30 @@ "name_unavailable": "{{ name }} is unavailable", "no_description": "no description", "no_notifications": "no new notifications", + "no_pinned_changes": "you currently do not have any changes to your pinned apps", "no_results": "no results", "one_app_per_name": "note: Currently, only one App and Website is allowed per Name.", + "overwrite_qdn": "overwrite to QDN", + "password_confirm": "please confirm a password", + "password_enter": "please enter a password", "publish_data": "publish data to Qortal: anything from apps to videos. Fully decentralized!", "publishing": "publishing... Please wait.", + "qdn": "use QDN saving", "rating": "rating for {{ service }} {{ name }}", + "register_name": "you need a registered Qortal name to save your pinned apps to QDN.", + "revert_default": "revert to default", + "revert_qdn": "revert to QDN", + "save_qdn": "save to QDN", "secure_ownership": "secure ownership of data published by your name. You can even sell your name, along with your data to a third party.", "select_file": "please select a file", "select_image": "please select an image for a logo", "select_zip": "select .zip file containing static content:", - "space_for_admins": "sorry, this space is only for Admins." + "settings": "you are using the export/import way of saving settings.", + "space_for_admins": "sorry, this space is only for Admins.", + "unsaved_changes": "you have unsaved changes to your pinned apps. Save them to QDN." }, "question": { + "logout": "are you sure you would like to logout?", "new_user": "are you a new user?" }, "status": { @@ -205,17 +219,6 @@ "reset_pinned": "don't like your current local changes? Would you like to reset to the default pinned apps?", "reset_qdn": "don't like your current local changes? Would you like to reset to your saved QDN pinned apps?" }, - "save_options": { - "no_pinned_changes": "you currently do not have any changes to your pinned apps", - "overwrite_qdn": "overwrite to QDN", - "qdn": "use QDN saving", - "register_name": "you need a registered Qortal name to save your pinned apps to QDN.", - "revert_default": "revert to default", - "revert_qdn": "revert to QDN", - "save_qdn": "save to QDN", - "settings": "you are using the export/import way of saving settings.", - "unsaved_changes": "you have unsaved changes to your pinned apps. Save them to QDN." - }, "server": "server", "settings": "settings", "supply": "supply",