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

Migrate codebase to use ESM (#7730)

* Update eslint-plugin-import version

* Convert JS files to use ESM

* Update ESLint rules to check imports

* Fix test:unit:global command env

* Cleanup mock-dev script
This commit is contained in:
Whymarrh Whitby 2020-01-09 00:04:58 -03:30 committed by GitHub
parent 5e461df617
commit 92971d3c87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
375 changed files with 2168 additions and 2596 deletions

View File

@ -46,7 +46,25 @@
"rules": { "rules": {
"default-case": 2, "default-case": 2,
"import/no-unresolved": ["error", { "commonjs": true }], "import/default": 2,
"import/export": 2,
"import/named": 2,
"import/namespace": 2,
"import/newline-after-import": 2,
"import/no-absolute-path": 2,
"import/no-amd": 2,
"import/no-anonymous-default-export": [2, { "allowObject": true }],
"import/no-duplicates": 2,
"import/no-dynamic-require": 2,
"import/no-mutable-exports": 2,
"import/no-named-as-default": 2,
"import/no-named-as-default-member": 2,
"import/no-named-default": 2,
"import/no-self-import": 2,
"import/no-unresolved": [2, { "commonjs": true }],
"import/no-unused-modules": 2,
"import/no-useless-path-segments": [2, { "commonjs": true }],
"import/no-webpack-loader-syntax": 2,
"no-restricted-globals": ["error", "event"], "no-restricted-globals": ["error", "event"],
"accessor-pairs": 2, "accessor-pairs": 2,
"arrow-spacing": [2, { "before": true, "after": true }], "arrow-spacing": [2, { "before": true, "after": true }],

View File

@ -1,6 +1,6 @@
const Wallet = require('ethereumjs-wallet') import Wallet from 'ethereumjs-wallet'
const importers = require('ethereumjs-wallet/thirdparty') import importers from 'ethereumjs-wallet/thirdparty'
const ethUtil = require('ethereumjs-util') import ethUtil from 'ethereumjs-util'
const accountImporter = { const accountImporter = {
@ -53,4 +53,4 @@ function walletToPrivateKey (wallet) {
return ethUtil.bufferToHex(privateKeyBuffer) return ethUtil.bufferToHex(privateKeyBuffer)
} }
module.exports = accountImporter export default accountImporter

View File

@ -4,41 +4,43 @@
// these need to run before anything else // these need to run before anything else
require('./lib/freezeGlobals') import './lib/freezeGlobals'
require('./lib/setupFetchDebugging')() import setupFetchDebugging from './lib/setupFetchDebugging'
setupFetchDebugging()
// polyfills // polyfills
import 'abortcontroller-polyfill/dist/polyfill-patch-fetch' import 'abortcontroller-polyfill/dist/polyfill-patch-fetch'
const endOfStream = require('end-of-stream') import endOfStream from 'end-of-stream'
const pump = require('pump') import pump from 'pump'
const debounce = require('debounce-stream') import debounce from 'debounce-stream'
const log = require('loglevel') import log from 'loglevel'
const extension = require('extensionizer') import extension from 'extensionizer'
const ReadOnlyNetworkStore = require('./lib/network-store') import ReadOnlyNetworkStore from './lib/network-store'
const LocalStore = require('./lib/local-store') import LocalStore from './lib/local-store'
const storeTransform = require('obs-store/lib/transform') import storeTransform from 'obs-store/lib/transform'
const asStream = require('obs-store/lib/asStream') import asStream from 'obs-store/lib/asStream'
const ExtensionPlatform = require('./platforms/extension') import ExtensionPlatform from './platforms/extension'
const Migrator = require('./lib/migrator/') import Migrator from './lib/migrator'
const migrations = require('./migrations/') import migrations from './migrations'
const PortStream = require('extension-port-stream') import PortStream from 'extension-port-stream'
const createStreamSink = require('./lib/createStreamSink') import createStreamSink from './lib/createStreamSink'
const NotificationManager = require('./lib/notification-manager.js') import NotificationManager from './lib/notification-manager.js'
const MetamaskController = require('./metamask-controller') import MetamaskController from './metamask-controller'
const rawFirstTimeState = require('./first-time-state') import rawFirstTimeState from './first-time-state'
const setupSentry = require('./lib/setupSentry') import setupSentry from './lib/setupSentry'
const reportFailedTxToSentry = require('./lib/reportFailedTxToSentry') import reportFailedTxToSentry from './lib/reportFailedTxToSentry'
const setupMetamaskMeshMetrics = require('./lib/setupMetamaskMeshMetrics') import setupMetamaskMeshMetrics from './lib/setupMetamaskMeshMetrics'
const getFirstPreferredLangCode = require('./lib/get-first-preferred-lang-code') import getFirstPreferredLangCode from './lib/get-first-preferred-lang-code'
const getObjStructure = require('./lib/getObjStructure') import getObjStructure from './lib/getObjStructure'
const setupEnsIpfsResolver = require('./lib/ens-ipfs/setup') import setupEnsIpfsResolver from './lib/ens-ipfs/setup'
const { import {
ENVIRONMENT_TYPE_POPUP, ENVIRONMENT_TYPE_POPUP,
ENVIRONMENT_TYPE_NOTIFICATION, ENVIRONMENT_TYPE_NOTIFICATION,
ENVIRONMENT_TYPE_FULLSCREEN, ENVIRONMENT_TYPE_FULLSCREEN,
} = require('./lib/enums') } from './lib/enums'
// METAMASK_TEST_CONFIG is used in e2e tests to set the default network to localhost // METAMASK_TEST_CONFIG is used in e2e tests to set the default network to localhost
const firstTimeState = Object.assign({}, rawFirstTimeState, global.METAMASK_TEST_CONFIG) const firstTimeState = Object.assign({}, rawFirstTimeState, global.METAMASK_TEST_CONFIG)

View File

@ -1,11 +1,13 @@
import pump from 'pump'
import querystring from 'querystring'
import LocalMessageDuplexStream from 'post-message-stream'
import ObjectMultiplex from 'obj-multiplex'
import extension from 'extensionizer'
import PortStream from 'extension-port-stream'
// These require calls need to use require to be statically recognized by browserify
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const pump = require('pump')
const querystring = require('querystring')
const LocalMessageDuplexStream = require('post-message-stream')
const ObjectMultiplex = require('obj-multiplex')
const extension = require('extensionizer')
const PortStream = require('extension-port-stream')
const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'inpage.js')).toString() const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'inpage.js')).toString()
const inpageSuffix = '//# sourceURL=' + extension.runtime.getURL('inpage.js') + '\n' const inpageSuffix = '//# sourceURL=' + extension.runtime.getURL('inpage.js') + '\n'

View File

@ -1,6 +1,6 @@
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const extend = require('xtend') import extend from 'xtend'
const { getRandomArrayItem } = require('../lib/util') import { getRandomArrayItem } from '../lib/util'
/** /**
* a/b test descriptions: * a/b test descriptions:
@ -53,5 +53,5 @@ ABTestController.abTestGroupNames = {
fullScreenVsPopup: ['control', 'fullScreen'], fullScreenVsPopup: ['control', 'fullScreen'],
} }
module.exports = ABTestController export default ABTestController

View File

@ -1,5 +1,5 @@
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const extend = require('xtend') import extend from 'xtend'
class AppStateController { class AppStateController {
/** /**
@ -76,5 +76,5 @@ class AppStateController {
} }
} }
module.exports = AppStateController export default AppStateController

View File

@ -1,6 +1,6 @@
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const PendingBalanceCalculator = require('../lib/pending-balance-calculator') import PendingBalanceCalculator from '../lib/pending-balance-calculator'
const BN = require('ethereumjs-util').BN import { BN } from 'ethereumjs-util'
class BalanceController { class BalanceController {
@ -133,4 +133,4 @@ class BalanceController {
} }
module.exports = BalanceController export default BalanceController

View File

@ -1,5 +1,5 @@
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const extend = require('xtend') import extend from 'xtend'
/** /**
* @typedef {Object} CachedBalancesOptions * @typedef {Object} CachedBalancesOptions
@ -80,4 +80,4 @@ class CachedBalancesController {
} }
} }
module.exports = CachedBalancesController export default CachedBalancesController

View File

@ -1,11 +1,12 @@
const Web3 = require('web3') import Web3 from 'web3'
const contracts = require('eth-contract-metadata') import contracts from 'eth-contract-metadata'
const { warn } = require('loglevel') import { warn } from 'loglevel'
const { MAINNET } = require('./network/enums') import { MAINNET } from './network/enums'
// By default, poll every 3 minutes // By default, poll every 3 minutes
const DEFAULT_INTERVAL = 180 * 1000 const DEFAULT_INTERVAL = 180 * 1000
const ERC20_ABI = [{ 'constant': true, 'inputs': [{ 'name': '_owner', 'type': 'address' }], 'name': 'balanceOf', 'outputs': [{ 'name': 'balance', 'type': 'uint256' }], 'payable': false, 'type': 'function' }] const ERC20_ABI = [{ 'constant': true, 'inputs': [{ 'name': '_owner', 'type': 'address' }], 'name': 'balanceOf', 'outputs': [{ 'name': 'balance', 'type': 'uint256' }], 'payable': false, 'type': 'function' }]
const SINGLE_CALL_BALANCES_ABI = require('single-call-balance-checker-abi') import SINGLE_CALL_BALANCES_ABI from 'single-call-balance-checker-abi'
const SINGLE_CALL_BALANCES_ADDRESS = '0xb1f8e55c7f64d203c1400b9d8555d050f94adf39' const SINGLE_CALL_BALANCES_ADDRESS = '0xb1f8e55c7f64d203c1400b9d8555d050f94adf39'
/** /**
* A controller that polls for token exchange * A controller that polls for token exchange
@ -165,4 +166,4 @@ class DetectTokensController {
} }
} }
module.exports = DetectTokensController export default DetectTokensController

View File

@ -1,5 +1,5 @@
const EthJsEns = require('ethjs-ens') import EthJsEns from 'ethjs-ens'
const ensNetworkMap = require('ethjs-ens/lib/network-map.json') import ensNetworkMap from 'ethjs-ens/lib/network-map.json'
class Ens { class Ens {
static getNetworkEnsSupport (network) { static getNetworkEnsSupport (network) {
@ -22,4 +22,4 @@ class Ens {
} }
} }
module.exports = Ens export default Ens

View File

@ -1,8 +1,8 @@
const ethUtil = require('ethereumjs-util') import ethUtil from 'ethereumjs-util'
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const punycode = require('punycode') import punycode from 'punycode'
const log = require('loglevel') import log from 'loglevel'
const Ens = require('./ens') import Ens from './ens'
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
const ZERO_X_ERROR_ADDRESS = '0x' const ZERO_X_ERROR_ADDRESS = '0x'
@ -91,4 +91,4 @@ class EnsController {
} }
} }
module.exports = EnsController export default EnsController

View File

@ -1,10 +1,11 @@
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const log = require('loglevel') import log from 'loglevel'
const BN = require('bn.js') import BN from 'bn.js'
const createId = require('../lib/random-id') import createId from '../lib/random-id'
const { bnToHex } = require('../lib/util') import { bnToHex } from '../lib/util'
import fetchWithTimeout from '../lib/fetch-with-timeout' import fetchWithTimeout from '../lib/fetch-with-timeout'
const {
import {
MAINNET_CODE, MAINNET_CODE,
ROPSTEN_CODE, ROPSTEN_CODE,
RINKEBY_CODE, RINKEBY_CODE,
@ -15,7 +16,8 @@ const {
KOVAN, KOVAN,
GOERLI, GOERLI,
MAINNET, MAINNET,
} = require('./network/enums') } from './network/enums'
const networkTypeToIdMap = { const networkTypeToIdMap = {
[ROPSTEN]: String(ROPSTEN_CODE), [ROPSTEN]: String(ROPSTEN_CODE),
[RINKEBY]: String(RINKEBY_CODE), [RINKEBY]: String(RINKEBY_CODE),
@ -267,7 +269,7 @@ class IncomingTransactionsController {
} }
} }
module.exports = IncomingTransactionsController export default IncomingTransactionsController
function pairwise (fn) { function pairwise (fn) {
let first = true let first = true

View File

@ -1,6 +1,6 @@
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const extend = require('xtend') import extend from 'xtend'
const log = require('loglevel') import log from 'loglevel'
// every ten minutes // every ten minutes
const POLLING_INTERVAL = 10 * 60 * 1000 const POLLING_INTERVAL = 10 * 60 * 1000
@ -39,4 +39,4 @@ class InfuraController {
} }
} }
module.exports = InfuraController export default InfuraController

View File

@ -1,11 +1,4 @@
const SINGLE_CALL_BALANCES_ADDRESS = '0xb1f8e55c7f64d203c1400b9d8555d050f94adf39' export const SINGLE_CALL_BALANCES_ADDRESS = '0xb1f8e55c7f64d203c1400b9d8555d050f94adf39'
const SINGLE_CALL_BALANCES_ADDRESS_RINKEBY = '0x9f510b19f1ad66f0dcf6e45559fab0d6752c1db7' export const SINGLE_CALL_BALANCES_ADDRESS_RINKEBY = '0x9f510b19f1ad66f0dcf6e45559fab0d6752c1db7'
const SINGLE_CALL_BALANCES_ADDRESS_ROPSTEN = '0xb8e671734ce5c8d7dfbbea5574fa4cf39f7a54a4' export const SINGLE_CALL_BALANCES_ADDRESS_ROPSTEN = '0xb8e671734ce5c8d7dfbbea5574fa4cf39f7a54a4'
const SINGLE_CALL_BALANCES_ADDRESS_KOVAN = '0xb1d3fbb2f83aecd196f474c16ca5d9cffa0d0ffc' export const SINGLE_CALL_BALANCES_ADDRESS_KOVAN = '0xb1d3fbb2f83aecd196f474c16ca5d9cffa0d0ffc'
module.exports = {
SINGLE_CALL_BALANCES_ADDRESS,
SINGLE_CALL_BALANCES_ADDRESS_RINKEBY,
SINGLE_CALL_BALANCES_ADDRESS_ROPSTEN,
SINGLE_CALL_BALANCES_ADDRESS_KOVAN,
}

View File

@ -1,15 +1,15 @@
const mergeMiddleware = require('json-rpc-engine/src/mergeMiddleware') import mergeMiddleware from 'json-rpc-engine/src/mergeMiddleware'
const createScaffoldMiddleware = require('json-rpc-engine/src/createScaffoldMiddleware') import createScaffoldMiddleware from 'json-rpc-engine/src/createScaffoldMiddleware'
const createBlockReRefMiddleware = require('eth-json-rpc-middleware/block-ref') import createBlockReRefMiddleware from 'eth-json-rpc-middleware/block-ref'
const createRetryOnEmptyMiddleware = require('eth-json-rpc-middleware/retryOnEmpty') import createRetryOnEmptyMiddleware from 'eth-json-rpc-middleware/retryOnEmpty'
const createBlockCacheMiddleware = require('eth-json-rpc-middleware/block-cache') import createBlockCacheMiddleware from 'eth-json-rpc-middleware/block-cache'
const createInflightMiddleware = require('eth-json-rpc-middleware/inflight-cache') import createInflightMiddleware from 'eth-json-rpc-middleware/inflight-cache'
const createBlockTrackerInspectorMiddleware = require('eth-json-rpc-middleware/block-tracker-inspector') import createBlockTrackerInspectorMiddleware from 'eth-json-rpc-middleware/block-tracker-inspector'
const providerFromMiddleware = require('eth-json-rpc-middleware/providerFromMiddleware') import providerFromMiddleware from 'eth-json-rpc-middleware/providerFromMiddleware'
const createInfuraMiddleware = require('eth-json-rpc-infura') import createInfuraMiddleware from 'eth-json-rpc-infura'
const BlockTracker = require('eth-block-tracker') import BlockTracker from 'eth-block-tracker'
module.exports = createInfuraClient export default createInfuraClient
function createInfuraClient ({ network, onRequest }) { function createInfuraClient ({ network, onRequest }) {
const infuraMiddleware = mergeMiddleware([ const infuraMiddleware = mergeMiddleware([

View File

@ -1,13 +1,13 @@
const mergeMiddleware = require('json-rpc-engine/src/mergeMiddleware') import mergeMiddleware from 'json-rpc-engine/src/mergeMiddleware'
const createFetchMiddleware = require('eth-json-rpc-middleware/fetch') import createFetchMiddleware from 'eth-json-rpc-middleware/fetch'
const createBlockRefRewriteMiddleware = require('eth-json-rpc-middleware/block-ref-rewrite') import createBlockRefRewriteMiddleware from 'eth-json-rpc-middleware/block-ref-rewrite'
const createBlockCacheMiddleware = require('eth-json-rpc-middleware/block-cache') import createBlockCacheMiddleware from 'eth-json-rpc-middleware/block-cache'
const createInflightMiddleware = require('eth-json-rpc-middleware/inflight-cache') import createInflightMiddleware from 'eth-json-rpc-middleware/inflight-cache'
const createBlockTrackerInspectorMiddleware = require('eth-json-rpc-middleware/block-tracker-inspector') import createBlockTrackerInspectorMiddleware from 'eth-json-rpc-middleware/block-tracker-inspector'
const providerFromMiddleware = require('eth-json-rpc-middleware/providerFromMiddleware') import providerFromMiddleware from 'eth-json-rpc-middleware/providerFromMiddleware'
const BlockTracker = require('eth-block-tracker') import BlockTracker from 'eth-block-tracker'
module.exports = createJsonRpcClient export default createJsonRpcClient
function createJsonRpcClient ({ rpcUrl }) { function createJsonRpcClient ({ rpcUrl }) {
const fetchMiddleware = createFetchMiddleware({ rpcUrl }) const fetchMiddleware = createFetchMiddleware({ rpcUrl })

View File

@ -1,14 +1,14 @@
const mergeMiddleware = require('json-rpc-engine/src/mergeMiddleware') import mergeMiddleware from 'json-rpc-engine/src/mergeMiddleware'
const createFetchMiddleware = require('eth-json-rpc-middleware/fetch') import createFetchMiddleware from 'eth-json-rpc-middleware/fetch'
const createBlockRefRewriteMiddleware = require('eth-json-rpc-middleware/block-ref-rewrite') import createBlockRefRewriteMiddleware from 'eth-json-rpc-middleware/block-ref-rewrite'
const createBlockTrackerInspectorMiddleware = require('eth-json-rpc-middleware/block-tracker-inspector') import createBlockTrackerInspectorMiddleware from 'eth-json-rpc-middleware/block-tracker-inspector'
const createAsyncMiddleware = require('json-rpc-engine/src/createAsyncMiddleware') import createAsyncMiddleware from 'json-rpc-engine/src/createAsyncMiddleware'
const providerFromMiddleware = require('eth-json-rpc-middleware/providerFromMiddleware') import providerFromMiddleware from 'eth-json-rpc-middleware/providerFromMiddleware'
const BlockTracker = require('eth-block-tracker') import BlockTracker from 'eth-block-tracker'
const inTest = process.env.IN_TEST === 'true' const inTest = process.env.IN_TEST === 'true'
module.exports = createLocalhostClient export default createLocalhostClient
function createLocalhostClient () { function createLocalhostClient () {
const fetchMiddleware = createFetchMiddleware({ rpcUrl: 'http://localhost:8545/' }) const fetchMiddleware = createFetchMiddleware({ rpcUrl: 'http://localhost:8545/' })

View File

@ -1,8 +1,9 @@
const mergeMiddleware = require('json-rpc-engine/src/mergeMiddleware') import mergeMiddleware from 'json-rpc-engine/src/mergeMiddleware'
const createScaffoldMiddleware = require('json-rpc-engine/src/createScaffoldMiddleware') import createScaffoldMiddleware from 'json-rpc-engine/src/createScaffoldMiddleware'
const createWalletSubprovider = require('eth-json-rpc-middleware/wallet') import createWalletSubprovider from 'eth-json-rpc-middleware/wallet'
const { createPendingNonceMiddleware, createPendingTxMiddleware } = require('./middleware/pending') import { createPendingNonceMiddleware, createPendingTxMiddleware } from './middleware/pending'
module.exports = createMetamaskMiddleware
export default createMetamaskMiddleware
function createMetamaskMiddleware ({ function createMetamaskMiddleware ({
version, version,

View File

@ -1,37 +1,18 @@
const ROPSTEN = 'ropsten' export const ROPSTEN = 'ropsten'
const RINKEBY = 'rinkeby' export const RINKEBY = 'rinkeby'
const KOVAN = 'kovan' export const KOVAN = 'kovan'
const MAINNET = 'mainnet' export const MAINNET = 'mainnet'
const LOCALHOST = 'localhost' export const LOCALHOST = 'localhost'
const GOERLI = 'goerli' export const GOERLI = 'goerli'
const MAINNET_CODE = 1 export const MAINNET_CODE = 1
const ROPSTEN_CODE = 3 export const ROPSTEN_CODE = 3
const RINKEBY_CODE = 4 export const RINKEBY_CODE = 4
const KOVAN_CODE = 42 export const KOVAN_CODE = 42
const GOERLI_CODE = 5 export const GOERLI_CODE = 5
const ROPSTEN_DISPLAY_NAME = 'Ropsten' export const ROPSTEN_DISPLAY_NAME = 'Ropsten'
const RINKEBY_DISPLAY_NAME = 'Rinkeby' export const RINKEBY_DISPLAY_NAME = 'Rinkeby'
const KOVAN_DISPLAY_NAME = 'Kovan' export const KOVAN_DISPLAY_NAME = 'Kovan'
const MAINNET_DISPLAY_NAME = 'Main Ethereum Network' export const MAINNET_DISPLAY_NAME = 'Main Ethereum Network'
const GOERLI_DISPLAY_NAME = 'Goerli' export const GOERLI_DISPLAY_NAME = 'Goerli'
module.exports = {
ROPSTEN,
RINKEBY,
KOVAN,
MAINNET,
LOCALHOST,
GOERLI,
MAINNET_CODE,
ROPSTEN_CODE,
RINKEBY_CODE,
KOVAN_CODE,
GOERLI_CODE,
ROPSTEN_DISPLAY_NAME,
RINKEBY_DISPLAY_NAME,
KOVAN_DISPLAY_NAME,
MAINNET_DISPLAY_NAME,
GOERLI_DISPLAY_NAME,
}

View File

@ -1,2 +1,3 @@
const NetworkController = require('./network') import NetworkController from './network'
module.exports = NetworkController
export default NetworkController

View File

@ -1,7 +1,7 @@
const { formatTxMetaForRpcResult } = require('../util') import { formatTxMetaForRpcResult } from '../util'
const createAsyncMiddleware = require('json-rpc-engine/src/createAsyncMiddleware') import createAsyncMiddleware from 'json-rpc-engine/src/createAsyncMiddleware'
function createPendingNonceMiddleware ({ getPendingNonce }) { export function createPendingNonceMiddleware ({ getPendingNonce }) {
return createAsyncMiddleware(async (req, res, next) => { return createAsyncMiddleware(async (req, res, next) => {
const { method, params } = req const { method, params } = req
if (method !== 'eth_getTransactionCount') { if (method !== 'eth_getTransactionCount') {
@ -15,7 +15,7 @@ function createPendingNonceMiddleware ({ getPendingNonce }) {
}) })
} }
function createPendingTxMiddleware ({ getPendingTransactionByHash }) { export function createPendingTxMiddleware ({ getPendingTransactionByHash }) {
return createAsyncMiddleware(async (req, res, next) => { return createAsyncMiddleware(async (req, res, next) => {
const { method, params } = req const { method, params } = req
if (method !== 'eth_getTransactionByHash') { if (method !== 'eth_getTransactionByHash') {
@ -29,8 +29,3 @@ function createPendingTxMiddleware ({ getPendingTransactionByHash }) {
res.result = formatTxMetaForRpcResult(txMeta) res.result = formatTxMetaForRpcResult(txMeta)
}) })
} }
module.exports = {
createPendingTxMiddleware,
createPendingNonceMiddleware,
}

View File

@ -1,27 +1,22 @@
const assert = require('assert') import assert from 'assert'
const EventEmitter = require('events') import EventEmitter from 'events'
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const ComposedStore = require('obs-store/lib/composed') import ComposedStore from 'obs-store/lib/composed'
const EthQuery = require('eth-query') import EthQuery from 'eth-query'
const JsonRpcEngine = require('json-rpc-engine') import JsonRpcEngine from 'json-rpc-engine'
const providerFromEngine = require('eth-json-rpc-middleware/providerFromEngine') import providerFromEngine from 'eth-json-rpc-middleware/providerFromEngine'
const log = require('loglevel') import log from 'loglevel'
const createMetamaskMiddleware = require('./createMetamaskMiddleware') import createMetamaskMiddleware from './createMetamaskMiddleware'
const createInfuraClient = require('./createInfuraClient') import createInfuraClient from './createInfuraClient'
const createJsonRpcClient = require('./createJsonRpcClient') import createJsonRpcClient from './createJsonRpcClient'
const createLocalhostClient = require('./createLocalhostClient') import createLocalhostClient from './createLocalhostClient'
const { createSwappableProxy, createEventEmitterProxy } = require('swappable-obj-proxy') import { createSwappableProxy, createEventEmitterProxy } from 'swappable-obj-proxy'
const extend = require('extend') import extend from 'extend'
const networks = { networkList: {} } const networks = { networkList: {} }
const { import { ROPSTEN, RINKEBY, KOVAN, MAINNET, LOCALHOST, GOERLI } from './enums'
ROPSTEN,
RINKEBY,
KOVAN,
MAINNET,
LOCALHOST,
GOERLI,
} = require('./enums')
const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET, GOERLI] const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET, GOERLI]
const env = process.env.METAMASK_ENV const env = process.env.METAMASK_ENV
@ -44,7 +39,7 @@ const defaultNetworkConfig = {
ticker: 'ETH', ticker: 'ETH',
} }
module.exports = class NetworkController extends EventEmitter { export default class NetworkController extends EventEmitter {
constructor (opts = {}) { constructor (opts = {}) {
super() super()

View File

@ -1,4 +1,4 @@
const { import {
ROPSTEN, ROPSTEN,
RINKEBY, RINKEBY,
KOVAN, KOVAN,
@ -13,7 +13,7 @@ const {
KOVAN_DISPLAY_NAME, KOVAN_DISPLAY_NAME,
MAINNET_DISPLAY_NAME, MAINNET_DISPLAY_NAME,
GOERLI_DISPLAY_NAME, GOERLI_DISPLAY_NAME,
} = require('./enums') } from './enums'
const networkToNameMap = { const networkToNameMap = {
[ROPSTEN]: ROPSTEN_DISPLAY_NAME, [ROPSTEN]: ROPSTEN_DISPLAY_NAME,
@ -27,9 +27,9 @@ const networkToNameMap = {
[GOERLI_CODE]: GOERLI_DISPLAY_NAME, [GOERLI_CODE]: GOERLI_DISPLAY_NAME,
} }
const getNetworkDisplayName = key => networkToNameMap[key] export const getNetworkDisplayName = key => networkToNameMap[key]
function formatTxMetaForRpcResult (txMeta) { export function formatTxMetaForRpcResult (txMeta) {
return { return {
'blockHash': txMeta.txReceipt ? txMeta.txReceipt.blockHash : null, 'blockHash': txMeta.txReceipt ? txMeta.txReceipt.blockHash : null,
'blockNumber': txMeta.txReceipt ? txMeta.txReceipt.blockNumber : null, 'blockNumber': txMeta.txReceipt ? txMeta.txReceipt.blockNumber : null,
@ -47,9 +47,3 @@ function formatTxMetaForRpcResult (txMeta) {
's': txMeta.s, 's': txMeta.s,
} }
} }
module.exports = {
getNetworkDisplayName,
formatTxMetaForRpcResult,
}

View File

@ -1,6 +1,6 @@
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const extend = require('xtend') import extend from 'xtend'
const log = require('loglevel') import log from 'loglevel'
/** /**
* @typedef {Object} InitState * @typedef {Object} InitState
@ -74,4 +74,4 @@ class OnboardingController {
} }
} }
module.exports = OnboardingController export default OnboardingController

View File

@ -1,28 +1,28 @@
const JsonRpcEngine = require('json-rpc-engine') import JsonRpcEngine from 'json-rpc-engine'
const asMiddleware = require('json-rpc-engine/src/asMiddleware') import asMiddleware from 'json-rpc-engine/src/asMiddleware'
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const log = require('loglevel') import log from 'loglevel'
const RpcCap = require('rpc-cap').CapabilitiesController import { CapabilitiesController as RpcCap } from 'rpc-cap'
const { ethErrors } = require('eth-json-rpc-errors') import { ethErrors } from 'eth-json-rpc-errors'
import getRestrictedMethods from './restrictedMethods'
const getRestrictedMethods = require('./restrictedMethods') import createMethodMiddleware from './methodMiddleware'
const createMethodMiddleware = require('./methodMiddleware') import createLoggerMiddleware from './loggerMiddleware'
const createLoggerMiddleware = require('./loggerMiddleware')
// Methods that do not require any permissions to use: // Methods that do not require any permissions to use:
const SAFE_METHODS = require('./permissions-safe-methods.json') import SAFE_METHODS from './permissions-safe-methods.json'
// some constants // some constants
const METADATA_STORE_KEY = 'domainMetadata' const METADATA_STORE_KEY = 'domainMetadata'
const LOG_STORE_KEY = 'permissionsLog' const LOG_STORE_KEY = 'permissionsLog'
const HISTORY_STORE_KEY = 'permissionsHistory' const HISTORY_STORE_KEY = 'permissionsHistory'
const WALLET_METHOD_PREFIX = 'wallet_' const WALLET_METHOD_PREFIX = 'wallet_'
const CAVEAT_NAMES = {
exposedAccounts: 'exposedAccounts',
}
const ACCOUNTS_CHANGED_NOTIFICATION = 'wallet_accountsChanged' const ACCOUNTS_CHANGED_NOTIFICATION = 'wallet_accountsChanged'
class PermissionsController { export const CAVEAT_NAMES = {
exposedAccounts: 'exposedAccounts',
}
export class PermissionsController {
constructor ( constructor (
{ {
@ -378,13 +378,6 @@ class PermissionsController {
} }
} }
module.exports = { export function addInternalMethodPrefix (method) {
PermissionsController,
addInternalMethodPrefix: prefix,
CAVEAT_NAMES,
}
function prefix (method) {
return WALLET_METHOD_PREFIX + method return WALLET_METHOD_PREFIX + method
} }

View File

@ -1,6 +1,5 @@
import clone from 'clone'
const clone = require('clone') import { isValidAddress } from 'ethereumjs-util'
const { isValidAddress } = require('ethereumjs-util')
const LOG_LIMIT = 100 const LOG_LIMIT = 100
@ -8,7 +7,7 @@ const LOG_LIMIT = 100
* Create middleware for logging requests and responses to restricted and * Create middleware for logging requests and responses to restricted and
* permissions-related methods. * permissions-related methods.
*/ */
module.exports = function createLoggerMiddleware ({ export default function createLoggerMiddleware ({
walletPrefix, restrictedMethods, store, logStoreKey, historyStoreKey, ignoreMethods, walletPrefix, restrictedMethods, store, logStoreKey, historyStoreKey, ignoreMethods,
}) { }) {
return (req, res, next, _end) => { return (req, res, next, _end) => {

View File

@ -1,11 +1,10 @@
import createAsyncMiddleware from 'json-rpc-engine/src/createAsyncMiddleware'
const createAsyncMiddleware = require('json-rpc-engine/src/createAsyncMiddleware') import { ethErrors } from 'eth-json-rpc-errors'
const { ethErrors } = require('eth-json-rpc-errors')
/** /**
* Create middleware for handling certain methods and preprocessing permissions requests. * Create middleware for handling certain methods and preprocessing permissions requests.
*/ */
module.exports = function createMethodMiddleware ({ export default function createMethodMiddleware ({
store, storeKey, getAccounts, requestAccountsPermission, store, storeKey, getAccounts, requestAccountsPermission,
}) { }) {
return createAsyncMiddleware(async (req, res, next) => { return createAsyncMiddleware(async (req, res, next) => {

View File

@ -1,5 +1,4 @@
export default function getRestrictedMethods (permissionsController) {
module.exports = function getRestrictedMethods (permissionsController) {
return { return {
'eth_accounts': { 'eth_accounts': {

View File

@ -1,8 +1,8 @@
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const { addInternalMethodPrefix } = require('./permissions') import { addInternalMethodPrefix } from './permissions'
const normalizeAddress = require('eth-sig-util').normalize import { normalize as normalizeAddress } from 'eth-sig-util'
const { isValidAddress, sha3, bufferToHex } = require('ethereumjs-util') import { isValidAddress, sha3, bufferToHex } from 'ethereumjs-util'
const extend = require('xtend') import extend from 'xtend'
class PreferencesController { class PreferencesController {
@ -739,4 +739,4 @@ class PreferencesController {
} }
} }
module.exports = PreferencesController export default PreferencesController

View File

@ -1,15 +1,10 @@
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const extend = require('xtend') import extend from 'xtend'
const EthQuery = require('eth-query') import EthQuery from 'eth-query'
const log = require('loglevel') import log from 'loglevel'
const pify = require('pify') import pify from 'pify'
const { import { ROPSTEN, RINKEBY, KOVAN, MAINNET, GOERLI } from './network/enums'
ROPSTEN,
RINKEBY,
KOVAN,
MAINNET,
GOERLI,
} = require('./network/enums')
const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET, GOERLI] const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET, GOERLI]
@ -180,4 +175,4 @@ class RecentBlocksController {
} }
module.exports = RecentBlocksController export default RecentBlocksController

View File

@ -1,14 +1,16 @@
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const Box = process.env.IN_TEST const Box = process.env.IN_TEST
? require('../../../development/mock-3box') ? require('../../../development/mock-3box')
: require('3box') : require('3box')
const log = require('loglevel')
const migrations = require('../migrations/') import log from 'loglevel'
const Migrator = require('../lib/migrator') import migrations from '../migrations'
const JsonRpcEngine = require('json-rpc-engine') import Migrator from '../lib/migrator'
const providerFromEngine = require('eth-json-rpc-middleware/providerFromEngine') import JsonRpcEngine from 'json-rpc-engine'
const createMetamaskMiddleware = require('./network/createMetamaskMiddleware') import providerFromEngine from 'eth-json-rpc-middleware/providerFromEngine'
const createOriginMiddleware = require('../lib/createOriginMiddleware') import createMetamaskMiddleware from './network/createMetamaskMiddleware'
import createOriginMiddleware from '../lib/createOriginMiddleware'
const SYNC_TIMEOUT = 60 * 1000 // one minute const SYNC_TIMEOUT = 60 * 1000 // one minute
@ -243,4 +245,4 @@ class ThreeBoxController {
} }
} }
module.exports = ThreeBoxController export default ThreeBoxController

View File

@ -1,7 +1,7 @@
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const log = require('loglevel') import log from 'loglevel'
const normalizeAddress = require('eth-sig-util').normalize import { normalize as normalizeAddress } from 'eth-sig-util'
const ethUtil = require('ethereumjs-util') import ethUtil from 'ethereumjs-util'
// By default, poll every 3 minutes // By default, poll every 3 minutes
@ -87,4 +87,4 @@ class TokenRatesController {
} }
} }
module.exports = TokenRatesController export default TokenRatesController

View File

@ -5,7 +5,7 @@ const TRANSACTION_TYPE_STANDARD = 'standard'
const TRANSACTION_STATUS_APPROVED = 'approved' const TRANSACTION_STATUS_APPROVED = 'approved'
const TRANSACTION_STATUS_CONFIRMED = 'confirmed' const TRANSACTION_STATUS_CONFIRMED = 'confirmed'
module.exports = { export {
TRANSACTION_TYPE_CANCEL, TRANSACTION_TYPE_CANCEL,
TRANSACTION_TYPE_RETRY, TRANSACTION_TYPE_RETRY,
TRANSACTION_TYPE_STANDARD, TRANSACTION_TYPE_STANDARD,

View File

@ -1,36 +1,40 @@
const EventEmitter = require('safe-event-emitter') import EventEmitter from 'safe-event-emitter'
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const ethUtil = require('ethereumjs-util') import ethUtil from 'ethereumjs-util'
const Transaction = require('ethereumjs-tx') import Transaction from 'ethereumjs-tx'
const EthQuery = require('ethjs-query') import EthQuery from 'ethjs-query'
const { ethErrors } = require('eth-json-rpc-errors') import { ethErrors } from 'eth-json-rpc-errors'
const abi = require('human-standard-token-abi') import abi from 'human-standard-token-abi'
const abiDecoder = require('abi-decoder') import abiDecoder from 'abi-decoder'
abiDecoder.addABI(abi) abiDecoder.addABI(abi)
const {
import {
TOKEN_METHOD_APPROVE, TOKEN_METHOD_APPROVE,
TOKEN_METHOD_TRANSFER, TOKEN_METHOD_TRANSFER,
TOKEN_METHOD_TRANSFER_FROM, TOKEN_METHOD_TRANSFER_FROM,
SEND_ETHER_ACTION_KEY, SEND_ETHER_ACTION_KEY,
DEPLOY_CONTRACT_ACTION_KEY, DEPLOY_CONTRACT_ACTION_KEY,
CONTRACT_INTERACTION_KEY, CONTRACT_INTERACTION_KEY,
} = require('../../../../ui/app/helpers/constants/transactions.js') } from '../../../../ui/app/helpers/constants/transactions.js'
const TransactionStateManager = require('./tx-state-manager')
const TxGasUtil = require('./tx-gas-utils') import TransactionStateManager from './tx-state-manager'
const PendingTransactionTracker = require('./pending-tx-tracker') import TxGasUtil from './tx-gas-utils'
const NonceTracker = require('nonce-tracker') import PendingTransactionTracker from './pending-tx-tracker'
const txUtils = require('./lib/util') import NonceTracker from 'nonce-tracker'
const cleanErrorStack = require('../../lib/cleanErrorStack') import * as txUtils from './lib/util'
const log = require('loglevel') import cleanErrorStack from '../../lib/cleanErrorStack'
const recipientBlacklistChecker = require('./lib/recipient-blacklist-checker') import log from 'loglevel'
const { import recipientBlacklistChecker from './lib/recipient-blacklist-checker'
import {
TRANSACTION_TYPE_CANCEL, TRANSACTION_TYPE_CANCEL,
TRANSACTION_TYPE_RETRY, TRANSACTION_TYPE_RETRY,
TRANSACTION_TYPE_STANDARD, TRANSACTION_TYPE_STANDARD,
TRANSACTION_STATUS_APPROVED, TRANSACTION_STATUS_APPROVED,
} = require('./enums') } from './enums'
const { hexToBn, bnToHex, BnMultiplyByFraction } = require('../../lib/util') import { hexToBn, bnToHex, BnMultiplyByFraction } from '../../lib/util'
/** /**
Transaction Controller is an aggregate of sub-controllers and trackers Transaction Controller is an aggregate of sub-controllers and trackers
@ -752,4 +756,4 @@ class TransactionController extends EventEmitter {
} }
} }
module.exports = TransactionController export default TransactionController

View File

@ -1,7 +1,7 @@
const Config = require('./recipient-blacklist.js') import Config from './recipient-blacklist.js'
/** @module*/ /** @module*/
module.exports = { export default {
checkAccount, checkAccount,
} }

View File

@ -1,4 +1,4 @@
module.exports = { export default {
'blacklist': [ 'blacklist': [
// IDEX phisher // IDEX phisher
'0x9bcb0A9d99d815Bb87ee3191b1399b1Bcc46dc77', '0x9bcb0A9d99d815Bb87ee3191b1399b1Bcc46dc77',

View File

@ -1,7 +1,8 @@
const jsonDiffer = require('fast-json-patch') import jsonDiffer from 'fast-json-patch'
const clone = require('clone') import clone from 'clone'
/** @module*/ /** @module*/
module.exports = { export default {
generateHistoryEntry, generateHistoryEntry,
replayHistory, replayHistory,
snapshotFromTxMeta, snapshotFromTxMeta,

View File

@ -1,18 +1,4 @@
const { import { addHexPrefix, isValidAddress } from 'ethereumjs-util'
addHexPrefix,
isValidAddress,
} = require('ethereumjs-util')
/**
@module
*/
module.exports = {
normalizeTxParams,
validateTxParams,
validateFrom,
validateRecipient,
getFinalStates,
}
// functions that handle normalizing of that key in txParams // functions that handle normalizing of that key in txParams
@ -31,7 +17,7 @@ const normalizers = {
@param txParams {object} @param txParams {object}
@returns {object} normalized txParams @returns {object} normalized txParams
*/ */
function normalizeTxParams (txParams, LowerCase) { export function normalizeTxParams (txParams, LowerCase) {
// apply only keys in the normalizers // apply only keys in the normalizers
const normalizedTxParams = {} const normalizedTxParams = {}
for (const key in normalizers) { for (const key in normalizers) {
@ -46,7 +32,7 @@ function normalizeTxParams (txParams, LowerCase) {
validates txParams validates txParams
@param txParams {object} @param txParams {object}
*/ */
function validateTxParams (txParams) { export function validateTxParams (txParams) {
validateFrom(txParams) validateFrom(txParams)
validateRecipient(txParams) validateRecipient(txParams)
if ('value' in txParams) { if ('value' in txParams) {
@ -65,7 +51,7 @@ function validateTxParams (txParams) {
validates the from field in txParams validates the from field in txParams
@param txParams {object} @param txParams {object}
*/ */
function validateFrom (txParams) { export function validateFrom (txParams) {
if (!(typeof txParams.from === 'string')) { if (!(typeof txParams.from === 'string')) {
throw new Error(`Invalid from address ${txParams.from} not a string`) throw new Error(`Invalid from address ${txParams.from} not a string`)
} }
@ -78,7 +64,7 @@ function validateFrom (txParams) {
validates the to field in txParams validates the to field in txParams
@param txParams {object} @param txParams {object}
*/ */
function validateRecipient (txParams) { export function validateRecipient (txParams) {
if (txParams.to === '0x' || txParams.to === null) { if (txParams.to === '0x' || txParams.to === null) {
if (txParams.data) { if (txParams.data) {
delete txParams.to delete txParams.to
@ -94,7 +80,7 @@ function validateRecipient (txParams) {
/** /**
@returns an {array} of states that can be considered final @returns an {array} of states that can be considered final
*/ */
function getFinalStates () { export function getFinalStates () {
return [ return [
'rejected', // the user has responded no! 'rejected', // the user has responded no!
'confirmed', // the tx has been included in a block. 'confirmed', // the tx has been included in a block.

View File

@ -1,6 +1,6 @@
const EventEmitter = require('safe-event-emitter') import EventEmitter from 'safe-event-emitter'
const log = require('loglevel') import log from 'loglevel'
const EthQuery = require('ethjs-query') import EthQuery from 'ethjs-query'
/** /**
@ -244,4 +244,4 @@ class PendingTransactionTracker extends EventEmitter {
} }
} }
module.exports = PendingTransactionTracker export default PendingTransactionTracker

View File

@ -1,12 +1,9 @@
const EthQuery = require('ethjs-query') import EthQuery from 'ethjs-query'
const { import { hexToBn, BnMultiplyByFraction, bnToHex } from '../../lib/util'
hexToBn, import log from 'loglevel'
BnMultiplyByFraction, import { addHexPrefix } from 'ethereumjs-util'
bnToHex, import { SEND_ETHER_ACTION_KEY } from '../../../../ui/app/helpers/constants/transactions.js'
} = require('../../lib/util')
const log = require('loglevel')
const { addHexPrefix } = require('ethereumjs-util')
const { SEND_ETHER_ACTION_KEY } = require('../../../../ui/app/helpers/constants/transactions.js')
const SIMPLE_GAS_COST = '0x5208' // Hex for 21000, cost of a simple send. const SIMPLE_GAS_COST = '0x5208' // Hex for 21000, cost of a simple send.
import { TRANSACTION_NO_CONTRACT_ERROR_KEY } from '../../../../ui/app/helpers/constants/error-keys' import { TRANSACTION_NO_CONTRACT_ERROR_KEY } from '../../../../ui/app/helpers/constants/error-keys'
@ -154,4 +151,4 @@ class TxGasUtil {
} }
} }
module.exports = TxGasUtil export default TxGasUtil

View File

@ -1,10 +1,10 @@
const extend = require('xtend') import extend from 'xtend'
const EventEmitter = require('safe-event-emitter') import EventEmitter from 'safe-event-emitter'
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const log = require('loglevel') import log from 'loglevel'
const txStateHistoryHelper = require('./lib/tx-state-history-helper') import txStateHistoryHelper from './lib/tx-state-history-helper'
const createId = require('../../lib/random-id') import createId from '../../lib/random-id'
const { getFinalStates, normalizeTxParams } = require('./lib/util') import { getFinalStates, normalizeTxParams } from './lib/util'
/** /**
TransactionStateManager is responsible for the state of a transaction and TransactionStateManager is responsible for the state of a transaction and
storing the transaction storing the transaction
@ -484,4 +484,4 @@ class TransactionStateManager extends EventEmitter {
} }
} }
module.exports = TransactionStateManager export default TransactionStateManager

View File

@ -12,4 +12,4 @@ const initialState = {
config: {}, config: {},
} }
module.exports = initialState export default initialState

View File

@ -32,13 +32,14 @@ const restoreContextAfterImports = () => {
cleanContextForImports() cleanContextForImports()
const log = require('loglevel') import log from 'loglevel'
const LocalMessageDuplexStream = require('post-message-stream') import LocalMessageDuplexStream from 'post-message-stream'
const MetamaskInpageProvider = require('metamask-inpage-provider') import MetamaskInpageProvider from 'metamask-inpage-provider'
// TODO:deprecate:2020-01-13 // TODO:deprecate:2020-01-13
require('web3/dist/web3.min.js') import 'web3/dist/web3.min.js'
const setupDappAutoReload = require('./lib/auto-reload.js')
import setupDappAutoReload from './lib/auto-reload.js'
restoreContextAfterImports() restoreContextAfterImports()

View File

@ -1,4 +1,4 @@
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
/** /**
* An ObservableStore that can composes a flat * An ObservableStore that can composes a flat
@ -48,4 +48,4 @@ class ComposableObservableStore extends ObservableStore {
} }
} }
module.exports = ComposableObservableStore export default ComposableObservableStore

View File

@ -7,16 +7,22 @@
* on each new block. * on each new block.
*/ */
const EthQuery = require('eth-query') import EthQuery from 'eth-query'
const ObservableStore = require('obs-store')
const log = require('loglevel')
const pify = require('pify')
const Web3 = require('web3')
const SINGLE_CALL_BALANCES_ABI = require('single-call-balance-checker-abi')
const { bnToHex } = require('./util') import ObservableStore from 'obs-store'
const { MAINNET_CODE, RINKEBY_CODE, ROPSTEN_CODE, KOVAN_CODE } = require('../controllers/network/enums') import log from 'loglevel'
const { SINGLE_CALL_BALANCES_ADDRESS, SINGLE_CALL_BALANCES_ADDRESS_RINKEBY, SINGLE_CALL_BALANCES_ADDRESS_ROPSTEN, SINGLE_CALL_BALANCES_ADDRESS_KOVAN } = require('../controllers/network/contract-addresses') import pify from 'pify'
import Web3 from 'web3'
import SINGLE_CALL_BALANCES_ABI from 'single-call-balance-checker-abi'
import { bnToHex } from './util'
import { MAINNET_CODE, RINKEBY_CODE, ROPSTEN_CODE, KOVAN_CODE } from '../controllers/network/enums'
import {
SINGLE_CALL_BALANCES_ADDRESS,
SINGLE_CALL_BALANCES_ADDRESS_RINKEBY,
SINGLE_CALL_BALANCES_ADDRESS_ROPSTEN,
SINGLE_CALL_BALANCES_ADDRESS_KOVAN,
} from '../controllers/network/contract-addresses'
class AccountTracker { class AccountTracker {
@ -255,4 +261,4 @@ class AccountTracker {
} }
module.exports = AccountTracker export default AccountTracker

View File

@ -1,7 +1,7 @@
// TODO:deprecate:2020-01-13 // TODO:deprecate:2020-01-13
module.exports = setupDappAutoReload export default setupDappAutoReload
function setupDappAutoReload (web3, observable) { function setupDappAutoReload (web3, observable) {
// export web3 as a global, checking for usage // export web3 as a global, checking for usage

View File

@ -1,9 +1,5 @@
const { import { getMetaMetricState } from '../../../ui/app/selectors/selectors'
getMetaMetricState, import { sendMetaMetricsEvent } from '../../../ui/app/helpers/utils/metametrics.util'
} = require('../../../ui/app/selectors/selectors')
const {
sendMetaMetricsEvent,
} = require('../../../ui/app/helpers/utils/metametrics.util')
const inDevelopment = process.env.NODE_ENV === 'development' const inDevelopment = process.env.NODE_ENV === 'development'
@ -23,4 +19,4 @@ function backEndMetaMetricsEvent (metaMaskState, eventData) {
} }
} }
module.exports = backEndMetaMetricsEvent export default backEndMetaMetricsEvent

View File

@ -1,4 +1,4 @@
module.exports = getBuyEthUrl export default getBuyEthUrl
/** /**
* Gives the caller a url at which the user can acquire eth, depending on the network they are in * Gives the caller a url at which the user can acquire eth, depending on the network they are in

View File

@ -21,4 +21,4 @@ function cleanErrorStack (err) {
return err return err
} }
module.exports = cleanErrorStack export default cleanErrorStack

View File

@ -1,4 +1,4 @@
module.exports = createDnodeRemoteGetter export default createDnodeRemoteGetter
function createDnodeRemoteGetter (dnode) { function createDnodeRemoteGetter (dnode) {
let remote let remote

View File

@ -1,6 +1,6 @@
const log = require('loglevel') import log from 'loglevel'
module.exports = createLoggerMiddleware export default createLoggerMiddleware
/** /**
* Returns a middleware that logs RPC activity * Returns a middleware that logs RPC activity

View File

@ -1,5 +1,5 @@
module.exports = createOriginMiddleware export default createOriginMiddleware
/** /**
* Returns a middleware that appends the DApp origin to request * Returns a middleware that appends the DApp origin to request

View File

@ -1,5 +1,5 @@
const WritableStream = require('readable-stream').Writable import { Writable as WritableStream } from 'readable-stream'
const promiseToCallback = require('promise-to-callback') import promiseToCallback from 'promise-to-callback'
class AsyncWritableStream extends WritableStream { class AsyncWritableStream extends WritableStream {
@ -20,4 +20,4 @@ function createStreamSink (asyncWriteFn, _opts) {
return new AsyncWritableStream(asyncWriteFn, _opts) return new AsyncWritableStream(asyncWriteFn, _opts)
} }
module.exports = createStreamSink export default createStreamSink

View File

@ -1 +1,2 @@
module.exports = [{ 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'resolver', 'outputs': [{ 'name': '', 'type': 'address' }], 'payable': false, 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'owner', 'outputs': [{ 'name': '', 'type': 'address' }], 'payable': false, 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'label', 'type': 'bytes32' }, { 'name': 'owner', 'type': 'address' }], 'name': 'setSubnodeOwner', 'outputs': [], 'payable': false, 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'ttl', 'type': 'uint64' }], 'name': 'setTTL', 'outputs': [], 'payable': false, 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'ttl', 'outputs': [{ 'name': '', 'type': 'uint64' }], 'payable': false, 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'resolver', 'type': 'address' }], 'name': 'setResolver', 'outputs': [], 'payable': false, 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'owner', 'type': 'address' }], 'name': 'setOwner', 'outputs': [], 'payable': false, 'type': 'function' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'owner', 'type': 'address' }], 'name': 'Transfer', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': true, 'name': 'label', 'type': 'bytes32' }, { 'indexed': false, 'name': 'owner', 'type': 'address' }], 'name': 'NewOwner', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'resolver', 'type': 'address' }], 'name': 'NewResolver', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'ttl', 'type': 'uint64' }], 'name': 'NewTTL', 'type': 'event' }] const abi = [{ 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'resolver', 'outputs': [{ 'name': '', 'type': 'address' }], 'payable': false, 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'owner', 'outputs': [{ 'name': '', 'type': 'address' }], 'payable': false, 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'label', 'type': 'bytes32' }, { 'name': 'owner', 'type': 'address' }], 'name': 'setSubnodeOwner', 'outputs': [], 'payable': false, 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'ttl', 'type': 'uint64' }], 'name': 'setTTL', 'outputs': [], 'payable': false, 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'ttl', 'outputs': [{ 'name': '', 'type': 'uint64' }], 'payable': false, 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'resolver', 'type': 'address' }], 'name': 'setResolver', 'outputs': [], 'payable': false, 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'owner', 'type': 'address' }], 'name': 'setOwner', 'outputs': [], 'payable': false, 'type': 'function' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'owner', 'type': 'address' }], 'name': 'Transfer', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': true, 'name': 'label', 'type': 'bytes32' }, { 'indexed': false, 'name': 'owner', 'type': 'address' }], 'name': 'NewOwner', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'resolver', 'type': 'address' }], 'name': 'NewResolver', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'ttl', 'type': 'uint64' }], 'name': 'NewTTL', 'type': 'event' }]
export default abi

View File

@ -1,2 +1,2 @@
module.exports = const abi = [{ 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'hash', 'type': 'bytes32' }], 'name': 'setContent', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'content', 'outputs': [{ 'name': '', 'type': 'bytes32' }], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'interfaceID', 'type': 'bytes4' }], 'name': 'supportsInterface', 'outputs': [{ 'name': '', 'type': 'bool' }], 'payable': false, 'stateMutability': 'pure', 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'key', 'type': 'string' }, { 'name': 'value', 'type': 'string' }], 'name': 'setText', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'contentTypes', 'type': 'uint256' }], 'name': 'ABI', 'outputs': [{ 'name': 'contentType', 'type': 'uint256' }, { 'name': 'data', 'type': 'bytes' }], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'x', 'type': 'bytes32' }, { 'name': 'y', 'type': 'bytes32' }], 'name': 'setPubkey', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'hash', 'type': 'bytes' }], 'name': 'setContenthash', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'addr', 'outputs': [{ 'name': '', 'type': 'address' }], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'key', 'type': 'string' }], 'name': 'text', 'outputs': [{ 'name': '', 'type': 'string' }], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'contentType', 'type': 'uint256' }, { 'name': 'data', 'type': 'bytes' }], 'name': 'setABI', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'name', 'outputs': [{ 'name': '', 'type': 'string' }], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'name', 'type': 'string' }], 'name': 'setName', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'contenthash', 'outputs': [{ 'name': '', 'type': 'bytes' }], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'pubkey', 'outputs': [{ 'name': 'x', 'type': 'bytes32' }, { 'name': 'y', 'type': 'bytes32' }], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'addr', 'type': 'address' }], 'name': 'setAddr', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }, { 'inputs': [{ 'name': 'ensAddr', 'type': 'address' }], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'constructor' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'a', 'type': 'address' }], 'name': 'AddrChanged', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'name', 'type': 'string' }], 'name': 'NameChanged', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': true, 'name': 'contentType', 'type': 'uint256' }], 'name': 'ABIChanged', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'x', 'type': 'bytes32' }, { 'indexed': false, 'name': 'y', 'type': 'bytes32' }], 'name': 'PubkeyChanged', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'indexedKey', 'type': 'string' }, { 'indexed': false, 'name': 'key', 'type': 'string' }], 'name': 'TextChanged', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'hash', 'type': 'bytes' }], 'name': 'ContenthashChanged', 'type': 'event' }]
[{ 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'hash', 'type': 'bytes32' }], 'name': 'setContent', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'content', 'outputs': [{ 'name': '', 'type': 'bytes32' }], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'interfaceID', 'type': 'bytes4' }], 'name': 'supportsInterface', 'outputs': [{ 'name': '', 'type': 'bool' }], 'payable': false, 'stateMutability': 'pure', 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'key', 'type': 'string' }, { 'name': 'value', 'type': 'string' }], 'name': 'setText', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'contentTypes', 'type': 'uint256' }], 'name': 'ABI', 'outputs': [{ 'name': 'contentType', 'type': 'uint256' }, { 'name': 'data', 'type': 'bytes' }], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'x', 'type': 'bytes32' }, { 'name': 'y', 'type': 'bytes32' }], 'name': 'setPubkey', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'hash', 'type': 'bytes' }], 'name': 'setContenthash', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'addr', 'outputs': [{ 'name': '', 'type': 'address' }], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'key', 'type': 'string' }], 'name': 'text', 'outputs': [{ 'name': '', 'type': 'string' }], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'contentType', 'type': 'uint256' }, { 'name': 'data', 'type': 'bytes' }], 'name': 'setABI', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'name', 'outputs': [{ 'name': '', 'type': 'string' }], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'name', 'type': 'string' }], 'name': 'setName', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'contenthash', 'outputs': [{ 'name': '', 'type': 'bytes' }], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'constant': true, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }], 'name': 'pubkey', 'outputs': [{ 'name': 'x', 'type': 'bytes32' }, { 'name': 'y', 'type': 'bytes32' }], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'constant': false, 'inputs': [{ 'name': 'node', 'type': 'bytes32' }, { 'name': 'addr', 'type': 'address' }], 'name': 'setAddr', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }, { 'inputs': [{ 'name': 'ensAddr', 'type': 'address' }], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'constructor' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'a', 'type': 'address' }], 'name': 'AddrChanged', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'name', 'type': 'string' }], 'name': 'NameChanged', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': true, 'name': 'contentType', 'type': 'uint256' }], 'name': 'ABIChanged', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'x', 'type': 'bytes32' }, { 'indexed': false, 'name': 'y', 'type': 'bytes32' }], 'name': 'PubkeyChanged', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'indexedKey', 'type': 'string' }, { 'indexed': false, 'name': 'key', 'type': 'string' }], 'name': 'TextChanged', 'type': 'event' }, { 'anonymous': false, 'inputs': [{ 'indexed': true, 'name': 'node', 'type': 'bytes32' }, { 'indexed': false, 'name': 'hash', 'type': 'bytes' }], 'name': 'ContenthashChanged', 'type': 'event' }] export default abi

View File

@ -1,11 +1,11 @@
const namehash = require('eth-ens-namehash') import namehash from 'eth-ens-namehash'
const Eth = require('ethjs-query') import Eth from 'ethjs-query'
const EthContract = require('ethjs-contract') import EthContract from 'ethjs-contract'
const registryAbi = require('./contracts/registry') import registryAbi from './contracts/registry'
const resolverAbi = require('./contracts/resolver') import resolverAbi from './contracts/resolver'
const contentHash = require('content-hash') import contentHash from 'content-hash'
module.exports = resolveEnsToIpfsContentId export default resolveEnsToIpfsContentId
async function resolveEnsToIpfsContentId ({ provider, name }) { async function resolveEnsToIpfsContentId ({ provider, name }) {

View File

@ -1,10 +1,10 @@
const urlUtil = require('url') import urlUtil from 'url'
const extension = require('extensionizer') import extension from 'extensionizer'
const resolveEnsToIpfsContentId = require('./resolver.js') import resolveEnsToIpfsContentId from './resolver.js'
const supportedTopLevelDomains = ['eth'] const supportedTopLevelDomains = ['eth']
module.exports = setupEnsIpfsResolver export default setupEnsIpfsResolver
function setupEnsIpfsResolver ({ provider, getIpfsGateway }) { function setupEnsIpfsResolver ({ provider, getIpfsGateway }) {

View File

@ -15,7 +15,7 @@ const RINKEBY_CHAIN_ID = '0x4'
const KOVAN_CHAIN_ID = '0x2a' const KOVAN_CHAIN_ID = '0x2a'
const GOERLI_CHAIN_ID = '0x5' const GOERLI_CHAIN_ID = '0x5'
module.exports = { export {
ENVIRONMENT_TYPE_POPUP, ENVIRONMENT_TYPE_POPUP,
ENVIRONMENT_TYPE_NOTIFICATION, ENVIRONMENT_TYPE_NOTIFICATION,
ENVIRONMENT_TYPE_FULLSCREEN, ENVIRONMENT_TYPE_FULLSCREEN,

View File

@ -1,7 +1,7 @@
const ethJsRpcSlug = 'Error: [ethjs-rpc] rpc error with payload ' const ethJsRpcSlug = 'Error: [ethjs-rpc] rpc error with payload '
const errorLabelPrefix = 'Error: ' const errorLabelPrefix = 'Error: '
module.exports = extractEthjsErrorMessage export default extractEthjsErrorMessage
/** /**

View File

@ -2,7 +2,7 @@
/** /**
* Freezes the Promise global and prevents its reassignment. * Freezes the Promise global and prevents its reassignment.
*/ */
const deepFreeze = require('deep-freeze-strict') import deepFreeze from 'deep-freeze-strict'
if ( if (
process.env.IN_TEST !== 'true' && process.env.IN_TEST !== 'true' &&

View File

@ -1,6 +1,6 @@
const extension = require('extensionizer') import extension from 'extensionizer'
const promisify = require('pify') import promisify from 'pify'
const allLocales = require('../../_locales/index.json') import allLocales from '../../_locales/index.json'
const getPreferredLocales = extension.i18n ? promisify( const getPreferredLocales = extension.i18n ? promisify(
extension.i18n.getAcceptLanguages, extension.i18n.getAcceptLanguages,
@ -45,5 +45,5 @@ async function getFirstPreferredLangCode () {
return existingLocaleCodes[firstPreferredLangCode] || 'en' return existingLocaleCodes[firstPreferredLangCode] || 'en'
} }
module.exports = getFirstPreferredLangCode export default getFirstPreferredLangCode

View File

@ -1,6 +1,6 @@
const clone = require('clone') import clone from 'clone'
module.exports = getObjStructure export default getObjStructure
// This will create an object that represents the structure of the given object // This will create an object that represents the structure of the given object
// it replaces all values with the result of their type // it replaces all values with the result of their type

View File

@ -1,11 +1,11 @@
const extension = require('extensionizer') import extension from 'extensionizer'
const log = require('loglevel') import log from 'loglevel'
const { checkForError } = require('./util') import { checkForError } from './util'
/** /**
* A wrapper around the extension's storage local API * A wrapper around the extension's storage local API
*/ */
module.exports = class ExtensionStore { export default class ExtensionStore {
/** /**
* @constructor * @constructor
*/ */

View File

@ -1,8 +1,8 @@
const EventEmitter = require('events') import EventEmitter from 'events'
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const ethUtil = require('ethereumjs-util') import ethUtil from 'ethereumjs-util'
const { ethErrors } = require('eth-json-rpc-errors') import { ethErrors } from 'eth-json-rpc-errors'
const createId = require('./random-id') import createId from './random-id'
/** /**
* Represents, and contains data about, an 'eth_sign' type signature request. These are created when a signature for * Represents, and contains data about, an 'eth_sign' type signature request. These are created when a signature for
@ -22,7 +22,7 @@ const createId = require('./random-id')
* *
*/ */
module.exports = class MessageManager extends EventEmitter { export default class MessageManager extends EventEmitter {
/** /**
* Controller in charge of managing - storing, adding, removing, updating - Messages. * Controller in charge of managing - storing, adding, removing, updating - Messages.

View File

@ -1,4 +1,4 @@
const EventEmitter = require('events') import EventEmitter from 'events'
/** /**
* @typedef {object} Migration * @typedef {object} Migration
@ -91,4 +91,4 @@ class Migrator extends EventEmitter {
} }
module.exports = Migrator export default Migrator

View File

@ -1,4 +1,4 @@
const log = require('loglevel') import log from 'loglevel'
const FIXTURE_SERVER_HOST = 'localhost' const FIXTURE_SERVER_HOST = 'localhost'
const FIXTURE_SERVER_PORT = 12345 const FIXTURE_SERVER_PORT = 12345
@ -59,4 +59,4 @@ class ReadOnlyNetworkStore {
} }
} }
module.exports = ReadOnlyNetworkStore export default ReadOnlyNetworkStore

View File

@ -1,4 +1,5 @@
const promiseToCallback = require('promise-to-callback') import promiseToCallback from 'promise-to-callback'
const callbackNoop = function (err) { const callbackNoop = function (err) {
if (err) { if (err) {
throw err throw err
@ -13,7 +14,7 @@ const callbackNoop = function (err) {
* @param {Object} context The context in which the fn is to be called, most often a this reference * @param {Object} context The context in which the fn is to be called, most often a this reference
* *
*/ */
module.exports = function nodeify (fn, context) { export default function nodeify (fn, context) {
return function () { return function () {
// parse arguments // parse arguments
const args = [].slice.call(arguments) const args = [].slice.call(arguments)

View File

@ -1,4 +1,5 @@
const extension = require('extensionizer') import extension from 'extensionizer'
const NOTIFICATION_HEIGHT = 620 const NOTIFICATION_HEIGHT = 620
const NOTIFICATION_WIDTH = 360 const NOTIFICATION_WIDTH = 360
@ -115,4 +116,4 @@ class NotificationManager {
} }
module.exports = NotificationManager export default NotificationManager

View File

@ -1,5 +1,5 @@
const BN = require('ethereumjs-util').BN import { BN } from 'ethereumjs-util'
const normalize = require('eth-sig-util').normalize import { normalize } from 'eth-sig-util'
class PendingBalanceCalculator { class PendingBalanceCalculator {
@ -78,4 +78,4 @@ class PendingBalanceCalculator {
} }
module.exports = PendingBalanceCalculator export default PendingBalanceCalculator

View File

@ -1,10 +1,11 @@
const EventEmitter = require('events') import EventEmitter from 'events'
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const ethUtil = require('ethereumjs-util') import ethUtil from 'ethereumjs-util'
const { ethErrors } = require('eth-json-rpc-errors') import { ethErrors } from 'eth-json-rpc-errors'
const createId = require('./random-id') import createId from './random-id'
const hexRe = /^[0-9A-Fa-f]+$/g const hexRe = /^[0-9A-Fa-f]+$/g
const log = require('loglevel') import log from 'loglevel'
/** /**
* Represents, and contains data about, an 'personal_sign' type signature request. These are created when a * Represents, and contains data about, an 'personal_sign' type signature request. These are created when a
@ -25,7 +26,7 @@ const log = require('loglevel')
* *
*/ */
module.exports = class PersonalMessageManager extends EventEmitter { export default class PersonalMessageManager extends EventEmitter {
/** /**
* Controller in charge of managing - storing, adding, removing, updating - PersonalMessage. * Controller in charge of managing - storing, adding, removing, updating - PersonalMessage.
* *

View File

@ -6,4 +6,4 @@ function createRandomId () {
return idCounter++ return idCounter++
} }
module.exports = createRandomId export default createRandomId

View File

@ -1,6 +1,6 @@
const extractEthjsErrorMessage = require('./extractEthjsErrorMessage') import extractEthjsErrorMessage from './extractEthjsErrorMessage'
module.exports = reportFailedTxToSentry export default reportFailedTxToSentry
// //
// utility for formatting failed transaction messages // utility for formatting failed transaction messages

View File

@ -1,5 +1,5 @@
const KeyringController = require('eth-keyring-controller') import KeyringController from 'eth-keyring-controller'
const log = require('loglevel') import log from 'loglevel'
const seedPhraseVerifier = { const seedPhraseVerifier = {
@ -54,4 +54,4 @@ const seedPhraseVerifier = {
}, },
} }
module.exports = seedPhraseVerifier export default seedPhraseVerifier

View File

@ -1,10 +1,10 @@
const { import {
MAINNET_CHAIN_ID, MAINNET_CHAIN_ID,
ROPSTEN_CHAIN_ID, ROPSTEN_CHAIN_ID,
RINKEBY_CHAIN_ID, RINKEBY_CHAIN_ID,
KOVAN_CHAIN_ID, KOVAN_CHAIN_ID,
GOERLI_CHAIN_ID, GOERLI_CHAIN_ID,
} = require('./enums') } from './enums'
const standardNetworkId = { const standardNetworkId = {
'1': MAINNET_CHAIN_ID, '1': MAINNET_CHAIN_ID,
@ -19,4 +19,4 @@ function selectChainId (metamaskState) {
return standardNetworkId[network] || `0x${parseInt(chainId, 10).toString(16)}` return standardNetworkId[network] || `0x${parseInt(chainId, 10).toString(16)}`
} }
module.exports = selectChainId export default selectChainId

View File

@ -1,4 +1,4 @@
module.exports = setupFetchDebugging export default setupFetchDebugging
// //
// This is a utility to help resolve cases where `window.fetch` throws a // This is a utility to help resolve cases where `window.fetch` throws a

View File

@ -1,5 +1,5 @@
module.exports = setupMetamaskMeshMetrics export default setupMetamaskMeshMetrics
/** /**
* Injects an iframe into the current document for testing * Injects an iframe into the current document for testing

View File

@ -1,10 +1,12 @@
const Sentry = require('@sentry/browser') import * as Sentry from '@sentry/browser'
const METAMASK_DEBUG = process.env.METAMASK_DEBUG const METAMASK_DEBUG = process.env.METAMASK_DEBUG
const extractEthjsErrorMessage = require('./extractEthjsErrorMessage') import extractEthjsErrorMessage from './extractEthjsErrorMessage'
const SENTRY_DSN_PROD = 'https://3567c198f8a8412082d32655da2961d0@sentry.io/273505' const SENTRY_DSN_PROD = 'https://3567c198f8a8412082d32655da2961d0@sentry.io/273505'
const SENTRY_DSN_DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496' const SENTRY_DSN_DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496'
module.exports = setupSentry export default setupSentry
// Setup sentry remote error reporting // Setup sentry remote error reporting
function setupSentry (opts) { function setupSentry (opts) {

View File

@ -1,16 +1,12 @@
const ObjectMultiplex = require('obj-multiplex') import ObjectMultiplex from 'obj-multiplex'
const pump = require('pump') import pump from 'pump'
module.exports = {
setupMultiplex: setupMultiplex,
}
/** /**
* Sets up stream multiplexing for the given stream * Sets up stream multiplexing for the given stream
* @param {any} connectionStream - the stream to mux * @param {any} connectionStream - the stream to mux
* @return {stream.Stream} the multiplexed stream * @return {stream.Stream} the multiplexed stream
*/ */
function setupMultiplex (connectionStream) { export function setupMultiplex (connectionStream) {
const mux = new ObjectMultiplex() const mux = new ObjectMultiplex()
pump( pump(
connectionStream, connectionStream,

View File

@ -1,11 +1,11 @@
const EventEmitter = require('events') import EventEmitter from 'events'
const ObservableStore = require('obs-store') import ObservableStore from 'obs-store'
const createId = require('./random-id') import createId from './random-id'
const assert = require('assert') import assert from 'assert'
const { ethErrors } = require('eth-json-rpc-errors') import { ethErrors } from 'eth-json-rpc-errors'
const sigUtil = require('eth-sig-util') import sigUtil from 'eth-sig-util'
const log = require('loglevel') import log from 'loglevel'
const jsonschema = require('jsonschema') import jsonschema from 'jsonschema'
/** /**
* Represents, and contains data about, an 'eth_signTypedData' type signature request. These are created when a * Represents, and contains data about, an 'eth_signTypedData' type signature request. These are created when a
@ -25,7 +25,7 @@ const jsonschema = require('jsonschema')
* *
*/ */
module.exports = class TypedMessageManager extends EventEmitter { export default class TypedMessageManager extends EventEmitter {
/** /**
* Controller in charge of managing - storing, adding, removing, updating - TypedMessage. * Controller in charge of managing - storing, adding, removing, updating - TypedMessage.
*/ */

View File

@ -1,8 +1,9 @@
const extension = require('extensionizer') import extension from 'extensionizer'
const ethUtil = require('ethereumjs-util') import ethUtil from 'ethereumjs-util'
const assert = require('assert') import assert from 'assert'
const BN = require('bn.js') import BN from 'bn.js'
const {
import {
ENVIRONMENT_TYPE_POPUP, ENVIRONMENT_TYPE_POPUP,
ENVIRONMENT_TYPE_NOTIFICATION, ENVIRONMENT_TYPE_NOTIFICATION,
ENVIRONMENT_TYPE_FULLSCREEN, ENVIRONMENT_TYPE_FULLSCREEN,
@ -12,7 +13,7 @@ const {
PLATFORM_CHROME, PLATFORM_CHROME,
PLATFORM_EDGE, PLATFORM_EDGE,
PLATFORM_BRAVE, PLATFORM_BRAVE,
} = require('./enums') } from './enums'
/** /**
* Used to determine the window type through which the app is being viewed. * Used to determine the window type through which the app is being viewed.
@ -158,7 +159,7 @@ function checkForError () {
return new Error(lastError.message) return new Error(lastError.message)
} }
module.exports = { export {
removeListeners, removeListeners,
getPlatform, getPlatform,
getEnvironmentType, getEnvironmentType,

View File

@ -4,69 +4,72 @@
* @license MIT * @license MIT
*/ */
const EventEmitter = require('events') import EventEmitter from 'events'
const pump = require('pump')
const Dnode = require('dnode') import pump from 'pump'
const extension = require('extensionizer') import Dnode from 'dnode'
const ObservableStore = require('obs-store') import extension from 'extensionizer'
const ComposableObservableStore = require('./lib/ComposableObservableStore') import ObservableStore from 'obs-store'
const asStream = require('obs-store/lib/asStream') import ComposableObservableStore from './lib/ComposableObservableStore'
const AccountTracker = require('./lib/account-tracker') import asStream from 'obs-store/lib/asStream'
const RpcEngine = require('json-rpc-engine') import AccountTracker from './lib/account-tracker'
const debounce = require('debounce') import RpcEngine from 'json-rpc-engine'
const createEngineStream = require('json-rpc-middleware-stream/engineStream') import debounce from 'debounce'
const createFilterMiddleware = require('eth-json-rpc-filters') import createEngineStream from 'json-rpc-middleware-stream/engineStream'
const createSubscriptionManager = require('eth-json-rpc-filters/subscriptionManager') import createFilterMiddleware from 'eth-json-rpc-filters'
const createLoggerMiddleware = require('./lib/createLoggerMiddleware') import createSubscriptionManager from 'eth-json-rpc-filters/subscriptionManager'
const createOriginMiddleware = require('./lib/createOriginMiddleware') import createLoggerMiddleware from './lib/createLoggerMiddleware'
import createOriginMiddleware from './lib/createOriginMiddleware'
import createOnboardingMiddleware from './lib/createOnboardingMiddleware' import createOnboardingMiddleware from './lib/createOnboardingMiddleware'
const providerAsMiddleware = require('eth-json-rpc-middleware/providerAsMiddleware') import providerAsMiddleware from 'eth-json-rpc-middleware/providerAsMiddleware'
const { setupMultiplex } = require('./lib/stream-utils.js') import { setupMultiplex } from './lib/stream-utils.js'
const KeyringController = require('eth-keyring-controller') import KeyringController from 'eth-keyring-controller'
const EnsController = require('./controllers/ens') import EnsController from './controllers/ens'
const NetworkController = require('./controllers/network') import NetworkController from './controllers/network'
const PreferencesController = require('./controllers/preferences') import PreferencesController from './controllers/preferences'
const AppStateController = require('./controllers/app-state') import AppStateController from './controllers/app-state'
const InfuraController = require('./controllers/infura') import InfuraController from './controllers/infura'
const CachedBalancesController = require('./controllers/cached-balances') import CachedBalancesController from './controllers/cached-balances'
const OnboardingController = require('./controllers/onboarding') import OnboardingController from './controllers/onboarding'
const ThreeBoxController = require('./controllers/threebox') import ThreeBoxController from './controllers/threebox'
const RecentBlocksController = require('./controllers/recent-blocks') import RecentBlocksController from './controllers/recent-blocks'
const IncomingTransactionsController = require('./controllers/incoming-transactions') import IncomingTransactionsController from './controllers/incoming-transactions'
const MessageManager = require('./lib/message-manager') import MessageManager from './lib/message-manager'
const PersonalMessageManager = require('./lib/personal-message-manager') import PersonalMessageManager from './lib/personal-message-manager'
const TypedMessageManager = require('./lib/typed-message-manager') import TypedMessageManager from './lib/typed-message-manager'
const TransactionController = require('./controllers/transactions') import TransactionController from './controllers/transactions'
const TokenRatesController = require('./controllers/token-rates') import TokenRatesController from './controllers/token-rates'
const DetectTokensController = require('./controllers/detect-tokens') import DetectTokensController from './controllers/detect-tokens'
const ABTestController = require('./controllers/ab-test') import ABTestController from './controllers/ab-test'
const { PermissionsController } = require('./controllers/permissions/') import { PermissionsController } from './controllers/permissions'
const nodeify = require('./lib/nodeify') import nodeify from './lib/nodeify'
const accountImporter = require('./account-import-strategies') import accountImporter from './account-import-strategies'
const getBuyEthUrl = require('./lib/buy-eth-url') import getBuyEthUrl from './lib/buy-eth-url'
const selectChainId = require('./lib/select-chain-id') import selectChainId from './lib/select-chain-id'
const { Mutex } = require('await-semaphore') import { Mutex } from 'await-semaphore'
const { version } = require('../manifest.json') import { version } from '../manifest.json'
const { BN } = require('ethereumjs-util') import ethUtil, { BN } from 'ethereumjs-util'
const GWEI_BN = new BN('1000000000') const GWEI_BN = new BN('1000000000')
const percentile = require('percentile') import percentile from 'percentile'
const seedPhraseVerifier = require('./lib/seed-phrase-verifier') import seedPhraseVerifier from './lib/seed-phrase-verifier'
const log = require('loglevel') import log from 'loglevel'
const TrezorKeyring = require('eth-trezor-keyring') import TrezorKeyring from 'eth-trezor-keyring'
const LedgerBridgeKeyring = require('eth-ledger-bridge-keyring') import LedgerBridgeKeyring from 'eth-ledger-bridge-keyring'
const EthQuery = require('eth-query') import EthQuery from 'eth-query'
const ethUtil = require('ethereumjs-util') import nanoid from 'nanoid'
const nanoid = require('nanoid') import contractMap from 'eth-contract-metadata'
const contractMap = require('eth-contract-metadata')
const { import {
AddressBookController, AddressBookController,
CurrencyRateController, CurrencyRateController,
ShapeShiftController, ShapeShiftController,
PhishingController, PhishingController,
} = require('gaba') } from 'gaba'
const backEndMetaMetricsEvent = require('./lib/backend-metametrics')
module.exports = class MetamaskController extends EventEmitter { import backEndMetaMetricsEvent from './lib/backend-metametrics'
export default class MetamaskController extends EventEmitter {
/** /**
* @constructor * @constructor

View File

@ -1,9 +1,9 @@
const version = 2 const version = 2
const clone = require('clone') import clone from 'clone'
module.exports = { export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -2,9 +2,9 @@ const version = 3
const oldTestRpc = 'https://rawtestrpc.metamask.io/' const oldTestRpc = 'https://rawtestrpc.metamask.io/'
const newTestRpc = 'https://testrpc.metamask.io/' const newTestRpc = 'https://testrpc.metamask.io/'
const clone = require('clone') import clone from 'clone'
module.exports = { export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -1,8 +1,8 @@
const version = 4 const version = 4
const clone = require('clone') import clone from 'clone'
module.exports = { export default {
version, version,
migrate: function (versionedData) { migrate: function (versionedData) {

View File

@ -6,11 +6,12 @@ This migration moves state from the flat state trie into KeyringController subst
*/ */
const extend = require('xtend') import extend from 'xtend'
const clone = require('clone')
import clone from 'clone'
module.exports = { export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -6,10 +6,11 @@ This migration moves KeyringController.selectedAddress to PreferencesController.
*/ */
const extend = require('xtend') import extend from 'xtend'
const clone = require('clone')
module.exports = { import clone from 'clone'
export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -6,10 +6,11 @@ This migration breaks out the TransactionManager substate
*/ */
const extend = require('xtend') import extend from 'xtend'
const clone = require('clone')
module.exports = { import clone from 'clone'
export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -6,10 +6,11 @@ This migration breaks out the NoticeController substate
*/ */
const extend = require('xtend') import extend from 'xtend'
const clone = require('clone')
module.exports = { import clone from 'clone'
export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -6,10 +6,11 @@ This migration breaks out the CurrencyController substate
*/ */
const merge = require('deep-extend') import merge from 'deep-extend'
const clone = require('clone')
module.exports = { import clone from 'clone'
export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -6,10 +6,11 @@ This migration breaks out the ShapeShiftController substate
*/ */
const merge = require('deep-extend') import merge from 'deep-extend'
const clone = require('clone')
module.exports = { import clone from 'clone'
export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -6,9 +6,9 @@ This migration removes the discaimer state from our app, which was integrated in
*/ */
const clone = require('clone') import clone from 'clone'
module.exports = { export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -6,9 +6,9 @@ This migration modifies our notices to delete their body after being read.
*/ */
const clone = require('clone') import clone from 'clone'
module.exports = { export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -6,9 +6,9 @@ This migration modifies the network config from ambiguous 'testnet' to explicit
*/ */
const clone = require('clone') import clone from 'clone'
module.exports = { export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -6,9 +6,9 @@ This migration removes provider from config and moves it too NetworkController.
*/ */
const clone = require('clone') import clone from 'clone'
module.exports = { export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -7,9 +7,9 @@ to a 'failed' stated
*/ */
const clone = require('clone') import clone from 'clone'
module.exports = { export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -7,9 +7,9 @@ to a 'failed' stated
*/ */
const clone = require('clone') import clone from 'clone'
module.exports = { export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -6,9 +6,9 @@ This migration sets transactions who were retried and marked as failed to submit
*/ */
const clone = require('clone') import clone from 'clone'
module.exports = { export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -6,11 +6,12 @@ This migration updates "transaction state history" to diffs style
*/ */
const clone = require('clone') import clone from 'clone'
const txStateHistoryHelper = require('../controllers/transactions/lib/tx-state-history-helper')
import txStateHistoryHelper from '../controllers/transactions/lib/tx-state-history-helper'
module.exports = { export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -8,9 +8,9 @@ whos nonce is too high
*/ */
const clone = require('clone') import clone from 'clone'
module.exports = { export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

View File

@ -8,9 +8,9 @@ so that we can version notices in the future.
*/ */
const clone = require('clone') import clone from 'clone'
module.exports = { export default {
version, version,
migrate: function (originalVersionedData) { migrate: function (originalVersionedData) {

Some files were not shown because too many files have changed in this diff Show More