fetchStandardData method
Fetch all standard chain data in parallel
This method fetches commonly needed chain data in a single batch for efficiency. Returns null for any values that shouldn't be fetched (based on skipFlags).
Implementation
Future<ChainData> fetchStandardData({final String? accountAddress}) async {
final futures = <Future<dynamic>>[
_chainApi.getBlockHash(blockNumber: 0),
fetchLatestHeader(),
_stateApi.getRuntimeVersion(),
accountAddress != null ? _systemApi.accountNextIndex(accountAddress) : Future.value(null),
];
try {
final results = await Future.wait(futures);
final genesisHash = results[0] as Uint8List;
final header = results[1] as BlockHeader;
final runtime = results[2] as RuntimeVersion;
final nonce = results[3] as int?;
return ChainData(
genesisHash: genesisHash,
blockHash: header.hash,
blockNumber: header.number,
specVersion: runtime.specVersion,
transactionVersion: runtime.transactionVersion,
nonce: nonce,
);
} catch (e) {
throw FetchError('Failed to fetch chain data: $e');
}
}