Skip to content

feat: rust algod client #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 74 commits into
base: main
Choose a base branch
from
Open

feat: rust algod client #179

wants to merge 74 commits into from

Conversation

aorumbayev
Copy link
Collaborator

@aorumbayev aorumbayev commented Jun 26, 2025

PR Description

This PR migrates from OpenAPI code generation to a custom Jinja2-based Rust client generator, removing Python/TypeScript clients for a unified Rust ecosystem.

Key Changes

Custom Rust OAS Generator

  • Added Jinja2-based code generator in api/oas_generator/
  • Implements Algorand-specific features including msgpack support and signed transaction handling
  • Supports vendor extension x-algokit-signed-txn for transaction endpoints
  • Complete type mapping from OpenAPI to Rust with proper error handling

New Rust Client Architecture

  • Replaced algod_api crate with generated algod_client crate
  • Migrated from reqwest to custom algokit_http_client for better abstraction
  • Automatic content type detection (JSON/msgpack) with proper serialization

Cleanup & Consolidation

  • Removed entire packages/ directory containing Python/TypeScript clients
  • Removed legacy OpenAPI templates and configuration files
  • Updated workspace dependencies to use new client architecture

Enhanced Documentation

  • Updated API README with comprehensive setup instructions
  • Added generator architecture documentation

Client Interface Improvements

  • Simplified client instantiation with network presets
  • Removed configuration complexity in favor of dependency injection
  • Better separation of concerns between HTTP client and API client
  • Comprehensive test suite with integration tests

Breaking Changes

  • algod_api crate replaced with algod_client
  • Python and TypeScript clients removed
  • Client instantiation API changed to use dependency injection pattern
  • Configuration management simplified

Next steps

Exposing AlgodClient via ffi is out of scope of this pr given # number of changes it introduces. Initial integration with changes from #166 are in place though

joe-p added 30 commits June 3, 2025 11:29
Had to work around this bug in maturin:
PyO3/maturin#2459

This fix is relatively simple but requires you to modify the packages
post-installation. A fix (more like feature) can be added to maturin and
I think it should be fairly straightforward
There is something weird going on with the env package though. For now
you need to bun rm env, run the build script, and then bun i env before
running the tests
Mutex works in WASM and only adds a few nanos of overhead, so just
easier to use Mutex for both uniffi and wasm
It works, but there seems to be some closure that isn't getting cleaned
up properly in the async call
Bun prefers main over module for some reason at runtime. See
oven-sh/bun#13430 (comment)
@aorumbayev aorumbayev force-pushed the feat/rust-client branch 2 times, most recently from 81aad13 to 10f4f80 Compare June 26, 2025 14:21
@aorumbayev aorumbayev marked this pull request as ready for review June 26, 2025 14:37
@Copilot Copilot AI review requested due to automatic review settings June 26, 2025 14:37
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces the autogenerated Python/TypeScript Algod clients with a custom Jinja2-based Rust client generator, consolidating all endpoints into a new algod_client crate and removing the old algod_api crate.

  • Introduced a unified Rust client in crates/algod_client with full endpoint coverage and message-pack support
  • Removed Python/TypeScript clients and legacy crates/algod_api
  • Updated workspace to use algokit_http_client and streamlined client instantiation

Reviewed Changes

Copilot reviewed 174 out of 604 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/algod_client/src/apis/mod.rs Added consolidated API modules and error mapping
crates/algod_client/src/apis/*.rs Implemented each endpoint with JSON/MsgPack support
crates/algod_client/src/apis/client.rs Exposed ergonomic AlgodClient interface
crates/algod_client/README.md Updated crate README for Rust client usage
crates/algod_client/Cargo.toml Defined algod_client package and dependencies
crates/algod_api/src/lib.rs & Cargo.toml Removed legacy Python/TS client code
Comments suppressed due to low confidence (2)

crates/algod_client/src/apis/health_check.rs:25

  • The variant Statusdefault does not follow Rust’s PascalCase convention. Consider renaming it to StatusDefault for consistency.
    Statusdefault(),

crates/algod_client/README.md:22

  • The usage example references configuration and default_api, which no longer exist. Update this snippet to show instantiation of AlgodClient (e.g., let client = AlgodClient::testnet();).
use algod_client::apis::{configuration, default_api};

Self::new(http_client)
}

/// Create a new AlgodClient for a local localnet environment.
Copy link
Preview

Copilot AI Jun 26, 2025

Choose a reason for hiding this comment

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

[nitpick] The phrase "local localnet" is redundant. Consider simplifying to "Create a new AlgodClient for a localnet environment."

Suggested change
/// Create a new AlgodClient for a local localnet environment.
/// Create a new AlgodClient for a localnet environment.

Copilot uses AI. Check for mistakes.

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.

3 participants