Skip to content

Commit d95c924

Browse files
author
Dev Kalra
authored
[cosmwasm] Release setup (#594)
* update comment * add a workflow * update contracts readme * add readme to pyth-sdk-cw
1 parent 6daeb88 commit d95c924

File tree

5 files changed

+77
-36
lines changed

5 files changed

+77
-36
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Publish Pyth SDK for Cosmwasm to crates.io
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
jobs:
8+
publish-pyth-sdk-cw:
9+
name: Publish Pyth SDK CW
10+
if: ${{ startsWith(github.ref, 'refs/tags/pyth-sdk-cw-v') }}
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout sources
14+
uses: actions/checkout@v2
15+
16+
- run: cargo publish --token ${CARGO_REGISTRY_TOKEN}
17+
env:
18+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
19+
working-directory: "target_chains/cosmwasm/pyth-sdk-cw"

target_chains/cosmwasm/contracts/README.md

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,11 @@
11
# Pyth Cosmwasm
22

3-
This crate includes the actual contract and exposes utilities to interact with the contract on the CosmWasm ecosystem.
4-
It also includes an [example contract](../examples/cw-contract/) demonstrating how to read price feeds from on-chain CosmWasm applications.
3+
This crate includes the actual contract for the CosmWasm ecosystem.
54

6-
## Installation
5+
## Integration
76

8-
Add this crate to the dependencies section of your CosmWasm contract's `Cargo.toml` file:
9-
10-
```
11-
[dependencies]
12-
pyth-cosmwasm = { git="https://github.com/pyth-network/pyth-crosschain", tag="pyth-cosmwasm-v0.1.0", features=["library"] }
13-
```
14-
15-
## Usage
16-
17-
Simply import the structs exposed by the crate and use them while interacting with the pyth contract. For example:
18-
19-
```rust
20-
// to query Pyth contract
21-
use pyth_cosmwasm::msg::{
22-
PriceFeedResponse,
23-
};
24-
25-
... {
26-
let price_feed_response: PriceFeedResponse =
27-
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
28-
contract_addr: state.pyth_contract_addr.into_string(),
29-
msg: to_binary(&PythQueryMsg::PriceFeed {
30-
id: state.price_feed_id,
31-
})?,
32-
}))?;
33-
34-
let price_feed = price_feed_response.price_feed;
35-
}
36-
....
37-
```
7+
You can use `pyth-sdk-cw` which has been published to crates.io to integrate with the Pyth contract.
8+
The sdk exposes data structures and testing utilities for ease of use. Please look into this [pyth-sdk-cw](https://github.com/pyth-network/pyth-crosschain/tree/main/target_chains/cosmwasm/pyth-sdk-cw)
389

3910
## Off-Chain Queries
4011

target_chains/cosmwasm/examples/cw-contract/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ 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 = { path="../../pyth-sdk-cw"}
37+
pyth-sdk-cw = "0.1.0"
3838
cosmwasm-schema = "1.1.9"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Pyth SDK CW
2+
3+
This crate exposes utilities to interact with the contract on the CosmWasm ecosystem.
4+
You can also look at the [example contract](../examples/cw-contract/) which demonstrates how to read price feeds from on-chain CosmWasm applications.
5+
6+
## Installation
7+
8+
Add this crate to the dependencies section of your CosmWasm contract's `Cargo.toml` file:
9+
10+
```
11+
[dependencies]
12+
pyth-sdk-cw = "0.1.0"
13+
```
14+
15+
## Usage
16+
17+
Simply import the structs exposed by the crate and use them while interacting with the pyth contract. For example:
18+
19+
```rust
20+
// to query Pyth contract
21+
use pyth_sdk_cw::{
22+
PriceFeedResponse,
23+
query_price_feed,
24+
};
25+
26+
... {
27+
let price_feed_response: PriceFeedResponse = query_price_feed(&deps.querier, state.pyth_contract_addr, state.price_feed_id)?;
28+
let price_feed = price_feed_response.price_feed;
29+
}
30+
....
31+
```
32+
33+
## Contracts and Price Feeds
34+
35+
Pyth is currently available on the following cosmwasm chains:
36+
37+
### Testnet
38+
39+
| Network | Contract address |
40+
| --------- | -------------------------------------------- |
41+
| Injective | `inj1z60tg0tekdzcasenhuuwq3htjcd5slmgf7gpez` |
42+
43+
Available price feeds on these networks can be find below:
44+
45+
### Price Feeds
46+
47+
| Network | Available Price Feeds |
48+
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
49+
| Injective Testnet | [https://pyth.network/developers/price-feed-ids#injective-testnet](https://pyth.network/developers/price-feed-ids#injective-testnet) |

target_chains/cosmwasm/pyth-sdk-cw/src/testing.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ impl MockPyth {
5353
self.feeds.insert(feed.id, feed);
5454
}
5555

56-
/// TODO: Update this with example contracts -> Handler for processing query messages. See the tests in `contract.rs` for how to use this
57-
/// handler within your tests.
56+
/// Handler for processing query messages.
57+
/// See the tests in `contract.rs`
58+
/// `https://github.com/pyth-network/pyth-crosschain/blob/main/target_chains/cosmwasm/examples/cw-contract/src/contract.rs#L13`
59+
/// for how to use this handler within your tests.
5860
pub fn handle_wasm_query(&self, msg: &Binary) -> QuerierResult {
5961
let query_msg = from_binary::<QueryMsg>(msg);
6062
match query_msg {

0 commit comments

Comments
 (0)