2021-02-04 19:15:23 +01:00
|
|
|
import contractMap from '@metamask/contract-metadata';
|
2023-01-05 15:58:16 +01:00
|
|
|
import BigNumber from 'bignumber.js';
|
2020-11-17 18:39:21 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A normalized list of addresses exported as part of the contractMap in
|
2022-01-07 16:57:33 +01:00
|
|
|
* `@metamask/contract-metadata`. Used primarily to validate if manually entered
|
2020-11-17 18:39:21 +01:00
|
|
|
* contract addresses do not match one of our listed tokens
|
|
|
|
*/
|
2022-07-31 20:26:40 +02:00
|
|
|
export const LISTED_CONTRACT_ADDRESSES = Object.keys(contractMap).map(
|
|
|
|
(address) => address.toLowerCase(),
|
|
|
|
);
|
2022-07-01 15:58:35 +02:00
|
|
|
|
|
|
|
/**
|
2022-07-27 15:28:05 +02:00
|
|
|
* @typedef {object} TokenDetails
|
2022-07-01 15:58:35 +02:00
|
|
|
* @property {string} address - The address of the selected 'TOKEN' or
|
2022-11-15 19:49:42 +01:00
|
|
|
* 'NFT' contract.
|
2022-07-01 15:58:35 +02:00
|
|
|
* @property {string} [symbol] - The symbol of the token.
|
|
|
|
* @property {number} [decimals] - The number of decimals of the selected
|
|
|
|
* 'ERC20' asset.
|
2022-11-15 19:49:42 +01:00
|
|
|
* @property {number} [tokenId] - The id of the selected 'NFT' asset.
|
2022-07-01 15:58:35 +02:00
|
|
|
* @property {TokenStandardStrings} [standard] - The standard of the selected
|
|
|
|
* asset.
|
|
|
|
* @property {boolean} [isERC721] - True when the asset is a ERC721 token.
|
|
|
|
*/
|
2022-08-10 03:26:25 +02:00
|
|
|
export const STATIC_MAINNET_TOKEN_LIST = Object.keys(contractMap).reduce(
|
|
|
|
(acc, base) => {
|
|
|
|
const { logo, ...tokenMetadata } = contractMap[base];
|
|
|
|
return {
|
|
|
|
...acc,
|
|
|
|
[base.toLowerCase()]: {
|
|
|
|
...tokenMetadata,
|
|
|
|
address: base.toLowerCase(),
|
|
|
|
iconUrl: `images/contract/${logo}`,
|
|
|
|
aggregators: [],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
);
|
2022-08-23 17:04:07 +02:00
|
|
|
|
|
|
|
export const TOKEN_API_METASWAP_CODEFI_URL =
|
|
|
|
'https://token-api.metaswap.codefi.network/tokens/';
|
2023-01-05 15:58:16 +01:00
|
|
|
export const MAX_TOKEN_ALLOWANCE_AMOUNT = new BigNumber(2)
|
|
|
|
.pow(256)
|
|
|
|
.minus(1)
|
|
|
|
.toString(10);
|
2023-01-18 10:53:10 +01:00
|
|
|
// number with optional decimal point using a comma or dot
|
|
|
|
export const NUM_W_OPT_DECIMAL_COMMA_OR_DOT_REGEX =
|
|
|
|
/^[0-9]{1,}([,.][0-9]{1,})?$/u;
|
2023-01-16 18:41:46 +01:00
|
|
|
export const DECIMAL_REGEX = /\.(\d*)/u;
|