mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Move export defaults statements alongside their objects (#8525)
This commit is contained in:
parent
de127b86eb
commit
f5a125fe61
@ -13,7 +13,7 @@ import { getRandomArrayItem } from '../lib/util'
|
|||||||
* browser tab
|
* browser tab
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ABTestController {
|
export default class ABTestController {
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param opts
|
* @param opts
|
||||||
@ -51,6 +51,3 @@ class ABTestController {
|
|||||||
ABTestController.abTestGroupNames = {
|
ABTestController.abTestGroupNames = {
|
||||||
fullScreenVsPopup: ['control', 'fullScreen'],
|
fullScreenVsPopup: ['control', 'fullScreen'],
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ABTestController
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import ObservableStore from 'obs-store'
|
import ObservableStore from 'obs-store'
|
||||||
import EventEmitter from 'events'
|
import EventEmitter from 'events'
|
||||||
|
|
||||||
class AppStateController extends EventEmitter {
|
export default class AppStateController extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param opts
|
* @param opts
|
||||||
@ -141,6 +141,3 @@ class AppStateController extends EventEmitter {
|
|||||||
this.timer = setTimeout(() => this.onInactiveTimeout(), timeoutMinutes * 60 * 1000)
|
this.timer = setTimeout(() => this.onInactiveTimeout(), timeoutMinutes * 60 * 1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AppStateController
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import ObservableStore from 'obs-store'
|
|||||||
import PendingBalanceCalculator from '../lib/pending-balance-calculator'
|
import PendingBalanceCalculator from '../lib/pending-balance-calculator'
|
||||||
import { BN } from 'ethereumjs-util'
|
import { BN } from 'ethereumjs-util'
|
||||||
|
|
||||||
class BalanceController {
|
export default class BalanceController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller responsible for storing and updating an account's balance.
|
* Controller responsible for storing and updating an account's balance.
|
||||||
@ -132,5 +132,3 @@ class BalanceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default BalanceController
|
|
||||||
|
@ -11,7 +11,7 @@ import ObservableStore from 'obs-store'
|
|||||||
* Background controller responsible for maintaining
|
* Background controller responsible for maintaining
|
||||||
* a cache of account balances in local storage
|
* a cache of account balances in local storage
|
||||||
*/
|
*/
|
||||||
class CachedBalancesController {
|
export default class CachedBalancesController {
|
||||||
/**
|
/**
|
||||||
* Creates a new controller instance
|
* Creates a new controller instance
|
||||||
*
|
*
|
||||||
@ -78,5 +78,3 @@ class CachedBalancesController {
|
|||||||
this.accountTracker.store.subscribe(update)
|
this.accountTracker.store.subscribe(update)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CachedBalancesController
|
|
||||||
|
@ -11,7 +11,7 @@ const SINGLE_CALL_BALANCES_ADDRESS = '0xb1f8e55c7f64d203c1400b9d8555d050f94adf39
|
|||||||
* A controller that polls for token exchange
|
* A controller that polls for token exchange
|
||||||
* rates based on a user's current token list
|
* rates based on a user's current token list
|
||||||
*/
|
*/
|
||||||
class DetectTokensController {
|
export default class DetectTokensController {
|
||||||
/**
|
/**
|
||||||
* Creates a DetectTokensController
|
* Creates a DetectTokensController
|
||||||
*
|
*
|
||||||
@ -162,5 +162,3 @@ class DetectTokensController {
|
|||||||
return this.isOpen && this.isUnlocked
|
return this.isOpen && this.isUnlocked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DetectTokensController
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import EthJsEns from 'ethjs-ens'
|
import EthJsEns from 'ethjs-ens'
|
||||||
import ensNetworkMap from 'ethereum-ens-network-map'
|
import ensNetworkMap from 'ethereum-ens-network-map'
|
||||||
|
|
||||||
class Ens {
|
export default class Ens {
|
||||||
static getNetworkEnsSupport (network) {
|
static getNetworkEnsSupport (network) {
|
||||||
return Boolean(ensNetworkMap[network])
|
return Boolean(ensNetworkMap[network])
|
||||||
}
|
}
|
||||||
@ -21,5 +21,3 @@ class Ens {
|
|||||||
return this._ethJsEns.reverse(address)
|
return this._ethJsEns.reverse(address)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Ens
|
|
||||||
|
@ -7,7 +7,7 @@ import Ens from './ens'
|
|||||||
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
|
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
|
||||||
const ZERO_X_ERROR_ADDRESS = '0x'
|
const ZERO_X_ERROR_ADDRESS = '0x'
|
||||||
|
|
||||||
class EnsController {
|
export default class EnsController {
|
||||||
constructor ({ ens, provider, networkStore } = {}) {
|
constructor ({ ens, provider, networkStore } = {}) {
|
||||||
const initState = {
|
const initState = {
|
||||||
ensResolutionsByAddress: {},
|
ensResolutionsByAddress: {},
|
||||||
@ -90,5 +90,3 @@ class EnsController {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default EnsController
|
|
||||||
|
@ -29,7 +29,7 @@ const fetch = fetchWithTimeout({
|
|||||||
timeout: 30000,
|
timeout: 30000,
|
||||||
})
|
})
|
||||||
|
|
||||||
class IncomingTransactionsController {
|
export default class IncomingTransactionsController {
|
||||||
|
|
||||||
constructor (opts = {}) {
|
constructor (opts = {}) {
|
||||||
const {
|
const {
|
||||||
@ -269,8 +269,6 @@ class IncomingTransactionsController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default IncomingTransactionsController
|
|
||||||
|
|
||||||
function pairwise (fn) {
|
function pairwise (fn) {
|
||||||
let first = true
|
let first = true
|
||||||
let cache
|
let cache
|
||||||
|
@ -4,7 +4,7 @@ import log from 'loglevel'
|
|||||||
// every ten minutes
|
// every ten minutes
|
||||||
const POLLING_INTERVAL = 10 * 60 * 1000
|
const POLLING_INTERVAL = 10 * 60 * 1000
|
||||||
|
|
||||||
class InfuraController {
|
export default class InfuraController {
|
||||||
|
|
||||||
constructor (opts = {}) {
|
constructor (opts = {}) {
|
||||||
const initState = Object.assign({
|
const initState = Object.assign({
|
||||||
@ -37,5 +37,3 @@ class InfuraController {
|
|||||||
}, POLLING_INTERVAL)
|
}, POLLING_INTERVAL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default InfuraController
|
|
||||||
|
@ -9,9 +9,7 @@ import providerFromMiddleware from 'eth-json-rpc-middleware/providerFromMiddlewa
|
|||||||
import createInfuraMiddleware from 'eth-json-rpc-infura'
|
import createInfuraMiddleware from 'eth-json-rpc-infura'
|
||||||
import BlockTracker from 'eth-block-tracker'
|
import BlockTracker from 'eth-block-tracker'
|
||||||
|
|
||||||
export default createInfuraClient
|
export default function createInfuraClient ({ network }) {
|
||||||
|
|
||||||
function createInfuraClient ({ network }) {
|
|
||||||
const infuraMiddleware = createInfuraMiddleware({ network, maxAttempts: 5, source: 'metamask' })
|
const infuraMiddleware = createInfuraMiddleware({ network, maxAttempts: 5, source: 'metamask' })
|
||||||
const infuraProvider = providerFromMiddleware(infuraMiddleware)
|
const infuraProvider = providerFromMiddleware(infuraMiddleware)
|
||||||
const blockTracker = new BlockTracker({ provider: infuraProvider })
|
const blockTracker = new BlockTracker({ provider: infuraProvider })
|
||||||
|
@ -7,9 +7,7 @@ import createBlockTrackerInspectorMiddleware from 'eth-json-rpc-middleware/block
|
|||||||
import providerFromMiddleware from 'eth-json-rpc-middleware/providerFromMiddleware'
|
import providerFromMiddleware from 'eth-json-rpc-middleware/providerFromMiddleware'
|
||||||
import BlockTracker from 'eth-block-tracker'
|
import BlockTracker from 'eth-block-tracker'
|
||||||
|
|
||||||
export default createJsonRpcClient
|
export default function createJsonRpcClient ({ rpcUrl }) {
|
||||||
|
|
||||||
function createJsonRpcClient ({ rpcUrl }) {
|
|
||||||
const fetchMiddleware = createFetchMiddleware({ rpcUrl })
|
const fetchMiddleware = createFetchMiddleware({ rpcUrl })
|
||||||
const blockProvider = providerFromMiddleware(fetchMiddleware)
|
const blockProvider = providerFromMiddleware(fetchMiddleware)
|
||||||
const blockTracker = new BlockTracker({ provider: blockProvider })
|
const blockTracker = new BlockTracker({ provider: blockProvider })
|
||||||
|
@ -8,9 +8,7 @@ import BlockTracker from 'eth-block-tracker'
|
|||||||
|
|
||||||
const inTest = process.env.IN_TEST === 'true'
|
const inTest = process.env.IN_TEST === 'true'
|
||||||
|
|
||||||
export default createLocalhostClient
|
export default function createLocalhostClient () {
|
||||||
|
|
||||||
function createLocalhostClient () {
|
|
||||||
const fetchMiddleware = createFetchMiddleware({ rpcUrl: 'http://localhost:8545/' })
|
const fetchMiddleware = createFetchMiddleware({ rpcUrl: 'http://localhost:8545/' })
|
||||||
const blockProvider = providerFromMiddleware(fetchMiddleware)
|
const blockProvider = providerFromMiddleware(fetchMiddleware)
|
||||||
const blockTracker = new BlockTracker({ provider: blockProvider, pollingInterval: 1000 })
|
const blockTracker = new BlockTracker({ provider: blockProvider, pollingInterval: 1000 })
|
||||||
|
@ -3,9 +3,7 @@ import createScaffoldMiddleware from 'json-rpc-engine/src/createScaffoldMiddlewa
|
|||||||
import createWalletSubprovider from 'eth-json-rpc-middleware/wallet'
|
import createWalletSubprovider from 'eth-json-rpc-middleware/wallet'
|
||||||
import { createPendingNonceMiddleware, createPendingTxMiddleware } from './middleware/pending'
|
import { createPendingNonceMiddleware, createPendingTxMiddleware } from './middleware/pending'
|
||||||
|
|
||||||
export default createMetamaskMiddleware
|
export default function createMetamaskMiddleware ({
|
||||||
|
|
||||||
function createMetamaskMiddleware ({
|
|
||||||
version,
|
version,
|
||||||
getAccounts,
|
getAccounts,
|
||||||
processTransaction,
|
processTransaction,
|
||||||
|
@ -16,7 +16,7 @@ import log from 'loglevel'
|
|||||||
* Controller responsible for maintaining
|
* Controller responsible for maintaining
|
||||||
* state related to onboarding
|
* state related to onboarding
|
||||||
*/
|
*/
|
||||||
class OnboardingController {
|
export default class OnboardingController {
|
||||||
/**
|
/**
|
||||||
* Creates a new controller instance
|
* Creates a new controller instance
|
||||||
*
|
*
|
||||||
@ -72,5 +72,3 @@ class OnboardingController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OnboardingController
|
|
||||||
|
@ -3,7 +3,7 @@ import { addInternalMethodPrefix } from './permissions'
|
|||||||
import { normalize as normalizeAddress } from 'eth-sig-util'
|
import { normalize as normalizeAddress } from 'eth-sig-util'
|
||||||
import { isValidAddress, sha3, bufferToHex } from 'ethereumjs-util'
|
import { isValidAddress, sha3, bufferToHex } from 'ethereumjs-util'
|
||||||
|
|
||||||
class PreferencesController {
|
export default class PreferencesController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -743,5 +743,3 @@ class PreferencesController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PreferencesController
|
|
||||||
|
@ -6,8 +6,7 @@ import { ROPSTEN, RINKEBY, KOVAN, MAINNET, GOERLI } from './network/enums'
|
|||||||
|
|
||||||
const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET, GOERLI]
|
const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET, GOERLI]
|
||||||
|
|
||||||
|
export default class RecentBlocksController {
|
||||||
class RecentBlocksController {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller responsible for storing, updating and managing the recent history of blocks. Blocks are back filled
|
* Controller responsible for storing, updating and managing the recent history of blocks. Blocks are back filled
|
||||||
@ -174,5 +173,3 @@ class RecentBlocksController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default RecentBlocksController
|
|
||||||
|
@ -14,7 +14,7 @@ import createOriginMiddleware from '../lib/createOriginMiddleware'
|
|||||||
|
|
||||||
const SYNC_TIMEOUT = 60 * 1000 // one minute
|
const SYNC_TIMEOUT = 60 * 1000 // one minute
|
||||||
|
|
||||||
class ThreeBoxController {
|
export default class ThreeBoxController {
|
||||||
constructor (opts = {}) {
|
constructor (opts = {}) {
|
||||||
const {
|
const {
|
||||||
preferencesController,
|
preferencesController,
|
||||||
@ -244,5 +244,3 @@ class ThreeBoxController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ThreeBoxController
|
|
||||||
|
@ -11,7 +11,7 @@ const DEFAULT_INTERVAL = 180 * 1000
|
|||||||
* A controller that polls for token exchange
|
* A controller that polls for token exchange
|
||||||
* rates based on a user's current token list
|
* rates based on a user's current token list
|
||||||
*/
|
*/
|
||||||
class TokenRatesController {
|
export default class TokenRatesController {
|
||||||
/**
|
/**
|
||||||
* Creates a TokenRatesController
|
* Creates a TokenRatesController
|
||||||
*
|
*
|
||||||
@ -86,5 +86,3 @@ class TokenRatesController {
|
|||||||
this.updateExchangeRates()
|
this.updateExchangeRates()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TokenRatesController
|
|
||||||
|
@ -4,7 +4,7 @@ import ObservableStore from 'obs-store'
|
|||||||
* An ObservableStore that can composes a flat
|
* An ObservableStore that can composes a flat
|
||||||
* structure of child stores based on configuration
|
* structure of child stores based on configuration
|
||||||
*/
|
*/
|
||||||
class ComposableObservableStore extends ObservableStore {
|
export default class ComposableObservableStore extends ObservableStore {
|
||||||
/**
|
/**
|
||||||
* Create a new store
|
* Create a new store
|
||||||
*
|
*
|
||||||
@ -47,5 +47,3 @@ class ComposableObservableStore extends ObservableStore {
|
|||||||
return flatState
|
return flatState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ComposableObservableStore
|
|
||||||
|
@ -24,8 +24,7 @@ import {
|
|||||||
SINGLE_CALL_BALANCES_ADDRESS_KOVAN,
|
SINGLE_CALL_BALANCES_ADDRESS_KOVAN,
|
||||||
} from '../controllers/network/contract-addresses'
|
} from '../controllers/network/contract-addresses'
|
||||||
|
|
||||||
|
export default class AccountTracker {
|
||||||
class AccountTracker {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This module is responsible for tracking any number of accounts and caching their current balances & transaction
|
* This module is responsible for tracking any number of accounts and caching their current balances & transaction
|
||||||
@ -260,5 +259,3 @@ class AccountTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AccountTracker
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
|
|
||||||
// TODO:deprecate:2020
|
// TODO:deprecate:2020
|
||||||
|
|
||||||
export default setupDappAutoReload
|
export default function setupDappAutoReload (web3, observable) {
|
||||||
|
|
||||||
function setupDappAutoReload (web3, observable) {
|
|
||||||
// export web3 as a global, checking for usage
|
// export web3 as a global, checking for usage
|
||||||
let reloadInProgress = false
|
let reloadInProgress = false
|
||||||
let lastTimeUsed
|
let lastTimeUsed
|
||||||
|
@ -7,7 +7,7 @@ const METAMETRICS_TRACKING_URL = inDevelopment
|
|||||||
? 'http://www.metamask.io/metametrics'
|
? 'http://www.metamask.io/metametrics'
|
||||||
: 'http://www.metamask.io/metametrics-prod'
|
: 'http://www.metamask.io/metametrics-prod'
|
||||||
|
|
||||||
function backEndMetaMetricsEvent (metaMaskState, eventData) {
|
export default function backEndMetaMetricsEvent (metaMaskState, eventData) {
|
||||||
const stateEventData = getMetaMetricState({ metamask: metaMaskState })
|
const stateEventData = getMetaMetricState({ metamask: metaMaskState })
|
||||||
|
|
||||||
if (stateEventData.participateInMetaMetrics) {
|
if (stateEventData.participateInMetaMetrics) {
|
||||||
@ -18,5 +18,3 @@ function backEndMetaMetricsEvent (metaMaskState, eventData) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default backEndMetaMetricsEvent
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
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
|
||||||
*
|
*
|
||||||
@ -10,7 +8,7 @@ export default getBuyEthUrl
|
|||||||
* network does not match any of the specified cases, or if no network is given, returns undefined.
|
* network does not match any of the specified cases, or if no network is given, returns undefined.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function getBuyEthUrl ({ network, address, service }) {
|
export default function getBuyEthUrl ({ network, address, service }) {
|
||||||
// default service by network if not specified
|
// default service by network if not specified
|
||||||
if (!service) {
|
if (!service) {
|
||||||
service = getDefaultServiceForNetwork(network)
|
service = getDefaultServiceForNetwork(network)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @param {Error} err - error
|
* @param {Error} err - error
|
||||||
* @returns {Error} - Error with clean stack trace.
|
* @returns {Error} - Error with clean stack trace.
|
||||||
*/
|
*/
|
||||||
function cleanErrorStack (err) {
|
export default function cleanErrorStack (err) {
|
||||||
let name = err.name
|
let name = err.name
|
||||||
name = (name === undefined) ? 'Error' : String(name)
|
name = (name === undefined) ? 'Error' : String(name)
|
||||||
|
|
||||||
@ -20,5 +20,3 @@ function cleanErrorStack (err) {
|
|||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
export default cleanErrorStack
|
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
import log from 'loglevel'
|
import log from 'loglevel'
|
||||||
|
|
||||||
export default createLoggerMiddleware
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a middleware that logs RPC activity
|
* Returns a middleware that logs RPC activity
|
||||||
* @param {{ origin: string }} opts - The middleware options
|
* @param {{ origin: string }} opts - The middleware options
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
function createLoggerMiddleware (opts) {
|
export default function createLoggerMiddleware (opts) {
|
||||||
return function loggerMiddleware (/** @type {any} */ req, /** @type {any} */ res, /** @type {Function} */ next) {
|
return function loggerMiddleware (/** @type {any} */ req, /** @type {any} */ res, /** @type {Function} */ next) {
|
||||||
next((/** @type {Function} */ cb) => {
|
next((/** @type {Function} */ cb) => {
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
|
@ -6,7 +6,7 @@ import extension from 'extensionizer'
|
|||||||
* @param {{ location: string, registerOnboarding: Function }} opts - The middleware options
|
* @param {{ location: string, registerOnboarding: Function }} opts - The middleware options
|
||||||
* @returns {(req: any, res: any, next: Function, end: Function) => void}
|
* @returns {(req: any, res: any, next: Function, end: Function) => void}
|
||||||
*/
|
*/
|
||||||
function createOnboardingMiddleware ({ location, registerOnboarding }) {
|
export default function createOnboardingMiddleware ({ location, registerOnboarding }) {
|
||||||
return async function originMiddleware (req, res, next, end) {
|
return async function originMiddleware (req, res, next, end) {
|
||||||
try {
|
try {
|
||||||
if (req.method !== 'wallet_registerOnboarding') {
|
if (req.method !== 'wallet_registerOnboarding') {
|
||||||
@ -25,5 +25,3 @@ function createOnboardingMiddleware ({ location, registerOnboarding }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default createOnboardingMiddleware
|
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
|
|
||||||
export default createOriginMiddleware
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a middleware that appends the DApp origin to request
|
* Returns a middleware that appends the DApp origin to request
|
||||||
* @param {{ origin: string }} opts - The middleware options
|
* @param {{ origin: string }} opts - The middleware options
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
function createOriginMiddleware (opts) {
|
export default function createOriginMiddleware (opts) {
|
||||||
return function originMiddleware (/** @type {any} */ req, /** @type {any} */ _, /** @type {Function} */ next) {
|
return function originMiddleware (/** @type {any} */ req, /** @type {any} */ _, /** @type {Function} */ next) {
|
||||||
req.origin = opts.origin
|
req.origin = opts.origin
|
||||||
next()
|
next()
|
||||||
|
@ -16,8 +16,6 @@ class AsyncWritableStream extends WritableStream {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createStreamSink (asyncWriteFn, _opts) {
|
export default function createStreamSink (asyncWriteFn, _opts) {
|
||||||
return new AsyncWritableStream(asyncWriteFn, _opts)
|
return new AsyncWritableStream(asyncWriteFn, _opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default createStreamSink
|
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
|
|
||||||
module.exports = createTabIdMiddleware
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a middleware that appends the DApp TabId to the request
|
* Returns a middleware that appends the DApp TabId to the request
|
||||||
* @param {{ tabId: number }} opts - The middleware options
|
* @param {{ tabId: number }} opts - The middleware options
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
function createTabIdMiddleware (opts) {
|
export default function createTabIdMiddleware (opts) {
|
||||||
return function tabIdMiddleware (/** @type {any} */ req, /** @type {any} */ _, /** @type {Function} */ next) {
|
return function tabIdMiddleware (/** @type {any} */ req, /** @type {any} */ _, /** @type {Function} */ next) {
|
||||||
req.tabId = opts.tabId
|
req.tabId = opts.tabId
|
||||||
next()
|
next()
|
||||||
|
@ -5,10 +5,7 @@ import registryAbi from './contracts/registry'
|
|||||||
import resolverAbi from './contracts/resolver'
|
import resolverAbi from './contracts/resolver'
|
||||||
import contentHash from 'content-hash'
|
import contentHash from 'content-hash'
|
||||||
|
|
||||||
export default resolveEnsToIpfsContentId
|
export default async function resolveEnsToIpfsContentId ({ provider, name }) {
|
||||||
|
|
||||||
|
|
||||||
async function resolveEnsToIpfsContentId ({ provider, name }) {
|
|
||||||
const eth = new Eth(provider)
|
const eth = new Eth(provider)
|
||||||
const hash = namehash.hash(name)
|
const hash = namehash.hash(name)
|
||||||
const contract = new EthContract(eth)
|
const contract = new EthContract(eth)
|
||||||
|
@ -4,9 +4,7 @@ import resolveEnsToIpfsContentId from './resolver.js'
|
|||||||
|
|
||||||
const supportedTopLevelDomains = ['eth']
|
const supportedTopLevelDomains = ['eth']
|
||||||
|
|
||||||
export default setupEnsIpfsResolver
|
export default function setupEnsIpfsResolver ({ provider, getCurrentNetwork, getIpfsGateway }) {
|
||||||
|
|
||||||
function setupEnsIpfsResolver ({ provider, getCurrentNetwork, getIpfsGateway }) {
|
|
||||||
|
|
||||||
// install listener
|
// install listener
|
||||||
const urlPatterns = supportedTopLevelDomains.map((tld) => `*://*.${tld}/*`)
|
const urlPatterns = supportedTopLevelDomains.map((tld) => `*://*.${tld}/*`)
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
const ethJsRpcSlug = 'Error: [ethjs-rpc] rpc error with payload '
|
const ethJsRpcSlug = 'Error: [ethjs-rpc] rpc error with payload '
|
||||||
const errorLabelPrefix = 'Error: '
|
const errorLabelPrefix = 'Error: '
|
||||||
|
|
||||||
export default extractEthjsErrorMessage
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the important part of an ethjs-rpc error message. If the passed error is not an isEthjsRpcError, the error
|
* Extracts the important part of an ethjs-rpc error message. If the passed error is not an isEthjsRpcError, the error
|
||||||
* is returned unchanged.
|
* is returned unchanged.
|
||||||
@ -16,7 +13,7 @@ export default extractEthjsErrorMessage
|
|||||||
* extractEthjsErrorMessage(`Error: [ethjs-rpc] rpc error with payload {"id":3947817945380,"jsonrpc":"2.0","params":["0xf8eb8208708477359400830398539406012c8cf97bead5deae237070f9587f8e7a266d80b8843d7d3f5a0000000000000000000000000000000000000000000000000000000000081d1a000000000000000000000000000000000000000000000000001ff973cafa800000000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000000000000003f48025a04c32a9b630e0d9e7ff361562d850c86b7a884908135956a7e4a336fa0300d19ca06830776423f25218e8d19b267161db526e66895567147015b1f3fc47aef9a3c7"],"method":"eth_sendRawTransaction"} Error: replacement transaction underpriced`)
|
* extractEthjsErrorMessage(`Error: [ethjs-rpc] rpc error with payload {"id":3947817945380,"jsonrpc":"2.0","params":["0xf8eb8208708477359400830398539406012c8cf97bead5deae237070f9587f8e7a266d80b8843d7d3f5a0000000000000000000000000000000000000000000000000000000000081d1a000000000000000000000000000000000000000000000000001ff973cafa800000000000000000000000000000000000000000000000000000038d7ea4c68000000000000000000000000000000000000000000000000000000000000003f48025a04c32a9b630e0d9e7ff361562d850c86b7a884908135956a7e4a336fa0300d19ca06830776423f25218e8d19b267161db526e66895567147015b1f3fc47aef9a3c7"],"method":"eth_sendRawTransaction"} Error: replacement transaction underpriced`)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function extractEthjsErrorMessage (errorMessage) {
|
export default function extractEthjsErrorMessage (errorMessage) {
|
||||||
const isEthjsRpcError = errorMessage.includes(ethJsRpcSlug)
|
const isEthjsRpcError = errorMessage.includes(ethJsRpcSlug)
|
||||||
if (isEthjsRpcError) {
|
if (isEthjsRpcError) {
|
||||||
const payloadAndError = errorMessage.slice(ethJsRpcSlug.length)
|
const payloadAndError = errorMessage.slice(ethJsRpcSlug.length)
|
||||||
|
@ -22,7 +22,7 @@ allLocales.forEach((locale) => {
|
|||||||
* @returns {Promise<string>} - Promises a locale code, either one from the user's preferred list that we have a translation for, or 'en'
|
* @returns {Promise<string>} - Promises a locale code, either one from the user's preferred list that we have a translation for, or 'en'
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
async function getFirstPreferredLangCode () {
|
export default async function getFirstPreferredLangCode () {
|
||||||
let userPreferredLocaleCodes
|
let userPreferredLocaleCodes
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -44,6 +44,3 @@ async function getFirstPreferredLangCode () {
|
|||||||
|
|
||||||
return existingLocaleCodes[firstPreferredLangCode] || 'en'
|
return existingLocaleCodes[firstPreferredLangCode] || 'en'
|
||||||
}
|
}
|
||||||
|
|
||||||
export default getFirstPreferredLangCode
|
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
@ -23,7 +21,7 @@ export default getObjStructure
|
|||||||
* replaced with the javascript type of that value.
|
* replaced with the javascript type of that value.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function getObjStructure (obj) {
|
export default function getObjStructure (obj) {
|
||||||
const structure = cloneDeep(obj)
|
const structure = cloneDeep(obj)
|
||||||
return deepMap(structure, (value) => {
|
return deepMap(structure, (value) => {
|
||||||
return value === null ? 'null' : typeof value
|
return value === null ? 'null' : typeof value
|
||||||
|
@ -7,7 +7,7 @@ const FIXTURE_SERVER_URL = `http://${FIXTURE_SERVER_HOST}:${FIXTURE_SERVER_PORT}
|
|||||||
/**
|
/**
|
||||||
* A read-only network-based storage wrapper
|
* A read-only network-based storage wrapper
|
||||||
*/
|
*/
|
||||||
class ReadOnlyNetworkStore {
|
export default class ReadOnlyNetworkStore {
|
||||||
constructor () {
|
constructor () {
|
||||||
this._initialized = false
|
this._initialized = false
|
||||||
this._initializing = this._init()
|
this._initializing = this._init()
|
||||||
@ -58,5 +58,3 @@ class ReadOnlyNetworkStore {
|
|||||||
this._state = state
|
this._state = state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ReadOnlyNetworkStore
|
|
||||||
|
@ -3,7 +3,7 @@ import ExtensionPlatform from '../platforms/extension'
|
|||||||
const NOTIFICATION_HEIGHT = 620
|
const NOTIFICATION_HEIGHT = 620
|
||||||
const NOTIFICATION_WIDTH = 360
|
const NOTIFICATION_WIDTH = 360
|
||||||
|
|
||||||
class NotificationManager {
|
export default class NotificationManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of methods for controlling the showing and hiding of the notification popup.
|
* A collection of methods for controlling the showing and hiding of the notification popup.
|
||||||
@ -103,5 +103,3 @@ class NotificationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default NotificationManager
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { BN } from 'ethereumjs-util'
|
import { BN } from 'ethereumjs-util'
|
||||||
import { normalize } from 'eth-sig-util'
|
import { normalize } from 'eth-sig-util'
|
||||||
|
|
||||||
class PendingBalanceCalculator {
|
export default class PendingBalanceCalculator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for calculating a users "pending balance": their current balance minus the total possible cost of all their
|
* Used for calculating a users "pending balance": their current balance minus the total possible cost of all their
|
||||||
@ -77,5 +77,3 @@ class PendingBalanceCalculator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PendingBalanceCalculator
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
const MAX = Number.MAX_SAFE_INTEGER
|
const MAX = Number.MAX_SAFE_INTEGER
|
||||||
|
|
||||||
let idCounter = Math.round(Math.random() * MAX)
|
let idCounter = Math.round(Math.random() * MAX)
|
||||||
function createRandomId () {
|
export default function createRandomId () {
|
||||||
idCounter = idCounter % MAX
|
idCounter = idCounter % MAX
|
||||||
return idCounter++
|
return idCounter++
|
||||||
}
|
}
|
||||||
|
|
||||||
export default createRandomId
|
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
import extractEthjsErrorMessage from './extractEthjsErrorMessage'
|
import extractEthjsErrorMessage from './extractEthjsErrorMessage'
|
||||||
|
|
||||||
export default reportFailedTxToSentry
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// utility for formatting failed transaction messages
|
// utility for formatting failed transaction messages
|
||||||
// for sending to sentry
|
// for sending to sentry
|
||||||
//
|
//
|
||||||
|
|
||||||
function reportFailedTxToSentry ({ sentry, txMeta }) {
|
export default function reportFailedTxToSentry ({ sentry, txMeta }) {
|
||||||
const errorMessage = 'Transaction Failed: ' + extractEthjsErrorMessage(txMeta.err.message)
|
const errorMessage = 'Transaction Failed: ' + extractEthjsErrorMessage(txMeta.err.message)
|
||||||
sentry.captureMessage(errorMessage, {
|
sentry.captureMessage(errorMessage, {
|
||||||
// "extra" key is required by Sentry
|
// "extra" key is required by Sentry
|
||||||
|
@ -14,9 +14,7 @@ const standardNetworkId = {
|
|||||||
'5': GOERLI_CHAIN_ID,
|
'5': GOERLI_CHAIN_ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectChainId (metamaskState) {
|
export default function selectChainId (metamaskState) {
|
||||||
const { network, provider: { chainId } } = metamaskState
|
const { network, provider: { chainId } } = metamaskState
|
||||||
return standardNetworkId[network] || `0x${parseInt(chainId, 10).toString(16)}`
|
return standardNetworkId[network] || `0x${parseInt(chainId, 10).toString(16)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export default selectChainId
|
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
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
|
||||||
// `TypeError: Failed to Fetch` without any stack or context for the request
|
// `TypeError: Failed to Fetch` without any stack or context for the request
|
||||||
// https://github.com/getsentry/sentry-javascript/pull/1293
|
// https://github.com/getsentry/sentry-javascript/pull/1293
|
||||||
//
|
//
|
||||||
|
|
||||||
function setupFetchDebugging () {
|
export default function setupFetchDebugging () {
|
||||||
if (!window.fetch) {
|
if (!window.fetch) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,7 @@ const METAMASK_ENVIRONMENT = process.env.METAMASK_ENVIRONMENT
|
|||||||
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'
|
||||||
|
|
||||||
export default setupSentry
|
export default function setupSentry (opts) {
|
||||||
|
|
||||||
// Setup sentry remote error reporting
|
|
||||||
function setupSentry (opts) {
|
|
||||||
const { release, getState } = opts
|
const { release, getState } = opts
|
||||||
let sentryTarget
|
let sentryTarget
|
||||||
// detect brave
|
// detect brave
|
||||||
|
@ -3,7 +3,7 @@ import { createExplorerLink as explorerLink } from '@metamask/etherscan-link'
|
|||||||
import { getEnvironmentType, checkForError } from '../lib/util'
|
import { getEnvironmentType, checkForError } from '../lib/util'
|
||||||
import { ENVIRONMENT_TYPE_BACKGROUND } from '../lib/enums'
|
import { ENVIRONMENT_TYPE_BACKGROUND } from '../lib/enums'
|
||||||
|
|
||||||
class ExtensionPlatform {
|
export default class ExtensionPlatform {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Public
|
// Public
|
||||||
@ -227,5 +227,3 @@ class ExtensionPlatform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ExtensionPlatform
|
|
||||||
|
Loading…
Reference in New Issue
Block a user