1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

move conversion utils to shared folder (#11451)

This commit is contained in:
Brad Decker 2021-07-06 12:48:49 -05:00 committed by GitHub
parent a835f00ba6
commit da9fb4636b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 25 additions and 23 deletions

View File

@ -6,7 +6,7 @@ import { mapValues, cloneDeep } from 'lodash';
import abi from 'human-standard-token-abi';
import { calcTokenAmount } from '../../../ui/helpers/utils/token-util';
import { calcGasTotal } from '../../../ui/pages/send/send.utils';
import { conversionUtil } from '../../../ui/helpers/utils/conversion-util';
import { conversionUtil } from '../../../shared/modules/conversion.utils';
import {
DEFAULT_ERC20_APPROVE_GAS,
QUOTES_EXPIRED_ERROR,

View File

@ -1,5 +1,5 @@
import BigNumber from 'bignumber.js';
import { addCurrencies, conversionUtil } from './conversion-util';
import { addCurrencies, conversionUtil } from './conversion.utils';
describe('conversion utils', () => {
describe('addCurrencies()', () => {

View File

@ -11,7 +11,7 @@ import {
import { getEnvironmentType } from '../../../../app/scripts/lib/util';
import Identicon from '../../ui/identicon';
import AccountListItem from '../account-list-item';
import { conversionUtil } from '../../../helpers/utils/conversion-util';
import { conversionUtil } from '../../../../shared/modules/conversion.utils';
import Button from '../../ui/button';
import SiteIcon from '../../ui/site-icon';

View File

@ -6,7 +6,7 @@ import { getWeiHexFromDecimalValue } from '../../../helpers/utils/conversions.ut
import {
conversionUtil,
multiplyCurrencies,
} from '../../../helpers/utils/conversion-util';
} from '../../../../shared/modules/conversion.utils';
import { ETH } from '../../../helpers/constants/common';
import { addHexPrefix } from '../../../../app/scripts/lib/util';

View File

@ -15,7 +15,7 @@ import {
import { getTokenData, sumHexes } from '../../helpers/utils/transactions.util';
import { conversionUtil } from '../../helpers/utils/conversion-util';
import { conversionUtil } from '../../../shared/modules/conversion.utils';
import { getAveragePriceEstimateInHexWEI } from '../../selectors/custom-gas';
// Actions

View File

@ -9,7 +9,7 @@ import {
conversionUtil,
multiplyCurrencies,
subtractCurrencies,
} from '../../helpers/utils/conversion-util';
} from '../../../shared/modules/conversion.utils';
import { GAS_LIMITS } from '../../../shared/constants/gas';
import {
CONTRACT_ADDRESS_ERROR,

View File

@ -45,7 +45,7 @@ import {
decGWEIToHexWEI,
hexWEIToDecGWEI,
} from '../../helpers/utils/conversions.util';
import { conversionLessThan } from '../../helpers/utils/conversion-util';
import { conversionLessThan } from '../../../shared/modules/conversion.utils';
import { calcTokenAmount } from '../../helpers/utils/token-util';
import {
getSelectedAccount,

View File

@ -9,7 +9,7 @@ import {
addCurrencies,
multiplyCurrencies,
conversionGreaterThan,
} from './conversion-util';
} from '../../../shared/modules/conversion.utils';
export function increaseLastGasPrice(lastGasPrice) {
return addHexPrefix(

View File

@ -4,7 +4,7 @@ import {
conversionUtil,
addCurrencies,
subtractCurrencies,
} from './conversion-util';
} from '../../../shared/modules/conversion.utils';
import { formatCurrency } from './confirm-tx.util';
export function bnToHex(inputBn) {

View File

@ -1,8 +1,11 @@
import log from 'loglevel';
import BigNumber from 'bignumber.js';
import contractMap from '@metamask/contract-metadata';
import {
conversionUtil,
multiplyCurrencies,
} from '../../../shared/modules/conversion.utils';
import * as util from './util';
import { conversionUtil, multiplyCurrencies } from './conversion-util';
import { formatCurrency } from './confirm-tx.util';
const casedContractMap = Object.keys(contractMap).reduce((acc, base) => {

View File

@ -9,10 +9,9 @@ import {
TRANSACTION_GROUP_STATUSES,
TRANSACTION_STATUSES,
} from '../../../shared/constants/transaction';
import { addCurrencies } from '../../../shared/modules/conversion.utils';
import fetchWithCache from './fetch-with-cache';
import { addCurrencies } from './conversion-util';
const hstInterface = new ethers.utils.Interface(abi);
/**

View File

@ -14,7 +14,7 @@ import {
setCustomGasLimit,
setCustomGasPriceForRetry,
} from '../ducks/gas/gas.duck';
import { multiplyCurrencies } from '../helpers/utils/conversion-util';
import { multiplyCurrencies } from '../../shared/modules/conversion.utils';
import { GAS_LIMITS } from '../../shared/constants/gas';
/**

View File

@ -10,7 +10,7 @@ import {
getNativeCurrency,
} from '../ducks/metamask/metamask';
import { conversionUtil } from '../helpers/utils/conversion-util';
import { conversionUtil } from '../../shared/modules/conversion.utils';
/**
* Defines the shape of the options parameter for useCurrencyDisplay

View File

@ -12,7 +12,7 @@ import Copy from '../../components/ui/icon/copy-icon.component';
import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../shared/constants/app';
import { SECOND } from '../../../shared/constants/time';
import { getEnvironmentType } from '../../../app/scripts/lib/util';
import { conversionUtil } from '../../helpers/utils/conversion-util';
import { conversionUtil } from '../../../shared/modules/conversion.utils';
export default class ConfirmDecryptMessage extends Component {
static contextTypes = {

View File

@ -7,7 +7,7 @@ import Identicon from '../../components/ui/identicon';
import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../shared/constants/app';
import { getEnvironmentType } from '../../../app/scripts/lib/util';
import { conversionUtil } from '../../helpers/utils/conversion-util';
import { conversionUtil } from '../../../shared/modules/conversion.utils';
export default class ConfirmEncryptionPublicKey extends Component {
static contextTypes = {

View File

@ -21,7 +21,7 @@ import {
} from '../../helpers/constants/error-keys';
import { getHexGasTotal } from '../../helpers/utils/confirm-tx.util';
import { isBalanceSufficient, calcGasTotal } from '../send/send.utils';
import { conversionGreaterThan } from '../../helpers/utils/conversion-util';
import { conversionGreaterThan } from '../../../shared/modules/conversion.utils';
import { MIN_GAS_LIMIT_DEC } from '../send/send.constants';
import { shortenAddress, valuesFor } from '../../helpers/utils/util';
import {

View File

@ -1,7 +1,7 @@
import {
conversionUtil,
multiplyCurrencies,
} from '../../helpers/utils/conversion-util';
} from '../../../shared/modules/conversion.utils';
import { addHexPrefix } from '../../../app/scripts/lib/util';
const MIN_GAS_PRICE_DEC = '0';

View File

@ -6,7 +6,7 @@ import {
multiplyCurrencies,
conversionGreaterThan,
conversionLessThan,
} from '../../helpers/utils/conversion-util';
} from '../../../shared/modules/conversion.utils';
import { calcTokenAmount } from '../../helpers/utils/token-util';
import { addHexPrefix } from '../../../app/scripts/lib/util';

View File

@ -5,7 +5,7 @@ import {
addCurrencies,
conversionGTE,
conversionUtil,
} from '../../helpers/utils/conversion-util';
} from '../../../shared/modules/conversion.utils';
import {
calcGasTotal,
@ -14,7 +14,7 @@ import {
isTokenBalanceSufficient,
} from './send.utils';
jest.mock('../../helpers/utils/conversion-util', () => ({
jest.mock('../../../shared/modules/conversion.utils', () => ({
addCurrencies: jest.fn((a, b) => {
let [a1, b1] = [a, b];
if (String(a).match(/^0x.+/u)) {

View File

@ -30,7 +30,7 @@ import {
getValueFromWeiHex,
} from '../../helpers/utils/conversions.util';
import { subtractCurrencies } from '../../helpers/utils/conversion-util';
import { subtractCurrencies } from '../../../shared/modules/conversion.utils';
import { formatCurrency } from '../../helpers/utils/confirm-tx.util';
import fetchWithCache from '../../helpers/utils/fetch-with-cache';

View File

@ -2,7 +2,7 @@ import { addHexPrefix } from '../../app/scripts/lib/util';
import {
conversionUtil,
conversionGreaterThan,
} from '../helpers/utils/conversion-util';
} from '../../shared/modules/conversion.utils';
import { formatCurrency } from '../helpers/utils/confirm-tx.util';
import { decEthToConvertedCurrency as ethTotalToConvertedCurrency } from '../helpers/utils/conversions.util';
import { formatETHFee } from '../helpers/utils/formatters';