Skip to content

Commit

Permalink
Update query returns
Browse files Browse the repository at this point in the history
  • Loading branch information
shapeshed committed May 7, 2024
1 parent b27b0b8 commit 13c9707
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.0] - 2014-05-07

### Change

- Don't return Binary from queries

## [0.3.1] - 2014-05-01

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ readme = "README.md"
repository = "https://github.com/margined-protocol/vaultenator"
resolver = "2"
rust-version = "1.77.2"
version = "0.3.1"
version = "0.4.0"

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
25 changes: 13 additions & 12 deletions src/query.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
use crate::config::Configure;
use crate::state::ManageState;
use cosmwasm_std::{to_json_binary, Binary, Deps, Env, StdError, StdResult, Uint128};
use cosmwasm_std::{Deps, Env, StdError, StdResult, Uint128};
use cw_vault_standard::VaultInfoResponse;
use serde::Serialize;

pub trait Query<C, S>
where
C: Configure + Serialize,
S: ManageState + Serialize,
{
fn query_config(deps: Deps) -> StdResult<Binary> {
fn query_config(deps: Deps) -> StdResult<C> {
match C::get_from_storage(deps) {
Ok(config) => to_json_binary(&config),
Ok(config) => Ok(config),
Err(e) => Err(StdError::generic_err(e.to_string())),
}
}

fn query_state(deps: Deps) -> StdResult<Binary> {
fn query_state(deps: Deps) -> StdResult<S> {
match S::get_from_storage(deps) {
Ok(config) => to_json_binary(&config),
Ok(state) => Ok(state),
Err(e) => Err(StdError::generic_err(e.to_string())),
}
}

fn query_info(deps: Deps, env: Env) -> StdResult<Binary>;
fn query_preview_deposit(amount: Uint128, deps: Deps, env: Env) -> StdResult<Binary>;
fn query_preview_redeem(amount: Uint128, deps: Deps, env: Env) -> StdResult<Binary>;
fn query_total_assets(deps: Deps, env: Env) -> StdResult<Binary>;
fn query_total_vault_token_supply(deps: Deps, env: Env) -> StdResult<Binary>;
fn query_convert_to_shares(amount: Uint128, deps: Deps, env: Env) -> StdResult<Binary>;
fn query_convert_to_assets(amount: Uint128, deps: Deps, env: Env) -> StdResult<Binary>;
fn query_info(deps: Deps, env: Env) -> StdResult<VaultInfoResponse>;
fn query_preview_deposit(amount: Uint128, deps: Deps, env: Env) -> StdResult<Uint128>;
fn query_preview_redeem(amount: Uint128, deps: Deps, env: Env) -> StdResult<Uint128>;
fn query_total_assets(deps: Deps, env: Env) -> StdResult<Uint128>;
fn query_total_vault_token_supply(deps: Deps, env: Env) -> StdResult<Uint128>;
fn query_convert_to_shares(amount: Uint128, deps: Deps, env: Env) -> StdResult<Uint128>;
fn query_convert_to_assets(amount: Uint128, deps: Deps, env: Env) -> StdResult<Uint128>;
}

0 comments on commit 13c9707

Please sign in to comment.