Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit 5de4594

Browse files
authored
Merge pull request #381 from 0xProject/hotfix/not-enough-eth
[Hotfix] Not Enough ETH
2 parents aa3eb5b + 5e7613d commit 5de4594

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

ts/pages/account/dashboard.tsx

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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';
3132
import { Dispatcher } from 'ts/redux/dispatcher';
3233
import { State } from 'ts/redux/reducer';
3334
import { 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}

ts/pages/governance/error_modal.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ErrorModal.defaultProps = {
4646
};
4747

4848
const Wrapper = styled.div<ErrorModalProps>`
49-
position: absolute;
49+
position: fixed;
5050
background-color: rgba(0, 0, 0, 0.75);
5151
display: flex;
5252
top: 0;
@@ -55,6 +55,7 @@ const Wrapper = styled.div<ErrorModalProps>`
5555
bottom: 0;
5656
opacity: 0;
5757
visibility: hidden;
58+
z-index: 30;
5859
5960
${(props) =>
6061
props.isOpen &&
@@ -69,7 +70,6 @@ const Inner = styled.div`
6970
background-color: #f6f6f6;
7071
padding: 30px 30px;
7172
width: 440px;
72-
height: 440px;
7373
text-align: center;
7474
`;
7575

@@ -79,7 +79,6 @@ const ErrorBox = styled.div`
7979
padding: 18px 30px;
8080
margin-bottom: 30px;
8181
overflow: auto;
82-
max-height: 95px;
8382
`;
8483

8584
const Text = styled(Paragraph).attrs({

0 commit comments

Comments
 (0)