Browse Source

Fix refuse on device to go on step 4

master
Gaëtan Renaudeau 7 years ago
parent
commit
3373ae69e5
  1. 4
      src/components/DeviceConfirm/index.js
  2. 5
      src/components/modals/Send/03-step-verification.js
  3. 16
      src/components/modals/Send/index.js
  4. 3
      src/helpers/createCustomErrorClass.js
  5. 1
      static/i18n/en/errors.yml

4
src/components/DeviceConfirm/index.js

@ -41,7 +41,7 @@ const WrapperIcon = styled(Box)`
} }
` `
const Check = ({ error }: { error: * }) => ( const Check = ({ error }: { error?: boolean }) => (
<WrapperIcon error={error}> <WrapperIcon error={error}>
{error ? <IconCross size={10} /> : <IconCheck size={10} />} {error ? <IconCross size={10} /> : <IconCheck size={10} />}
</WrapperIcon> </WrapperIcon>
@ -74,7 +74,7 @@ const PushButton = styled(Box)`
` `
type Props = { type Props = {
error: *, error?: boolean,
} }
const SVG = ( const SVG = (

5
src/components/modals/Send/03-step-verification.js

@ -27,14 +27,13 @@ const Info = styled(Box).attrs({
` `
type Props = { type Props = {
hasError: boolean,
t: T, t: T,
} }
export default ({ t, hasError }: Props) => ( export default ({ t }: Props) => (
<Container> <Container>
<WarnBox>{multiline(t('app:send.steps.verification.warning'))}</WarnBox> <WarnBox>{multiline(t('app:send.steps.verification.warning'))}</WarnBox>
<Info>{t('app:send.steps.verification.body')}</Info> <Info>{t('app:send.steps.verification.body')}</Info>
<DeviceConfirm error={hasError} /> <DeviceConfirm />
</Container> </Container>
) )

16
src/components/modals/Send/index.js

@ -15,6 +15,7 @@ import { getBridgeForCurrency } from 'bridge'
import { accountsSelector } from 'reducers/accounts' import { accountsSelector } from 'reducers/accounts'
import { updateAccountWithUpdater } from 'actions/accounts' import { updateAccountWithUpdater } from 'actions/accounts'
import createCustomErrorClass from 'helpers/createCustomErrorClass'
import { MODAL_SEND } from 'config/constants' import { MODAL_SEND } from 'config/constants'
import Modal, { ModalBody, ModalContent, ModalTitle } from 'components/base/Modal' import Modal, { ModalBody, ModalContent, ModalTitle } from 'components/base/Modal'
@ -32,6 +33,8 @@ import StepAmount from './01-step-amount'
import StepVerification from './03-step-verification' import StepVerification from './03-step-verification'
import StepConfirmation from './04-step-confirmation' import StepConfirmation from './04-step-confirmation'
export const UserRefusedOnDevice = createCustomErrorClass('UserRefusedOnDevice')
type Props = { type Props = {
updateAccountWithUpdater: (string, (Account) => Account) => void, updateAccountWithUpdater: (string, (Account) => Account) => void,
accounts: Account[], accounts: Account[],
@ -226,14 +229,11 @@ class SendModal extends Component<Props, State<*>> {
}) })
} }
onOperationError = (error: Error) => { onOperationError = (error: *) => {
// $FlowFixMe this.setState({
if (error.statusCode === 0x6985) { error: error.statusCode === 0x6985 ? new UserRefusedOnDevice() : error,
// User denied on device stepIndex: 3,
this.setState({ error }) })
} else {
this.setState({ error, stepIndex: 3 })
}
} }
onChangeAccount = account => { onChangeAccount = account => {

3
src/helpers/createCustomErrorClass.js

@ -1,6 +1,6 @@
// @flow // @flow
export default (name: string) => { export default (name: string): Class<any> => {
const C = function CustomError(message?: string, fields?: Object) { const C = function CustomError(message?: string, fields?: Object) {
this.name = name this.name = name
this.message = message || name this.message = message || name
@ -9,5 +9,6 @@ export default (name: string) => {
} }
// $FlowFixMe // $FlowFixMe
C.prototype = new Error() C.prototype = new Error()
// $FlowFixMe we can't easily type a subset of Error for now...
return C return C
} }

1
static/i18n/en/errors.yml

@ -11,3 +11,4 @@ LedgerAPINotAvailable: 'Ledger API is not available for currency {{currencyName}
LedgerAPIError: 'A problem occurred with Ledger API. Please try again later. (HTTP {{status}})' LedgerAPIError: 'A problem occurred with Ledger API. Please try again later. (HTTP {{status}})'
NetworkDown: 'Your internet connection seems down. Please try again later.' NetworkDown: 'Your internet connection seems down. Please try again later.'
NoAddressesFound: 'No accounts found' NoAddressesFound: 'No accounts found'
UserRefusedOnDevice: Transaction have been aborted

Loading…
Cancel
Save