Struct rhaki_cw_multi_test::ContractWrapper
source · pub struct ContractWrapper<T1, T2, T3, E1, E2, E3, C = Empty, Q = Empty, T4 = Empty, E4 = AnyError, E5 = AnyError, T6 = Empty, E6 = AnyError>where
T1: DeserializeOwned,
T2: DeserializeOwned,
T3: DeserializeOwned,
T4: DeserializeOwned,
T6: DeserializeOwned,
E1: Display + Debug + Send + Sync,
E2: Display + Debug + Send + Sync,
E3: Display + Debug + Send + Sync,
E4: Display + Debug + Send + Sync,
E5: Display + Debug + Send + Sync,
E6: Display + Debug + Send + Sync,
C: CustomMsg,
Q: CustomQuery + DeserializeOwned,{ /* private fields */ }
Expand description
This structure wraps the Contract trait implementor and provides generic access to the contract’s entry-points.
List of generic types used in ContractWrapper:
- T1 type of message passed to execute entry-point.
- T2 type of message passed to instantiate entry-point.
- T3 type of message passed to query entry-point.
- T4 type of message passed to sudo entry-point.
- instead of
T5, always theReply
type is used in reply entry-point. - T6 type of message passed to migrate entry-point.
- E1 type of error returned from execute entry-point.
- E2 type of error returned from instantiate entry-point.
- E3 type of error returned from query entry-point.
- E4 type of error returned from sudo entry-point.
- E5 type of error returned from reply entry-point.
- E6 type of error returned from migrate entry-point.
- C type of custom message returned from all entry-points except query.
- Q type of custom query in
Querier
passed as ‘Deps’ or ‘DepsMut’ to all entry-points.
The following table summarizes the purpose of all generic types used in ContractWrapper.
┌─────────────┬────────────────┬─────────────────────┬─────────┬─────────┬───────┬───────┐
│ Contract │ Contract │ │ │ │ │ │
│ entry-point │ wrapper │ Closure type │ Message │ Message │ Error │ Query │
│ │ member │ │ IN │ OUT │ OUT │ │
╞═════════════╪════════════════╪═════════════════════╪═════════╪═════════╪═══════╪═══════╡
│ (1) │ │ │ │ │ │ │
╞═════════════╪════════════════╪═════════════════════╪═════════╪═════════╪═══════╪═══════╡
│ execute │ execute_fn │ ContractClosure │ T1 │ C │ E1 │ Q │
├─────────────┼────────────────┼─────────────────────┼─────────┼─────────┼───────┼───────┤
│ instantiate │ instantiate_fn │ ContractClosure │ T2 │ C │ E2 │ Q │
├─────────────┼────────────────┼─────────────────────┼─────────┼─────────┼───────┼───────┤
│ query │ query_fn │ QueryClosure │ T3 │ Binary │ E3 │ Q │
├─────────────┼────────────────┼─────────────────────┼─────────┼─────────┼───────┼───────┤
│ sudo │ sudo_fn │ PermissionedClosure │ T4 │ C │ E4 │ Q │
├─────────────┼────────────────┼─────────────────────┼─────────┼─────────┼───────┼───────┤
│ reply │ reply_fn │ ReplyClosure │ Reply │ C │ E5 │ Q │
├─────────────┼────────────────┼─────────────────────┼─────────┼─────────┼───────┼───────┤
│ migrate │ migrate_fn │ PermissionedClosure │ T6 │ C │ E6 │ Q │
└─────────────┴────────────────┴─────────────────────┴─────────┴─────────┴───────┴───────┘
The general schema depicting which generic type is used in entry points is shown below.
Entry point, when called, is provided minimum two arguments: custom query of type Q
(inside Deps
or DepsMut
) and input message of type T1, T2, T3, T4,
Reply or T6. As a result, entry point returns custom output message of type
Response<C> or Binary and an error of type E1, E2, E3, E4, E5
or E6.
entry_point(query, .., message_in) -> Result<message_out, error>
┬ ┬ ┬ ┬
Q >──┘ │ │ └──> E1,E2,E3,E4,E5,E6
T1,T2,T3,T4,Reply,T6 >────┘ └─────────────> C,Binary
Generic type C defines a custom message that is specific for the whole blockchain.
Similarly, the generic type Q defines a custom query that is also specific
to the whole blockchain. Other generic types are specific to the implemented contract.
So all smart contracts used in the same blockchain will have the same types for C and Q,
but each contract may use different type for other generic types.
It means that e.g. T1 in smart contract A
may differ from T1 in smart contract B
.
Implementations§
source§impl<T1, T2, T3, E1, E2, E3, C, Q> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q>where
T1: DeserializeOwned + 'static,
T2: DeserializeOwned + 'static,
T3: DeserializeOwned + 'static,
E1: Display + Debug + Send + Sync + 'static,
E2: Display + Debug + Send + Sync + 'static,
E3: Display + Debug + Send + Sync + 'static,
C: CustomMsg + 'static,
Q: CustomQuery + DeserializeOwned + 'static,
impl<T1, T2, T3, E1, E2, E3, C, Q> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q>where
T1: DeserializeOwned + 'static,
T2: DeserializeOwned + 'static,
T3: DeserializeOwned + 'static,
E1: Display + Debug + Send + Sync + 'static,
E2: Display + Debug + Send + Sync + 'static,
E3: Display + Debug + Send + Sync + 'static,
C: CustomMsg + 'static,
Q: CustomQuery + DeserializeOwned + 'static,
sourcepub fn new(
execute_fn: fn(deps: DepsMut<'_, Q>, env: Env, info: MessageInfo, msg: T1) -> Result<Response<C>, E1>,
instantiate_fn: fn(deps: DepsMut<'_, Q>, env: Env, info: MessageInfo, msg: T2) -> Result<Response<C>, E2>,
query_fn: fn(deps: Deps<'_, Q>, env: Env, msg: T3) -> Result<Binary, E3>
) -> Self
pub fn new( execute_fn: fn(deps: DepsMut<'_, Q>, env: Env, info: MessageInfo, msg: T1) -> Result<Response<C>, E1>, instantiate_fn: fn(deps: DepsMut<'_, Q>, env: Env, info: MessageInfo, msg: T2) -> Result<Response<C>, E2>, query_fn: fn(deps: Deps<'_, Q>, env: Env, msg: T3) -> Result<Binary, E3> ) -> Self
Creates a new contract wrapper with default settings.
sourcepub fn new_with_empty(
execute_fn: fn(deps: DepsMut<'_, Empty>, env: Env, info: MessageInfo, msg: T1) -> Result<Response<Empty>, E1>,
instantiate_fn: fn(deps: DepsMut<'_, Empty>, env: Env, info: MessageInfo, msg: T2) -> Result<Response<Empty>, E2>,
query_fn: fn(deps: Deps<'_, Empty>, env: Env, msg: T3) -> Result<Binary, E3>
) -> Self
pub fn new_with_empty( execute_fn: fn(deps: DepsMut<'_, Empty>, env: Env, info: MessageInfo, msg: T1) -> Result<Response<Empty>, E1>, instantiate_fn: fn(deps: DepsMut<'_, Empty>, env: Env, info: MessageInfo, msg: T2) -> Result<Response<Empty>, E2>, query_fn: fn(deps: Deps<'_, Empty>, env: Env, msg: T3) -> Result<Binary, E3> ) -> Self
This will take a contract that returns Response<Empty>
and will upgrade it
to Response<C>
if needed, to be compatible with a chain-specific extension.
source§impl<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6, E6> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6, E6>where
T1: DeserializeOwned,
T2: DeserializeOwned,
T3: DeserializeOwned,
T4: DeserializeOwned,
T6: DeserializeOwned,
E1: Display + Debug + Send + Sync,
E2: Display + Debug + Send + Sync,
E3: Display + Debug + Send + Sync,
E4: Display + Debug + Send + Sync,
E5: Display + Debug + Send + Sync,
E6: Display + Debug + Send + Sync,
C: CustomMsg + 'static,
Q: CustomQuery + DeserializeOwned + 'static,
impl<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6, E6> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6, E6>where
T1: DeserializeOwned,
T2: DeserializeOwned,
T3: DeserializeOwned,
T4: DeserializeOwned,
T6: DeserializeOwned,
E1: Display + Debug + Send + Sync,
E2: Display + Debug + Send + Sync,
E3: Display + Debug + Send + Sync,
E4: Display + Debug + Send + Sync,
E5: Display + Debug + Send + Sync,
E6: Display + Debug + Send + Sync,
C: CustomMsg + 'static,
Q: CustomQuery + DeserializeOwned + 'static,
sourcepub fn with_sudo<T4A, E4A>(
self,
sudo_fn: fn(deps: DepsMut<'_, Q>, env: Env, msg: T4A) -> Result<Response<C>, E4A>
) -> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4A, E4A, E5, T6, E6>
pub fn with_sudo<T4A, E4A>( self, sudo_fn: fn(deps: DepsMut<'_, Q>, env: Env, msg: T4A) -> Result<Response<C>, E4A> ) -> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4A, E4A, E5, T6, E6>
Populates ContractWrapper with contract’s sudo
entry-point and custom message type.
sourcepub fn with_sudo_empty<T4A, E4A>(
self,
sudo_fn: fn(deps: DepsMut<'_, Empty>, env: Env, msg: T4A) -> Result<Response<Empty>, E4A>
) -> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4A, E4A, E5, T6, E6>
pub fn with_sudo_empty<T4A, E4A>( self, sudo_fn: fn(deps: DepsMut<'_, Empty>, env: Env, msg: T4A) -> Result<Response<Empty>, E4A> ) -> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4A, E4A, E5, T6, E6>
Populates ContractWrapper with contract’s sudo
entry-point and Empty
as a custom message.
sourcepub fn with_reply<E5A>(
self,
reply_fn: fn(deps: DepsMut<'_, Q>, env: Env, msg: Reply) -> Result<Response<C>, E5A>
) -> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5A, T6, E6>
pub fn with_reply<E5A>( self, reply_fn: fn(deps: DepsMut<'_, Q>, env: Env, msg: Reply) -> Result<Response<C>, E5A> ) -> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5A, T6, E6>
Populates ContractWrapper with contract’s reply
entry-point and custom message type.
sourcepub fn with_reply_empty<E5A>(
self,
reply_fn: fn(deps: DepsMut<'_, Empty>, env: Env, msg: Reply) -> Result<Response<Empty>, E5A>
) -> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5A, T6, E6>
pub fn with_reply_empty<E5A>( self, reply_fn: fn(deps: DepsMut<'_, Empty>, env: Env, msg: Reply) -> Result<Response<Empty>, E5A> ) -> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5A, T6, E6>
Populates ContractWrapper with contract’s reply
entry-point and Empty
as a custom message.
sourcepub fn with_migrate<T6A, E6A>(
self,
migrate_fn: fn(deps: DepsMut<'_, Q>, env: Env, msg: T6A) -> Result<Response<C>, E6A>
) -> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6A, E6A>
pub fn with_migrate<T6A, E6A>( self, migrate_fn: fn(deps: DepsMut<'_, Q>, env: Env, msg: T6A) -> Result<Response<C>, E6A> ) -> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6A, E6A>
Populates ContractWrapper with contract’s migrate
entry-point and custom message type.
sourcepub fn with_migrate_empty<T6A, E6A>(
self,
migrate_fn: fn(deps: DepsMut<'_, Empty>, env: Env, msg: T6A) -> Result<Response<Empty>, E6A>
) -> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6A, E6A>
pub fn with_migrate_empty<T6A, E6A>( self, migrate_fn: fn(deps: DepsMut<'_, Empty>, env: Env, msg: T6A) -> Result<Response<Empty>, E6A> ) -> ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6A, E6A>
Populates ContractWrapper with contract’s migrate
entry-point and Empty
as a custom message.
Trait Implementations§
source§impl<T1, T2, T3, E1, E2, E3, C, T4, E4, E5, T6, E6, Q> Contract<C, Q> for ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6, E6>where
T1: DeserializeOwned,
T2: DeserializeOwned,
T3: DeserializeOwned,
T4: DeserializeOwned,
T6: DeserializeOwned,
E1: Display + Debug + Send + Sync + 'static,
E2: Display + Debug + Send + Sync + 'static,
E3: Display + Debug + Send + Sync + 'static,
E4: Display + Debug + Send + Sync + 'static,
E5: Display + Debug + Send + Sync + 'static,
E6: Display + Debug + Send + Sync + 'static,
C: CustomMsg,
Q: CustomQuery + DeserializeOwned,
impl<T1, T2, T3, E1, E2, E3, C, T4, E4, E5, T6, E6, Q> Contract<C, Q> for ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6, E6>where
T1: DeserializeOwned,
T2: DeserializeOwned,
T3: DeserializeOwned,
T4: DeserializeOwned,
T6: DeserializeOwned,
E1: Display + Debug + Send + Sync + 'static,
E2: Display + Debug + Send + Sync + 'static,
E3: Display + Debug + Send + Sync + 'static,
E4: Display + Debug + Send + Sync + 'static,
E5: Display + Debug + Send + Sync + 'static,
E6: Display + Debug + Send + Sync + 'static,
C: CustomMsg,
Q: CustomQuery + DeserializeOwned,
source§fn execute(
&self,
deps: DepsMut<'_, Q>,
env: Env,
info: MessageInfo,
msg: Vec<u8>
) -> AnyResult<Response<C>>
fn execute( &self, deps: DepsMut<'_, Q>, env: Env, info: MessageInfo, msg: Vec<u8> ) -> AnyResult<Response<C>>
source§fn instantiate(
&self,
deps: DepsMut<'_, Q>,
env: Env,
info: MessageInfo,
msg: Vec<u8>
) -> AnyResult<Response<C>>
fn instantiate( &self, deps: DepsMut<'_, Q>, env: Env, info: MessageInfo, msg: Vec<u8> ) -> AnyResult<Response<C>>
Calls instantiate on wrapped Contract trait implementor.
Auto Trait Implementations§
impl<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6, E6> Freeze for ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6, E6>
impl<T1, T2, T3, E1, E2, E3, C = Empty, Q = Empty, T4 = Empty, E4 = Error, E5 = Error, T6 = Empty, E6 = Error> !RefUnwindSafe for ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6, E6>
impl<T1, T2, T3, E1, E2, E3, C = Empty, Q = Empty, T4 = Empty, E4 = Error, E5 = Error, T6 = Empty, E6 = Error> !Send for ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6, E6>
impl<T1, T2, T3, E1, E2, E3, C = Empty, Q = Empty, T4 = Empty, E4 = Error, E5 = Error, T6 = Empty, E6 = Error> !Sync for ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6, E6>
impl<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6, E6> Unpin for ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6, E6>
impl<T1, T2, T3, E1, E2, E3, C = Empty, Q = Empty, T4 = Empty, E4 = Error, E5 = Error, T6 = Empty, E6 = Error> !UnwindSafe for ContractWrapper<T1, T2, T3, E1, E2, E3, C, Q, T4, E4, E5, T6, E6>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more