use thruput_xdr::contract::ContractEntrypointID;
use thruput_xdr::types::ContractAddress;
use xdrs::{ReadXDROwned, WriteXDR};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MethodEffect {
Pure,
ReadOnly,
StateChanging,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct RemoteMethod {
pub interface: Option<&'static str>,
pub version: &'static str,
pub name: &'static str,
pub entrypoint: ContractEntrypointID,
pub effect: Option<MethodEffect>,
}
impl RemoteMethod {
pub fn is_read_only(&self) -> bool {
matches!(
self.effect,
Some(MethodEffect::Pure | MethodEffect::ReadOnly)
)
}
}
pub trait RemoteInvoker {
type Call<R>;
type View<R>;
fn call<R, A>(
&self,
target: &ContractAddress,
method: RemoteMethod,
args: &A,
) -> Self::Call<R>
where
R: ReadXDROwned,
A: WriteXDR + ?Sized;
fn view<R, A>(
&self,
target: &ContractAddress,
method: RemoteMethod,
args: &A,
) -> Self::View<R>
where
R: ReadXDROwned,
A: WriteXDR + ?Sized;
}