Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding gas estimate in the send page even if enough ETH is not available #18554

Merged
merged 1 commit into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions ui/pages/send/send-content/send-content.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
ETH_GAS_PRICE_FETCH_WARNING_KEY,
GAS_PRICE_FETCH_FAILURE_ERROR_KEY,
GAS_PRICE_EXCESSIVE_ERROR_KEY,
INSUFFICIENT_FUNDS_FOR_GAS_ERROR_KEY,
} from '../../../helpers/constants/error-keys';
import { AssetType } from '../../../../shared/constants/transaction';
import { CONTRACT_ADDRESS_LINK } from '../../../helpers/constants/common';
Expand All @@ -30,7 +29,6 @@ export default class SendContent extends Component {
isEthGasPrice: PropTypes.bool,
noGasPrice: PropTypes.bool,
networkOrAccountNotSupports1559: PropTypes.bool,
getIsBalanceInsufficient: PropTypes.bool,
asset: PropTypes.object,
assetError: PropTypes.string,
recipient: PropTypes.object,
Expand All @@ -46,7 +44,6 @@ export default class SendContent extends Component {
isEthGasPrice,
noGasPrice,
networkOrAccountNotSupports1559,
getIsBalanceInsufficient,
asset,
assetError,
recipient,
Expand All @@ -58,8 +55,6 @@ export default class SendContent extends Component {
gasError = GAS_PRICE_EXCESSIVE_ERROR_KEY;
} else if (noGasPrice) {
gasError = GAS_PRICE_FETCH_FAILURE_ERROR_KEY;
} else if (getIsBalanceInsufficient) {
gasError = INSUFFICIENT_FUNDS_FOR_GAS_ERROR_KEY;
}
const showHexData =
this.props.showHexData &&
Expand Down
36 changes: 0 additions & 36 deletions ui/pages/send/send-content/send-content.component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import configureMockStore from 'redux-mock-store';

import { renderWithProvider } from '../../../../test/lib/render-helpers';
import mockSendState from '../../../../test/data/mock-send-state.json';
import { INSUFFICIENT_FUNDS_ERROR } from '../send.constants';
import SendContent from '.';

jest.mock('../../../store/actions', () => ({
Expand Down Expand Up @@ -148,41 +147,6 @@ describe('SendContent Component', () => {
expect(gasWarning).toBeInTheDocument();
});
});

it('should show gas warning for gas error state in draft transaction', async () => {
const props = {
gasIsExcessive: false,
showHexData: false,
};

const gasErrorState = {
...mockSendState,
send: {
...mockSendState.send,
draftTransactions: {
'1-tx': {
...mockSendState.send.draftTransactions['1-tx'],
gas: {
error: INSUFFICIENT_FUNDS_ERROR,
},
},
},
},
};

const mockStore = configureMockStore()(gasErrorState);

const { queryByTestId } = renderWithProvider(
<SendContent {...props} />,
mockStore,
);

const gasWarning = queryByTestId('gas-warning-message');

await waitFor(() => {
expect(gasWarning).toBeInTheDocument();
});
});
});

describe('Recipient Warning', () => {
Expand Down
7 changes: 5 additions & 2 deletions ui/pages/send/send-footer/send-footer.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from '../../../helpers/constants/routes';
import { MetaMetricsEventCategory } from '../../../../shared/constants/metametrics';
import { SEND_STAGES } from '../../../ducks/send';
import { INSUFFICIENT_FUNDS_ERROR } from '../send.constants';

export default class SendFooter extends Component {
static propTypes = {
Expand Down Expand Up @@ -92,12 +93,14 @@ export default class SendFooter extends Component {

render() {
const { t } = this.context;
const { sendStage } = this.props;
const { sendStage, sendErrors } = this.props;
return (
<PageContainerFooter
onCancel={() => this.onCancel()}
onSubmit={(e) => this.onSubmit(e)}
disabled={this.props.disabled}
disabled={
this.props.disabled && sendErrors.gasFee !== INSUFFICIENT_FUNDS_ERROR
}
cancelText={sendStage === SEND_STAGES.EDIT ? t('reject') : t('cancel')}
/>
);
Expand Down