aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers/transactions/index.js
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2018-04-20 02:29:26 +0800
committerfrankiebee <frankie.diamond@gmail.com>2018-04-20 02:46:15 +0800
commiteeb9390de81ce6fc92247d5c499e991dce8330bd (patch)
tree400f07cb6028e6e1f8ae5328d1c5544277de837f /app/scripts/controllers/transactions/index.js
parent943eea043cc40ea42ffe757a7115ccbc5585b37b (diff)
downloadtangerine-wallet-browser-eeb9390de81ce6fc92247d5c499e991dce8330bd.tar.gz
tangerine-wallet-browser-eeb9390de81ce6fc92247d5c499e991dce8330bd.tar.zst
tangerine-wallet-browser-eeb9390de81ce6fc92247d5c499e991dce8330bd.zip
meta - transactions - docs yo!
Diffstat (limited to 'app/scripts/controllers/transactions/index.js')
-rw-r--r--app/scripts/controllers/transactions/index.js27
1 files changed, 16 insertions, 11 deletions
diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js
index c81251cd2..d7287450b 100644
--- a/app/scripts/controllers/transactions/index.js
+++ b/app/scripts/controllers/transactions/index.js
@@ -25,14 +25,15 @@ const txUtils = require('./lib/util')
@param {object} opts -
- - initState, initial transaction list default is an empty array<br>
- - networkStore, an observable store for network number<br>
- - blockTracker,<br>
- - provider,<br>
- - signTransaction, function the signs an ethereumjs-tx<br>
- - getGasPrice, optional gas price calculator<br>
- - txHistoryLimit, number *optional* for limiting how many transactions are in state <br>
- - preferencesStore,
+ @property {object} opts.initState initial transaction list default is an empty array
+ @property {Object} opts.networkStore an observable store for network number
+ @property {Object} opts.blockTracker
+ @property {Object} opts.provider
+ @property {Object} opts.signTransaction function the signs an ethereumjs-tx
+ @property {function} opts.getGasPrice optional gas price calculator
+ @property {function} opts.signTransaction ethTx signer that returns a rawTx
+ @property {number} opts.txHistoryLimit number *optional* for limiting how many transactions are in state
+ @property {Object} opts.preferencesStore
@class
*/
@@ -50,12 +51,12 @@ class TransactionController extends EventEmitter {
this.query = new EthQuery(this.provider)
this.txGasUtil = new TxGasUtil(this.provider)
+ this._mapMethods()
this.txStateManager = new TransactionStateManager({
initState: opts.initState,
txHistoryLimit: opts.txHistoryLimit,
getNetwork: this.getNetwork.bind(this),
})
- this._mapMethods()
this._onBootCleanUp()
this.store = this.txStateManager.store
@@ -92,7 +93,10 @@ class TransactionController extends EventEmitter {
}
}
-/** Adds a tx to the txlist */
+/**
+ Adds a tx to the txlist
+ @emits ${txMeta.id}:unapproved
+*/
addTx (txMeta) {
this.txStateManager.addTx(txMeta)
this.emit(`${txMeta.id}:unapproved`, txMeta)
@@ -172,6 +176,7 @@ add a new unapproved transaction to the pipeline
async addTxGasDefaults (txMeta) {
const txParams = txMeta.txParams
// ensure value
+ txParams.value = txParams.value ? ethUtil.addHexPrefix(value) : '0x0',
txMeta.gasPriceSpecified = Boolean(txParams.gasPrice)
let gasPrice = txParams.gasPrice
if (!gasPrice) {
@@ -412,4 +417,4 @@ add a new unapproved transaction to the pipeline
}
}
-module.exports = TransactionController \ No newline at end of file
+module.exports = TransactionController