#![deny(missing_docs)]
#[macro_use]
pub mod util;
pub mod abis;
mod base;
pub mod contract;
#[cfg(feature = "ethereum")]
pub mod ethereum;
mod extensions;
pub mod formats;
pub mod graphql;
pub mod linera_base_types;
mod log;
pub mod service;
#[cfg(with_testing)]
pub mod test;
pub mod views;
use std::fmt::Debug;
pub use bcs;
pub use linera_base::{
abi,
data_types::{
CanonicalBTreeMap, CanonicalBTreeSet, NonCanonicalBTreeMap, NonCanonicalBTreeSet,
Resources, SendMessageRequest,
},
ensure, http, task_processor,
};
use linera_base::{
abi::{ContractAbi, ServiceAbi, WithContractAbi, WithServiceAbi},
data_types::StreamUpdate,
};
use serde::{de::DeserializeOwned, Serialize};
pub use serde_json;
#[doc(hidden)]
pub use self::{contract::export_contract, service::export_service};
pub use self::{
contract::ContractRuntime,
extensions::{FromBcsBytes, ToBcsBytes},
log::{ContractLogger, ServiceLogger},
service::ServiceRuntime,
views::{KeyValueStore, ViewStorageContext},
};
#[allow(async_fn_in_trait)]
pub trait Contract: WithContractAbi + ContractAbi + Sized {
type Message: Serialize + DeserializeOwned + Debug;
type Parameters: Serialize + DeserializeOwned + Clone + Debug;
type InstantiationArgument: Serialize + DeserializeOwned + Debug;
type EventValue: Serialize + DeserializeOwned + Debug;
async fn load(runtime: ContractRuntime<Self>) -> Self;
async fn instantiate(&mut self, argument: Self::InstantiationArgument);
async fn execute_operation(&mut self, operation: Self::Operation) -> Self::Response;
async fn execute_message(&mut self, message: Self::Message);
async fn process_streams(&mut self, _updates: Vec<StreamUpdate>) {}
async fn store(self);
}
#[allow(async_fn_in_trait)]
pub trait Service: WithServiceAbi + ServiceAbi + Sized {
type Parameters: Serialize + DeserializeOwned + Send + Sync + Clone + Debug + 'static;
async fn new(runtime: ServiceRuntime<Self>) -> Self;
async fn handle_query(&self, query: Self::Query) -> Self::QueryResponse;
}