From a9ab4c2f0b6e82f4bf43811e5ec4b36a4dcaca92 Mon Sep 17 00:00:00 2001 From: pr0n00gler Date: Mon, 7 Oct 2024 14:42:06 +0300 Subject: [PATCH] wip --- Cargo.lock | 7 ++++--- Cargo.toml | 2 +- contracts/dex_grpc/src/contract.rs | 1 + contracts/oracle/Cargo.toml | 7 ++++--- contracts/oracle/src/contract.rs | 26 ++++++++++---------------- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 365d55a..f70464b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1161,8 +1161,8 @@ dependencies = [ [[package]] name = "neutron-std" -version = "4.2.2" -source = "git+https://github.com/neutron-org/neutron-std?branch=main#895e303fad4e152317fd3dee4f22880bfde55bc6" +version = "4.2.2-rc" +source = "git+https://github.com/neutron-org/neutron-std?branch=feat/connect#85cc4e832fd885c6316df3b1f517f5e0aaaf2d0e" dependencies = [ "bech32 0.9.1", "chrono", @@ -1186,7 +1186,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-std?branch=main#895e303fad4e152317fd3dee4f22880bfde55bc6" +source = "git+https://github.com/neutron-org/neutron-std?branch=feat/connect#85cc4e832fd885c6316df3b1f517f5e0aaaf2d0e" dependencies = [ "itertools 0.10.5", "proc-macro2", @@ -1311,6 +1311,7 @@ dependencies = [ "cosmwasm-std 2.1.3", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "schemars", "serde", ] diff --git a/Cargo.toml b/Cargo.toml index e52c312..121f7f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/contracts/dex_grpc/src/contract.rs b/contracts/dex_grpc/src/contract.rs index e7936c2..4ab8464 100644 --- a/contracts/dex_grpc/src/contract.rs +++ b/contracts/dex_grpc/src/contract.rs @@ -133,6 +133,7 @@ pub fn execute( } } +#[allow(deprecated)] #[entry_point] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { deps.api diff --git a/contracts/oracle/Cargo.toml b/contracts/oracle/Cargo.toml index 603ddc9..f4112a9 100644 --- a/contracts/oracle/Cargo.toml +++ b/contracts/oracle/Cargo.toml @@ -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 @@ -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 } diff --git a/contracts/oracle/src/contract.rs b/contracts/oracle/src/contract.rs index fd78e97..a6c56a3 100644 --- a/contracts/oracle/src/contract.rs +++ b/contracts/oracle/src/contract.rs @@ -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"); @@ -51,18 +47,16 @@ pub fn query(deps: Deps, env: Env, msg: OracleQuery) -> StdResult< } fn query_oracle(deps: Deps, _env: Env, msg: OracleQuery) -> StdResult { + 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()?) } } }