use super::{RuntimeApi, RuntimeApiClient};
use crate::{api::Result, rpc::Request};
use ac_primitives::config::Config;
#[cfg(all(not(feature = "sync-api"), not(feature = "std")))]
use alloc::boxed::Box;
use alloc::vec;
use sp_core::Encode;
#[maybe_async::maybe_async(?Send)]
pub trait AccountNonceApi: RuntimeApi {
type Index;
type AccountId;
async fn account_nonce(
&self,
account_id: Self::AccountId,
at_block: Option<Self::Hash>,
) -> Result<Self::Index>;
}
#[maybe_async::maybe_async(?Send)]
impl<T, Client> AccountNonceApi for RuntimeApiClient<T, Client>
where
T: Config,
Client: Request,
{
type Index = T::Index;
type AccountId = T::AccountId;
async fn account_nonce(
&self,
account_id: Self::AccountId,
at_block: Option<Self::Hash>,
) -> Result<Self::Index> {
self.runtime_call("AccountNonceApi_account_nonce", vec![account_id.encode()], at_block)
.await
}
}