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

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

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

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

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

3
src/helpers/createCustomErrorClass.js

@ -1,6 +1,6 @@
// @flow
export default (name: string) => {
export default (name: string): Class<any> => {
const C = function CustomError(message?: string, fields?: Object) {
this.name = name
this.message = message || name
@ -9,5 +9,6 @@ export default (name: string) => {
}
// $FlowFixMe
C.prototype = new Error()
// $FlowFixMe we can't easily type a subset of Error for now...
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}})'
NetworkDown: 'Your internet connection seems down. Please try again later.'
NoAddressesFound: 'No accounts found'
UserRefusedOnDevice: Transaction have been aborted

Loading…
Cancel
Save