1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-01 21:57:06 +01:00
metamask-extension/ui/helpers/constants/common.js
Dan J Miller c63714c4f2 Show users a warning when they are sending directly to a token contract (#13588)
* Fix warning dialog when sending tokens to a known token contract address

Fixing after rebase

Covering missed cases

Rebased and ran yarn setup

Rebased

Fix checkContractAddress condition

Lint fix

Applied requested changes

Fix unit tests

Applying requested changes

Applied requested changes

Refactor and update

Lint fix

Use V2 of ActionableMessage component

Adding Learn More Link

Updating warning copy

Addressing review feedback

Fix up copy changes

Simplify validation of pasted addresses

Improve detection of whether this is a token contract

Refactor to leave updateRecipient unchanged, and to prevent the double calling of update recipient

Update tests

fix

* Fix unit tests

* Fix e2e tests

* Ensure next button is disabled while recipient type is loading

* Add optional chaining and a fallback to getRecipientWarningAcknowledgement

* Fix lint

* Don't reset recipient warning on asset change, because we should show recipient warnings regardless of asset

* Update unit tests

* Update unit tests

Co-authored-by: Filip Sekulic <filip.sekulic@consensys.net>
2022-07-13 19:46:30 -02:30

62 lines
1.7 KiB
JavaScript

export const ETH = 'ETH';
export const GWEI = 'GWEI';
export const WEI = 'WEI';
export const PRIMARY = 'PRIMARY';
export const SECONDARY = 'SECONDARY';
export const ERC20 = 'ERC20';
export const ERC721 = 'ERC721';
export const ERC1155 = 'ERC1155';
/**
* @typedef {Object} TokenStandards
* @property {'ERC20'} ERC20 - A token that conforms to the ERC20 standard.
* @property {'ERC721'} ERC721 - A token that conforms to the ERC721 standard.
* @property {'ERC1155'} ERC1155 - A token that conforms to the ERC1155
* standard.
* @property {'NONE'} NONE - Not a token, but rather the base asset of the
* selected chain.
*/
/**
* This type will work anywhere you expect a string that can be one of the
* above statuses
*
* @typedef {TokenStandards[keyof TokenStandards]} TokenStandardStrings
*/
/**
* Describes the standard which a token conforms to.
*
* @type {TokenStandards}
*/
export const TOKEN_STANDARDS = {
ERC20,
ERC721,
ERC1155,
NONE: 'NONE',
};
export const GAS_ESTIMATE_TYPES = {
SLOW: 'SLOW',
AVERAGE: 'AVERAGE',
FAST: 'FAST',
FASTEST: 'FASTEST',
};
let _supportLink = 'https://support.metamask.io';
let _supportRequestLink = 'https://metamask.zendesk.com/hc/en-us/requests/new';
const _contractAddressLink =
'https://metamask.zendesk.com/hc/en-us/articles/360020028092-What-is-the-known-contract-address-warning-';
///: BEGIN:ONLY_INCLUDE_IN(flask)
_supportLink = 'https://metamask-flask.zendesk.com/hc';
_supportRequestLink =
'https://metamask-flask.zendesk.com/hc/en-us/requests/new';
///: END:ONLY_INCLUDE_IN
export const SUPPORT_LINK = _supportLink;
export const SUPPORT_REQUEST_LINK = _supportRequestLink;
export const CONTRACT_ADDRESS_LINK = _contractAddressLink;