diff options
author | Frankie <frankie.diamond@gmail.com> | 2017-01-05 05:53:54 +0800 |
---|---|---|
committer | Frankie <frankie.diamond@gmail.com> | 2017-01-05 05:53:54 +0800 |
commit | f50e98350062970b0b6d3c142acd44d0830e7a33 (patch) | |
tree | c9429039e1c2f378fd69ed71cb457734f98db832 /app/scripts/transaction-manager.js | |
parent | c22da8450cf5014fb2bf3c96e0df88c70aa39465 (diff) | |
parent | b13c54682b75aaceba1ef37a4d97669f57e448a9 (diff) | |
download | tangerine-wallet-browser-f50e98350062970b0b6d3c142acd44d0830e7a33.tar tangerine-wallet-browser-f50e98350062970b0b6d3c142acd44d0830e7a33.tar.gz tangerine-wallet-browser-f50e98350062970b0b6d3c142acd44d0830e7a33.tar.bz2 tangerine-wallet-browser-f50e98350062970b0b6d3c142acd44d0830e7a33.tar.lz tangerine-wallet-browser-f50e98350062970b0b6d3c142acd44d0830e7a33.tar.xz tangerine-wallet-browser-f50e98350062970b0b6d3c142acd44d0830e7a33.tar.zst tangerine-wallet-browser-f50e98350062970b0b6d3c142acd44d0830e7a33.zip |
Merge branch 'TxManager' of https://github.com/MetaMask/metamask-plugin into TxManager
Diffstat (limited to 'app/scripts/transaction-manager.js')
-rw-r--r-- | app/scripts/transaction-manager.js | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/app/scripts/transaction-manager.js b/app/scripts/transaction-manager.js index fd136a51b..d426993a4 100644 --- a/app/scripts/transaction-manager.js +++ b/app/scripts/transaction-manager.js @@ -137,25 +137,33 @@ module.exports = class TransactionManager extends EventEmitter { } // formats txParams so the keyringController can sign it - formatTxForSigining (txParams, cb) { - var address = txParams.from - var metaTx = this.getTx(txParams.metamaskId) - var gasMultiplier = metaTx.gasMultiplier - 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 ethTx = new Transaction(txParams) - - // listener is assigned in metamaskController - this.emit(`${txParams.metamaskId}:formatted`, ethTx, address, txParams.metamaskId, cb) + formatTxForSigning (txParams, cb) { + this.getNetwork((err, networkId) => { + if (err) { + return cb(err) + } + + var address = txParams.from + var metaTx = this.getTx(txParams.metamaskId) + var gasMultiplier = metaTx.gasMultiplier + 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) + txParams.chainId = parseInt(networkId) + + const ethTx = new Transaction(txParams) + + // listener is assigned in metamaskController + this.emit(`${txParams.metamaskId}:formatted`, ethTx, address, txParams.metamaskId, cb) + }) } // receives a signed tx object and updates the tx hash |