Skip to content

Commit

Permalink
Got consumer/converter to compile (but not tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed May 6, 2024
1 parent 94171cc commit 71dffdf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion contracts/consumer/converter/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_schema::write_api;

use mesh_converter::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};
use mesh_converter::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};

#[cfg(not(tarpaulin_include))]
fn main() {
Expand Down
17 changes: 11 additions & 6 deletions contracts/consumer/converter/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use cosmwasm_std::{
ensure_eq, to_json_binary, Addr, BankMsg, Coin, CosmosMsg, Decimal, Deps, DepsMut, Event,
Fraction, MessageInfo, Reply, Response, SubMsg, SubMsgResponse, Uint128, Validator, WasmMsg,
ensure_eq, to_json_binary, Addr, BankMsg, Coin, CosmosMsg, Decimal, Deps, DepsMut, Event, Fraction, MessageInfo, Reply, Response, StdError, SubMsg, SubMsgResponse, Uint128, Validator, WasmMsg
};
use cw2::set_contract_version;
use cw_storage_plus::Item;
Expand Down Expand Up @@ -275,8 +274,11 @@ impl ConverterContract<'_> {
// FIXME not sure how to get this to compile with latest sylvia
// get the price value (usage is a bit clunky, need to use trait and cannot chain Remote::new() with .querier())
// also see https://github.com/CosmWasm/sylvia/issues/181 to just store Remote in state
use price_feed_api::Querier;
let remote = price_feed_api::Remote::new(config.price_feed);
use price_feed_api::sv::Querier;
use sylvia::types::Remote;
// NOTE: Jan, this feels hacky... I'm not sure if this is the right way to do it
// Also, I am sticking in a random error type here, not what I will get (which is unknown)
let remote = Remote::<&dyn price_feed_api::PriceFeedApi<Error=StdError>>::new(config.price_feed);
let price = remote.querier(&deps.querier).price()?.native_per_foreign;
let converted = (amount.amount * price) * config.price_adjustment;

Expand All @@ -299,8 +301,11 @@ impl ConverterContract<'_> {

// get the price value (usage is a bit clunky, need to use trait and cannot chain Remote::new() with .querier())
// also see https://github.com/CosmWasm/sylvia/issues/181 to just store Remote in state
use price_feed_api::Querier;
let remote = price_feed_api::Remote::new(config.price_feed);
use price_feed_api::sv::Querier;
use sylvia::types::Remote;
// NOTE: Jan, this feels hacky... I'm not sure if this is the right way to do it
// Also, I am sticking in a random error type here, not what I will get (which is unknown)
let remote = Remote::<&dyn price_feed_api::PriceFeedApi<Error=StdError>>::new(config.price_feed);
let price = remote.querier(&deps.querier).price()?.native_per_foreign;
let converted = (amount.amount * price.inv().ok_or(ContractError::InvalidPrice {})?)
* config
Expand Down

0 comments on commit 71dffdf

Please sign in to comment.