diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-05-19 05:54:02 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-05-19 06:14:10 +0800 |
commit | f87ea49b5ac2d66d8f281f08f42e8cfd2d701ba7 (patch) | |
tree | 349903e455ddeccb64b913b12c950e5f5548d046 /app/scripts/lib | |
parent | 03d454f73baa27f9b44ec4bee0ba8f3c71414aa6 (diff) | |
download | tangerine-wallet-browser-f87ea49b5ac2d66d8f281f08f42e8cfd2d701ba7.tar tangerine-wallet-browser-f87ea49b5ac2d66d8f281f08f42e8cfd2d701ba7.tar.gz tangerine-wallet-browser-f87ea49b5ac2d66d8f281f08f42e8cfd2d701ba7.tar.bz2 tangerine-wallet-browser-f87ea49b5ac2d66d8f281f08f42e8cfd2d701ba7.tar.lz tangerine-wallet-browser-f87ea49b5ac2d66d8f281f08f42e8cfd2d701ba7.tar.xz tangerine-wallet-browser-f87ea49b5ac2d66d8f281f08f42e8cfd2d701ba7.tar.zst tangerine-wallet-browser-f87ea49b5ac2d66d8f281f08f42e8cfd2d701ba7.zip |
Create a network controller to manage switcing networks an updating the provider
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/config-manager.js | 67 | ||||
-rw-r--r-- | app/scripts/lib/tx-utils.js | 8 |
2 files changed, 3 insertions, 72 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index ab9410842..1098cc474 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -1,14 +1,6 @@ -const MetamaskConfig = require('../config.js') const ethUtil = require('ethereumjs-util') const normalize = require('eth-sig-util').normalize -const TESTNET_RPC = MetamaskConfig.network.testnet -const MAINNET_RPC = MetamaskConfig.network.mainnet -const MORDEN_RPC = MetamaskConfig.network.morden -const KOVAN_RPC = MetamaskConfig.network.kovan -const RINKEBY_RPC = MetamaskConfig.network.rinkeby - - /* The config-manager is a convenience object * wrapping a pojo-migrator. * @@ -35,36 +27,6 @@ ConfigManager.prototype.getConfig = function () { return data.config } -ConfigManager.prototype.setRpcTarget = function (rpcUrl) { - var config = this.getConfig() - config.provider = { - type: 'rpc', - rpcTarget: rpcUrl, - } - this.setConfig(config) -} - -ConfigManager.prototype.setProviderType = function (type) { - var config = this.getConfig() - config.provider = { - type: type, - } - this.setConfig(config) -} - -ConfigManager.prototype.useEtherscanProvider = function () { - var config = this.getConfig() - config.provider = { - type: 'etherscan', - } - this.setConfig(config) -} - -ConfigManager.prototype.getProvider = function () { - var config = this.getConfig() - return config.provider -} - ConfigManager.prototype.setData = function (data) { this.store.putState(data) } @@ -139,35 +101,6 @@ ConfigManager.prototype.getSeedWords = function () { return data.seedWords } -ConfigManager.prototype.getCurrentRpcAddress = function () { - var provider = this.getProvider() - if (!provider) return null - switch (provider.type) { - - case 'mainnet': - return MAINNET_RPC - - case 'testnet': - return TESTNET_RPC - - case 'morden': - return MORDEN_RPC - - case 'kovan': - return KOVAN_RPC - - case 'rinkeby': - return RINKEBY_RPC - - default: - return provider && provider.rpcTarget ? provider.rpcTarget : TESTNET_RPC - } -} - -// -// Tx -// - ConfigManager.prototype.getTxList = function () { var data = this.getData() if (data.transactions !== undefined) { diff --git a/app/scripts/lib/tx-utils.js b/app/scripts/lib/tx-utils.js index 084ca3721..76b311653 100644 --- a/app/scripts/lib/tx-utils.js +++ b/app/scripts/lib/tx-utils.js @@ -1,5 +1,4 @@ const async = require('async') -const EthQuery = require('eth-query') const ethUtil = require('ethereumjs-util') const Transaction = require('ethereumjs-tx') const normalize = require('eth-sig-util').normalize @@ -7,15 +6,14 @@ const BN = ethUtil.BN /* tx-utils are utility methods for Transaction manager -its passed a provider and that is passed to ethquery +its passed ethquery and used to do things like calculate gas of a tx. */ module.exports = class txProviderUtils { - constructor (provider) { - this.provider = provider - this.query = new EthQuery(provider) + constructor (ethQuery) { + this.query = ethQuery } analyzeGasUsage (txMeta, cb) { |