Skip to content

feat!: initial sdk release - #4

Merged
distributedstatemachine merged 3 commits into
mainfrom
feat/crates.io
Dec 27, 2025
Merged

feat!: initial sdk release#4
distributedstatemachine merged 3 commits into
mainfrom
feat/crates.io

Conversation

@distributedstatemachine

@distributedstatemachine distributedstatemachine commented Dec 27, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Neuron and subnet chain queries added.
    • Added a convenience transfer_all API.
    • Constructor for weights now returns a Result (must be unwrapped).
  • Documentation

    • Comprehensive README and CHANGELOG added; examples updated to the new crate path.
    • Expanded module docs with architecture notes and usage samples.
  • Chores

    • Automated release and publish workflows added.
    • Project metadata and license updated.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 27, 2025

Copy link
Copy Markdown

Walkthrough

Adds release automation (release-please + publish workflow), crate metadata and licensing, comprehensive docs and changelog, many documentation/import-path updates across the crate, new query modules (neuron, subnet) and connection submodules, a public export transfer_all, and a signature change for WeightsParams::new.

Changes

Cohort / File(s) Summary
Release workflows & automation
.github/workflows/publish.yml, .github/workflows/release-please.yml
New GitHub Actions: publish.yml runs on release.published (tag prefix bittensor-rs-v) performing toolchain setup, dry-run and actual cargo publish, and failure issue creation; release-please.yml invokes googleapis/release-please-action to create releases and exposes outputs.
Release configuration & manifest
.release-please-manifest.json, release-please-config.json
Adds release-please manifest and config for Rust releases, changelog sections, bump rules, and package mapping (bittensor-rs v0.1.0).
Repo metadata & licensing
LICENSE, bittensor-rs/Cargo.toml, bittensor-rs/LICENSE
Root LICENSE copyright updated; crate Cargo.toml gains authors, documentation, homepage, repository, readme fields; new MIT license file added for the crate.
Top-level documentation
README.md, bittensor-rs/CHANGELOG.md, bittensor-rs/README.md
Adds comprehensive workspace and crate READMEs and a CHANGELOG (Unreleased + 0.1.0) with usage examples, contribution/release guidance, and API summaries.
Module docs & examples (crate-wide)
bittensor-rs/src/service.rs, bittensor-rs/src/connect/mod.rs, bittensor-rs/src/extrinsics/mod.rs, bittensor-rs/src/wallet/*, bittensor-rs/src/*
Large documentation expansions and example updates across service, connect, extrinsics, wallet, utils, types, queries, and other modules; many doc-import paths changed from bittensor::bittensor_rs::.
Query & connection API surface
bittensor-rs/src/queries/mod.rs, bittensor-rs/src/queries/neuron.rs, bittensor-rs/src/queries/subnet.rs, bittensor-rs/src/connect/*
Adds neuron and subnet modules and re-exports (e.g., get_neuron, get_subnet_info, types), and exposes pool/state connection submodules (re-exports for pool/health/manager types).
Extrinsics changes
bittensor-rs/src/extrinsics/weights.rs, bittensor-rs/src/extrinsics/transfer.rs, bittensor-rs/src/extrinsics/*
Public API change: WeightsParams::new(...) now returns Result<Self, &'static str> (call sites updated to unwrap()); transfer_all added to exports; many examples updated to bittensor_rs:: paths and example formats adjusted.
Examples & tests import updates
bittensor-rs/examples/test_axon_discovery.rs, bittensor-rs/tests/connection_reliability_tests.rs
Updated crate import paths from bittensor::bittensor_rs::; one change uses hotkey.clone() in an example storage query.

Sequence Diagram(s)

mermaid
sequenceDiagram
autonumber
participant ReleasePlease as Release-Please Action
participant Repo as GitHub Repo
participant GHActions as GitHub Actions Runner
participant PublishJob as publish.yml Job
participant CratesIO as crates.io
participant IssueAPI as GitHub Issues API

Note right of ReleasePlease: On push to main
ReleasePlease->>Repo: create release PR / tag
Repo-->>ReleasePlease: outputs (tag, release_created)
Note over Repo,GHActions: On release published with tag prefix `bittensor-rs-v`
Repo->>GHActions: trigger publish.yml (release.published)
GHActions->>PublishJob: start job (checkout, setup rust, protoc, cache)
PublishJob->>PublishJob: run dry-run `cargo publish --dry-run` (bittensor-rs/)
alt dry-run success
    PublishJob->>CratesIO: perform `cargo publish` with CARGO_REGISTRY_TOKEN
    CratesIO-->>PublishJob: publish result (success)
else dry-run or publish failure
    PublishJob->>IssueAPI: create failure issue (labels bug, ci) referencing run & release
    IssueAPI-->>Repo: issue created
end

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A crate takes wing with docs and a tag,
Actions hum softly — no need to lag,
New queries and weights with a tidy new name,
Publish and changelog join the release game,
Hops, naps, and crates.io: a rabbit’s small brag 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat!: initial sdk release' directly and clearly summarizes the main objective of this pull request, which is preparing the initial release of the bittensor-rs SDK for publication to crates.io.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/crates.io

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
bittensor-rs/examples/test_axon_discovery.rs (1)

32-32: Inconsistent import path with line 117.

This function uses use bittensor::api::api; while test_direct_extrinsic at line 117 uses use bittensor_rs::api::api;. Both imports should use the same crate path.

🔎 Proposed fix
-    use bittensor::api::api;
+    use bittensor_rs::api::api;
bittensor-rs/src/service.rs (2)

577-589: Potential race condition in circuit breaker state update.

The circuit breaker is cloned, executed, then the original is overwritten. With concurrent calls to get_metagraph, one call's state update could overwrite another's, potentially losing failure/success counts.

Consider using an atomic state update pattern or accepting the current behavior if occasional state loss is acceptable for circuit breaker semantics.


871-875: Hardcoded circuit breaker reset values ignore configuration.

The reset uses hardcoded (5, Duration::from_secs(60)) instead of the configured circuit_breaker_threshold and circuit_breaker_recovery from self.config. This could lead to different behavior after reset.

🔎 Suggested fix
     pub async fn reset_circuit_breaker(&self) {
         let mut cb = self.circuit_breaker.lock().await;
-        *cb = CircuitBreaker::new(5, Duration::from_secs(60));
+        *cb = CircuitBreaker::new(
+            self.config.circuit_breaker_threshold.unwrap_or(5),
+            self.config.circuit_breaker_recovery.unwrap_or(Duration::from_secs(60)),
+        );
         info!("Circuit breaker reset");
     }
🧹 Nitpick comments (3)
bittensor-rs/LICENSE (1)

3-3: Consider updating the copyright year.

The copyright notice shows 2024, but the current date is December 27, 2025. Consider updating to "2024-2025" or just "2025" to reflect the actual release timeframe.

LICENSE (1)

3-3: Consider updating the copyright year.

The copyright notice shows 2024, but the current date is December 27, 2025. Consider updating to "2024-2025" or just "2025" to reflect the actual release timeframe.

bittensor-rs/tests/connection_reliability_tests.rs (1)

289-314: Consider using public API for metrics manipulation in tests.

The test directly accesses checker.metrics internal fields via atomic operations. If HealthChecker provides a public API for metrics (like reset_metrics()), consider using that consistently. Direct field access couples tests to internal implementation.

However, if this is intentional to test atomic behavior, it's acceptable.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68bbdf0 and 039b53f.

📒 Files selected for processing (16)
  • .github/workflows/publish.yml
  • .github/workflows/release-please.yml
  • .release-please-manifest.json
  • LICENSE
  • README.md
  • bittensor-rs/CHANGELOG.md
  • bittensor-rs/Cargo.toml
  • bittensor-rs/LICENSE
  • bittensor-rs/README.md
  • bittensor-rs/examples/test_axon_discovery.rs
  • bittensor-rs/src/connect/mod.rs
  • bittensor-rs/src/extrinsics/mod.rs
  • bittensor-rs/src/queries/mod.rs
  • bittensor-rs/src/service.rs
  • bittensor-rs/tests/connection_reliability_tests.rs
  • release-please-config.json
🧰 Additional context used
🪛 LanguageTool
bittensor-rs/README.md

[style] ~231-~231: Consider using a less common alternative to make your writing sound more unique and professional.
Context: ...ontributing Contributions are welcome! Please feel free to submit a Pull Request. ## Related Proj...

(FEEL_FREE_TO_STYLE_ME)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Coverage
🔇 Additional comments (14)
bittensor-rs/src/extrinsics/mod.rs (1)

1-46: Documentation improvements are well-structured and comprehensive.

The reorganized module documentation with the categorized function table and practical example code demonstrates good API clarity. Ensure the example import statement is corrected as flagged above.

bittensor-rs/examples/test_axon_discovery.rs (1)

117-117: LGTM - Import path updated correctly.

The import path has been updated to bittensor_rs::api::api to align with the crate rename. However, note that line 32 still uses the old import path and needs to be updated for consistency.

bittensor-rs/CHANGELOG.md (1)

1-61: LGTM - Well-structured changelog.

The CHANGELOG follows Keep a Changelog format and provides comprehensive documentation of the initial release features. The structure and content are clear and well-organized.

release-please-config.json (1)

1-26: LGTM - Release Please configuration is correct.

The configuration properly sets up automated releases for the bittensor-rs crate with appropriate bump rules for pre-1.0 versions and well-organized changelog sections.

bittensor-rs/Cargo.toml (1)

5-19: LGTM - Package metadata properly configured for publishing.

The metadata fields (authors, documentation, homepage, repository, readme, keywords) are well-configured for crates.io publication. URLs are consistent and appropriate.

Consider verifying that the rust-version = "1.70" requirement is accurate for your actual MSRV (Minimum Supported Rust Version). Rust 1.70 was released in 2023, so you may want to confirm this is the oldest version you've tested against.

bittensor-rs/README.md (1)

23-26: LGTM - Installation instructions are clear.

The Cargo.toml dependency specification is correct with bittensor-rs = "0.1".

.release-please-manifest.json (1)

1-4: LGTM!

The release-please manifest is correctly configured for the initial 0.1.0 release of bittensor-rs.

bittensor-rs/tests/connection_reliability_tests.rs (1)

3-6: LGTM!

The import path update from bittensor to bittensor_rs correctly follows Rust's crate naming convention where hyphens in package names become underscores in imports.

bittensor-rs/src/service.rs (1)

106-113: LGTM!

The signer_from_seed function correctly uses SecretUri to parse various seed formats (mnemonic, hex) and the error is properly mapped to BittensorError at the call site.

.github/workflows/publish.yml (2)

41-51: LGTM - publish workflow structure is sound.

The dry-run verification before actual publish is a good practice. Using --no-verify on the actual publish is acceptable since the prior step already verified the package.


53-70: LGTM!

The failure notification job properly creates an issue with relevant labels and links to the failed workflow run, providing good visibility for publish failures.

.github/workflows/release-please.yml (1)

1-26: LGTM!

The release-please workflow is correctly configured with appropriate permissions, outputs for downstream consumption, and references to the manifest and config files.

bittensor-rs/src/queries/mod.rs (1)

32-45: LGTM!

The module structure is well-organized with clear separation between account, metagraph, neuron, and subnet queries. The public re-exports provide a clean API surface for consumers.

bittensor-rs/src/connect/mod.rs (1)

55-75: LGTM!

The module structure is well-organized with clear submodule separation. The prelude module follows Rust conventions and provides convenient bulk imports for connection-related types.

Comment on lines +20 to +23
- name: Install Rust toolchain
uses: dtolnay/rust-action@stable
with:
components: rustfmt, clippy

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

dtolnay rust-toolchain github action

💡 Result:

dtolnay/rust-toolchain is a concise GitHub Action that installs a Rust toolchain via rustup. Key points:

  • Repo/README: usage example (one-line use like uses: dtolnay/rust-toolchain@stable or @nightly), inputs (toolchain, targets, components), and outputs (cachekey, name). [1]
  • Action selects toolchain from the action ref by default (e.g. @nightly or @1.89.0); to override with an explicit toolchain input use @master. [1]
  • Marketplace entry and related actions (actions-rust-lang/setup-rust-toolchain) show alternatives with extra features (caching, problem matchers). [2][3]

Sources:
[1] dtolnay/rust-toolchain (README & action.yml).
[2] GitHub Marketplace: Setup Rust Toolchain for GitHub CI (actions-rust-lang).
[3] dtolnay/rust-toolchain repository Actions page.


🌐 Web query:

dtolnay/rust-action github

💡 Result:

You likely mean dtolnay/rust-toolchain — a concise GitHub Action that installs a Rust toolchain via rustup (usage: e.g. uses: dtolnay/rust-toolchain@stable). (github.com)

Citations:


🏁 Script executed:

cat -n .github/workflows/publish.yml | sed -n '20,23p'

Repository: one-covenant/bittensor-rs

Length of output: 226


Invalid GitHub Action reference - workflow will fail.

The action dtolnay/rust-action@stable does not exist. The correct action is dtolnay/rust-toolchain@stable.

       - name: Install Rust toolchain
-        uses: dtolnay/rust-action@stable
+        uses: dtolnay/rust-toolchain@stable
         with:
           components: rustfmt, clippy
🤖 Prompt for AI Agents
In .github/workflows/publish.yml around lines 20 to 23 the workflow references a
non-existent action `dtolnay/rust-action@stable`; replace that reference with
the correct action `dtolnay/rust-toolchain@stable` so the step becomes `uses:
dtolnay/rust-toolchain@stable` and keep the existing `with: components: rustfmt,
clippy` configuration intact.

Comment thread bittensor-rs/README.md
## Quick Start

```rust
use bittensor::{config::BittensorConfig, Service};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Import path inconsistency with crate name.

The example shows use bittensor::{config::BittensorConfig, Service}; but the crate name is bittensor-rs, which means imports should use use bittensor_rs:: (with underscore).

This same issue affects all code examples throughout this README at lines 31, 58, 81, 99, 131, 151, and 174.

🔎 Proposed fix for all occurrences
-use bittensor::{config::BittensorConfig, Service};
+use bittensor_rs::{config::BittensorConfig, Service};

Apply similar changes to all other import statements throughout the file.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
use bittensor::{config::BittensorConfig, Service};
use bittensor_rs::{config::BittensorConfig, Service};
🤖 Prompt for AI Agents
In bittensor-rs/README.md around lines 31, 58, 81, 99, 131, 151, and 174 the
import statements use the incorrect crate path `use bittensor::...`; update each
occurrence to use the actual crate name with an underscore `use
bittensor_rs::...` (e.g., change `use bittensor::{...}` to `use
bittensor_rs::{...}`) and apply the same replacement consistently to all code
examples in the README so imports compile against the crate name.

Comment thread bittensor-rs/src/connect/mod.rs
Comment thread bittensor-rs/src/extrinsics/mod.rs Outdated
Comment thread bittensor-rs/src/queries/mod.rs Outdated
Comment thread bittensor-rs/src/service.rs
Comment thread README.md
Comment on lines +29 to +44
```rust
use bittensor::{config::BittensorConfig, Service};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connect to Finney mainnet
let config = BittensorConfig::finney("my_wallet", "my_hotkey", 1);
let service = Service::new(config).await?;

// Query metagraph
let metagraph = service.get_metagraph(1).await?;
println!("Found {} neurons", metagraph.hotkeys.len());

Ok(())
}
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Import path inconsistency with crate name.

The example shows use bittensor::{config::BittensorConfig, Service}; but the Cargo.toml dependency specifies bittensor-rs = "0.1". This means the import should be use bittensor_rs::{config::BittensorConfig, Service}; (with underscore, not hyphen).

This inconsistency will cause compilation errors for users following the Quick Start guide.

🔎 Proposed fix
-use bittensor::{config::BittensorConfig, Service};
+use bittensor_rs::{config::BittensorConfig, Service};
🤖 Prompt for AI Agents
In README.md around lines 29 to 44 the example imports "bittensor::{...}" but
the crate in Cargo.toml is declared as "bittensor-rs", causing a compile-time
import error; update the import to use the actual crate identifier (replace the
hyphenated crate name with the valid Rust identifier form) and ensure any other
README examples and import references match the crate name in Cargo.toml (or
alternatively update Cargo.toml to expose the intended crate name).

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
bittensor-rs/src/types/balance.rs (1)

79-81: Consider validating or using saturating conversion for f64→u64 casts.

Both Balance::from_tao and tao_to_rao perform unchecked f64 to u64 casts that can panic on:

  • Negative input values
  • Values that overflow u64::MAX when multiplied by RAO_PER_TAO
  • NaN or infinity

Since this is a public SDK being released to crates.io, consider adding validation or using saturating conversions to prevent panics in user code.

🔎 Suggested fix with validation
 pub fn from_tao(tao: f64) -> Self {
+    let tao = tao.max(0.0); // Clamp negative to zero
     let rao = (tao * RAO_PER_TAO as f64) as u64;
     Self { rao }
 }
 pub fn tao_to_rao(tao: f64) -> u64 {
+    let tao = tao.max(0.0); // Clamp negative to zero
     (tao * RAO_PER_TAO as f64) as u64
 }

Alternatively, consider returning Result<Self, Error> to explicitly handle invalid inputs.

Also applies to: 287-289

🧹 Nitpick comments (1)
bittensor-rs/src/extrinsics/weights.rs (1)

40-50: Consider using BittensorError instead of &'static str for error handling.

The signature change from Self to Result<Self, &'static str> is a breaking change (appropriate for an initial release), but the error type is inconsistent with the rest of the codebase. For consistency and better error handling, consider returning Result<Self, BittensorError> instead. This would allow for more descriptive error messages and align with other functions like verify_bittensor_signature that return BittensorError.

Additionally, the doc comment doesn't document the error case. It should mention that an error is returned when UIDs and weights have different lengths.

🔎 Recommended refactor using BittensorError
     /// Create new weights params
     ///
+    /// # Errors
+    ///
+    /// Returns an error if the UIDs and weights vectors have different lengths.
+    ///
     /// # Example
     ///
     /// ```
     /// use bittensor_rs::extrinsics::WeightsParams;
     ///
     /// let params = WeightsParams::new(1, vec![0, 1, 2], vec![100, 200, 300]).unwrap();
     /// assert_eq!(params.netuid, 1);
     /// assert_eq!(params.uids.len(), 3);
     /// ```
-    pub fn new(netuid: u16, uids: Vec<u16>, weights: Vec<u16>) -> Result<Self, &'static str> {
+    pub fn new(netuid: u16, uids: Vec<u16>, weights: Vec<u16>) -> Result<Self, BittensorError> {
         if uids.len() != weights.len() {
-            return Err("UIDs and weights must have the same length");
+            return Err(BittensorError::ConfigError {
+                field: "weights".to_string(),
+                message: format!("UIDs and weights must have the same length: got {} UIDs and {} weights", uids.len(), weights.len()),
+            });
         }
         Ok(Self {
             netuid,
             uids,
             weights,
             version_key: 0,
         })
     }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 039b53f and 8696c31.

📒 Files selected for processing (23)
  • bittensor-rs/examples/test_axon_discovery.rs
  • bittensor-rs/src/config.rs
  • bittensor-rs/src/connect/mod.rs
  • bittensor-rs/src/extrinsics/children.rs
  • bittensor-rs/src/extrinsics/mod.rs
  • bittensor-rs/src/extrinsics/registration.rs
  • bittensor-rs/src/extrinsics/response.rs
  • bittensor-rs/src/extrinsics/root.rs
  • bittensor-rs/src/extrinsics/staking.rs
  • bittensor-rs/src/extrinsics/subnet.rs
  • bittensor-rs/src/extrinsics/transfer.rs
  • bittensor-rs/src/extrinsics/weights.rs
  • bittensor-rs/src/lib.rs
  • bittensor-rs/src/queries/account.rs
  • bittensor-rs/src/queries/metagraph.rs
  • bittensor-rs/src/queries/mod.rs
  • bittensor-rs/src/service.rs
  • bittensor-rs/src/types/account.rs
  • bittensor-rs/src/types/balance.rs
  • bittensor-rs/src/types/hotkey.rs
  • bittensor-rs/src/utils.rs
  • bittensor-rs/src/wallet/mod.rs
  • bittensor-rs/src/wallet/signer.rs
✅ Files skipped from review due to trivial changes (7)
  • bittensor-rs/src/types/hotkey.rs
  • bittensor-rs/src/extrinsics/registration.rs
  • bittensor-rs/src/wallet/signer.rs
  • bittensor-rs/src/config.rs
  • bittensor-rs/src/extrinsics/transfer.rs
  • bittensor-rs/src/queries/metagraph.rs
  • bittensor-rs/src/extrinsics/response.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • bittensor-rs/src/service.rs
  • bittensor-rs/src/connect/mod.rs
  • bittensor-rs/examples/test_axon_discovery.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test
  • GitHub Check: Coverage
🔇 Additional comments (17)
bittensor-rs/src/extrinsics/subnet.rs (1)

42-42: LGTM! Documentation import path updated correctly.

The import path change from bittensor to bittensor_rs correctly reflects the crate naming convention for the crates.io release. The documentation example remains accurate and functional.

bittensor-rs/src/extrinsics/children.rs (1)

34-34: LGTM! Documentation updated to reflect correct crate name.

The import path in the documentation example has been correctly updated to bittensor_rs, ensuring users can reference accurate examples when using the SDK.

bittensor-rs/src/extrinsics/root.rs (1)

38-38: Documentation import path correctly updated.

The import path in the code example has been properly updated from bittensor::extrinsics to bittensor_rs::extrinsics on line 38, aligning with the crate renaming for this initial SDK release. A search of the codebase confirms no remaining old-style imports in documentation comments and consistent application of the new crate path throughout.

bittensor-rs/src/types/account.rs (1)

15-15: LGTM! Documentation paths updated correctly.

The documentation examples have been updated to use the correct crate path bittensor_rs::types for the crates.io release.

Also applies to: 32-32

bittensor-rs/src/types/balance.rs (1)

23-23: LGTM! Comprehensive documentation path updates.

All documentation examples have been correctly updated to use bittensor_rs::types for the crates.io release. The examples are well-written and cover the API surface thoroughly.

Also applies to: 45-45, 60-60, 74-74, 89-89, 103-103, 117-117, 131-131, 149-149, 167-167, 183-183, 282-282, 296-296

bittensor-rs/src/utils.rs (1)

38-38: LGTM! Documentation paths updated correctly.

The documentation examples have been properly updated to reflect the new crate path bittensor_rs::.

Also applies to: 115-116

bittensor-rs/src/lib.rs (1)

14-14: LGTM! Quick Start example updated correctly.

The documentation correctly references the new crate path.

bittensor-rs/src/wallet/mod.rs (2)

9-9: LGTM! Documentation updated consistently.

All documentation examples have been properly updated to use the bittensor_rs:: crate path.

Also applies to: 43-43, 48-48, 94-94, 97-97, 115-115, 120-120, 164-166, 193-193, 197-197, 233-233, 275-277, 305-307, 321-323, 336-338, 364-366


442-442: LGTM! Test adjustments are appropriate.

Using .unwrap() on Wallet::create_random in tests is acceptable since create_random returns a Result and test failures are expected to panic.

Also applies to: 452-452, 462-462, 491-491, 498-498, 505-505, 515-515

bittensor-rs/src/extrinsics/staking.rs (1)

35-35: LGTM! Documentation examples updated correctly.

The documentation has been properly updated to use the bittensor_rs:: crate path, and the examples now use the ignore attribute which is appropriate for code that requires real infrastructure.

Also applies to: 78-90

bittensor-rs/src/extrinsics/weights.rs (2)

276-280: LGTM! Tests properly updated for the new constructor signature.

All test call sites correctly handle the Result return type with .unwrap(), which is appropriate for test code.

Also applies to: 285-289, 293-300


160-168: LGTM! Documentation example updated correctly.

The example properly demonstrates the new constructor signature with .unwrap() and uses the correct bittensor_rs:: crate path.

bittensor-rs/src/extrinsics/mod.rs (2)

1-16: Well-structured module documentation!

The reorganized documentation with categorized table format clearly presents all available extrinsic functions, making the API surface easy to understand.


68-68: LGTM: transfer_all properly exported.

The addition of transfer_all to the public exports is consistent with the documentation and expands the transfer functionality appropriately.

bittensor-rs/src/queries/account.rs (1)

27-27: Documentation import path correctly updated.

The example now references the correct crate name bittensor_rs::queries::get_balance, aligning with the crate renaming in this PR.

bittensor-rs/src/queries/mod.rs (2)

1-11: Improved documentation structure and clarity.

The module documentation has been enhanced with a clearer title, structured overview of available query types, and better organization. This improves discoverability for users of the SDK.


32-45: Module structure and exports look correct.

The module declarations and public re-exports are well organized, providing a clean public API surface for the Chain Queries functionality.

Comment on lines +28 to +33
//! let params = WeightsParams {
//! netuid: 1,
//! uids: vec![0, 1, 2],
//! weights: vec![100, 200, 300],
//! version_key: 0,
//! };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find the file containing WeightsParams definition
fd -t f -e rs | xargs grep -l "struct WeightsParams" | head -5

Repository: one-covenant/bittensor-rs

Length of output: 107


🏁 Script executed:

#!/bin/bash
# Search for WeightsParams struct definition
rg "struct WeightsParams" -A 15 -B 2

Repository: one-covenant/bittensor-rs

Length of output: 1179


🏁 Script executed:

#!/bin/bash
# Search for WeightsParams::new constructor
rg "impl.*WeightsParams" -A 20 | head -50

Repository: one-covenant/bittensor-rs

Length of output: 2934


🏁 Script executed:

#!/bin/bash
# Read the example code in mod.rs around lines 17-44
sed -n '17,44p' bittensor-rs/src/extrinsics/mod.rs

Repository: one-covenant/bittensor-rs

Length of output: 962


Use WeightsParams::new() constructor instead of direct struct construction.

The example constructs WeightsParams directly as a struct literal, but the WeightsParams::new() constructor returns a Result and validates that uids and weights have matching lengths. Direct construction bypasses this validation. Update the example to use the constructor pattern: WeightsParams::new(1, vec![0, 1, 2], vec![100, 200, 300]).unwrap() (which also automatically sets version_key: 0, eliminating the need to specify it manually).

🤖 Prompt for AI Agents
In bittensor-rs/src/extrinsics/mod.rs around lines 28 to 33, the example
constructs WeightsParams directly which bypasses validation; replace the struct
literal with the constructor call WeightsParams::new(netuid, uids,
weights).unwrap() (e.g., WeightsParams::new(1, vec![0,1,2],
vec![100,200,300]).unwrap()) so the lengths of uids and weights are validated
and version_key is set automatically.

Comment on lines +14 to +28
//! ```rust,ignore
//! use bittensor_rs::queries::{get_metagraph, get_balance, get_neuron};
//!
//! async fn example(client: &subxt::OnlineClient<subxt::PolkadotConfig>, account_id: &subxt::config::polkadot::AccountId32) -> Result<(), Box<dyn std::error::Error>> {
//! // Get metagraph for subnet 1
//! let metagraph = get_metagraph(client, 1).await?;
//!
//! // Check account balance
//! let balance = get_balance(client, account_id).await?;
//!
//! // Get specific neuron by UID
//! let neuron = get_neuron(client, 1, 0).await?;
//! Ok(())
//! }
//! ```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix type mismatch in documentation example.

Line 22 calls get_balance(client, account_id) where account_id is typed as &subxt::config::polkadot::AccountId32, but the get_balance function signature (from account.rs line 38) expects address: &str.

This example will not compile due to the type mismatch.

🔎 Proposed fix

Option 1: Use a string address directly:

-//! async fn example(client: &subxt::OnlineClient<subxt::PolkadotConfig>, account_id: &subxt::config::polkadot::AccountId32) -> Result<(), Box<dyn std::error::Error>> {
+//! async fn example(client: &subxt::OnlineClient<subxt::PolkadotConfig>) -> Result<(), Box<dyn std::error::Error>> {
 //!     // Get metagraph for subnet 1
 //!     let metagraph = get_metagraph(client, 1).await?;
 //!
 //!     // Check account balance
-//!     let balance = get_balance(client, account_id).await?;
+//!     let balance = get_balance(client, "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY").await?;
 //!
 //!     // Get specific neuron by UID
 //!     let neuron = get_neuron(client, 1, 0).await?;

Option 2: Convert AccountId32 to SS58 string (if demonstrating AccountId usage is important):

+//! use subxt::ext::sp_core::crypto::Ss58Codec;
+//!
 //! async fn example(client: &subxt::OnlineClient<subxt::PolkadotConfig>, account_id: &subxt::config::polkadot::AccountId32) -> Result<(), Box<dyn std::error::Error>> {
 //!     // Get metagraph for subnet 1
 //!     let metagraph = get_metagraph(client, 1).await?;
 //!
 //!     // Check account balance
-//!     let balance = get_balance(client, account_id).await?;
+//!     let balance = get_balance(client, &account_id.to_ss58check()).await?;
 //!
 //!     // Get specific neuron by UID
 //!     let neuron = get_neuron(client, 1, 0).await?;

@distributedstatemachine
distributedstatemachine merged commit 55eca76 into main Dec 27, 2025
1 of 3 checks passed
@distributedstatemachine
distributedstatemachine deleted the feat/crates.io branch December 27, 2025 23:10
@coderabbitai coderabbitai Bot mentioned this pull request Dec 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant