Skip to content

Conversation

@zees-dev
Copy link
Collaborator

@zees-dev zees-dev commented Jul 8, 2025

Description

This pull request introduces significant updates to the Blockless SDK, focusing on improving HTTP client functionality, updating examples, and enhancing documentation.

Additionally introduced json-rpc based host-call; through which the HTTP-v2 client operates.
Going forward this will be the single/primary entrypoint/host-call through which all the modules call host functionality.

HTTP Client Enhancements:

  • Added a new HTTP client (HttpClient) with support for advanced features such as query parameters, authentication, multipart file uploads, and custom headers. This replaces the legacy BlocklessHttp implementation. (examples/http_client.rs, examples/http_client.rsR1-R175)

Example Updates:

  • Updated examples/coingecko_oracle.rs to use the new HttpClient for making HTTP requests, simplifying the code and improving readability. (examples/coingecko_oracle.rs, [1] [2]
  • Added a new example examples/ipfs_api.rs demonstrating the use of the HTTP client for interacting with the IPFS API, including file uploads and repository statistics. (examples/ipfs_api.rs, examples/ipfs_api.rsR1-R298)
  • Removed the outdated examples/httpbin.rs and replaced it with examples/http_client.rs, showcasing the new HTTP client capabilities. (examples/httpbin.rs, examples/httpbin.rsL1-L26)

Documentation Updates:

  • Revised the README.md to reflect changes in build commands, example file names, and descriptions of updated features. (README.md, [1] [2] [3]

Dependency Updates:

  • Added the base64 crate as a new dependency to support encoding and decoding operations. (Cargo.toml, Cargo.tomlR13)

Pre-requisites

This comment was marked as outdated.

@zees-dev zees-dev requested a review from Copilot July 14, 2025 03:09
Copy link

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 legacy HTTP bindings with a full reqwest-like HTTP client built on the new JSON-RPC host call and also introduces a unified RpcClient. Key changes include:

  • Added RpcClient for JSON-RPC 2.0 calls in src/rpc.rs
  • Replaced BlocklessHttp FFI with HttpClient, HttpOptions, and RequestBuilder in src/http.rs
  • Updated examples and README to use the new client and added the base64 dependency

Reviewed Changes

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

Show a summary per file
File Description
src/rpc.rs Added unified JSON-RPC client (RpcClient) with error mapping and tests
src/http.rs Implemented HttpClient, HttpOptions, and RequestBuilder for HTTP RPC
src/lib.rs Exposed http and rpc modules publicly
README.md Updated build commands and example references
Cargo.toml Added base64 dependency
examples/http_client.rs New HTTP v2 client demo
examples/ipfs_api.rs New IPFS API example demonstrating file uploads
examples/rpc.rs New RPC client usage example
examples/httpbin.rs Removed outdated HTTP example
examples/coingecko_oracle.rs Updated to use the new HttpClient
Comments suppressed due to low confidence (4)

src/http.rs:79

  • [nitpick] The naming for binary body methods is inconsistent: HttpOptions provides body_binary but RequestBuilder uses body_bytes. Consider unifying the method names to improve consistency, e.g., use body_bytes in both places or rename both to body_binary.
    pub fn body_binary(mut self, data: Vec<u8>) -> Self {

src/http.rs:357

  • [nitpick] Creating a new RpcClient for each HTTP request can lead to repeated buffer allocations and reset of the next_id counter. Consider reusing a single RpcClient instance inside HttpClient to reduce allocation overhead and preserve request sequencing.
    fn execute(&self, builder: &RequestBuilder) -> Result<HttpResponse, HttpError> {

src/rpc.rs:146

  • There are no tests covering the error mapping in RpcClient::call when rpc_call returns non-zero codes. Consider adding unit tests to simulate each return value and verify it maps to the correct RpcError variant.
        if result != 0 {

src/rpc.rs:90

  • [nitpick] The public RpcClient API lacks Rustdoc comments. Adding documentation for RpcClient and its key methods (new, call, ping, echo, version) would improve usability and maintainability.
pub struct RpcClient {

@zees-dev zees-dev merged commit 5ad0dba into main Jul 15, 2025
1 check passed
@zees-dev zees-dev deleted the feat/http-v2-client branch July 15, 2025 02:08
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