loadAccountData method
Loads account balance and avatar. Returns true if it was able to actually load data (i.e. there is a selected chain and session)
Implementation
@override
Future<void> loadAccountData() async {
// If there is no selected chain or session, stop. No account to load in.
if (_currentSelectedChainId == null ||
_currentSession == null ||
_currentSession?.address == null) {
return;
}
// Get the chain balance.
_chainBalance = await blockchainService.instance.rpcRequest(
chainId: '${CoreConstants.namespace}:$_currentSelectedChainId',
request: SessionRequestParams(
method: 'eth_getBalance',
params: [_currentSession!.address!, 'latest'],
),
);
final tokenName = selectedChain?.currency ?? '';
balanceNotifier.value = '$_chainBalance $tokenName';
// Get the avatar, each chainId is just a number in string form.
try {
final blockchainId = await blockchainService.instance.getIdentity(
_currentSession!.address!,
);
_avatarUrl = blockchainId.avatar;
_logger.i('[$runtimeType] loadAccountData');
} catch (e) {
_logger.e('[$runtimeType] loadAccountData $e');
}
_notify();
}