|
@ -40,7 +40,6 @@ type State = { |
|
|
isAppOpened: boolean, |
|
|
isAppOpened: boolean, |
|
|
isAddressVerified: ?boolean, |
|
|
isAddressVerified: ?boolean, |
|
|
disabledSteps: number[], |
|
|
disabledSteps: number[], |
|
|
errorSteps: number[], |
|
|
|
|
|
verifyAddressError: ?Error, |
|
|
verifyAddressError: ?Error, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -76,15 +75,16 @@ const createSteps = ({ t }: { t: T }) => [ |
|
|
{ |
|
|
{ |
|
|
id: 'confirm', |
|
|
id: 'confirm', |
|
|
label: t('app:receive.steps.confirmAddress.title'), |
|
|
label: t('app:receive.steps.confirmAddress.title'), |
|
|
component: StepConfirmAddress, |
|
|
|
|
|
footer: StepConfirmAddressFooter, |
|
|
footer: StepConfirmAddressFooter, |
|
|
|
|
|
component: StepConfirmAddress, |
|
|
|
|
|
onBack: ({ transitionTo }: StepProps) => transitionTo('device'), |
|
|
shouldRenderFooter: ({ isAddressVerified }: StepProps) => isAddressVerified === false, |
|
|
shouldRenderFooter: ({ isAddressVerified }: StepProps) => isAddressVerified === false, |
|
|
shouldPreventClose: ({ isAddressVerified }: StepProps) => isAddressVerified === null, |
|
|
|
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
id: 'receive', |
|
|
id: 'receive', |
|
|
label: t('app:receive.steps.receiveFunds.title'), |
|
|
label: t('app:receive.steps.receiveFunds.title'), |
|
|
component: StepReceiveFunds, |
|
|
component: StepReceiveFunds, |
|
|
|
|
|
shouldPreventClose: ({ isAddressVerified }: StepProps) => isAddressVerified === null, |
|
|
}, |
|
|
}, |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
@ -103,7 +103,6 @@ const INITIAL_STATE = { |
|
|
isAppOpened: false, |
|
|
isAppOpened: false, |
|
|
isAddressVerified: null, |
|
|
isAddressVerified: null, |
|
|
disabledSteps: [], |
|
|
disabledSteps: [], |
|
|
errorSteps: [], |
|
|
|
|
|
verifyAddressError: null, |
|
|
verifyAddressError: null, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -124,35 +123,38 @@ class ReceiveModal extends PureComponent<Props, State> { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
handleRetry = () => this.setState({ isAddressVerified: null, isAppOpened: false, errorSteps: [] }) |
|
|
handleRetry = () => |
|
|
|
|
|
this.setState({ |
|
|
|
|
|
verifyAddressError: null, |
|
|
|
|
|
isAddressVerified: null, |
|
|
|
|
|
isAppOpened: false, |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
handleReset = () => this.setState({ ...INITIAL_STATE }) |
|
|
handleReset = () => this.setState({ ...INITIAL_STATE }) |
|
|
|
|
|
|
|
|
handleCloseModal = () => this.props.closeModal(MODAL_RECEIVE) |
|
|
handleCloseModal = () => this.props.closeModal(MODAL_RECEIVE) |
|
|
|
|
|
|
|
|
handleStepChange = step => this.setState({ stepId: step.id }) |
|
|
handleStepChange = step => this.setState({ stepId: step.id }) |
|
|
|
|
|
|
|
|
handleChangeAccount = (account: ?Account) => this.setState({ account }) |
|
|
handleChangeAccount = (account: ?Account) => this.setState({ account }) |
|
|
|
|
|
|
|
|
handleChangeAppOpened = (isAppOpened: boolean) => this.setState({ isAppOpened }) |
|
|
handleChangeAppOpened = (isAppOpened: boolean) => this.setState({ isAppOpened }) |
|
|
|
|
|
|
|
|
handleChangeAddressVerified = (isAddressVerified: boolean, err: ?Error) => { |
|
|
handleChangeAddressVerified = (isAddressVerified: boolean, err: ?Error) => { |
|
|
if (isAddressVerified) { |
|
|
|
|
|
this.setState({ isAddressVerified, verifyAddressError: err }) |
|
|
this.setState({ isAddressVerified, verifyAddressError: err }) |
|
|
} else if (isAddressVerified === null) { |
|
|
|
|
|
this.setState({ isAddressVerified: null, errorSteps: [], verifyAddressError: err }) |
|
|
|
|
|
} else { |
|
|
|
|
|
const confirmStepIndex = this.STEPS.findIndex(step => step.id === 'confirm') |
|
|
|
|
|
if (confirmStepIndex > -1) { |
|
|
|
|
|
this.setState({ |
|
|
|
|
|
isAddressVerified, |
|
|
|
|
|
verifyAddressError: err, |
|
|
|
|
|
errorSteps: [confirmStepIndex], |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
handleResetSkip = () => this.setState({ disabledSteps: [] }) |
|
|
handleResetSkip = () => this.setState({ disabledSteps: [] }) |
|
|
|
|
|
|
|
|
handleSkipConfirm = () => { |
|
|
handleSkipConfirm = () => { |
|
|
const connectStepIndex = this.STEPS.findIndex(step => step.id === 'device') |
|
|
const connectStepIndex = this.STEPS.findIndex(step => step.id === 'device') |
|
|
const confirmStepIndex = this.STEPS.findIndex(step => step.id === 'confirm') |
|
|
const confirmStepIndex = this.STEPS.findIndex(step => step.id === 'confirm') |
|
|
if (confirmStepIndex > -1 && connectStepIndex > -1) { |
|
|
if (confirmStepIndex > -1 && connectStepIndex > -1) { |
|
|
this.setState({ disabledSteps: [connectStepIndex, confirmStepIndex] }) |
|
|
this.setState({ |
|
|
|
|
|
isAddressVerified: false, |
|
|
|
|
|
verifyAddressError: null, |
|
|
|
|
|
disabledSteps: [connectStepIndex, confirmStepIndex], |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -164,7 +166,6 @@ class ReceiveModal extends PureComponent<Props, State> { |
|
|
isAppOpened, |
|
|
isAppOpened, |
|
|
isAddressVerified, |
|
|
isAddressVerified, |
|
|
disabledSteps, |
|
|
disabledSteps, |
|
|
errorSteps, |
|
|
|
|
|
verifyAddressError, |
|
|
verifyAddressError, |
|
|
} = this.state |
|
|
} = this.state |
|
|
|
|
|
|
|
@ -183,6 +184,10 @@ class ReceiveModal extends PureComponent<Props, State> { |
|
|
onChangeAddressVerified: this.handleChangeAddressVerified, |
|
|
onChangeAddressVerified: this.handleChangeAddressVerified, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const errorSteps = verifyAddressError |
|
|
|
|
|
? [verifyAddressError.name === 'UserRefusedAddress' ? 2 : 3] |
|
|
|
|
|
: [] |
|
|
|
|
|
|
|
|
const isModalLocked = stepId === 'confirm' && isAddressVerified === null |
|
|
const isModalLocked = stepId === 'confirm' && isAddressVerified === null |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|