Struct WasmKeeper

Source
pub struct WasmKeeper<ExecC: 'static, QueryC: CustomQuery + 'static> {
    pub code_base: RefCell<HashMap<usize, WasmContract>>,
    pub rust_codes: HashMap<usize, *mut dyn Contract<ExecC, QueryC>>,
    pub code_data: HashMap<usize, CodeData>,
    /* private fields */
}

Fields§

§code_base: RefCell<HashMap<usize, WasmContract>>

Contract codes that stand for wasm code in real-life blockchain.

§rust_codes: HashMap<usize, *mut dyn Contract<ExecC, QueryC>>

Contract codes that stand for rust code living in the current instance We also associate the queries to them to make sure we are able to use them with the vm instance

§code_data: HashMap<usize, CodeData>

Code data with code base identifier and additional attributes.

Implementations§

Source§

impl<ExecC, QueryC> WasmKeeper<ExecC, QueryC>
where ExecC: CustomMsg + DeserializeOwned + 'static, QueryC: CustomQuery + DeserializeOwned + 'static,

Source

pub fn contract_code<'a, 'b>( &'a self, code_id: u64, ) -> AnyResult<ContractBox<'a, ExecC, QueryC>>
where 'a: 'b,

Returns a handler to code of the contract with specified code id.

Source

pub fn dump_wasm_raw( &self, storage: &dyn Storage, address: &Addr, ) -> Vec<Record>

Source§

impl<ExecC, QueryC> WasmKeeper<ExecC, QueryC>
where ExecC: CustomMsg + DeserializeOwned + 'static, QueryC: CustomQuery + DeserializeOwned + 'static,

Source

pub fn new() -> Self

Source

pub fn new_with_custom_address_generator( address_generator: impl AddressGenerator + 'static, ) -> Self

👎Deprecated since 0.18.0: use WasmKeeper::new().with_address_generator instead; will be removed in version 1.0.0
Source

pub fn with_remote(self, remote: RemoteChannel) -> Self

Source

pub fn with_address_generator( self, address_generator: impl AddressGenerator + 'static, ) -> Self

Source

pub fn with_checksum_generator( self, checksum_generator: impl ChecksumGenerator + 'static, ) -> Self

Source

pub fn query_smart( &self, address: Addr, api: &dyn Api, storage: &dyn Storage, querier: &dyn Querier, block: &BlockInfo, msg: Vec<u8>, querier_storage: QuerierStorage, ) -> AnyResult<Binary>

Executes the contract’s query entry-point.

Source

pub fn query_raw( &self, address: Addr, storage: &dyn Storage, key: &[u8], ) -> Binary

Source

pub fn register_contract( &self, api: &dyn Api, storage: &mut dyn Storage, code_id: u64, creator: Addr, admin: impl Into<Option<Addr>>, _label: String, _created: u64, salt: impl Into<Option<Binary>>, ) -> AnyResult<Addr>

Creates a contract address and empty storage instance. Returns the new contract address.

You have to call init after this to set up the contract properly. These two steps are separated to have cleaner return values.

Source

pub fn call_execute( &self, api: &dyn Api, storage: &mut dyn Storage, address: Addr, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, info: MessageInfo, msg: Vec<u8>, querier_storage: QuerierStorage, ) -> AnyResult<Response<ExecC>>

Source

pub fn call_instantiate( &self, address: Addr, api: &dyn Api, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, info: MessageInfo, msg: Vec<u8>, querier_storage: QuerierStorage, ) -> AnyResult<Response<ExecC>>

Source

pub fn call_reply( &self, address: Addr, api: &dyn Api, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, reply: Reply, ) -> AnyResult<Response<ExecC>>

Source

pub fn call_sudo( &self, address: Addr, api: &dyn Api, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, msg: Vec<u8>, querier_storage: QuerierStorage, ) -> AnyResult<Response<ExecC>>

Source

pub fn call_migrate( &self, address: Addr, api: &dyn Api, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, msg: Vec<u8>, querier_storage: QuerierStorage, ) -> AnyResult<Response<ExecC>>

Source

pub fn save_contract( &self, storage: &mut dyn Storage, address: &Addr, contract: &ContractData, ) -> AnyResult<()>

Trait Implementations§

Source§

impl<ExecC, QueryC: CustomQuery> AllWasmQuerier for WasmKeeper<ExecC, QueryC>

Source§

fn query_all(&self, storage: &dyn Storage) -> AnyResult<WasmStorage>

Source§

impl<ExecC, QueryC: CustomQuery> Default for WasmKeeper<ExecC, QueryC>

Source§

fn default() -> WasmKeeper<ExecC, QueryC>

Returns the “default value” for a type. Read more
Source§

impl<ExecC, QueryC> Wasm<ExecC, QueryC> for WasmKeeper<ExecC, QueryC>
where ExecC: CustomMsg + DeserializeOwned + 'static, QueryC: CustomQuery + DeserializeOwned + 'static,

Source§

fn store_wasm_code(&mut self, creator: Addr, code: Vec<u8>) -> u64

Stores the contract’s code in the in-memory lookup table. Returns an identifier of the stored contract code.

Source§

fn store_code( &mut self, creator: Addr, code: Box<dyn Contract<ExecC, QueryC>>, ) -> u64

Stores the contract’s code in the in-memory lookup table. Returns an identifier of the stored contract code.

Source§

fn contract_data( &self, storage: &dyn Storage, address: &Addr, ) -> AnyResult<ContractData>

Returns ContractData for the contract with specified address.

Source§

fn dump_wasm_raw(&self, storage: &dyn Storage, address: &Addr) -> Vec<Record>

Returns a raw state dump of all key-values held by a contract with specified address.

Source§

fn query( &self, api: &dyn Api, storage: &dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, querier: &dyn Querier, block: &BlockInfo, request: WasmQuery, ) -> AnyResult<Binary>

Handles all WasmQuery requests
Source§

fn execute( &self, api: &dyn Api, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, sender: Addr, msg: WasmMsg, ) -> AnyResult<AppResponse>

Handles all WasmMsg messages.
Source§

fn sudo( &self, api: &dyn Api, contract: Addr, storage: &mut dyn Storage, router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>, block: &BlockInfo, msg: Binary, ) -> AnyResult<AppResponse>

Handles all sudo messages, this is an admin interface and can not be called via CosmosMsg.

Auto Trait Implementations§

§

impl<ExecC, QueryC> !Freeze for WasmKeeper<ExecC, QueryC>

§

impl<ExecC, QueryC> !RefUnwindSafe for WasmKeeper<ExecC, QueryC>

§

impl<ExecC, QueryC> !Send for WasmKeeper<ExecC, QueryC>

§

impl<ExecC, QueryC> !Sync for WasmKeeper<ExecC, QueryC>

§

impl<ExecC, QueryC> Unpin for WasmKeeper<ExecC, QueryC>
where ExecC: Unpin, QueryC: Unpin,

§

impl<ExecC, QueryC> !UnwindSafe for WasmKeeper<ExecC, QueryC>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,