Skip to content

Commit

Permalink
#11 Adjust getBalanceOfAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
ceres3idoo committed Feb 22, 2019
1 parent a27c999 commit 2d672a2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/services/Erc20TokenService.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ class Erc20TokenService extends BaseTransactionService {

return this.web3.toBigNumber(allowance).toString(10)
}

/**
* It gets balance of an erc20 token.
*
* @param {String} personalWalletAddress The personal wallet address, owner of the (EOA).
* @throws {InvalidEthereumAddress} If personalWalletAddress or the tokenAddress is not a valid ethereum address.
*/
async getBalanceOfAsync(personalWalletAddress) {
this.checkEtherumAddress(personalWalletAddress)

const transactionObjectDraft = this.transactionBuilder.buildGetBalanceOfTransactionDraft(
personalWalletAddress,
)
const assetBalance = await this.transactionLib.call(transactionObjectDraft)
return this.web3.toBigNumber(assetBalance).toString(10)
}
}

module.exports = Erc20TokenService

0 comments on commit 2d672a2

Please sign in to comment.