Skip to content

Commit

Permalink
Merge branch 'master' into chore/router-v6
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/App.js
  • Loading branch information
tuliomir committed Mar 28, 2024
2 parents 0d08da8 + abb4da2 commit fbf87d4
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 4 deletions.
16 changes: 15 additions & 1 deletion QA.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,21 @@ You can connect your wallet to the testnet (https://node1.foxtrot.testnet.hathor
1. Close and open the wallet again and start a new wallet one without doing backup. It must show a yellow warning saying a backup must be done.
1. Do the backup (following procedures in the 'Initialization' tests). The backup message has to disappear.

1. **Reset menu**
1. Click on the application menu Debug > Reset all data. Then fill the form with "anything" and click on the "Reset all data" button.
1. Check that a message with "Invalid value." appears.
1. Click on "Cancel", the modal should close.
1. Click on the application menu Debug > Reset all data. Then fill the form with "I want to reset my wallet" and click on the "Reset all data" button. The wallet should close.
1. Open the wallet again, it should open the Welcome screen. Do NOT click on "Get started".
1. Close the wallet.

1. **Hardware wallet migration**
1. Uninstall the wallet and install the previous version.
1. Connect your Ledger device to the computer. The Ledger should be initialized already.
1. Start the wallet with the Ledger device and copy the current address.
1. Close the wallet and install the latest version.

1. **Hardware wallet initialization**
1. Reset the wallet one more time.
1. Connect your Ledger device to the computer. The Ledger should be initialized already.
1. Open the Hathor app on Ledger.
1. On the desktop wallet, mark the checkbox and click 'Get Started'.
Expand All @@ -216,6 +229,7 @@ You can connect your wallet to the testnet (https://node1.foxtrot.testnet.hathor
1. Deny the authorization request on Ledger (scroll with left or right and click both buttons on "Reject" step). It should show an error on the wallet.
1. Click 'Try again'. It goes through both steps and asks for authorization again.
1. Grant authorization request (click both buttons on the "Approve" step). It will proceed to 'Loading transactions' screen.
1. Once the wallet is loaded check that the current address match the copied address during "**Hardware wallet migration**"

1. **Ledger wallet screen**
1. On the main wallet screen, confirm 'Address to receive tokens' is truncated (eg: 'HGZmqThwa6...'). There should be a 'Show full address' button next to it.
Expand Down
10 changes: 8 additions & 2 deletions public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,15 @@ function createWindow () {
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
{ label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:' }
]}
]},
];

if (debugMode) {
template.push({
label: 'Debug',
submenu: [
{ label: `Open DevTools`, accelerator: 'CmdOrCtrl+B', click: function() { mainWindow.webContents.openDevTools(); }}
{ label: `Open DevTools`, accelerator: 'CmdOrCtrl+B', click: function() { mainWindow.webContents.openDevTools(); }},
{ label: 'Reset all data', click: function() { mainWindow.webContents.send('app:clear_storage'); }},
]
});
};
Expand Down Expand Up @@ -167,6 +168,11 @@ function createWindow () {
}
});

ipcMain.on('app:clear_storage_success', () => {
console.log('Data reset success. Closing window...');
mainWindow.close();
});

addLedgerListeners(mainWindow);
}

Expand Down
15 changes: 14 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import React, { useEffect, useState } from 'react';
import React, { useEffect, useState, useContext } from 'react';
import { Navigate, Route, Routes, useLocation, useNavigate } from 'react-router-dom';
import Wallet from './screens/Wallet';
import SendTokens from './screens/SendTokens';
Expand Down Expand Up @@ -38,6 +38,7 @@ import tokensUtils from './utils/tokens';
import storageUtils from './utils/storage';
import { useDispatch, useSelector } from 'react-redux';
import RequestErrorModal from './components/RequestError';
import { GlobalModalContext, MODAL_TYPES } from './components/GlobalModal';
import createRequestInstance from './api/axiosInstance';
import hathorLib from '@hathor/wallet-lib';
import { IPC_RENDERER } from './constants';
Expand Down Expand Up @@ -67,6 +68,7 @@ function Root() {
});
const dispatch = useDispatch();
const navigate = useNavigate();
const context = useContext(GlobalModalContext);

Check warning on line 71 in src/App.js

View check run for this annotation

Codecov / codecov/patch

src/App.js#L70-L71

Added lines #L70 - L71 were not covered by tests

// Monitors when Ledger device loses connection or the app is closed
useEffect(() => {
Expand Down Expand Up @@ -98,6 +100,17 @@ function Root() {

// If there is an `Inter Process Communication` channel available, initialize Ledger logic
if (IPC_RENDERER) {
// Event called when the user wants to reset all data
IPC_RENDERER.on('app:clear_storage', async () => {
context.showModal(MODAL_TYPES.CONFIRM_CLEAR_STORAGE, {
success: () => {
localStorage.clear();
IPC_RENDERER.send('app:clear_storage_success');
},
});

});

// Registers the event handlers for the ledger

// Event called when user quits hathor app
Expand Down
3 changes: 3 additions & 0 deletions src/components/GlobalModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import ModalLedgerResetTokenSignatures from './ModalLedgerResetTokenSignatures';
import ModalResetAllData from './ModalResetAllData';
import ModalLedgerSignToken from './ModalLedgerSignToken';
import ModalConfirmTestnet from './ModalConfirmTestnet';
import ModalConfirmClearStorage from './ModalConfirmClearStorage';
import ModalSendTx from './ModalSendTx';
import ModalUnregisteredTokenInfo from './ModalUnregisteredTokenInfo';
import ModalPin from "./ModalPin";
Expand All @@ -43,6 +44,7 @@ export const MODAL_TYPES = {
'RESET_ALL_DATA': 'RESET_ALL_DATA',
'LEDGER_SIGN_TOKEN': 'LEDGER_SIGN_TOKEN',
'CONFIRM_TESTNET': 'CONFIRM_TESTNET',
'CONFIRM_CLEAR_STORAGE': 'CONFIRM_CLEAR_STORAGE',
'SEND_TX': 'SEND_TX',
'UNREGISTERED_TOKEN_INFO': 'UNREGISTERED_TOKEN_INFO',
'PIN': 'PIN',
Expand All @@ -63,6 +65,7 @@ export const MODAL_COMPONENTS = {
[MODAL_TYPES.RESET_ALL_DATA]: ModalResetAllData,
[MODAL_TYPES.LEDGER_SIGN_TOKEN]: ModalLedgerSignToken,
[MODAL_TYPES.CONFIRM_TESTNET]: ModalConfirmTestnet,
[MODAL_TYPES.CONFIRM_CLEAR_STORAGE]: ModalConfirmClearStorage,
[MODAL_TYPES.SEND_TX]: ModalSendTx,
[MODAL_TYPES.UNREGISTERED_TOKEN_INFO]: ModalUnregisteredTokenInfo,
[MODAL_TYPES.PIN]: ModalPin,
Expand Down
68 changes: 68 additions & 0 deletions src/components/ModalConfirmClearStorage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React, { useEffect, useState, useCallback } from 'react';
import { t } from 'ttag';
import $ from 'jquery';
import SpanFmt from './SpanFmt';
import { CONFIRM_RESET_MESSAGE } from '../constants';

export default function ModalConfirmClearStorage({ onClose, success }) {
const [confirmText, setConfirmText] = useState('');
const [confirmError, setConfirmError] = useState('');

useEffect(() => {
$('#modalConfirmResetAllData').modal('show');
$('#modalConfirmResetAllData').on('hidden.bs.modal', onClose);

return () => {
$('#modalConfirmResetAllData').modal('hide');
$('#modalConfirmResetAllData').off();
};
}, []);

const confirmResetData = useCallback(() => {
if (confirmText.toLowerCase() !== CONFIRM_RESET_MESSAGE.toLowerCase()) {
setConfirmError(t`Invalid value.`);
return;
}

success();
}, [confirmText, setConfirmError]);

return (
<div className="modal fade" id="modalConfirmResetAllData" tabIndex="-1" role="dialog" aria-labelledby="alertModal" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div className="modal-dialog" role="document">
<div className="modal-content">
<div className="modal-header">
<h5 className="modal-title">
{ t`Confirm reset all data` }
</h5>
</div>
<div className="modal-body">
<div>
<p><SpanFmt>{t`**Make sure you have the backup of your seed because this will turn your wallet into a fresh install.**`}</SpanFmt></p>
<p>{t`Do you want to reset all of your wallet data? Only continue if you know what you are doing.`}</p>
<p>{t`This action cannot be undone. All your data will be erased.`}</p>
<p>{t`Your wallet uniqueId will be reset.`}</p>
<p>uniqueId: {localStorage.getItem('app:uniqueId')}</p>
<p>{t`If you want to reset all data, please type '${CONFIRM_RESET_MESSAGE}' in the box below and click on 'Reset all data' button.`}</p>
<p>{t`After resetting the data, the application will close, and you will need to open it again.`}</p>
<div>
<input type="text" className="form-control" placeholder={t`Write '${CONFIRM_RESET_MESSAGE}'`} onChange={(e) => setConfirmText(e.target.value)} />
<span className="text-danger ml-2">
{confirmError}
</span>
</div>
</div>
</div>
<div className="modal-footer">
<button onClick={confirmResetData} type="button" className="btn btn-secondary">
{t`Reset all data`}
</button>
<button onClick={onClose} type="button" className="btn btn-hathor">
{ t`Cancel` }
</button>
</div>
</div>
</div>
</div>
);
}

0 comments on commit fbf87d4

Please sign in to comment.