diff options
Diffstat (limited to 'packages/contracts/util/balances.ts')
-rw-r--r-- | packages/contracts/util/balances.ts | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/packages/contracts/util/balances.ts b/packages/contracts/util/balances.ts index ef4abd7bf..fce15db6d 100644 --- a/packages/contracts/util/balances.ts +++ b/packages/contracts/util/balances.ts @@ -7,24 +7,24 @@ import {BalancesByOwner, ContractInstance} from './types'; bigNumberConfigs.configure(); export class Balances { - private tokenContractInstances: ContractInstance[]; - private ownerAddresses: string[]; - constructor(tokenContractInstances: ContractInstance[], ownerAddresses: string[]) { - this.tokenContractInstances = tokenContractInstances; - this.ownerAddresses = ownerAddresses; - } - public async getAsync(): Promise<BalancesByOwner> { - const balancesByOwner: BalancesByOwner = {}; - for (const tokenContractInstance of this.tokenContractInstances) { - for (const ownerAddress of this.ownerAddresses) { - let balance = await tokenContractInstance.balanceOf(ownerAddress); - balance = new BigNumber(balance); - if (_.isUndefined(balancesByOwner[ownerAddress])) { - balancesByOwner[ownerAddress] = {}; + private tokenContractInstances: ContractInstance[]; + private ownerAddresses: string[]; + constructor(tokenContractInstances: ContractInstance[], ownerAddresses: string[]) { + this.tokenContractInstances = tokenContractInstances; + this.ownerAddresses = ownerAddresses; + } + public async getAsync(): Promise<BalancesByOwner> { + const balancesByOwner: BalancesByOwner = {}; + for (const tokenContractInstance of this.tokenContractInstances) { + for (const ownerAddress of this.ownerAddresses) { + let balance = await tokenContractInstance.balanceOf(ownerAddress); + balance = new BigNumber(balance); + if (_.isUndefined(balancesByOwner[ownerAddress])) { + balancesByOwner[ownerAddress] = {}; + } + balancesByOwner[ownerAddress][tokenContractInstance.address] = balance; + } } - balancesByOwner[ownerAddress][tokenContractInstance.address] = balance; - } + return balancesByOwner; } - return balancesByOwner; - } } |