muta_protocol/traits/
api.rs1use async_trait::async_trait;
2
3use crate::traits::{Context, ExecResp};
4use crate::types::{Address, Epoch, Hash, Receipt, SignedTransaction};
5use crate::ProtocolResult;
6
7#[async_trait]
8pub trait APIAdapter: Send + Sync {
9 async fn insert_signed_txs(
10 &self,
11 ctx: Context,
12 signed_tx: SignedTransaction,
13 ) -> ProtocolResult<()>;
14
15 async fn get_epoch_by_id(&self, ctx: Context, epoch_id: Option<u64>) -> ProtocolResult<Epoch>;
16
17 async fn get_receipt_by_tx_hash(&self, ctx: Context, tx_hash: Hash) -> ProtocolResult<Receipt>;
18
19 async fn get_transaction_by_hash(
20 &self,
21 ctx: Context,
22 tx_hash: Hash,
23 ) -> ProtocolResult<SignedTransaction>;
24
25 async fn query_service(
26 &self,
27 ctx: Context,
28 epoch_id: u64,
29 cycles_limit: u64,
30 cycles_price: u64,
31 caller: Address,
32 service_name: String,
33 method: String,
34 payload: String,
35 ) -> ProtocolResult<ExecResp>;
36}