move conversion utils to shared folder (#11451)

feature/default_network_editable
Brad Decker 3 years ago committed by GitHub
parent a835f00ba6
commit da9fb4636b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/scripts/controllers/swaps.js
  2. 0
      shared/modules/conversion.utils.js
  3. 2
      shared/modules/conversion.utils.test.js
  4. 2
      ui/components/app/signature-request-original/signature-request-original.component.js
  5. 2
      ui/components/ui/token-input/token-input.component.js
  6. 2
      ui/ducks/confirm-transaction/confirm-transaction.duck.js
  7. 2
      ui/ducks/send/send.js
  8. 2
      ui/ducks/swaps/swaps.js
  9. 2
      ui/helpers/utils/confirm-tx.util.js
  10. 2
      ui/helpers/utils/conversions.util.js
  11. 5
      ui/helpers/utils/token-util.js
  12. 3
      ui/helpers/utils/transactions.util.js
  13. 2
      ui/hooks/useCancelTransaction.js
  14. 2
      ui/hooks/useCurrencyDisplay.js
  15. 2
      ui/pages/confirm-decrypt-message/confirm-decrypt-message.component.js
  16. 2
      ui/pages/confirm-encryption-public-key/confirm-encryption-public-key.component.js
  17. 2
      ui/pages/confirm-transaction-base/confirm-transaction-base.container.js
  18. 2
      ui/pages/send/send.constants.js
  19. 2
      ui/pages/send/send.utils.js
  20. 4
      ui/pages/send/send.utils.test.js
  21. 2
      ui/pages/swaps/swaps.util.js
  22. 2
      ui/selectors/custom-gas.js

@ -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,

@ -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()', () => {

@ -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';

@ -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';

@ -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

@ -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,

@ -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,

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

@ -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) {

@ -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) => {

@ -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);
/**

@ -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';
/**

@ -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

@ -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 = {

@ -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 = {

@ -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 {

@ -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';

@ -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';

@ -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)) {

@ -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';

@ -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';

Loading…
Cancel
Save