diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-10-19 03:21:22 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-10-19 03:21:22 +0800 |
commit | ea79eca8eb19cf7ce375e03ad8cbde010299936c (patch) | |
tree | 44958d794fba6646608e5ed93f1a64bff3d50764 /app/scripts | |
parent | 7032edf32b43e94a7f58c7bcb068da63fa6bda1b (diff) | |
download | tangerine-wallet-browser-ea79eca8eb19cf7ce375e03ad8cbde010299936c.tar tangerine-wallet-browser-ea79eca8eb19cf7ce375e03ad8cbde010299936c.tar.gz tangerine-wallet-browser-ea79eca8eb19cf7ce375e03ad8cbde010299936c.tar.bz2 tangerine-wallet-browser-ea79eca8eb19cf7ce375e03ad8cbde010299936c.tar.lz tangerine-wallet-browser-ea79eca8eb19cf7ce375e03ad8cbde010299936c.tar.xz tangerine-wallet-browser-ea79eca8eb19cf7ce375e03ad8cbde010299936c.tar.zst tangerine-wallet-browser-ea79eca8eb19cf7ce375e03ad8cbde010299936c.zip |
Add validation to balance constructor
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/controllers/balance.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/scripts/controllers/balance.js b/app/scripts/controllers/balance.js index 4fa4c78fe..f83f294cc 100644 --- a/app/scripts/controllers/balance.js +++ b/app/scripts/controllers/balance.js @@ -5,7 +5,9 @@ const BN = require('ethereumjs-util').BN class BalanceController { constructor (opts = {}) { + this._validateParams(opts) const { address, accountTracker, txController, blockTracker } = opts + this.address = address this.accountTracker = accountTracker this.txController = txController @@ -65,6 +67,14 @@ class BalanceController { return pending } + _validateParams (opts) { + const { address, accountTracker, txController, blockTracker } = opts + if (!address || !accountTracker || !txController || !blockTracker) { + const error = 'Cannot construct a balance checker without address, accountTracker, txController, and blockTracker.' + throw new Error(error) + } + } + } module.exports = BalanceController |