Trait oasis_contract_sdk::contract::Contract

source ·
pub trait Contract {
    type Request: Decode;
    type Response: Encode;
    type Error: Error;

    // Required methods
    fn call<C: Context>(
        ctx: &mut C,
        request: Self::Request,
    ) -> Result<Self::Response, Self::Error>;
    fn query<C: Context>(
        _ctx: &mut C,
        _request: Self::Request,
    ) -> Result<Self::Response, Self::Error>;

    // Provided methods
    fn instantiate<C: Context>(
        _ctx: &mut C,
        _request: Self::Request,
    ) -> Result<(), Self::Error> { ... }
    fn handle_reply<C: Context>(
        _ctx: &mut C,
        _reply: Reply,
    ) -> Result<Option<Self::Response>, Self::Error> { ... }
    fn pre_upgrade<C: Context>(
        _ctx: &mut C,
        _request: Self::Request,
    ) -> Result<(), Self::Error> { ... }
    fn post_upgrade<C: Context>(
        _ctx: &mut C,
        _request: Self::Request,
    ) -> Result<(), Self::Error> { ... }
}
Expand description

Trait that needs to be implemented by contract implementations.

Required Associated Types§

source

type Request: Decode

Type of all requests.

source

type Response: Encode

Type of all responses.

source

type Error: Error

Type of all errors.

Required Methods§

source

fn call<C: Context>( ctx: &mut C, request: Self::Request, ) -> Result<Self::Response, Self::Error>

Call the contract.

source

fn query<C: Context>( _ctx: &mut C, _request: Self::Request, ) -> Result<Self::Response, Self::Error>

Query the contract.

Provided Methods§

source

fn instantiate<C: Context>( _ctx: &mut C, _request: Self::Request, ) -> Result<(), Self::Error>

Instantiate the contract.

source

fn handle_reply<C: Context>( _ctx: &mut C, _reply: Reply, ) -> Result<Option<Self::Response>, Self::Error>

Handle replies from sent messages.

source

fn pre_upgrade<C: Context>( _ctx: &mut C, _request: Self::Request, ) -> Result<(), Self::Error>

Perform any pre-upgrade tasks. This method is called on the old contract code.

If this method reports an error the upgrade will be aborted.

source

fn post_upgrade<C: Context>( _ctx: &mut C, _request: Self::Request, ) -> Result<(), Self::Error>

Perform any post-upgrade tasks. This method is called on the new contract code.

If this method reports an error the upgrade will be aborted.

Object Safety§

This trait is not object safe.

Implementors§