Skip to content

Commit

Permalink
refactor: fix typos (#2738)
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY authored Jun 28, 2023
1 parent 232b947 commit 94678b0
Show file tree
Hide file tree
Showing 80 changed files with 271 additions and 246 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/check-spell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Check spell
on:
- pull_request
- push

jobs:
run:
name: Check spell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- id: changed-files
uses: tj-actions/changed-files@v36

- uses: crate-ci/typos@master
with:
files: ${{ steps.changed-files.outputs.all_changed_files }}
11 changes: 11 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[default.extend-words]
thur = "thur"

# defined in database schema
lastest = "lastest"

[files]
extend-exclude = ["CHANGELOG.md", "**/migrations/*.ts"]



6 changes: 3 additions & 3 deletions packages/neuron-ui/src/components/DataSetting/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const type = 'ckb'

export const useDataPath = () => {
const [t] = useTranslation()
const [isSaving, setIsSaveing] = useState(false)
const [isSaving, setIsSaving] = useState(false)
const [savingType, setSavingType] = useState<string | null>()
const [prevPath, setPrevPath] = useState<string>()
const [currentPath, setCurrentPath] = useState<string | undefined>()
Expand Down Expand Up @@ -50,7 +50,7 @@ export const useDataPath = () => {
const onConfirm = useCallback(
(e: React.MouseEvent<HTMLDivElement>) => {
const { dataset } = e.currentTarget
setIsSaveing(true)
setIsSaving(true)
setSavingType(dataset.syncType)
setCkbNodeDataPath({
dataPath: currentPath!,
Expand All @@ -63,7 +63,7 @@ export const useDataPath = () => {
}
})
.finally(() => {
setIsSaveing(false)
setIsSaving(false)
setSavingType(null)
})
},
Expand Down
4 changes: 2 additions & 2 deletions packages/neuron-ui/src/components/GeneralSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { checkForUpdates, downloadUpdate, installUpdate, getVersion } from 'serv
import { LanguageSelect, CheckUpdateIcon } from 'widgets/Icons/icon'
import styles from './generalSetting.module.scss'

interface UpdateDowloadStatusProps {
interface UpdateDownloadStatusProps {
show: boolean
onCancel: () => void
progress: number
Expand All @@ -22,7 +22,7 @@ const UpdateDownloadStatus = ({
progress = 0,
newVersion = '',
releaseNotes = '',
}: UpdateDowloadStatusProps) => {
}: UpdateDownloadStatusProps) => {
const [t] = useTranslation()
const available = newVersion !== '' && progress < 0
const downloaded = progress >= 1
Expand Down
16 changes: 8 additions & 8 deletions packages/neuron-ui/src/components/HDWalletSign/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const HDWalletSign = ({ tx }: { tx: State.DetailedTransaction }) => {
const [isMainnet, setIsMainnet] = useState(false)
const addressPrefix = isMainnet ? ckbCore.utils.AddressPrefix.Mainnet : ckbCore.utils.AddressPrefix.Testnet
const [systemCodeHash, setSystemCodeHash] = useState<string>('')
const [inputVisable, setInputVisable] = useState(true)
const [inputVisible, setInputVisible] = useState(true)
const [activeInputIndex, setActiveInputIndex] = useState(0)

useDidMount(() => {
Expand Down Expand Up @@ -118,27 +118,27 @@ const HDWalletSign = ({ tx }: { tx: State.DetailedTransaction }) => {
}, [activeInputIndex, tx.outputs, renderList])

const showInput = useCallback(() => {
setInputVisable(true)
}, [setInputVisable])
setInputVisible(true)
}, [setInputVisible])

const showOutput = useCallback(() => {
setInputVisable(false)
}, [setInputVisable])
setInputVisible(false)
}, [setInputVisible])

return (
<div className={styles.sign}>
<div className={styles.tabs}>
<button className={inputVisable ? styles.active : ''} onClick={showInput} type="button">
<button className={inputVisible ? styles.active : ''} onClick={showInput} type="button">
{t('hardware-sign.inputs', { index: activeInputIndex, length: tx.inputs.length })}
</button>
<button className={!inputVisable ? styles.active : ''} onClick={showOutput} type="button">
<button className={!inputVisible ? styles.active : ''} onClick={showOutput} type="button">
{t('hardware-sign.outputs', { length: tx.outputs.length })}
</button>
</div>
<div className={styles.table}>
<hr />
<table className={styles.inputList}>
<tbody>{inputVisable ? inputBody : outputBody}</tbody>
<tbody>{inputVisible ? inputBody : outputBody}</tbody>
</table>
<hr />
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/neuron-ui/src/components/HardwareSign/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ const HardwareSign = ({
const ensureDeviceAvailable = useCallback(
async (device: DeviceInfo) => {
try {
const conectionRes = await connectDevice(device)
const connectionRes = await connectDevice(device)
let { descriptor } = device
if (!isSuccessResponse(conectionRes)) {
if (!isSuccessResponse(connectionRes)) {
// for win32, opening or closing the ckb app changes the HID descriptor(deviceInfo),
// so if we can't connect to the device, we need to re-search device automatically.
// for unix, the descriptor never changes unless user plugs the device into another USB port,
Expand Down
30 changes: 14 additions & 16 deletions packages/neuron-ui/src/components/ImportHardware/detect-device.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ const Info = (
) => {
if (isError) {
return (
<>
<div className={styles.errorInfo}>
<div className={styles.errorInfo}>
<span>
<ErrorIcon type="error" />
</span>
<span className={styles.error}>{msg}</span>
</div>
</>
)
}
return (
Expand All @@ -48,20 +46,20 @@ const DetectDevice = ({ dispatch, model }: { dispatch: React.Dispatch<ActionType
dispatch({ step: ImportStep.ImportHardware })
}, [dispatch])

const [scaning, setScaning] = useState(true)
const [scanning, setScanning] = useState(true)
const [error, setError] = useState('')
const [appVersion, setAppVersion] = useState('')
const [firmwareVersion, setFirmwareVersion] = useState('')

const findDevice = useCallback(async () => {
setError('')
setScaning(true)
setScanning(true)
try {
const res = await getDevices(model)
if (isSuccessResponse(res) && Array.isArray(res.result) && res.result.length > 0) {
const [device, ...rest] = res.result
if (rest.length > 0) {
setScaning(false)
setScanning(false)
throw new MultiDeviceException()
}
if (!model) {
Expand All @@ -72,10 +70,10 @@ const DetectDevice = ({ dispatch, model }: { dispatch: React.Dispatch<ActionType
},
})
}
const conectionRes = await connectDevice(device)
if (!isSuccessResponse(conectionRes)) {
setScaning(false)
throw new ConnectFailedException(errorFormatter(conectionRes.message, t))
const connectionRes = await connectDevice(device)
if (!isSuccessResponse(connectionRes)) {
setScanning(false)
throw new ConnectFailedException(errorFormatter(connectionRes.message, t))
}
const firmwareVersionRes = await getDeviceFirmwareVersion(device.descriptor)
if (isSuccessResponse(firmwareVersionRes)) {
Expand All @@ -95,9 +93,9 @@ const DetectDevice = ({ dispatch, model }: { dispatch: React.Dispatch<ActionType
setError(err.message)
}
} finally {
setScaning(false)
setScanning(false)
}
}, [model, setError, setScaning, t])
}, [model, setError, setScanning, t])

useDidMount(() => {
findDevice()
Expand All @@ -117,16 +115,16 @@ const DetectDevice = ({ dispatch, model }: { dispatch: React.Dispatch<ActionType
<section className={styles.detect}>
<h3 className={styles.model}>{productName}</h3>
{errorMsg ? <Info isError msg={errorMsg} /> : null}
{scaning ? <Info isWaiting={scaning} msg={t('import-hardware.waiting')} /> : null}
{firmwareVersion && !errorMsg && !scaning ? (
{scanning ? <Info isWaiting={scanning} msg={t('import-hardware.waiting')} /> : null}
{firmwareVersion && !errorMsg && !scanning ? (
<Info msg={t('import-hardware.firmware-version', { version: firmwareVersion })} />
) : null}
{appVersion ? <Info msg={t('import-hardware.app-version', { version: appVersion })} /> : null}
</section>
<footer className={styles.dialogFooter}>
<Button type="cancel" label={t('import-hardware.actions.cancel')} onClick={onBack} />
{!scaning && errorMsg && <Button type="ok" label={t('import-hardware.actions.rescan')} onClick={findDevice} />}
{!scaning && !errorMsg && (
{!scanning && errorMsg && <Button type="ok" label={t('import-hardware.actions.rescan')} onClick={findDevice} />}
{!scanning && !errorMsg && (
<Button type="submit" label={t('import-hardware.actions.next')} onClick={onNext} disabled={!ready} />
)}
</footer>
Expand Down
18 changes: 8 additions & 10 deletions packages/neuron-ui/src/components/NetworkSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ReactComponent as DeleteNetwork } from 'widgets/Icons/Delete.svg'
import { ReactComponent as AddSimple } from 'widgets/Icons/AddSimple.svg'
import NetworkEditorDialog from 'components/NetworkEditorDialog'
import { chainState } from 'states'
import { setCurrentNetowrk } from 'services/remote'
import { setCurrentNetwork } from 'services/remote'
import RadioGroup from 'widgets/RadioGroup'
import { useOnHandleNetwork, useOnWindowResize, useToggleChoiceGroupBorder } from 'utils'
import { LIGHT_CLIENT_TESTNET } from 'utils/const'
Expand Down Expand Up @@ -41,7 +41,7 @@ const NetworkSetting = ({ chain = chainState, settings: { networks = [] } }: Sta
const handleChange = useCallback(
checked => {
if (checked !== currentId) {
setCurrentNetowrk(checked)
setCurrentNetwork(checked)
}
},
[currentId]
Expand All @@ -62,14 +62,12 @@ const NetworkSetting = ({ chain = chainState, settings: { networks = [] } }: Sta
),
suffix: (
<div className={styles.suffix}>
{
network.chain === LIGHT_CLIENT_TESTNET ? null : (
<button type="button" aria-label={t('common.edit')} onClick={onHandleNetwork}>
<EditNetwork data-action="edit" data-id={network.id} />
</button>
)
}
{(network.type && network.chain !== LIGHT_CLIENT_TESTNET) ? (
{network.chain === LIGHT_CLIENT_TESTNET ? null : (
<button type="button" aria-label={t('common.edit')} onClick={onHandleNetwork}>
<EditNetwork data-action="edit" data-id={network.id} />
</button>
)}
{network.type && network.chain !== LIGHT_CLIENT_TESTNET ? (
<button type="button" aria-label={t('common.delete')} onClick={onHandleNetwork}>
<DeleteNetwork data-action="delete" data-id={network.id} />
</button>
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/components/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ const Overview = () => {
</div>
<Table
head={
<div className={styles.transactionTablleHead}>
<div className={styles.transactionTableHead}>
<h2 className={styles.recentActivitiesTitle}>{t('overview.recent-activities')}</h2>
{items.length > 10 && (
<Link className={styles.linkToHistory} to={RoutePath.History}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
}
}

.transactionTablleHead {
.transactionTableHead {
display: flex;
padding: 18px 16px;
justify-content: space-between;
Expand Down
6 changes: 3 additions & 3 deletions packages/neuron-ui/src/components/PageContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const PageHeadNotice = ({ notice }: { notice: State.PageNotice }) => {
)
}

const getNetworkTypeLable = (type: 'ckb' | 'ckb_testnet' | 'ckb_dev' | string) => {
const getNetworkTypeLabel = (type: 'ckb' | 'ckb_testnet' | 'ckb_dev' | string) => {
switch (type) {
case 'ckb': {
return 'settings.network.mainnet'
Expand Down Expand Up @@ -75,7 +75,7 @@ const PageContainer: React.FC<ComponentProps> = props => {
})
}, [theme])
const network = useMemo(() => networks.find(n => n.id === networkID), [networks, networkID])
const netWorkTypeLabel = useMemo(() => (network ? getNetworkTypeLable(network.chain) : ''), [network])
const netWorkTypeLabel = useMemo(() => (network ? getNetworkTypeLabel(network.chain) : ''), [network])
const [syncPercents, syncBlockNumbers] = useMemo(() => {
const bestBlockNumber = Math.max(cacheTipBlockNumber, bestKnownBlockNumber)
return [
Expand Down Expand Up @@ -148,7 +148,7 @@ const PageContainer: React.FC<ComponentProps> = props => {
)
}

export const Breadcrumbs: FC<PropsWithChildren<{}>> = ({ children }) => {
export const Breadcrumbs: FC<PropsWithChildren<React.ReactNode>> = ({ children }) => {
const childList = React.Children.toArray(children).filter(child => {
return React.isValidElement(child)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/neuron-ui/src/components/Receive/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useParams } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { useState as useGlobalState } from 'states'
import PageContainer from 'components/PageContainer'
import SignleAddressReceive from './singleAddressReceive'
import SingleAddressReceive from './singleAddressReceive'
import MultiAddressReceive from './multiAddressReceive'

const Receive = () => {
Expand Down Expand Up @@ -37,7 +37,7 @@ const Receive = () => {
notice={pageNotice}
>
{isSingleAddress ? (
<SignleAddressReceive address={accountAddress} wallet={wallet} />
<SingleAddressReceive address={accountAddress} wallet={wallet} />
) : (
<MultiAddressReceive address={accountAddress} addresses={addresses} walletId={walletId} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const MultiAddressReceive = ({
type="button"
className={styles.addressToggle}
onClick={() => setIsInShortFormat(is => !is)}
title={t(isInShortFormat ? `receive.turn-into-full-version-fomrat` : `receive.turn-into-deprecated-format`)}
title={t(isInShortFormat ? `receive.turn-into-full-version-format` : `receive.turn-into-deprecated-format`)}
onFocus={stopPropagation}
onMouseOver={stopPropagation}
onMouseUp={stopPropagation}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ReactComponent as Copy } from 'widgets/Icons/Copy.svg'
import { useCopyAndDownloadQrCode, useSwitchAddress } from './hooks'
import styles from './receive.module.scss'

const SignleAddressReceive = ({ address, wallet }: { address: string; wallet: State.Wallet }) => {
const SingleAddressReceive = ({ address, wallet }: { address: string; wallet: State.Wallet }) => {
const [t] = useTranslation()
const [displayVerifyDialog, setDisplayVerifyDialog] = useState(false)
const onVerifyAddressClick = useCallback(() => {
Expand Down Expand Up @@ -42,7 +42,7 @@ const SignleAddressReceive = ({ address, wallet }: { address: string; wallet: St
type="button"
className={styles.addressToggle}
onClick={() => setIsInShortFormat(is => !is)}
title={t(isInShortFormat ? `receive.turn-into-full-version-fomrat` : `receive.turn-into-deprecated-format`)}
title={t(isInShortFormat ? `receive.turn-into-full-version-format` : `receive.turn-into-deprecated-format`)}
onFocus={stopPropagation}
onMouseOver={stopPropagation}
onMouseUp={stopPropagation}
Expand Down Expand Up @@ -75,6 +75,6 @@ const SignleAddressReceive = ({ address, wallet }: { address: string; wallet: St
)
}

SignleAddressReceive.displayName = 'SignleAddressReceive'
SingleAddressReceive.displayName = 'SingleAddressReceive'

export default SignleAddressReceive
export default SingleAddressReceive
4 changes: 2 additions & 2 deletions packages/neuron-ui/src/components/SUDTMigrateDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const items = [
},
]

const leastSUDTAcccountCapacity = BigInt(MIN_CKB_REQUIRED_BY_NORMAL_SUDT) * BigInt(SHANNON_CKB_RATIO)
const leastSUDTAccountCapacity = BigInt(MIN_CKB_REQUIRED_BY_NORMAL_SUDT) * BigInt(SHANNON_CKB_RATIO)

const SUDTMigrateDialog = ({
cell,
Expand All @@ -27,7 +27,7 @@ const SUDTMigrateDialog = ({
openDialog?: (e: React.SyntheticEvent) => void
}) => {
const [t] = useTranslation()
const isNewSUDTAccountDisabled = useMemo(() => BigInt(cell.capacity) < leastSUDTAcccountCapacity, [cell.capacity])
const isNewSUDTAccountDisabled = useMemo(() => BigInt(cell.capacity) < leastSUDTAccountCapacity, [cell.capacity])
return (
<div className={styles.container}>
<p>{t('migrate-sudt.title')}</p>
Expand Down
Loading

1 comment on commit 94678b0

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packaging for test is done in 5399228647

Please sign in to comment.