Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Osmosis queriers to not take ownership of QuerierWrapper #37

Merged
merged 1 commit into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/cosmwasm/contracts/osmosis-stargate/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
}

fn query_token_creation_fee(deps: Deps) -> StdResult<QueryTokenCreationFeeResponse> {
let res = TokenfactoryQuerier::new(deps.querier).params()?;
let res = TokenfactoryQuerier::new(&deps.querier).params()?;
let params = res.params.ok_or(StdError::NotFound {
kind: "osmosis_std::types::osmosis::tokenfactory::v1beta1::Params".to_string(),
})?;
Expand All @@ -210,7 +210,7 @@ fn query_token_creation_fee(deps: Deps) -> StdResult<QueryTokenCreationFeeRespon

fn query_creator_denoms(deps: Deps, env: Env) -> StdResult<QueryCreatorDenomsResponse> {
let res =
TokenfactoryQuerier::new(deps.querier).denoms_from_creator(env.contract.address.into())?;
TokenfactoryQuerier::new(&deps.querier).denoms_from_creator(env.contract.address.into())?;

Ok(QueryCreatorDenomsResponse { denoms: res.denoms })
}
2 changes: 1 addition & 1 deletion packages/osmosis-std-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn derive_cosmwasm_ext(input: TokenStream) -> TokenStream {
};

let cosmwasm_query = quote! {
pub fn query(self, querier: cosmwasm_std::QuerierWrapper<cosmwasm_std::Empty>) -> cosmwasm_std::StdResult<#res> {
pub fn query(self, querier: &cosmwasm_std::QuerierWrapper<cosmwasm_std::Empty>) -> cosmwasm_std::StdResult<#res> {
querier.query::<#res>(&self.into())
}
};
Expand Down
4 changes: 2 additions & 2 deletions packages/osmosis-std/src/types/osmosis/epochs/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ pub struct QueryCurrentEpochResponse {
pub current_epoch: i64,
}
pub struct EpochsQuerier<'a> {
querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
}
impl<'a> EpochsQuerier<'a> {
pub fn new(querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
pub fn new(querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
Self { querier }
}
pub fn epoch_infos(&self) -> Result<QueryEpochsInfoResponse, cosmwasm_std::StdError> {
Expand Down
4 changes: 2 additions & 2 deletions packages/osmosis-std/src/types/osmosis/gamm/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,10 +836,10 @@ pub struct GenesisState {
pub params: ::core::option::Option<Params>,
}
pub struct GammQuerier<'a> {
querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
}
impl<'a> GammQuerier<'a> {
pub fn new(querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
pub fn new(querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
Self { querier }
}
pub fn pools(
Expand Down
4 changes: 2 additions & 2 deletions packages/osmosis-std/src/types/osmosis/incentives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,10 @@ pub struct GenesisState {
pub last_gauge_id: u64,
}
pub struct IncentivesQuerier<'a> {
querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
}
impl<'a> IncentivesQuerier<'a> {
pub fn new(querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
pub fn new(querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
Self { querier }
}
pub fn module_to_distribute_coins(
Expand Down
4 changes: 2 additions & 2 deletions packages/osmosis-std/src/types/osmosis/lockup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,10 +767,10 @@ pub struct GenesisState {
pub synthetic_locks: ::prost::alloc::vec::Vec<SyntheticLock>,
}
pub struct LockupQuerier<'a> {
querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
}
impl<'a> LockupQuerier<'a> {
pub fn new(querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
pub fn new(querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
Self { querier }
}
pub fn module_balance(&self) -> Result<ModuleBalanceResponse, cosmwasm_std::StdError> {
Expand Down
4 changes: 2 additions & 2 deletions packages/osmosis-std/src/types/osmosis/mint/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ pub struct GenesisState {
pub halven_started_epoch: i64,
}
pub struct MintQuerier<'a> {
querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
}
impl<'a> MintQuerier<'a> {
pub fn new(querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
pub fn new(querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
Self { querier }
}
pub fn params(&self) -> Result<QueryParamsResponse, cosmwasm_std::StdError> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,10 @@ pub struct GenesisState {
pub distr_info: ::core::option::Option<DistrInfo>,
}
pub struct PoolincentivesQuerier<'a> {
querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
}
impl<'a> PoolincentivesQuerier<'a> {
pub fn new(querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
pub fn new(querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
Self { querier }
}
pub fn gauge_ids(&self, pool_id: u64) -> Result<QueryGaugeIdsResponse, cosmwasm_std::StdError> {
Expand Down
4 changes: 2 additions & 2 deletions packages/osmosis-std/src/types/osmosis/superfluid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,10 +744,10 @@ pub struct GenesisState {
::prost::alloc::vec::Vec<LockIdIntermediaryAccountConnection>,
}
pub struct SuperfluidQuerier<'a> {
querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
}
impl<'a> SuperfluidQuerier<'a> {
pub fn new(querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
pub fn new(querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
Self { querier }
}
pub fn params(&self) -> Result<QueryParamsResponse, cosmwasm_std::StdError> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,10 @@ pub struct GenesisDenom {
pub authority_metadata: ::core::option::Option<DenomAuthorityMetadata>,
}
pub struct TokenfactoryQuerier<'a> {
querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
}
impl<'a> TokenfactoryQuerier<'a> {
pub fn new(querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
pub fn new(querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
Self { querier }
}
pub fn params(&self) -> Result<QueryParamsResponse, cosmwasm_std::StdError> {
Expand Down
4 changes: 2 additions & 2 deletions packages/osmosis-std/src/types/osmosis/txfees/v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ pub struct GenesisState {
pub feetokens: ::prost::alloc::vec::Vec<FeeToken>,
}
pub struct TxfeesQuerier<'a> {
querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>,
}
impl<'a> TxfeesQuerier<'a> {
pub fn new(querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
pub fn new(querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
Self { querier }
}
pub fn fee_tokens(&self) -> Result<QueryFeeTokensResponse, cosmwasm_std::StdError> {
Expand Down
4 changes: 2 additions & 2 deletions packages/proto-build/src/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@ pub fn append_querier(
vec![
parse_quote! {
pub struct #querier_wrapper_ident<'a> {
querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>
querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>
}
},
parse_quote! {
impl<'a> #querier_wrapper_ident<'a> {
pub fn new(querier: cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
pub fn new(querier: &'a cosmwasm_std::QuerierWrapper<'a, cosmwasm_std::Empty>) -> Self {
Self { querier }
}
#(#query_fns)*
Expand Down