Skip to content

Commit cdc6f98

Browse files
author
0xfirefist
committed
remove pyth-sdk-cw
1 parent 0003e44 commit cdc6f98

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

examples/cw-contract/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ cosmwasm-storage = { version = "1.0.0" }
3434
cw-storage-plus = "0.13.4"
3535
schemars = "0.8"
3636
serde = { version = "1.0", default-features = false, features = ["derive"] }
37-
pyth-sdk-cw = { version = "0.3.0", path = "../../pyth-sdk-cw" } # Remove path and use version only when you use this example on your own.
37+
pyth-cosmwasm = { path = "/Users/pyth/Desktop/pyth-crosschain/target-chains/cosmwasm/contracts/pyth" }
3838

3939
[dev-dependencies]
4040
cosmwasm-schema = { version = "1.0.0" }

examples/cw-contract/src/contract.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@ use cosmwasm_std::{
77
DepsMut,
88
Env,
99
MessageInfo,
10+
QueryRequest,
1011
Response,
1112
StdError,
1213
StdResult,
14+
WasmQuery,
1315
};
1416

15-
use pyth_sdk_cw::query_price_feed;
17+
use pyth_cosmwasm::msg::{
18+
PriceFeedResponse,
19+
QueryMsg as PythQueryMsg,
20+
};
1621

1722
use crate::msg::{
1823
ExecuteMsg,
@@ -80,8 +85,15 @@ fn query_fetch_price(deps: Deps, env: Env) -> StdResult<FetchPriceResponse> {
8085
// price feed. The result is a PriceFeed object with fields for the current price and other
8186
// useful information. The function will fail if the contract address or price feed id are
8287
// invalid.
83-
let price_feed =
84-
query_price_feed(&deps.querier, state.pyth_contract_addr, state.price_feed_id)?.price_feed;
88+
let price_feed_response: PriceFeedResponse =
89+
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
90+
contract_addr: state.pyth_contract_addr.into_string(),
91+
msg: to_binary(&PythQueryMsg::PriceFeed {
92+
id: state.price_feed_id,
93+
})?,
94+
}))?;
95+
96+
let price_feed = price_feed_response.price_feed;
8597

8698
// Get the current price and confidence interval from the price feed.
8799
// This function returns None if the price is not currently available.

examples/cw-contract/src/msg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use pyth_sdk_cw::{
1+
use pyth_cosmwasm::{
22
Price,
33
PriceIdentifier,
44
};

examples/cw-contract/src/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use serde::{
66
};
77

88
use cw_storage_plus::Item;
9-
use pyth_sdk_cw::PriceIdentifier;
9+
use pyth_cosmwasm::PriceIdentifier;
1010

1111
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
1212
pub struct State {

pyth-sdk/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub type DurationInSeconds = u64;
103103
#[repr(C)]
104104
pub struct PriceFeed {
105105
/// Unique identifier for this price.
106-
pub id: PriceIdentifier,
106+
pub id: PriceIdentifier,
107107
/// Price.
108108
pub price: Price,
109109
/// Exponentially-weighted moving average (EMA) price.

0 commit comments

Comments
 (0)