mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Overriding gas estimate in the send page even if enough ETH is not available (#18554)
This commit is contained in:
parent
e6f73f5fe9
commit
9d3cdd1b79
@ -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';
|
||||
@ -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,
|
||||
@ -46,7 +44,6 @@ export default class SendContent extends Component {
|
||||
isEthGasPrice,
|
||||
noGasPrice,
|
||||
networkOrAccountNotSupports1559,
|
||||
getIsBalanceInsufficient,
|
||||
asset,
|
||||
assetError,
|
||||
recipient,
|
||||
@ -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 &&
|
||||
|
@ -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', () => ({
|
||||
@ -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', () => {
|
||||
|
@ -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 = {
|
||||
@ -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')}
|
||||
/>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user