1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +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": {
"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"],
"accessor-pairs": 2,
"arrow-spacing": [2, { "before": true, "after": true }],

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
const ObservableStore = require('obs-store')
const extend = require('xtend')
import ObservableStore from 'obs-store'
import extend from 'xtend'
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')
const PendingBalanceCalculator = require('../lib/pending-balance-calculator')
const BN = require('ethereumjs-util').BN
import ObservableStore from 'obs-store'
import PendingBalanceCalculator from '../lib/pending-balance-calculator'
import { BN } from 'ethereumjs-util'
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')
const extend = require('xtend')
import ObservableStore from 'obs-store'
import extend from 'xtend'
/**
* @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')
const contracts = require('eth-contract-metadata')
const { warn } = require('loglevel')
const { MAINNET } = require('./network/enums')
import Web3 from 'web3'
import contracts from 'eth-contract-metadata'
import { warn } from 'loglevel'
import { MAINNET } from './network/enums'
// By default, poll every 3 minutes
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 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'
/**
* 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')
const ensNetworkMap = require('ethjs-ens/lib/network-map.json')
import EthJsEns from 'ethjs-ens'
import ensNetworkMap from 'ethjs-ens/lib/network-map.json'
class Ens {
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')
const ObservableStore = require('obs-store')
const punycode = require('punycode')
const log = require('loglevel')
const Ens = require('./ens')
import ethUtil from 'ethereumjs-util'
import ObservableStore from 'obs-store'
import punycode from 'punycode'
import log from 'loglevel'
import Ens from './ens'
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
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')
const log = require('loglevel')
const BN = require('bn.js')
const createId = require('../lib/random-id')
const { bnToHex } = require('../lib/util')
import ObservableStore from 'obs-store'
import log from 'loglevel'
import BN from 'bn.js'
import createId from '../lib/random-id'
import { bnToHex } from '../lib/util'
import fetchWithTimeout from '../lib/fetch-with-timeout'
const {
import {
MAINNET_CODE,
ROPSTEN_CODE,
RINKEBY_CODE,
@ -15,7 +16,8 @@ const {
KOVAN,
GOERLI,
MAINNET,
} = require('./network/enums')
} from './network/enums'
const networkTypeToIdMap = {
[ROPSTEN]: String(ROPSTEN_CODE),
[RINKEBY]: String(RINKEBY_CODE),
@ -267,7 +269,7 @@ class IncomingTransactionsController {
}
}
module.exports = IncomingTransactionsController
export default IncomingTransactionsController
function pairwise (fn) {
let first = true

View File

@ -1,6 +1,6 @@
const ObservableStore = require('obs-store')
const extend = require('xtend')
const log = require('loglevel')
import ObservableStore from 'obs-store'
import extend from 'xtend'
import log from 'loglevel'
// every ten minutes
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'
const SINGLE_CALL_BALANCES_ADDRESS_RINKEBY = '0x9f510b19f1ad66f0dcf6e45559fab0d6752c1db7'
const SINGLE_CALL_BALANCES_ADDRESS_ROPSTEN = '0xb8e671734ce5c8d7dfbbea5574fa4cf39f7a54a4'
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,
}
export const SINGLE_CALL_BALANCES_ADDRESS = '0xb1f8e55c7f64d203c1400b9d8555d050f94adf39'
export const SINGLE_CALL_BALANCES_ADDRESS_RINKEBY = '0x9f510b19f1ad66f0dcf6e45559fab0d6752c1db7'
export const SINGLE_CALL_BALANCES_ADDRESS_ROPSTEN = '0xb8e671734ce5c8d7dfbbea5574fa4cf39f7a54a4'
export const SINGLE_CALL_BALANCES_ADDRESS_KOVAN = '0xb1d3fbb2f83aecd196f474c16ca5d9cffa0d0ffc'

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
const ObservableStore = require('obs-store')
const extend = require('xtend')
const log = require('loglevel')
import ObservableStore from 'obs-store'
import extend from 'xtend'
import log from 'loglevel'
/**
* @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')
const asMiddleware = require('json-rpc-engine/src/asMiddleware')
const ObservableStore = require('obs-store')
const log = require('loglevel')
const RpcCap = require('rpc-cap').CapabilitiesController
const { ethErrors } = require('eth-json-rpc-errors')
const getRestrictedMethods = require('./restrictedMethods')
const createMethodMiddleware = require('./methodMiddleware')
const createLoggerMiddleware = require('./loggerMiddleware')
import JsonRpcEngine from 'json-rpc-engine'
import asMiddleware from 'json-rpc-engine/src/asMiddleware'
import ObservableStore from 'obs-store'
import log from 'loglevel'
import { CapabilitiesController as RpcCap } from 'rpc-cap'
import { ethErrors } from 'eth-json-rpc-errors'
import getRestrictedMethods from './restrictedMethods'
import createMethodMiddleware from './methodMiddleware'
import createLoggerMiddleware from './loggerMiddleware'
// 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
const METADATA_STORE_KEY = 'domainMetadata'
const LOG_STORE_KEY = 'permissionsLog'
const HISTORY_STORE_KEY = 'permissionsHistory'
const WALLET_METHOD_PREFIX = 'wallet_'
const CAVEAT_NAMES = {
exposedAccounts: 'exposedAccounts',
}
const ACCOUNTS_CHANGED_NOTIFICATION = 'wallet_accountsChanged'
class PermissionsController {
export const CAVEAT_NAMES = {
exposedAccounts: 'exposedAccounts',
}
export class PermissionsController {
constructor (
{
@ -378,13 +378,6 @@ class PermissionsController {
}
}
module.exports = {
PermissionsController,
addInternalMethodPrefix: prefix,
CAVEAT_NAMES,
}
function prefix (method) {
export function addInternalMethodPrefix (method) {
return WALLET_METHOD_PREFIX + method
}

View File

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

View File

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

View File

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

View File

@ -1,8 +1,8 @@
const ObservableStore = require('obs-store')
const { addInternalMethodPrefix } = require('./permissions')
const normalizeAddress = require('eth-sig-util').normalize
const { isValidAddress, sha3, bufferToHex } = require('ethereumjs-util')
const extend = require('xtend')
import ObservableStore from 'obs-store'
import { addInternalMethodPrefix } from './permissions'
import { normalize as normalizeAddress } from 'eth-sig-util'
import { isValidAddress, sha3, bufferToHex } from 'ethereumjs-util'
import extend from 'xtend'
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')
const extend = require('xtend')
const EthQuery = require('eth-query')
const log = require('loglevel')
const pify = require('pify')
const {
ROPSTEN,
RINKEBY,
KOVAN,
MAINNET,
GOERLI,
} = require('./network/enums')
import ObservableStore from 'obs-store'
import extend from 'xtend'
import EthQuery from 'eth-query'
import log from 'loglevel'
import pify from 'pify'
import { ROPSTEN, RINKEBY, KOVAN, MAINNET, GOERLI } from './network/enums'
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
? require('../../../development/mock-3box')
: require('3box')
const log = require('loglevel')
const migrations = require('../migrations/')
const Migrator = require('../lib/migrator')
const JsonRpcEngine = require('json-rpc-engine')
const providerFromEngine = require('eth-json-rpc-middleware/providerFromEngine')
const createMetamaskMiddleware = require('./network/createMetamaskMiddleware')
const createOriginMiddleware = require('../lib/createOriginMiddleware')
import log from 'loglevel'
import migrations from '../migrations'
import Migrator from '../lib/migrator'
import JsonRpcEngine from 'json-rpc-engine'
import providerFromEngine from 'eth-json-rpc-middleware/providerFromEngine'
import createMetamaskMiddleware from './network/createMetamaskMiddleware'
import createOriginMiddleware from '../lib/createOriginMiddleware'
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')
const log = require('loglevel')
const normalizeAddress = require('eth-sig-util').normalize
const ethUtil = require('ethereumjs-util')
import ObservableStore from 'obs-store'
import log from 'loglevel'
import { normalize as normalizeAddress } from 'eth-sig-util'
import ethUtil from 'ethereumjs-util'
// 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_CONFIRMED = 'confirmed'
module.exports = {
export {
TRANSACTION_TYPE_CANCEL,
TRANSACTION_TYPE_RETRY,
TRANSACTION_TYPE_STANDARD,

View File

@ -1,36 +1,40 @@
const EventEmitter = require('safe-event-emitter')
const ObservableStore = require('obs-store')
const ethUtil = require('ethereumjs-util')
const Transaction = require('ethereumjs-tx')
const EthQuery = require('ethjs-query')
const { ethErrors } = require('eth-json-rpc-errors')
const abi = require('human-standard-token-abi')
const abiDecoder = require('abi-decoder')
import EventEmitter from 'safe-event-emitter'
import ObservableStore from 'obs-store'
import ethUtil from 'ethereumjs-util'
import Transaction from 'ethereumjs-tx'
import EthQuery from 'ethjs-query'
import { ethErrors } from 'eth-json-rpc-errors'
import abi from 'human-standard-token-abi'
import abiDecoder from 'abi-decoder'
abiDecoder.addABI(abi)
const {
import {
TOKEN_METHOD_APPROVE,
TOKEN_METHOD_TRANSFER,
TOKEN_METHOD_TRANSFER_FROM,
SEND_ETHER_ACTION_KEY,
DEPLOY_CONTRACT_ACTION_KEY,
CONTRACT_INTERACTION_KEY,
} = require('../../../../ui/app/helpers/constants/transactions.js')
const TransactionStateManager = require('./tx-state-manager')
const TxGasUtil = require('./tx-gas-utils')
const PendingTransactionTracker = require('./pending-tx-tracker')
const NonceTracker = require('nonce-tracker')
const txUtils = require('./lib/util')
const cleanErrorStack = require('../../lib/cleanErrorStack')
const log = require('loglevel')
const recipientBlacklistChecker = require('./lib/recipient-blacklist-checker')
const {
} from '../../../../ui/app/helpers/constants/transactions.js'
import TransactionStateManager from './tx-state-manager'
import TxGasUtil from './tx-gas-utils'
import PendingTransactionTracker from './pending-tx-tracker'
import NonceTracker from 'nonce-tracker'
import * as txUtils from './lib/util'
import cleanErrorStack from '../../lib/cleanErrorStack'
import log from 'loglevel'
import recipientBlacklistChecker from './lib/recipient-blacklist-checker'
import {
TRANSACTION_TYPE_CANCEL,
TRANSACTION_TYPE_RETRY,
TRANSACTION_TYPE_STANDARD,
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
@ -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.exports = {
export default {
checkAccount,
}

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
const EventEmitter = require('safe-event-emitter')
const log = require('loglevel')
const EthQuery = require('ethjs-query')
import EventEmitter from 'safe-event-emitter'
import log from 'loglevel'
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')
const {
hexToBn,
BnMultiplyByFraction,
bnToHex,
} = require('../../lib/util')
const log = require('loglevel')
const { addHexPrefix } = require('ethereumjs-util')
const { SEND_ETHER_ACTION_KEY } = require('../../../../ui/app/helpers/constants/transactions.js')
import EthQuery from 'ethjs-query'
import { hexToBn, BnMultiplyByFraction, bnToHex } from '../../lib/util'
import log from 'loglevel'
import { addHexPrefix } from 'ethereumjs-util'
import { SEND_ETHER_ACTION_KEY } from '../../../../ui/app/helpers/constants/transactions.js'
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'
@ -154,4 +151,4 @@ class TxGasUtil {
}
}
module.exports = TxGasUtil
export default TxGasUtil

View File

@ -1,10 +1,10 @@
const extend = require('xtend')
const EventEmitter = require('safe-event-emitter')
const ObservableStore = require('obs-store')
const log = require('loglevel')
const txStateHistoryHelper = require('./lib/tx-state-history-helper')
const createId = require('../../lib/random-id')
const { getFinalStates, normalizeTxParams } = require('./lib/util')
import extend from 'xtend'
import EventEmitter from 'safe-event-emitter'
import ObservableStore from 'obs-store'
import log from 'loglevel'
import txStateHistoryHelper from './lib/tx-state-history-helper'
import createId from '../../lib/random-id'
import { getFinalStates, normalizeTxParams } from './lib/util'
/**
TransactionStateManager is responsible for the state of a transaction and
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: {},
}
module.exports = initialState
export default initialState

View File

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

View File

@ -1,4 +1,4 @@
const ObservableStore = require('obs-store')
import ObservableStore from 'obs-store'
/**
* 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.
*/
const EthQuery = require('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')
import EthQuery from 'eth-query'
const { bnToHex } = require('./util')
const { MAINNET_CODE, RINKEBY_CODE, ROPSTEN_CODE, KOVAN_CODE } = require('../controllers/network/enums')
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 ObservableStore from 'obs-store'
import log from 'loglevel'
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 {
@ -255,4 +261,4 @@ class AccountTracker {
}
module.exports = AccountTracker
export default AccountTracker

View File

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

View File

@ -1,9 +1,5 @@
const {
getMetaMetricState,
} = require('../../../ui/app/selectors/selectors')
const {
sendMetaMetricsEvent,
} = require('../../../ui/app/helpers/utils/metametrics.util')
import { getMetaMetricState } from '../../../ui/app/selectors/selectors'
import { sendMetaMetricsEvent } from '../../../ui/app/helpers/utils/metametrics.util'
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

View File

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

View File

@ -1,4 +1,4 @@
module.exports = createDnodeRemoteGetter
export default createDnodeRemoteGetter
function createDnodeRemoteGetter (dnode) {
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

View File

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

View File

@ -1,5 +1,5 @@
const WritableStream = require('readable-stream').Writable
const promiseToCallback = require('promise-to-callback')
import { Writable as WritableStream } from 'readable-stream'
import promiseToCallback from 'promise-to-callback'
class AsyncWritableStream extends WritableStream {
@ -20,4 +20,4 @@ function createStreamSink (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 =
[{ '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' }]
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' }]
export default abi

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
const extension = require('extensionizer')
const promisify = require('pify')
const allLocales = require('../../_locales/index.json')
import extension from 'extensionizer'
import promisify from 'pify'
import allLocales from '../../_locales/index.json'
const getPreferredLocales = extension.i18n ? promisify(
extension.i18n.getAcceptLanguages,
@ -45,5 +45,5 @@ async function getFirstPreferredLangCode () {
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
// it replaces all values with the result of their type

View File

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

View File

@ -1,8 +1,8 @@
const EventEmitter = require('events')
const ObservableStore = require('obs-store')
const ethUtil = require('ethereumjs-util')
const { ethErrors } = require('eth-json-rpc-errors')
const createId = require('./random-id')
import EventEmitter from 'events'
import ObservableStore from 'obs-store'
import ethUtil from 'ethereumjs-util'
import { ethErrors } from 'eth-json-rpc-errors'
import createId from './random-id'
/**
* 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.

View File

@ -1,4 +1,4 @@
const EventEmitter = require('events')
import EventEmitter from 'events'
/**
* @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_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) {
if (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
*
*/
module.exports = function nodeify (fn, context) {
export default function nodeify (fn, context) {
return function () {
// parse 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_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
const normalize = require('eth-sig-util').normalize
import { BN } from 'ethereumjs-util'
import { normalize } from 'eth-sig-util'
class PendingBalanceCalculator {
@ -78,4 +78,4 @@ class PendingBalanceCalculator {
}
module.exports = PendingBalanceCalculator
export default PendingBalanceCalculator

View File

@ -1,10 +1,11 @@
const EventEmitter = require('events')
const ObservableStore = require('obs-store')
const ethUtil = require('ethereumjs-util')
const { ethErrors } = require('eth-json-rpc-errors')
const createId = require('./random-id')
import EventEmitter from 'events'
import ObservableStore from 'obs-store'
import ethUtil from 'ethereumjs-util'
import { ethErrors } from 'eth-json-rpc-errors'
import createId from './random-id'
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
@ -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.
*

View File

@ -6,4 +6,4 @@ function createRandomId () {
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

View File

@ -1,5 +1,5 @@
const KeyringController = require('eth-keyring-controller')
const log = require('loglevel')
import KeyringController from 'eth-keyring-controller'
import log from 'loglevel'
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,
ROPSTEN_CHAIN_ID,
RINKEBY_CHAIN_ID,
KOVAN_CHAIN_ID,
GOERLI_CHAIN_ID,
} = require('./enums')
} from './enums'
const standardNetworkId = {
'1': MAINNET_CHAIN_ID,
@ -19,4 +19,4 @@ function selectChainId (metamaskState) {
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

View File

@ -1,5 +1,5 @@
module.exports = setupMetamaskMeshMetrics
export default setupMetamaskMeshMetrics
/**
* 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 extractEthjsErrorMessage = require('./extractEthjsErrorMessage')
import extractEthjsErrorMessage from './extractEthjsErrorMessage'
const SENTRY_DSN_PROD = 'https://3567c198f8a8412082d32655da2961d0@sentry.io/273505'
const SENTRY_DSN_DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496'
module.exports = setupSentry
export default setupSentry
// Setup sentry remote error reporting
function setupSentry (opts) {

View File

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

View File

@ -1,11 +1,11 @@
const EventEmitter = require('events')
const ObservableStore = require('obs-store')
const createId = require('./random-id')
const assert = require('assert')
const { ethErrors } = require('eth-json-rpc-errors')
const sigUtil = require('eth-sig-util')
const log = require('loglevel')
const jsonschema = require('jsonschema')
import EventEmitter from 'events'
import ObservableStore from 'obs-store'
import createId from './random-id'
import assert from 'assert'
import { ethErrors } from 'eth-json-rpc-errors'
import sigUtil from 'eth-sig-util'
import log from 'loglevel'
import jsonschema from 'jsonschema'
/**
* 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.
*/

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,8 @@
const version = 4
const clone = require('clone')
import clone from 'clone'
module.exports = {
export default {
version,
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')
const clone = require('clone')
import extend from 'xtend'
import clone from 'clone'
module.exports = {
export default {
version,
migrate: function (originalVersionedData) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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