Struct abstract_api::state::ApiContract
source · [−]pub struct ApiContract<'a, Request: Serialize + DeserializeOwned, Error: From<StdError> + From<ApiError>, Receive: Serialize + DeserializeOwned = Empty> {
pub traders: Map<'a, Addr, HashSet<Addr>>,
pub base_state: Item<'a, ApiState>,
pub version: Item<'a, ContractVersion>,
pub target_os: Option<Core>,
pub dependencies: &'static [&'static str],
/* private fields */
}Expand description
The state variables for our ApiContract.
Fields
traders: Map<'a, Addr, HashSet<Addr>>base_state: Item<'a, ApiState>version: Item<'a, ContractVersion>Stores the API version
target_os: Option<Core>dependencies: &'static [&'static str]Implementations
sourceimpl<'a, T: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> ApiContract<'a, T, E>
impl<'a, T: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> ApiContract<'a, T, E>
sourcepub fn instantiate(
deps: DepsMut<'_>,
_env: Env,
_info: MessageInfo,
msg: BaseInstantiateMsg,
module_name: &str,
module_version: &str,
_api_dependencies: Vec<String>
) -> StdResult<Self>
pub fn instantiate(
deps: DepsMut<'_>,
_env: Env,
_info: MessageInfo,
msg: BaseInstantiateMsg,
module_name: &str,
module_version: &str,
_api_dependencies: Vec<String>
) -> StdResult<Self>
Instantiate the API
sourceimpl<'a, T: Serialize + DeserializeOwned, C: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> ApiContract<'a, T, E, C>
impl<'a, T: Serialize + DeserializeOwned, C: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> ApiContract<'a, T, E, C>
Where we dispatch the queries for the ApiContract
These ApiQueryMsg declarations can be found in abstract_os::common_module::add_on_msg
sourceimpl<'a, T: Serialize + DeserializeOwned, R: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> ApiContract<'a, T, E, R>
impl<'a, T: Serialize + DeserializeOwned, R: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> ApiContract<'a, T, E, R>
Constructor
pub const fn new() -> Self
sourcepub const fn with_ibc_callbacks(
self,
callbacks: &'a [(&'static str, IbcCallbackHandlerFn<Self, E>)]
) -> Self
pub const fn with_ibc_callbacks(
self,
callbacks: &'a [(&'static str, IbcCallbackHandlerFn<Self, E>)]
) -> Self
add IBC callback handler to contract
pub const fn with_receive(
self,
receive_handler: ReceiveHandlerFn<Self, R, E>
) -> Self
sourcepub const fn with_dependencies(
self,
dependencies: &'static [&'static str]
) -> Self
pub const fn with_dependencies(
self,
dependencies: &'static [&'static str]
) -> Self
add dependencies to the contract
pub fn state(&self, store: &dyn Storage) -> StdResult<ApiState>
pub fn version(&self, store: &dyn Storage) -> StdResult<ContractVersion>
pub fn target(&self) -> Result<&Addr, ApiError>
Trait Implementations
sourceimpl<'a, T: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>, C: Serialize + DeserializeOwned> AbstractExecute for ApiContract<'a, T, E, C>
impl<'a, T: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>, C: Serialize + DeserializeOwned> AbstractExecute for ApiContract<'a, T, E, C>
type RequestMsg = T
type ExecuteMsg<P> = ExecuteMsg<T, C>
type ContractError = E
sourcefn execute(
self,
deps: DepsMut<'_>,
env: Env,
info: MessageInfo,
msg: Self::ExecuteMsg<Self::RequestMsg>,
request_handler: impl FnOnce(DepsMut<'_>, Env, MessageInfo, Self, T) -> Result<Response, E>
) -> Result<Response, Self::ContractError>
fn execute(
self,
deps: DepsMut<'_>,
env: Env,
info: MessageInfo,
msg: Self::ExecuteMsg<Self::RequestMsg>,
request_handler: impl FnOnce(DepsMut<'_>, Env, MessageInfo, Self, T) -> Result<Response, E>
) -> Result<Response, Self::ContractError>
Takes request, sets destination and executes request handler
This fn is the only way to get an ApiContract instance which ensures the destination address is set correctly. Read more
sourceimpl<'a, T: Serialize + DeserializeOwned, C: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> Default for ApiContract<'a, T, E, C>
impl<'a, T: Serialize + DeserializeOwned, C: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> Default for ApiContract<'a, T, E, C>
sourceimpl<T: Serialize + DeserializeOwned, C: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> Dependency for ApiContract<'_, T, E, C>
impl<T: Serialize + DeserializeOwned, C: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> Dependency for ApiContract<'_, T, E, C>
Implement the dependency functions for an API contract
sourceimpl<'a, T: Serialize + DeserializeOwned, C: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> IbcCallbackEndpoint for ApiContract<'a, T, E, C>
impl<'a, T: Serialize + DeserializeOwned, C: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> IbcCallbackEndpoint for ApiContract<'a, T, E, C>
type ContractError = E
sourcefn callback_handler(
&self,
id: &str
) -> Option<IbcCallbackHandlerFn<Self, Self::ContractError>>
fn callback_handler(
&self,
id: &str
) -> Option<IbcCallbackHandlerFn<Self, Self::ContractError>>
Takes request, sets destination and executes request handler
This fn is the only way to get an ApiContract instance which ensures the destination address is set correctly. Read more
fn handle_ibc_callback(
self,
deps: DepsMut<'_, Empty>,
env: Env,
info: MessageInfo,
msg: IbcResponseMsg
) -> Result<Response<Empty>, Self::ContractError>
sourceimpl<T: Serialize + DeserializeOwned, C: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> MemoryOperation for ApiContract<'_, T, E, C>
impl<T: Serialize + DeserializeOwned, C: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> MemoryOperation for ApiContract<'_, T, E, C>
sourceimpl<T: Serialize + DeserializeOwned, C: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> OsExecute for ApiContract<'_, T, E, C>
impl<T: Serialize + DeserializeOwned, C: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>> OsExecute for ApiContract<'_, T, E, C>
Execute a set of CosmosMsgs on the proxy contract of an OS.
sourceimpl<'a, T: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>, R: Serialize + DeserializeOwned> ReceiveEndpoint for ApiContract<'a, T, E, R>
impl<'a, T: Serialize + DeserializeOwned, E: From<StdError> + From<ApiError>, R: Serialize + DeserializeOwned> ReceiveEndpoint for ApiContract<'a, T, E, R>
type ContractError = E
type ReceiveMsg = R
fn receive_handler(
&self
) -> Option<ReceiveHandlerFn<Self, Self::ReceiveMsg, Self::ContractError>>
fn handle_receive(
self,
deps: DepsMut<'_, Empty>,
env: Env,
info: MessageInfo,
msg: Self::ReceiveMsg
) -> Result<Response<Empty>, Self::ContractError>
Auto Trait Implementations
impl<'a, Request, Error, Receive> RefUnwindSafe for ApiContract<'a, Request, Error, Receive>where
Error: RefUnwindSafe,
Receive: RefUnwindSafe,
Request: RefUnwindSafe,
impl<'a, Request, Error, Receive> Send for ApiContract<'a, Request, Error, Receive>where
Error: Send,
Receive: Send,
Request: Send,
impl<'a, Request, Error, Receive> Sync for ApiContract<'a, Request, Error, Receive>where
Error: Sync,
Receive: Sync,
Request: Sync,
impl<'a, Request, Error, Receive> Unpin for ApiContract<'a, Request, Error, Receive>where
Error: Unpin,
Receive: Unpin,
Request: Unpin,
impl<'a, Request, Error, Receive> UnwindSafe for ApiContract<'a, Request, Error, Receive>where
Error: UnwindSafe,
Receive: UnwindSafe,
Request: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more