Skip to content

Commit

Permalink
Merge branch 'develop' into fix-288
Browse files Browse the repository at this point in the history
  • Loading branch information
devchenyan committed Jan 24, 2024
2 parents 2068f3d + d3c98b5 commit 4792496
Show file tree
Hide file tree
Showing 111 changed files with 4,132 additions and 992 deletions.
2 changes: 1 addition & 1 deletion .ckb-light-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.3.4
v0.3.5
2 changes: 1 addition & 1 deletion _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ numer = "numer"
lastest = "lastest"

[files]
extend-exclude = ["CHANGELOG.md", "**/migrations/*.ts", "**/fr.{ts,json}"]
extend-exclude = ["CHANGELOG.md", "**/migrations/*.ts", "**/fr.{ts,json}", "**/es.{ts,json}"]
2 changes: 1 addition & 1 deletion packages/neuron-ui/.storybook/electron.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const sendSyncValues = {
'get-locale': ('zh', 'fr'),
'get-locale': ('zh', 'fr', 'es'),
'get-version': '0.103.1',
}

Expand Down
111 changes: 111 additions & 0 deletions packages/neuron-ui/src/components/HardwareSign/HardwareSignOnPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import React from 'react'
import { useTranslation } from 'react-i18next'
import { useState as useGlobalState } from 'states'
import { errorFormatter, useGoBack } from 'utils'
import AlertDialog from 'widgets/AlertDialog'
import Button from 'widgets/Button'
import { Export, Sign } from 'widgets/Icons/icon'
import HDWalletSign from '../HDWalletSign'
import useHardwareSign, { HardwareSignProps } from './hooks'
import styles from './hardwareSign.module.scss'

const HardwareSignOnPage = ({
signType,
signMessage,
wallet,
onDismiss,
offlineSignJSON,
offlineSignType,
walletID,
actionType,
multisigConfig,
onSuccess,
}: HardwareSignProps & State.PasswordRequest) => {
const {
app: {
send: { description, generatedTx },
loadings: { sending: isSending = false },
},
experimental,
} = useGlobalState()
const [t] = useTranslation()
const onGoBack = useGoBack()
const {
offlineSignActionType,
status,
error,
isLoading,
isNotAvailableToSign,
productName,
signAndExportFromGenerateTx,
sign,
reconnect,
exportTransaction,
} = useHardwareSign({
signType,
signMessage,
wallet,
offlineSignJSON,
offlineSignType,
description,
generatedTx,
isSending,
passwordRequest: { walletID, actionType, multisigConfig, onSuccess },
experimental,
})

if (error) {
return <AlertDialog show message={errorFormatter(error, t)} type="failed" onCancel={onDismiss || onGoBack} />
}

return (
<div title={t('hardware-sign.title')} className={styles.hardwareSignInPage}>
<div className={styles.container}>
<p>
{t('hardware-sign.device')}
<span>{productName}</span>
</p>
<p>
{t('hardware-sign.status.label')}
<span className={isNotAvailableToSign ? styles.warning : ''}>{status}</span>
</p>

<div>{wallet.isHD && generatedTx ? <HDWalletSign tx={generatedTx} /> : null}</div>

{offlineSignJSON === undefined && signType === 'transaction' ? (
<div className={styles.footer}>
<Button type="text" onClick={exportTransaction} disabled={isLoading}>
{t('offline-sign.export')} <Export />
</Button>
<div className={styles.divider} />
<Button
type="text"
className={styles.signAndExportFromGenerateTx}
onClick={signAndExportFromGenerateTx}
disabled={isNotAvailableToSign}
loading={!isNotAvailableToSign && isLoading}
>
{t('offline-sign.sign-and-export')} <Sign />
</Button>
</div>
) : null}
</div>
<div className={styles.actions}>
<Button type="cancel" onClick={onDismiss || onGoBack} label={t('common.cancel')} />
{(actionType || offlineSignActionType) !== 'send-from-multisig' ? (
<Button
type="submit"
label={isNotAvailableToSign ? t('hardware-sign.actions.rescan') : t('sign-and-verify.sign')}
loading={isLoading}
disabled={isLoading}
onClick={isNotAvailableToSign ? reconnect : sign}
/>
) : null}
</div>
</div>
)
}

HardwareSignOnPage.displayName = 'HardwareSignOnPage'

export default HardwareSignOnPage
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,15 @@
.warning {
color: var(--error-color);
}

.hardwareSignInPage {
.container {
width: 100%;
}
.actions {
display: flex;
justify-content: center;
gap: 12px;
margin-top: 24px;
}
}
Loading

1 comment on commit 4792496

@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 7634732521

Please sign in to comment.