aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2018-04-05 05:56:30 +0800
committerfrankiebee <frankie.diamond@gmail.com>2018-04-05 05:57:27 +0800
commit245c01bc0fed585c4ac8ed05edf7ebe1a65de80b (patch)
tree72dd6dbf4c97409b54bfe857bbe8cb18b6dc7849
parent6ab938546c3b41d188df62f0cc180aa9b6c72cf6 (diff)
downloadtangerine-wallet-browser-245c01bc0fed585c4ac8ed05edf7ebe1a65de80b.tar
tangerine-wallet-browser-245c01bc0fed585c4ac8ed05edf7ebe1a65de80b.tar.gz
tangerine-wallet-browser-245c01bc0fed585c4ac8ed05edf7ebe1a65de80b.tar.bz2
tangerine-wallet-browser-245c01bc0fed585c4ac8ed05edf7ebe1a65de80b.tar.lz
tangerine-wallet-browser-245c01bc0fed585c4ac8ed05edf7ebe1a65de80b.tar.xz
tangerine-wallet-browser-245c01bc0fed585c4ac8ed05edf7ebe1a65de80b.tar.zst
tangerine-wallet-browser-245c01bc0fed585c4ac8ed05edf7ebe1a65de80b.zip
transactions - make #_validateTxParams not async and "linting" wink wink nudge nudge
-rw-r--r--app/scripts/controllers/transactions.js19
-rw-r--r--test/unit/tx-controller-test.js19
2 files changed, 20 insertions, 18 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js
index 9568fcbb9..a73a8b36d 100644
--- a/app/scripts/controllers/transactions.js
+++ b/app/scripts/controllers/transactions.js
@@ -185,7 +185,7 @@ module.exports = class TransactionController extends EventEmitter {
async addUnapprovedTransaction (txParams) {
// validate
- await this._validateTxParams(txParams)
+ this._validateTxParams(txParams)
this._normalizeTxParams(txParams)
// construct txMeta
let txMeta = this.txStateManager.generateTxMeta({txParams})
@@ -317,13 +317,18 @@ module.exports = class TransactionController extends EventEmitter {
_normalizeTxParams (txParams) {
delete txParams.chainId
- if ( !txParams.to ) delete txParams.to
- else txParams.to = ethUtil.addHexPrefix(txParams.to)
-
+ if ( !txParams.to ) {
+ delete txParams.to
+ } else {
+ txParams.to = ethUtil.addHexPrefix(txParams.to)
+ }
txParams.from = ethUtil.addHexPrefix(txParams.from).toLowerCase()
- if (!txParams.data) delete txParams.data
- else txParams.data = ethUtil.addHexPrefix(txParams.data)
+ if (!txParams.data) {
+ delete txParams.data
+ } else {
+ txParams.data = ethUtil.addHexPrefix(txParams.data)
+ }
if (txParams.value) txParams.value = ethUtil.addHexPrefix(txParams.value)
@@ -331,7 +336,7 @@ module.exports = class TransactionController extends EventEmitter {
if (txParams.gasPrice) txParams.gas = ethUtil.addHexPrefix(txParams.gas)
}
- async _validateTxParams (txParams) {
+ _validateTxParams (txParams) {
this._validateFrom(txParams)
this._validateRecipient(txParams)
if ('value' in txParams) {
diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js
index 81d32ae29..3fec9758f 100644
--- a/test/unit/tx-controller-test.js
+++ b/test/unit/tx-controller-test.js
@@ -210,28 +210,25 @@ describe('Transaction Controller', function () {
})
})
- describe('#validateTxParams', function () {
- it('does not throw for positive values', function (done) {
+ describe('#_validateTxParams', function () {
+ it('does not throw for positive values', function () {
var sample = {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
value: '0x01',
}
- txController._validateTxParams(sample).then(() => {
- done()
- }).catch(done)
+ txController._validateTxParams(sample)
})
- it('returns error for negative values', function (done) {
+ it('returns error for negative values', function () {
var sample = {
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
value: '-0x01',
}
- txController._validateTxParams(sample)
- .then(() => done('expected to thrown on negativity values but didn\'t'))
- .catch((err) => {
+ try {
+ txController._validateTxParams(sample)
+ } catch (err) {
assert.ok(err, 'error')
- done()
- })
+ }
})
})