oasis_contract_sdk/
context.rs

1//! Contract execution context.
2use crate::{
3    env::{Crypto, Env},
4    event::Event,
5    storage::{ConfidentialStore, PublicStore},
6    types::{address::Address, message::Message, token, CallFormat, InstanceId},
7};
8
9/// Execution context.
10pub trait Context {
11    /// The public store.
12    type PublicStore: PublicStore;
13    /// The confidential store.
14    type ConfidentialStore: ConfidentialStore;
15    /// The environment.
16    type Env: Env + Crypto;
17
18    /// Contract instance identifier.
19    fn instance_id(&self) -> InstanceId;
20
21    /// Contract instance address.
22    fn instance_address(&self) -> &Address;
23
24    /// Caller address.
25    fn caller_address(&self) -> &Address;
26
27    /// Tokens deposited by the caller.
28    fn deposited_tokens(&self) -> &[token::BaseUnits];
29
30    /// Whether the call is read-only and must not make any storage modifications.
31    fn is_read_only(&self) -> bool;
32
33    /// Call format.
34    fn call_format(&self) -> CallFormat;
35
36    /// Emits a message.
37    fn emit_message(&mut self, msg: Message);
38
39    /// Emits an event.
40    fn emit_event<E: Event>(&mut self, event: E);
41
42    /// Public contract store.
43    fn public_store(&mut self) -> &mut Self::PublicStore;
44
45    /// Confidential contract store.
46    fn confidential_store(&mut self) -> &mut Self::ConfidentialStore;
47
48    /// Environment.
49    fn env(&self) -> &Self::Env;
50}