Releases: near/near-jsonrpc-client-rs
v0.6.0
v0.5.1
What's changed?
- Updated
borsh
to0.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
What's changed?
Added
ApiKey::new
now accepts byte arrays and byte slices. #119Authorization::bearer
method for token-authenticated requests. #121ApiKey::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 of1.67.1
. #122 ApiKey::new
no longer requres the input of a valid UUID. #119Debug
onApiKey
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 validApiKey
input. #119 - Replaced the
ApiKey::as_str
method withApiKey::to_str
, now returning aResult
. #119 - Replaced the
InvalidApiKey
error withInvalidHeaderValue
re-exported fromhttp
. #119 - Removed
Display
onApiKey
. #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
What's changed?
- Fixed an issue where an
&RpcMethod
's response was being parsed differently from anRpcMethod
. #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
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 enablerustls
as an alternative tonative-tls
. #103 - Switched to using
log::debug!
instead oflog::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
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
What's changed?
- Dropped generic authentication and added support for custom headers. #47
- Added the
sandbox_fast_forward
RPC Method. #38 - Upgraded
nearcore
crates tov0.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. #35JsonRpcClient
now defaults to theUnauthenticated
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
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, especiallyfmt::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 🎉
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.
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);