Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0n00gler committed Oct 7, 2024
1 parent 64e14e4 commit a9ab4c2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
7 changes: 4 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ overflow-checks = true

[workspace.dependencies]
neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "chore/neutron-std" }
neutron-std = { package = "neutron-std", git = "https://github.com/neutron-org/neutron-std", branch = "main" }
neutron-std = { package = "neutron-std", git = "https://github.com/neutron-org/neutron-std", branch = "feat/connect" }
prost = "0.12.4"
prost-types = "0.12.4"
cosmos-sdk-proto = { version = "0.20.0", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions contracts/dex_grpc/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ pub fn execute(
}
}

#[allow(deprecated)]
#[entry_point]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
deps.api
Expand Down
7 changes: 4 additions & 3 deletions contracts/oracle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ edition = "2021"


exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down Expand Up @@ -36,6 +36,7 @@ cw2 = { workspace = true }
schemars = { workspace = true }
serde = { version = "1.0.180", default-features = false, features = ["derive"] }
neutron-sdk = { workspace = true }
neutron-std = { workspace = true }

[dev-dependencies]
cosmwasm-schema = { workspace = true }
26 changes: 10 additions & 16 deletions contracts/oracle/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ pub struct InstantiateMsg {}
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {}

use neutron_sdk::bindings::{
msg::NeutronMsg,
oracle::query::{
GetAllCurrencyPairsResponse, GetPriceResponse, GetPricesResponse, OracleQuery,
},
query::NeutronQuery,
};
use neutron_sdk::bindings::{msg::NeutronMsg, oracle::query::OracleQuery, query::NeutronQuery};

use neutron_std::types::connect::oracle::v2::OracleQuerier;

const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME"));
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
Expand Down Expand Up @@ -51,18 +47,16 @@ pub fn query(deps: Deps<NeutronQuery>, env: Env, msg: OracleQuery) -> StdResult<
}

fn query_oracle(deps: Deps<NeutronQuery>, _env: Env, msg: OracleQuery) -> StdResult<Binary> {
let oracle_querier = OracleQuerier::new(&deps.querier);
match msg {
OracleQuery::GetPrice { .. } => {
let query_response: GetPriceResponse = deps.querier.query(&msg.into())?;
to_json_binary(&query_response)
}
OracleQuery::GetPrices { .. } => {
let query_response: GetPricesResponse = deps.querier.query(&msg.into())?;
to_json_binary(&query_response)
OracleQuery::GetPrice { currency_pair } => to_json_binary(
&oracle_querier.get_price(format!("{}/{}", currency_pair.base, currency_pair.quote))?,
),
OracleQuery::GetPrices { currency_pair_ids } => {
to_json_binary(&oracle_querier.get_prices(currency_pair_ids)?)
}
OracleQuery::GetAllCurrencyPairs { .. } => {
let query_response: GetAllCurrencyPairsResponse = deps.querier.query(&msg.into())?;
to_json_binary(&query_response)
to_json_binary(&oracle_querier.get_all_currency_pairs()?)
}
}
}

0 comments on commit a9ab4c2

Please sign in to comment.