-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Create ctx module for context types
- Loading branch information
Showing
71 changed files
with
286 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
examples/contracts/cw20-base/src/multitest/receiver_contract.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
examples/contracts/generic_contract/src/custom_and_generic.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
examples/contracts/generic_iface_on_contract/src/custom_and_generic.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
examples/contracts/generics_forwarded/src/custom_and_generic.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![allow(deprecated)] | ||
|
||
use sylvia::cw_std::{CosmosMsg, Response, StdError}; | ||
|
||
use sylvia::interface; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![allow(deprecated)] | ||
|
||
pub mod responses; | ||
|
||
use cw_utils::Expiration; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![allow(deprecated)] | ||
|
||
pub mod responses; | ||
|
||
use responses::{DownloadLogoResponse, MarketingInfoResponse}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![allow(deprecated)] | ||
|
||
pub mod responses; | ||
|
||
use responses::MinterResponse; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![allow(deprecated)] | ||
|
||
pub mod responses; | ||
|
||
use responses::{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![allow(deprecated)] | ||
|
||
use sylvia::cw_std::{CosmosMsg, Response, StdError}; | ||
|
||
use sylvia::interface; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![allow(deprecated)] | ||
|
||
use anyhow::Error; | ||
use cosmwasm_std::{Addr, Response}; | ||
use cw_storage_plus::{Item, Map}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
use cosmwasm_std::{Deps, DepsMut, Empty, Env, Event, MessageInfo, MsgResponse}; | ||
|
||
/// Represantation of `reply` context received in entry point. | ||
#[non_exhaustive] | ||
pub struct ReplyCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { | ||
pub deps: DepsMut<'a, C>, | ||
pub env: Env, | ||
pub gas_used: u64, | ||
pub events: Vec<Event>, | ||
pub msg_responses: Vec<MsgResponse>, | ||
} | ||
|
||
/// Represantation of `migrate` context received in entry point. | ||
#[non_exhaustive] | ||
pub struct MigrateCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { | ||
pub deps: DepsMut<'a, C>, | ||
pub env: Env, | ||
} | ||
|
||
/// Represantation of `execute` context received in entry point. | ||
#[non_exhaustive] | ||
pub struct ExecCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { | ||
pub deps: DepsMut<'a, C>, | ||
pub env: Env, | ||
pub info: MessageInfo, | ||
} | ||
|
||
/// Represantation of `instantiate` context received in entry point. | ||
#[non_exhaustive] | ||
pub struct InstantiateCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { | ||
pub deps: DepsMut<'a, C>, | ||
pub env: Env, | ||
pub info: MessageInfo, | ||
} | ||
|
||
/// Represantation of `query` context received in entry point. | ||
#[non_exhaustive] | ||
pub struct QueryCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { | ||
pub deps: Deps<'a, C>, | ||
pub env: Env, | ||
} | ||
|
||
/// Represantation of `sudo` context received in entry point. | ||
#[non_exhaustive] | ||
pub struct SudoCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { | ||
pub deps: DepsMut<'a, C>, | ||
pub env: Env, | ||
} | ||
|
||
impl<C: cosmwasm_std::CustomQuery> ExecCtx<'_, C> { | ||
pub fn branch(&'_ mut self) -> ExecCtx<'_, C> { | ||
ExecCtx { | ||
deps: self.deps.branch(), | ||
env: self.env.clone(), | ||
info: self.info.clone(), | ||
} | ||
} | ||
} | ||
|
||
impl<C: cosmwasm_std::CustomQuery> InstantiateCtx<'_, C> { | ||
pub fn branch(&'_ mut self) -> InstantiateCtx<'_, C> { | ||
InstantiateCtx { | ||
deps: self.deps.branch(), | ||
env: self.env.clone(), | ||
info: self.info.clone(), | ||
} | ||
} | ||
} | ||
|
||
impl<C: cosmwasm_std::CustomQuery> SudoCtx<'_, C> { | ||
pub fn branch(&'_ mut self) -> SudoCtx<'_, C> { | ||
SudoCtx { | ||
deps: self.deps.branch(), | ||
env: self.env.clone(), | ||
} | ||
} | ||
} | ||
|
||
impl<'a, C: cosmwasm_std::CustomQuery> From<(DepsMut<'a, C>, Env)> for MigrateCtx<'a, C> { | ||
fn from((deps, env): (DepsMut<'a, C>, Env)) -> Self { | ||
Self { deps, env } | ||
} | ||
} | ||
|
||
impl<'a, C: cosmwasm_std::CustomQuery> | ||
From<(DepsMut<'a, C>, Env, u64, Vec<Event>, Vec<MsgResponse>)> for ReplyCtx<'a, C> | ||
{ | ||
fn from( | ||
(deps, env, gas_used, events, msg_responses): ( | ||
DepsMut<'a, C>, | ||
Env, | ||
u64, | ||
Vec<Event>, | ||
Vec<MsgResponse>, | ||
), | ||
) -> Self { | ||
Self { | ||
deps, | ||
env, | ||
gas_used, | ||
events, | ||
msg_responses, | ||
} | ||
} | ||
} | ||
|
||
impl<'a, C: cosmwasm_std::CustomQuery> From<(DepsMut<'a, C>, Env, MessageInfo)> for ExecCtx<'a, C> { | ||
fn from((deps, env, info): (DepsMut<'a, C>, Env, MessageInfo)) -> Self { | ||
Self { deps, env, info } | ||
} | ||
} | ||
|
||
impl<'a, C: cosmwasm_std::CustomQuery> From<(DepsMut<'a, C>, Env, MessageInfo)> | ||
for InstantiateCtx<'a, C> | ||
{ | ||
fn from((deps, env, info): (DepsMut<'a, C>, Env, MessageInfo)) -> Self { | ||
Self { deps, env, info } | ||
} | ||
} | ||
|
||
impl<'a, C: cosmwasm_std::CustomQuery> From<(Deps<'a, C>, Env)> for QueryCtx<'a, C> { | ||
fn from((deps, env): (Deps<'a, C>, Env)) -> Self { | ||
Self { deps, env } | ||
} | ||
} | ||
|
||
impl<'a, C: cosmwasm_std::CustomQuery> From<(DepsMut<'a, C>, Env)> for SudoCtx<'a, C> { | ||
fn from((deps, env): (DepsMut<'a, C>, Env)) -> Self { | ||
Self { deps, env } | ||
} | ||
} |
Oops, something went wrong.