mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
e056c88ba7
* integration for tx decoding confirmation and history view * upgrading @truffle/decoder to latest release 5.1.0 * Update acorn and colors patches * feat: remove redundant styling * feat: basic integration for nickname components * feat: wiring functionality of adding new nickname * feat: wire functionality of showing nickname modal * feat: link the nickname popover with add/update popover * feat: moving forward with address nicknames integration * feat: fixing a bug related to passing chainId in addressBook * feat: populating memo prop in addressbook entry * feat: add explorer link * feat: bug fixing update nickname component * feat: fix proptypes * feat: adding tooltip for copying nickname address * featL fix styling for tx-details page * feat: optimize code for error handling * feat: limiting transaction decoding to tx with data * feat: remove tree UI component * feat: adding request to check for tx decoding supported networks * feat: showing data hex component * feat: fix react warnings * feat: remove extra margin in tx decoding * Remove unused package @truffle/source-map-utils * Ensure messages get translated * feat: link tx-decoding addresses with nicknames * Omit value for boolean attributes * Fix props reading in CopyRawData * fix: fixing issue with transaltion * Fix lint errors in TransactionDecoding - Remove unused import - Reorder imports - Address conflict between caught `error` and error state flag by renaming state flag to `hasError` - Fix requestUrl identifier casing and use of template string - Ensure `useEffect` gets passed the deps it needs - Add scope braces around case statement where it's needed - Omit literal `true` for boolean jsx attribute - Refactor nested ternary as `if` statements * fix: revert fetchWithCache modifications * Fix linting for TransactionListItemDetails - Remove unused import - Fix import spacing - Remove unused prop dereference - Fix string interpolation for translated From/To * Moving to popover pattern * fix: sass color variable * Omit value for boolean attribute * Remove changes from modal.js * fix: refactor nickname popovers * Ensure const gets declared before it's used * Fix linting for ConfirmTransactionBase - Remove unused prop chainId - Stop destructuring an unused field * fix: refactor usage of nicknames popovers in send-content-container * fix: remove extra prop updateAccountNicknameModal * fix: refactor code for address.component * fix: remove extra tooltip * Ensure NicknamePopovers always returns component * Fix linting for NicknamePopover component - Fix useCallback deps - Switch ternary to logical-or * Fix linting for SenderToRecipient ... by fixing import order * Remove unused addressCopied state * Delete empty file * fix: remove sender-to-recipient.container * fix: refactor usage of nickname popovers in confirm-page-container * fix: bug related to state variable * Stylelint fix * Lint fix * Change "Total Amount" to "Total" * Lint fix locales * Update address-book.spec.js * e2e test update * Update e2e tests * Fix issue where absence of function params in data hex tab would result in rendering a string * Fix border radius, and width and height in small notification windows, of the update-nickname-popover * Remove fake await * Clean up * Clean up Co-authored-by: Alaa Hadad <alaahd@Alaas-MacBook-M1-Pro-14-inch.local> Co-authored-by: Dan Miller <danjm.com@gmail.com> Co-authored-by: g. nicholas d'andrea <gnidan@trufflesuite.com>
134 lines
3.8 KiB
JavaScript
134 lines
3.8 KiB
JavaScript
import React, { Component } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import PageContainerContent from '../../../components/ui/page-container/page-container-content.component';
|
|
import Dialog from '../../../components/ui/dialog';
|
|
import NicknamePopovers from '../../../components/app/modals/nickname-popovers';
|
|
import {
|
|
ETH_GAS_PRICE_FETCH_WARNING_KEY,
|
|
GAS_PRICE_FETCH_FAILURE_ERROR_KEY,
|
|
GAS_PRICE_EXCESSIVE_ERROR_KEY,
|
|
UNSENDABLE_ASSET_ERROR_KEY,
|
|
INSUFFICIENT_FUNDS_FOR_GAS_ERROR_KEY,
|
|
} from '../../../helpers/constants/error-keys';
|
|
import { ASSET_TYPES } from '../../../ducks/send';
|
|
import SendAmountRow from './send-amount-row';
|
|
import SendHexDataRow from './send-hex-data-row';
|
|
import SendAssetRow from './send-asset-row';
|
|
import SendGasRow from './send-gas-row';
|
|
|
|
export default class SendContent extends Component {
|
|
state = {
|
|
showNicknamePopovers: false,
|
|
};
|
|
|
|
static contextTypes = {
|
|
t: PropTypes.func,
|
|
};
|
|
|
|
static propTypes = {
|
|
isAssetSendable: PropTypes.bool,
|
|
showHexData: PropTypes.bool,
|
|
contact: PropTypes.object,
|
|
isOwnedAccount: PropTypes.bool,
|
|
warning: PropTypes.string,
|
|
error: PropTypes.string,
|
|
gasIsExcessive: PropTypes.bool.isRequired,
|
|
isEthGasPrice: PropTypes.bool,
|
|
noGasPrice: PropTypes.bool,
|
|
networkOrAccountNotSupports1559: PropTypes.bool,
|
|
getIsBalanceInsufficient: PropTypes.bool,
|
|
asset: PropTypes.object,
|
|
to: PropTypes.string,
|
|
};
|
|
|
|
render() {
|
|
const {
|
|
warning,
|
|
error,
|
|
gasIsExcessive,
|
|
isEthGasPrice,
|
|
noGasPrice,
|
|
isAssetSendable,
|
|
networkOrAccountNotSupports1559,
|
|
getIsBalanceInsufficient,
|
|
asset,
|
|
} = this.props;
|
|
|
|
let gasError;
|
|
if (gasIsExcessive) 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 && asset.type !== ASSET_TYPES.TOKEN;
|
|
|
|
return (
|
|
<PageContainerContent>
|
|
<div className="send-v2__form">
|
|
{gasError ? this.renderError(gasError) : null}
|
|
{isEthGasPrice
|
|
? this.renderWarning(ETH_GAS_PRICE_FETCH_WARNING_KEY)
|
|
: null}
|
|
{isAssetSendable === false
|
|
? this.renderError(UNSENDABLE_ASSET_ERROR_KEY)
|
|
: null}
|
|
{error ? this.renderError(error) : null}
|
|
{warning ? this.renderWarning() : null}
|
|
{this.maybeRenderAddContact()}
|
|
<SendAssetRow />
|
|
<SendAmountRow />
|
|
{networkOrAccountNotSupports1559 ? <SendGasRow /> : null}
|
|
{showHexData ? <SendHexDataRow /> : null}
|
|
</div>
|
|
</PageContainerContent>
|
|
);
|
|
}
|
|
|
|
maybeRenderAddContact() {
|
|
const { t } = this.context;
|
|
const { isOwnedAccount, contact = {}, to } = this.props;
|
|
const { showNicknamePopovers } = this.state;
|
|
|
|
if (isOwnedAccount || contact.name) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Dialog
|
|
type="message"
|
|
className="send__dialog"
|
|
onClick={() => this.setState({ showNicknamePopovers: true })}
|
|
>
|
|
{t('newAccountDetectedDialogMessage')}
|
|
</Dialog>
|
|
{showNicknamePopovers ? (
|
|
<NicknamePopovers
|
|
onClose={() => this.setState({ showNicknamePopovers: false })}
|
|
address={to}
|
|
/>
|
|
) : null}
|
|
</>
|
|
);
|
|
}
|
|
|
|
renderWarning(gasWarning = '') {
|
|
const { t } = this.context;
|
|
const { warning } = this.props;
|
|
return (
|
|
<Dialog type="warning" className="send__error-dialog">
|
|
{gasWarning === '' ? t(warning) : t(gasWarning)}
|
|
</Dialog>
|
|
);
|
|
}
|
|
|
|
renderError(error) {
|
|
const { t } = this.context;
|
|
return (
|
|
<Dialog type="error" className="send__error-dialog">
|
|
{t(error)}
|
|
</Dialog>
|
|
);
|
|
}
|
|
}
|