Skip to content

Commit

Permalink
feat(rescan): ability to rescan timechain (#838)
Browse files Browse the repository at this point in the history
  • Loading branch information
nischal-shetty2 authored Sep 7, 2024
1 parent 2494a8c commit 3ec72b1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
19 changes: 9 additions & 10 deletions src/components/RescanChain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const RescanChainForm = ({ disabled, submitButtonText, onSubmit }: RescanChainFo
validate={(values) => {
const errors = {} as FormikErrors<RescanChainFormValues>
if (typeof values.blockheight !== 'number' || values.blockheight < 0) {
errors.blockheight = t('Please provide a valid blockheight value greater than or equal to {{ min }}.', {
errors.blockheight = t('rescan_chain.feedback_invalid_blockheight', {
min: 0,
})
}
Expand All @@ -57,16 +57,16 @@ const RescanChainForm = ({ disabled, submitButtonText, onSubmit }: RescanChainFo
{({ handleSubmit, handleBlur, handleChange, values, touched, errors, isSubmitting }) => (
<rb.Form onSubmit={handleSubmit} noValidate lang={i18n.resolvedLanguage || i18n.language}>
<rb.Form.Group controlId="blockheight" className="mb-4">
<rb.Form.Label>{t('Blockheight')}</rb.Form.Label>
<rb.Form.Label>{t('rescan_chain.label_blockheight')}</rb.Form.Label>
<rb.Form.Text className="d-block text-secondary mb-2">
{t('The height of the chain at which the rescan process is started.')}
{t('rescan_chain.description_blockheight')}
</rb.Form.Text>
<rb.InputGroup hasValidation>
<rb.InputGroup.Text id="blockheight-addon1">
<Sprite symbol="block" width="24" height="24" name="Block" />
</rb.InputGroup.Text>
<rb.Form.Control
aria-label={t('Blockheight')}
aria-label={t('rescan_chain.label_blockheight')}
className="slashed-zeroes"
name="blockheight"
type="number"
Expand Down Expand Up @@ -131,7 +131,7 @@ export default function RescanChain({ wallet }: RescanChainProps) {
} catch (e: any) {
if (signal.aborted) return

const message = t('Error while starting the rescan process. Reason: {{ reason }}', {
const message = t('rescan_chain.error_rescanning_failed', {
reason: e.message || t('global.errors.reason_unknown'),
})
setAlert({ variant: 'danger', message })
Expand All @@ -142,16 +142,15 @@ export default function RescanChain({ wallet }: RescanChainProps) {

return (
<div className="import-wallet">
<PageTitle
title={t('Rescan timechain (Experimental)')}
subtitle={t('Rescan the local timechain for wallet related transactions.')}
/>
<PageTitle title={t('rescan_chain.title')} subtitle={t('rescan_chain.subtitle')} />
{alert && <rb.Alert variant={alert.variant}>{alert.message}</rb.Alert>}
<div className="mb-4">
{serviceInfo?.rescanning === true && <rb.Alert variant="success">{t('app.alert_rescan_in_progress')}</rb.Alert>}
<RescanChainForm
disabled={serviceInfo?.rescanning}
submitButtonText={(isSubmitting) => t(isSubmitting ? 'Rescan timechain' : 'Rescan timechain')}
submitButtonText={(isSubmitting) =>
t(isSubmitting ? 'rescan_chain.text_button_submitting' : 'rescan_chain.text_button_submit')
}
onSubmit={async (values) => {
const abortCtrl = new AbortController()

Expand Down
14 changes: 4 additions & 10 deletions src/components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import languages from '../i18n/languages'
import styles from './Settings.module.css'
import SeedModal from './settings/SeedModal'
import FeeConfigModal from './settings/FeeConfigModal'
import { isDebugFeatureEnabled, isDevMode } from '../constants/debugFeatures'
import { isDevMode } from '../constants/debugFeatures'
import { isFeatureEnabled } from '../constants/features'
import { CurrentWallet } from '../context/WalletContext'

Expand Down Expand Up @@ -213,16 +213,10 @@ export default function Settings({ wallet, stopWallet }: SettingsProps) {
{t('settings.button_switch_wallet')}
</Link>

{serviceInfo && isFeatureEnabled('rescanChain', serviceInfo) && isDebugFeatureEnabled('rescanChainPage') && (
<Link
to={routes.rescanChain}
className={`btn btn-outline-dark ${styles['settings-btn']} position-relative`}
>
{serviceInfo && isFeatureEnabled('rescanChain', serviceInfo) && (
<Link to={routes.rescanChain} className={`btn btn-outline-dark ${styles['settings-btn']}`}>
<Sprite symbol="block" width="24" height="24" />
Rescan chain
<span className="position-absolute top-50 start-0 translate-middle badge rounded-pill bg-warning">
dev
</span>
{t('settings.rescan_chain')}
</Link>
)}

Expand Down
11 changes: 11 additions & 0 deletions src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
"confirm_locking_modal_title": "Lock Wallet",
"confirm_locking_modal_body_earn": "Earn is active. Locking the wallet will stop the service. You can close the browser window to let it run in the background.",
"confirm_locking_modal_body_jam": "A collaborative transaction is being executed. Locking the wallet will stop the service. You can close the browser window to let it run in the background.",
"rescan_chain": "Rescan chain",
"fees": {
"title": "Fee Limits",
"description": "Adjust mining fees and collaborator fees according to your needs. These settings will be reset to default values when the JoinMarket service restarts, e.g. on a system reboot. For more information, <1>see the documentation on fees</1>.",
Expand Down Expand Up @@ -270,6 +271,16 @@
"error_saving_fee_config_failed": "Error while saving fee config values. Reason: {{ reason }}"
}
},
"rescan_chain": {
"title": "Rescan timechain (Experimental)",
"subtitle": "Rescan the local timechain for wallet related transactions.",
"label_blockheight": "Rescan height",
"description_blockheight": "The height of the chain at which the rescan process is started.",
"error_rescanning_failed": "Error while starting the rescan process. Reason: {{ reason }}",
"feedback_invalid_blockheight": "Please provide a valid value between {{ min }} and the current blockheight.",
"text_button_submit": "Rescan timechain",
"text_button_submitting": "Rescanning timechain..."
},
"logs": {
"title": "Logs",
"error_loading_logs_failed": "Could not retrieve log file."
Expand Down

0 comments on commit 3ec72b1

Please sign in to comment.