Skip to content

Releases: near/near-jsonrpc-client-rs

v0.6.0

02 Jun 19:52
517ba06
Compare
Choose a tag to compare

Other

  • [breaking] Upgrade near primitive crates version to 0.17.0 (#126)

v0.5.1

22 Mar 17:43
2991aa7
Compare
Choose a tag to compare

What's changed?

  • Updated borsh to 0.10.2. #124

Crate Link: https://crates.io/crates/near-jsonrpc-client/0.5.1

Full Changelog: v0.5.0...v0.5.1

🎉 Thanks to @aleksuss for their contributions to this release. 🎉

v0.5.0

24 Feb 21:21
1079e0a
Compare
Choose a tag to compare

What's changed?

Added

  • ApiKey::new now accepts byte arrays and byte slices. #119
  • Authorization::bearer method for token-authenticated requests. #121
  • ApiKey::as_bytes returns a byte slice of the key without utf-8 validation. #119

Changed

  • Updated nearcore dependencies to 0.16.0, which now requires a MSRV of 1.67.1. #122
  • ApiKey::new no longer requres the input of a valid UUID. #119
  • Debug on ApiKey doesn't reveal the key anymore. #120
  • The auth module is no longer feature gated. #119

Breaking

  • Removed the auth::IntoApiKey trait, any thing you can get a byte slice from is now a valid ApiKey input. #119
  • Replaced the ApiKey::as_str method with ApiKey::to_str, now returning a Result. #119
  • Replaced the InvalidApiKey error with InvalidHeaderValue re-exported from http. #119
  • Removed Display on ApiKey. #117

Crate Link: https://crates.io/crates/near-jsonrpc-client/0.5.0

Full Changelog: v0.4.1...v0.5.0

🎉 Thanks to @anthony-near, @iTranscend and @miraclx for their contributions to this release. 🎉

v0.4.1

11 Nov 02:15
76fbf59
Compare
Choose a tag to compare

What's changed?

  • Fixed an issue where an &RpcMethod's response was being parsed differently from an RpcMethod. #114

Crate Link: https://crates.io/crates/near-jsonrpc-client/0.4.1

Full Changelog: v0.4.0...v0.4.1

🎉 Thanks to @miraclx for their contributions to this release. 🎉

v0.4.0

04 Oct 01:35
b526240
Compare
Choose a tag to compare

What's changed?

  • Updated nearcore dependencies, which now requires a MSRV of 1.64.0. #100, #110
  • Updated other dependencies, with some general improvements. #111
  • Added rustls-tls feature flag to enable rustls as an alternative to native-tls. #103
  • Switched to using log::debug! instead of log::info! for debug logging. #107
  • Fixed gas_price RPC method serialization. #73
  • Fixed query method error deserialization. #82
  • Reworked the JsonRpcError::handler_error method. #99
  • Moved auth specific logic behind a feature flag. #55
  • Added the methods::to_json() helper method for visualizing the serialization of the RPC methods. #49

Crate Link: https://crates.io/crates/near-jsonrpc-client/0.4.0

Full Changelog: v0.3.0...v0.4.0

🎉 Thanks to @iTranscend, @joel-u410, @joshuajbouw, @medvedNick and @miraclx for their contributions to this release. 🎉

v0.4.0-beta.0

31 May 15:24
bdf3158
Compare
Choose a tag to compare
v0.4.0-beta.0 Pre-release
Pre-release

What's changed?

  • Updated nearcore dependencies, fixing a previous breaking change. #100
  • Fixed gas_price RPC method serialization. #73
  • Fixed query method error deserialization. #82
  • Reworked the JsonRpcError::handler_error method. #99
  • Moved auth specific logic behind a feature flag. #55
  • Added the methods::to_json() helper method for visualizing the serialization of the RPC methods. #49

Crate Link: https://crates.io/crates/near-jsonrpc-client/0.4.0-beta.0

Full Changelog: v0.3.0...v0.4.0-beta.0

v0.3.0

09 Feb 10:18
56b1a7d
Compare
Choose a tag to compare

What's changed?

  • Dropped generic authentication and added support for custom headers. #47
  • Added the sandbox_fast_forward RPC Method. #38
  • Upgraded nearcore crates to v0.12.0 #48
  • Executing the examples now allows custom RPC addr specification with interactive server selection. b130118 c5e938a
  • JsonRpcClient::connect is now generic over any url-like type. Url, &str, String and &String are all supported. #35
  • JsonRpcClient now defaults to the Unauthenticated state, easing a type specification pain point. #36

Crate Link: https://crates.io/crates/near-jsonrpc-client/0.3.0

Full Changelog: v0.2.0...v0.3.0

v0.2.0

22 Dec 17:01
34acf7d
Compare
Choose a tag to compare

What's Changed

  • Updated nearcore version to 0.11.0 (near/nearcore#5943).
  • Fixed chunk method serialization. f40ad74
  • Client::call no longer consumes the client. 471a53b
  • Implemented workaround for partially serialized server responses. #29
  • Dropped base64 API token support in favor of a generic key-value approach. dd7761b
  • Added examples to repo. #32
  • Ensured None-typed wrapped errors are actual errors (i.e. have all traits attributed with errors, especially fmt::Display). #34

Crate Link: https://crates.io/crates/near-jsonrpc-client/0.2.0

Full Changelog: v0.1.0...v0.2.0

Initial Release: v0.1.0 🎉

11 Nov 04:37
f60ff14
Compare
Choose a tag to compare

Documentation: https://docs.rs/near-jsonrpc-client/0.1.0/near_jsonrpc_client
Full Changelog: https://github.com/near/near-jsonrpc-client-rs/commits/v0.1.0

near-jsonrpc-client

Lower-level API for interfacing with the NEAR Protocol via JSONRPC.

crates.io Documentation Version MIT or Apache 2.0 licensed Dependency Status

Usage

Each one of the valid JSON RPC methods are defined in the methods module.
For instance, to make a tx request, you start with the tx module
and construct a request using the methods::tx::RpcTransactionStatusRequest struct.

use near_jsonrpc_client::{methods, JsonRpcClient};
use near_jsonrpc_primitives::types::transactions::TransactionInfo;

let mainnet_client = JsonRpcClient::connect("https://archival-rpc.mainnet.near.org");

let tx_status_request = methods::tx::RpcTransactionStatusRequest {
    transaction_info: TransactionInfo::TransactionId {
        hash: "9FtHUFBQsZ2MG77K3x3MJ9wjX3UT8zE1TczCrhZEcG8U".parse()?,
        account_id: "miraclx.near".parse()?,
    },
};

// call a method on the server via the connected client
let tx_status = mainnet_client.call(tx_status_request).await?;

println!("{:?}", tx_status);

For all intents and purposes, the predefined structures in methods should suffice, if you find that they
don't or you crave extra flexibility, well, you can opt in to use the generic constructor methods::any() with the any feature flag.

In this example, we retrieve only the parts from the genesis config response that we care about.

# in Cargo.toml
near-jsonrpc-client = { ..., features = ["any"] }
use serde::Deserialize;
use serde_json::json;

use near_jsonrpc_client::{methods, JsonRpcClient};
use near_primitives::serialize::u128_dec_format;
use near_primitives::types::*;

#[derive(Debug, Deserialize)]
struct PartialGenesisConfig {
    protocol_version: ProtocolVersion,
    chain_id: String,
    genesis_height: BlockHeight,
    epoch_length: BlockHeightDelta,
    #[serde(with = "u128_dec_format")]
    min_gas_price: Balance,
    #[serde(with = "u128_dec_format")]
    max_gas_price: Balance,
    #[serde(with = "u128_dec_format")]
    total_supply: Balance,
    validators: Vec<AccountInfo>,
}

impl methods::RpcHandlerResponse for PartialGenesisConfig {}

let mainnet_client = JsonRpcClient::connect("https://rpc.mainnet.near.org");

let genesis_config_request = methods::any::<Result<PartialGenesisConfig, ()>>(
    "EXPERIMENTAL_genesis_config",
    json!(null),
);

let partial_genesis = mainnet_client.call(genesis_config_request).await?;

println!("{:#?}", partial_genesis);