diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/lib/config-manager.js | 7 | ||||
-rw-r--r-- | app/scripts/lib/tx-utils.js | 17 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 23 |
3 files changed, 11 insertions, 36 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index 93501c859..3a1f12ac0 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -1,7 +1,6 @@ const Migrator = require('pojo-migrator') const MetamaskConfig = require('../config.js') const migrations = require('./migrations') -const rp = require('request-promise') const ethUtil = require('ethereumjs-util') const normalize = require('./sig-util').normalize @@ -301,9 +300,9 @@ ConfigManager.prototype.getCurrentFiat = function () { ConfigManager.prototype.updateConversionRate = function () { var data = this.getData() - return rp(`https://www.cryptonator.com/api/ticker/eth-${data.fiatCurrency}`) - .then((response) => { - const parsedResponse = JSON.parse(response) + return fetch(`https://www.cryptonator.com/api/ticker/eth-${data.fiatCurrency}`) + .then(response => response.json()) + .then((parsedResponse) => { this.setConversionPrice(parsedResponse.ticker.price) this.setConversionDate(parsedResponse.timestamp) }).catch((err) => { diff --git a/app/scripts/lib/tx-utils.js b/app/scripts/lib/tx-utils.js index a976173f5..d1fb98f42 100644 --- a/app/scripts/lib/tx-utils.js +++ b/app/scripts/lib/tx-utils.js @@ -20,7 +20,6 @@ module.exports = class txProviderUtils { if (err) return cb(err) async.waterfall([ self.estimateTxGas.bind(self, txData, block.gasLimit), - self.checkForTxGasError.bind(self, txData), self.setTxGas.bind(self, txData, block.gasLimit), ], cb) }) @@ -38,22 +37,10 @@ module.exports = class txProviderUtils { this.query.estimateGas(txParams, cb) } - checkForTxGasError (txData, estimatedGasHex, cb) { + setTxGas (txData, blockGasLimitHex, estimatedGasHex, cb) { txData.estimatedGas = estimatedGasHex - // all gas used - must be an error - if (estimatedGasHex === txData.txParams.gas) { - txData.simulationFails = true - } - cb() - } - - setTxGas (txData, blockGasLimitHex, cb) { const txParams = txData.txParams - // if OOG, nothing more to do - if (txData.simulationFails) { - cb() - return - } + // if gasLimit was specified and doesnt OOG, // use original specified amount if (txData.gasLimitSpecified) { diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index ae7aee9e3..c0b9b753c 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -13,6 +13,7 @@ const extension = require('./lib/extension') const autoFaucet = require('./lib/auto-faucet') const nodeify = require('./lib/nodeify') const IdStoreMigrator = require('./lib/idStore-migrator') +const version = require('../manifest.json').version module.exports = class MetamaskController extends EventEmitter { @@ -176,6 +177,10 @@ module.exports = class MetamaskController extends EventEmitter { const keyringController = this.keyringController var providerOpts = { + static: { + eth_syncing: false, + web3_clientVersion: `MetaMask/v${version}`, + }, rpcUrl: this.configManager.getCurrentRpcAddress(), // account mgmt getAccounts: (cb) => { @@ -224,37 +229,21 @@ module.exports = class MetamaskController extends EventEmitter { initPublicConfigStore () { // get init state - var initPublicState = extend( - keyringControllerToPublic(this.keyringController.getState()), - configToPublic(this.configManager.getConfig()) - ) - + var initPublicState = configToPublic(this.configManager.getConfig()) var publicConfigStore = new HostStore(initPublicState) // subscribe to changes this.configManager.subscribe(function (state) { storeSetFromObj(publicConfigStore, configToPublic(state)) }) - this.keyringController.on('update', () => { - const state = this.keyringController.getState() - storeSetFromObj(publicConfigStore, keyringControllerToPublic(state)) - this.sendUpdate() - }) this.keyringController.on('newAccount', (account) => { autoFaucet(account) }) - // keyringController substate - function keyringControllerToPublic (state) { - return { - selectedAccount: state.selectedAccount, - } - } // config substate function configToPublic (state) { return { - provider: state.provider, selectedAccount: state.selectedAccount, } } |