@@ -10,6 +10,7 @@ import styled from 'styled-components';
1010import { Button } from 'ts/components/button' ;
1111import { CallToAction } from 'ts/components/call_to_action' ;
1212import { ChangePoolDialog } from 'ts/components/staking/change_pool_dialog' ;
13+ import { ErrorModal } from 'ts/pages/governance/error_modal' ;
1314import { StakingPageLayout } from 'ts/components/staking/layout/staking_page_layout' ;
1415import { RemoveStakeDialog } from 'ts/components/staking/remove_stake_dialog' ;
1516import { Heading , Paragraph } from 'ts/components/text' ;
@@ -122,6 +123,8 @@ export const Account: React.FC<AccountProps> = () => {
122123 // NOTE: not yet implemented but left in for future reference
123124 const voteHistory : VoteHistory [ ] = [ ] ;
124125
126+ const [ isErrorModalOpen , setErrorModalOpen ] = React . useState ( false ) ;
127+ const [ stakingError , setStakingError ] = React . useState < Error | undefined > ( undefined ) ;
125128 const [ isApplyModalOpen , toggleApplyModal ] = React . useState ( false ) ;
126129 const [ changePoolDetails , setChangePoolDetails ] = React . useState < PoolDetails | undefined > ( undefined ) ;
127130 const [ removeStakePoolDetails , setRemoveStakePoolDetails ] = React . useState < PoolDetails | undefined > ( undefined ) ;
@@ -147,7 +150,7 @@ export const Account: React.FC<AccountProps> = () => {
147150 const [ pendingUnstakePoolSet , setPendingUnstakePoolSet ] = React . useState < Set < string > > ( new Set ( ) ) ;
148151
149152 const apiClient = useAPIClient ( networkId ) ;
150- const { stakingContract, unstake, withdrawStake, withdrawRewards, moveStake, currentEpochRewards } = useStake (
153+ const { stakingContract, unstake, withdrawStake, withdrawRewards, moveStake, currentEpochRewards, error : useStakeError } = useStake (
151154 networkId ,
152155 providerState ,
153156 ) ;
@@ -389,6 +392,12 @@ export const Account: React.FC<AccountProps> = () => {
389392 ) ;
390393 } , [ currentEpochStakeMap , nextEpochStakeMap , delegatorData ] ) ;
391394
395+ React . useEffect ( ( ) => {
396+ if ( useStakeError ) {
397+ setStakingError ( useStakeError ) ;
398+ }
399+ } , [ useStakeError ] )
400+
392401 const accountLoaded = account && account . address ;
393402
394403 if ( ! accountLoaded ) {
@@ -424,7 +433,6 @@ export const Account: React.FC<AccountProps> = () => {
424433 }
425434
426435 const nextEpochStart = nextEpochStats && new Date ( nextEpochStats . epochStart . timestamp ) ;
427-
428436 return (
429437 < StakingPageLayout title = "0x Staking | Account" >
430438 < HeaderWrapper >
@@ -770,6 +778,10 @@ export const Account: React.FC<AccountProps> = () => {
770778 } ) ;
771779 } }
772780 />
781+ < ErrorModal isOpen = { Boolean ( stakingError ) } text = { 'More ETH is required to complete this transaction. Fund your wallet and try again.' } heading = { 'Insufficient ETH' } buttonText = { 'Dismiss' } onClose = { ( ) => {
782+ setStakingError ( undefined ) ;
783+ } } />
784+
773785 < DialogOverlay
774786 style = { { background : 'rgba(0, 0, 0, 0.75)' , zIndex : 30 } }
775787 isOpen = { shouldOpenStakeDecisionModal }
0 commit comments