TgradeApp

Struct TgradeApp 

Source
pub struct TgradeApp(/* private fields */);

Implementations§

Source§

impl TgradeApp

Source

pub fn new(owner: &str) -> Self

Source

pub fn new_genesis(owner: &str) -> Self

Source

pub fn block_info(&self) -> BlockInfo

Source

pub fn promote(&mut self, owner: &str, contract: &str) -> AnyResult<AppResponse>

Source

pub fn back_to_genesis(&mut self)

This reverses to genesis (based on current time/height)

Source

pub fn advance_blocks(&mut self, blocks: u64)

This advances BlockInfo by given number of blocks. It does not do any callbacks, but keeps the ratio of seconds/blokc

Source

pub fn advance_seconds(&mut self, seconds: u64)

This advances BlockInfo by given number of seconds. It does not do any callbacks, but keeps the ratio of seconds/blokc

Source

pub fn next_block(&mut self) -> AnyResult<Option<ValidatorDiff>>

next_block will call the end_blocker, increment block info 1 height and 5 seconds, and then call the begin_blocker (with no evidence) in the next block. It returns the validator diff if any.

Simple iterator when you don’t care too much about the details and just want to simulate forward motion.

Source

pub fn with_privilege(&self, requested: Privilege) -> AnyResult<Vec<Addr>>

Returns a list of all contracts that have the requested privilege

Source

pub fn begin_block( &mut self, evidence: Vec<Evidence>, ) -> AnyResult<Vec<AppResponse>>

Make the BeginBlock sudo callback on all contracts that have registered with the BeginBlocker Privilege

Source

pub fn end_block( &mut self, ) -> AnyResult<(Vec<AppResponse>, Option<ValidatorDiff>)>

Make the EndBlock sudo callback on all contracts that have registered with the EndBlocker Privilege. Then makes the EndWithValidatorUpdate callback on any registered valset_updater.

Methods from Deref<Target = TgradeAppWrapped>§

Source

pub fn init_modules<F, T>(&mut self, init_fn: F) -> T
where F: FnOnce(&mut Router<BankT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT>, &dyn Api, &mut dyn Storage) -> T,

Source

pub fn read_module<F, T>(&self, query_fn: F) -> T
where F: FnOnce(&Router<BankT, CustomT, WasmT, StakingT, DistrT, IbcT, GovT>, &dyn Api, &dyn Storage) -> T,

Source

pub fn store_code( &mut self, code: Box<dyn Contract<<CustomT as Module>::ExecT, <CustomT as Module>::QueryT>>, ) -> u64

This registers contract code (like uploading wasm bytecode on a chain), so it can later be used to instantiate a contract.

Source

pub fn contract_data(&self, address: &Addr) -> Result<ContractData, Error>

This allows to get ContractData for specific contract

Source

pub fn dump_wasm_raw(&self, address: &Addr) -> Vec<(Vec<u8>, Vec<u8>)>

This gets a raw state dump of all key-values held by a given contract

Source

pub fn set_block(&mut self, block: BlockInfo)

Source

pub fn update_block<F>(&mut self, action: F)
where F: Fn(&mut BlockInfo),

Source

pub fn block_info(&self) -> BlockInfo

Returns a copy of the current block_info

Source

pub fn wrap(&self) -> QuerierWrapper<'_, <CustomT as Module>::QueryT>

Simple helper so we get access to all the QuerierWrapper helpers, eg. wrap().query_wasm_smart, query_all_balances, …

Source

pub fn execute_multi( &mut self, sender: Addr, msgs: Vec<CosmosMsg<<CustomT as Module>::ExecT>>, ) -> Result<Vec<AppResponse>, Error>

Runs multiple CosmosMsg in one atomic operation. This will create a cache before the execution, so no state changes are persisted if any of them return an error. But all writes are persisted on success.

Source

pub fn wasm_sudo<T, U>( &mut self, contract_addr: U, msg: &T, ) -> Result<AppResponse, Error>
where T: Serialize, U: Into<Addr>,

Call a smart contract in “sudo” mode. This will create a cache before the execution, so no state changes are persisted if this returns an error, but all are persisted on success.

Source

pub fn sudo(&mut self, msg: SudoMsg) -> Result<AppResponse, Error>

Runs arbitrary SudoMsg. This will create a cache before the execution, so no state changes are persisted if this returns an error, but all are persisted on success.

Trait Implementations§

Source§

impl Deref for TgradeApp

Source§

type Target = App<BankKeeper, MockApi, MemoryStorage, TgradeModule, WasmKeeper<TgradeMsg, TgradeQuery>>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for TgradeApp

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Querier for TgradeApp

Source§

fn raw_query(&self, bin_request: &[u8]) -> QuerierResult

raw_query is all that must be implemented for the Querier. This allows us to pass through binary queries from one level to another without knowing the custom format, or we can decode it, with the knowledge of the allowed types. People using the querier probably want one of the simpler auto-generated helper methods

Auto Trait Implementations§

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<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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.