@@ -28,6 +28,7 @@ import {
2828 AccountSelfVotingPowerOverview ,
2929 AccountVotingPowerOverview ,
3030} from 'ts/pages/account/account_voting_power_overview' ;
31+ import { ErrorModal } from 'ts/pages/governance/error_modal' ;
3132import { Dispatcher } from 'ts/redux/dispatcher' ;
3233import { State } from 'ts/redux/reducer' ;
3334import { colors } from 'ts/style/colors' ;
@@ -122,6 +123,7 @@ export const Account: React.FC<AccountProps> = () => {
122123 // NOTE: not yet implemented but left in for future reference
123124 const voteHistory : VoteHistory [ ] = [ ] ;
124125
126+ const [ stakingError , setStakingError ] = React . useState < Error | undefined > ( undefined ) ;
125127 const [ isApplyModalOpen , toggleApplyModal ] = React . useState ( false ) ;
126128 const [ changePoolDetails , setChangePoolDetails ] = React . useState < PoolDetails | undefined > ( undefined ) ;
127129 const [ removeStakePoolDetails , setRemoveStakePoolDetails ] = React . useState < PoolDetails | undefined > ( undefined ) ;
@@ -147,10 +149,15 @@ export const Account: React.FC<AccountProps> = () => {
147149 const [ pendingUnstakePoolSet , setPendingUnstakePoolSet ] = React . useState < Set < string > > ( new Set ( ) ) ;
148150
149151 const apiClient = useAPIClient ( networkId ) ;
150- const { stakingContract, unstake, withdrawStake, withdrawRewards, moveStake, currentEpochRewards } = useStake (
151- networkId ,
152- providerState ,
153- ) ;
152+ const {
153+ stakingContract,
154+ unstake,
155+ withdrawStake,
156+ withdrawRewards,
157+ moveStake,
158+ currentEpochRewards,
159+ error : useStakeError ,
160+ } = useStake ( networkId , providerState ) ;
154161
155162 const hasDataLoaded = ( ) => Boolean ( delegatorData && poolWithStatsMap && availableRewardsMap ) ;
156163 const hasRewards = ( ) => Boolean ( allTimeRewards . isGreaterThan ( 0 ) || expectedCurrentEpochRewards . isGreaterThan ( 0 ) ) ;
@@ -389,6 +396,12 @@ export const Account: React.FC<AccountProps> = () => {
389396 ) ;
390397 } , [ currentEpochStakeMap , nextEpochStakeMap , delegatorData ] ) ;
391398
399+ React . useEffect ( ( ) => {
400+ if ( useStakeError ) {
401+ setStakingError ( useStakeError ) ;
402+ }
403+ } , [ useStakeError ] ) ;
404+
392405 const accountLoaded = account && account . address ;
393406
394407 if ( ! accountLoaded ) {
@@ -424,7 +437,6 @@ export const Account: React.FC<AccountProps> = () => {
424437 }
425438
426439 const nextEpochStart = nextEpochStats && new Date ( nextEpochStats . epochStart . timestamp ) ;
427-
428440 return (
429441 < StakingPageLayout title = "0x Staking | Account" >
430442 < HeaderWrapper >
@@ -770,6 +782,16 @@ export const Account: React.FC<AccountProps> = () => {
770782 } ) ;
771783 } }
772784 />
785+ < ErrorModal
786+ isOpen = { Boolean ( stakingError ) }
787+ text = { 'More ETH is required to complete this transaction. Fund your wallet and try again.' }
788+ heading = { 'Insufficient ETH' }
789+ buttonText = { 'Dismiss' }
790+ onClose = { ( ) => {
791+ setStakingError ( undefined ) ;
792+ } }
793+ />
794+
773795 < DialogOverlay
774796 style = { { background : 'rgba(0, 0, 0, 0.75)' , zIndex : 30 } }
775797 isOpen = { shouldOpenStakeDecisionModal }
0 commit comments