macro_rules! contract_harness {
    (@init $init:path) => { ... };
    (@execute $execute:path) => { ... };
    (@query $query:path) => { ... };
    (@reply $reply:path) => { ... };
    (@trait_impl $visibility:vis $name:ident, $($contents:tt)*) => { ... };
    (
        $visibility:vis $name:ident,
        init: $init:path,
        execute: $execute:path,
        query: $query:path,
        reply: $reply:path
    ) => { ... };
    (
        $visibility:vis $name:ident,
        init: $init:path,
        execute: $execute:path,
        query: $query:path
    ) => { ... };
}
Expand description

Generate a struct and implement ContractHarness for the given struct identifier, using the provided entry point functions.

Supports init, execute and query or init, execute, query and reply.

Examples

pub fn instantiate(
    _deps: DepsMut,
    _env: Env,
    _info: MessageInfo,
    _msg: InitMsg
) -> StdResult<Response> {
    Ok(Response::default())
}

pub fn execute(
    _deps: DepsMut,
    _env: Env,
    _info: MessageInfo,
    _msg: ExecuteMsg
) -> StdResult<Response> {
    Ok(Response::default())
}

pub fn query(
    _deps: Deps,
    _env: Env,
    _msg: QueryMsg
) -> StdResult<Binary> {
    to_binary(&true)
}
 
contract_harness! {
    pub NameOfStruct,
    init: instantiate,
    execute: execute,
    query: query
}