use error::Error;
use jsonrpsee::proc_macros::rpc;
use sc_transaction_pool_api::TransactionStatus;
use sp_core::Bytes;
pub mod error;
pub mod hash;
#[derive(serde::Serialize, serde::Deserialize, Clone)]
pub struct GeneratedSessionKeys {
pub keys: Bytes,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub proof: Option<Bytes>,
}
#[rpc(client, server)]
pub trait AuthorApi<Hash, BlockHash> {
#[method(name = "author_submitExtrinsic")]
async fn submit_extrinsic(&self, extrinsic: Bytes) -> Result<Hash, Error>;
#[method(name = "author_insertKey", with_extensions)]
fn insert_key(&self, key_type: String, suri: String, public: Bytes) -> Result<(), Error>;
#[method(name = "author_rotateKeys", with_extensions)]
fn rotate_keys(&self) -> Result<Bytes, Error>;
#[method(name = "author_rotateKeysWithOwner", with_extensions)]
fn rotate_keys_with_owner(&self, owner: Bytes) -> Result<GeneratedSessionKeys, Error>;
#[method(name = "author_hasSessionKeys", with_extensions)]
fn has_session_keys(&self, session_keys: Bytes) -> Result<bool, Error>;
#[method(name = "author_hasKey", with_extensions)]
fn has_key(&self, public_key: Bytes, key_type: String) -> Result<bool, Error>;
#[method(name = "author_pendingExtrinsics")]
fn pending_extrinsics(&self) -> Result<Vec<Bytes>, Error>;
#[method(name = "author_removeExtrinsic", with_extensions)]
async fn remove_extrinsic(
&self,
bytes_or_hash: Vec<hash::ExtrinsicOrHash<Hash>>,
) -> Result<Vec<Hash>, Error>;
#[subscription(
name = "author_submitAndWatchExtrinsic" => "author_extrinsicUpdate",
unsubscribe = "author_unwatchExtrinsic",
item = TransactionStatus<Hash, BlockHash>,
)]
fn watch_extrinsic(&self, bytes: Bytes);
}