diff --git a/README.md b/README.md index adadbcb..d3d3c33 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # data-streams-sdk + Chainlink Data Streams client SDK implementation. See the language directories for specific documentation, usage and examples. ## [Go](go/README.md) [![go.dev reference](https://img.shields.io/badge/go-reference-blue)](https://pkg.go.dev/github.com/smartcontractkit/data-streams-sdk/go) [![Go Report Card](https://goreportcard.com/badge/github.com/smartcontractkit/data-streams-sdk/go)](https://goreportcard.com/report/github.com/smartcontractkit/data-streams-sdk/go) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smartcontractkit/data-streams-sdk/blob/main/LICENSE) + +## [Rust](rust/README.md) ![Crates.io sdk](https://img.shields.io/crates/v/chainlink-data-streams-sdk?label=chainlink-data-streams-sdk) ![Crates.io report](https://img.shields.io/crates/v/chainlink-data-streams-report?label=chainlink-data-streams-report) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smartcontractkit/data-streams-sdk/blob/main/LICENSE) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index e30354a..4162618 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -125,6 +125,43 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chainlink-data-streams-report" +version = "0.1.0" +dependencies = [ + "hex", + "num-bigint", + "serde", + "serde_json", + "snap", + "thiserror", +] + +[[package]] +name = "chainlink-data-streams-sdk" +version = "0.1.0" +dependencies = [ + "byteorder", + "criterion", + "data-streams-report", + "dotenv", + "futures", + "futures-util", + "hex", + "hmac", + "reqwest", + "serde", + "serde_json", + "serde_urlencoded", + "sha2", + "thiserror", + "tokio", + "tokio-tungstenite", + "tracing", + "tracing-subscriber", + "zeroize", +] + [[package]] name = "ciborium" version = "0.2.2" @@ -287,18 +324,6 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" -[[package]] -name = "data-streams-report" -version = "0.0.1" -dependencies = [ - "hex", - "num-bigint", - "serde", - "serde_json", - "snap", - "thiserror", -] - [[package]] name = "data-streams-report" version = "0.0.1" @@ -312,31 +337,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "data-streams-sdk" -version = "0.0.1" -dependencies = [ - "byteorder", - "criterion", - "data-streams-report 0.0.1 (git+https://github.com/smartcontractkit/data-streams-sdk.git)", - "dotenv", - "futures", - "futures-util", - "hex", - "hmac", - "reqwest", - "serde", - "serde_json", - "serde_urlencoded", - "sha2", - "thiserror", - "tokio", - "tokio-tungstenite", - "tracing", - "tracing-subscriber", - "zeroize", -] - [[package]] name = "deranged" version = "0.3.11" diff --git a/rust/README.md b/rust/README.md index 69e0fd5..603ebcb 100644 --- a/rust/README.md +++ b/rust/README.md @@ -11,8 +11,8 @@ The Data Streams SDK is a Rust library that provides a convenient way to consume The project is organized into the following crates: -- `data-streams-report` - The crate that provides the data structures for the reports. -- `data-streams-sdk` - The main crate that provides the REST and WebSocket clients. +- `chainlink-data-streams-report` - The crate that provides the data structures for the reports. +- `chainlink-data-streams-sdk` - The main crate that provides the REST and WebSocket clients. ## Installation @@ -20,7 +20,7 @@ Add the following to your `Cargo.toml`: ```toml [dependencies] -data-streams-sdk = { git = "https://github.com/smartcontractkit/data-streams-sdk.git", subdir = "rust/crates/sdk" } +chainlink-data-streams-sdk = { version = "0.1.0", features = ["full"] } ``` #### Features @@ -37,10 +37,10 @@ data-streams-sdk = { git = "https://github.com/smartcontractkit/data-streams-sdk Here is the basic example that demontstrates how to get the latest report for a ETH/USD feed on Arbitrum Sepolia: ```rust -use data_streams_report::feed_id::ID; -use data_streams_report::report::{decode_full_report, v3::ReportDataV3}; -use data_streams_sdk::client::Client; -use data_streams_sdk::config::Config; +use chainlink_data_streams_report::feed_id::ID; +use chainlink_data_streams_report::report::{decode_full_report, v3::ReportDataV3}; +use chainlink_data_streams_sdk::client::Client; +use chainlink_data_streams_sdk::config::Config; use std::error::Error; #[tokio::main] @@ -94,9 +94,9 @@ async fn main() -> Result<(), Box> { Here is the basic example that demonstrates how to connect to the Data Streams WebSocket server and subscribe to a single stream of ETH/USD Feed Reports on Arbitrum Sepolia: ```rust -use data_streams_report::feed_id::ID; -use data_streams_sdk::config::Config; -use data_streams_sdk::stream::Stream; +use chainlink_data_streams_report::feed_id::ID; +use chainlink_data_streams_sdk::config::Config; +use chainlink_data_streams_sdk::stream::Stream; use tokio::signal; use tracing_subscriber::fmt::time::UtcTime; diff --git a/rust/crates/report/.github/workflows/publish-rust-report-crate.yml b/rust/crates/report/.github/workflows/publish-rust-report-crate.yml new file mode 100644 index 0000000..69fdf37 --- /dev/null +++ b/rust/crates/report/.github/workflows/publish-rust-report-crate.yml @@ -0,0 +1,38 @@ +name: Publish Chainlink Data Streams Report Crate + +on: + push: + tags: + - "rust/chainlink-data-streams-report-v*" + workflow_dispatch: # Keeping manual trigger as fallback + +jobs: + publish: + runs-on: ubuntu-latest + environment: publish + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + + - name: Verify tag matches version + run: | + VERSION=$(grep '^version = "' rust/crates/report/Cargo.toml | cut -d '"' -f2) + TAG_VERSION=${GITHUB_REF#refs/tags/rust/chainlink-data-streams-report-v} + if [ "$VERSION" != "$TAG_VERSION" ]; then + echo "Version mismatch: Cargo.toml ($VERSION) != tag ($TAG_VERSION)" + exit 1 + fi + + - name: Publish chainlink-data-streams-report + run: | + cd rust/crates/report + cargo publish --token ${CARGO_DATA_STREAMS_SDK} + if ! cargo owner --list | grep -q "github:smartcontractkit:RustCrates"; then + cargo owner --add github:smartcontractkit:RustCrates + fi + env: + CARGO_DATA_STREAMS_SDK: ${{ secrets.CARGO_DATA_STREAMS_SDK }} diff --git a/rust/crates/report/Cargo.toml b/rust/crates/report/Cargo.toml index db883f9..218fe7b 100644 --- a/rust/crates/report/Cargo.toml +++ b/rust/crates/report/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "data-streams-report" +name = "chainlink-data-streams-report" version = "0.0.1" edition = "2021" description = "Chainlink Data Streams Report" diff --git a/rust/crates/sdk/.github/workflows/publish-rust-sdk-crate.yml b/rust/crates/sdk/.github/workflows/publish-rust-sdk-crate.yml new file mode 100644 index 0000000..3eda946 --- /dev/null +++ b/rust/crates/sdk/.github/workflows/publish-rust-sdk-crate.yml @@ -0,0 +1,38 @@ +name: Publish Chainlink Data Streams SDK Crate + +on: + push: + tags: + - "rust/chainlink-data-streams-sdk-v*" + workflow_dispatch: # Keeping manual trigger as fallback + +jobs: + publish: + runs-on: ubuntu-latest + environment: publish + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + + - name: Verify tag matches version + run: | + VERSION=$(grep '^version = "' rust/crates/sdk/Cargo.toml | cut -d '"' -f2) + TAG_VERSION=${GITHUB_REF#refs/tags/rust/chainlink-data-streams-sdk-v} + if [ "$VERSION" != "$TAG_VERSION" ]; then + echo "Version mismatch: Cargo.toml ($VERSION) != tag ($TAG_VERSION)" + exit 1 + fi + + - name: Publish chainlink-data-streams-sdk + run: | + cd rust/crates/sdk + cargo publish --token ${CARGO_DATA_STREAMS_SDK} + if ! cargo owner --list | grep -q "github:smartcontractkit:RustCrates"; then + cargo owner --add github:smartcontractkit:RustCrates + fi + env: + CARGO_DATA_STREAMS_SDK: ${{ secrets.CARGO_DATA_STREAMS_SDK }} diff --git a/rust/crates/sdk/Cargo.toml b/rust/crates/sdk/Cargo.toml index bb46212..3c6a1ec 100644 --- a/rust/crates/sdk/Cargo.toml +++ b/rust/crates/sdk/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "data-streams-sdk" +name = "chainlink-data-streams-sdk" version = "0.0.1" edition = "2021" rust-version = "1.70" @@ -11,7 +11,7 @@ exclude = ["/target/*", "examples/*", "tests/*", "docs/*", "book/*"] keywords = ["chainlink"] [dependencies] -data-streams-report = { git = "https://github.com/smartcontractkit/data-streams-sdk.git", subdir = "rust/crates/report" } +chainlink-data-streams-report = "0.0.1" reqwest = { version = "0.11.20", features = ["json", "rustls-tls"] } tokio = { version = "1.29.1", features = ["full"] } tokio-tungstenite = { version = "0.20.1", features = [