getBalance method

Future<int> getBalance (BigInt accountNumber, MoacDefaultBlock block)

Get balance, the balance of the account of the given address.

Implementation

Future<int> getBalance(BigInt accountNumber, MoacDefaultBlock block) async {
  if (accountNumber == null) {
    throw ArgumentError.notNull("Moac::getBalance - accountNumber");
  }
  if (block == null) {
    throw ArgumentError.notNull("Moac::getBalance - block");
  }
  final String method = MoacRpcMethods.balance;
  final String blockString = block.getSelection();
  final List params = [
    MoacUtilities.bigIntegerToHex(accountNumber),
    blockString
  ];
  final res = await rpcClient.request(method, params);
  if (res != null && res.containsKey(moacResultKey)) {
    return MoacUtilities.hexToInt(res[moacResultKey]);
  }
  _processError(method, res);
  return null;
}