mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
Add validation to balance constructor
This commit is contained in:
parent
7032edf32b
commit
ea79eca8eb
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user