accountBalance static method
Future<Tokens>
accountBalance({
- required AgentFactory agent,
- required String accountIdOrPrincipal,
- SignIdentity? identity,
Implementation
static Future<Tokens> accountBalance({
required AgentFactory agent,
required String accountIdOrPrincipal,
SignIdentity? identity,
}) async {
try {
var ledgerInstance = Ledger.hook(agent)..setIdentity(identity);
var accountId = isHexString(accountIdOrPrincipal)
? (accountIdOrPrincipal).toU8a().toList()
: Principal.fromText(accountIdOrPrincipal).toAccountID().toList();
var res = await ledgerInstance.agent.actor!
.getFunc(LedgerMethods.accountBalance)!(
[AccountBalanceArgsNew(account: accountId).toJson()]);
if (res != null) {
return Tokens.fromMap(res);
}
throw "Cannot get count but $res";
} catch (e) {
rethrow;
}
}