diff options
author | Frances Pangilinan <frankie.diamond@gmail.com> | 2016-12-21 05:12:14 +0800 |
---|---|---|
committer | Frances Pangilinan <frankie.diamond@gmail.com> | 2016-12-22 05:41:49 +0800 |
commit | 1ebcbe296b060c9cf431d485d7bb84f696edbdf5 (patch) | |
tree | 0b9cf46894b54f61476b2ebc74d069cab6dc46cd /app/scripts/keyring-controller.js | |
parent | 6e78494846c9032fbf1264a0225c0df4df0867cb (diff) | |
download | tangerine-wallet-browser-1ebcbe296b060c9cf431d485d7bb84f696edbdf5.tar tangerine-wallet-browser-1ebcbe296b060c9cf431d485d7bb84f696edbdf5.tar.gz tangerine-wallet-browser-1ebcbe296b060c9cf431d485d7bb84f696edbdf5.tar.bz2 tangerine-wallet-browser-1ebcbe296b060c9cf431d485d7bb84f696edbdf5.tar.lz tangerine-wallet-browser-1ebcbe296b060c9cf431d485d7bb84f696edbdf5.tar.xz tangerine-wallet-browser-1ebcbe296b060c9cf431d485d7bb84f696edbdf5.tar.zst tangerine-wallet-browser-1ebcbe296b060c9cf431d485d7bb84f696edbdf5.zip |
Migrate all tx mutation code out of keyring controller and
Fix up txManager to reflect code review requests
Diffstat (limited to 'app/scripts/keyring-controller.js')
-rw-r--r-- | app/scripts/keyring-controller.js | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js index 64c2ac933..0a06e4a5d 100644 --- a/app/scripts/keyring-controller.js +++ b/app/scripts/keyring-controller.js @@ -1,6 +1,5 @@ const ethUtil = require('ethereumjs-util') const bip39 = require('bip39') -const Transaction = require('ethereumjs-tx') const EventEmitter = require('events').EventEmitter const filter = require('promise-filter') const normalize = require('./lib/sig-util').normalize @@ -321,28 +320,14 @@ module.exports = class KeyringController extends EventEmitter { // // This method signs tx and returns a promise for // TX Manager to update the state after signing - signTransaction (txParams, cb) { + signTransaction (ethTx, selectedAddress, txId, cb) { try { - const address = normalize(txParams.from) + const address = normalize(selectedAddress) return this.getKeyringForAccount(address) .then((keyring) => { - // Handle gas pricing - var gasMultiplier = this.configManager.getGasMultiplier() || 1 - var gasPrice = new BN(ethUtil.stripHexPrefix(txParams.gasPrice), 16) - gasPrice = gasPrice.mul(new BN(gasMultiplier * 100, 10)).div(new BN(100, 10)) - txParams.gasPrice = ethUtil.intToHex(gasPrice.toNumber()) - - // normalize values - txParams.to = normalize(txParams.to) - txParams.from = normalize(txParams.from) - txParams.value = normalize(txParams.value) - txParams.data = normalize(txParams.data) - txParams.gasLimit = normalize(txParams.gasLimit || txParams.gas) - txParams.nonce = normalize(txParams.nonce) - const tx = new Transaction(txParams) - return keyring.signTransaction(address, tx) + return keyring.signTransaction(address, ethTx) }).then((tx) => { - return {tx, txParams, cb} + this.emit(`${txId}:signed`, {tx, txId, cb}) }) } catch (e) { cb(e) |