J’ai trouvé comment utiliser OnlineClient
dans subxt avec le dernier bloc :
async fn new_client(url: &str) -> (Client, Hash, BlockNumber) {
let client = subxt::backend::rpc::RpcClient::from_insecure_url(url).await.unwrap();
let backend = subxt::backend::legacy::LegacyBackend::builder().build(client);
let best_block = backend.stream_best_block_headers().await.unwrap().next().await.unwrap().unwrap();
let (genesis_hash, runtime_version, metadata) = futures::future::join3(
backend.genesis_hash(),
backend.current_runtime_version(),
backend.legacy_metadata(best_block.1.hash()),
)
.await;
(Client::from_backend_with(genesis_hash.unwrap(), runtime_version.unwrap(), metadata.unwrap(), std::sync::Arc::new(backend)).unwrap(), best_block.1.hash(), best_block.0.number)
}