Skip to content

Commit

Permalink
Fix JSON-RPC parse failure (#51)
Browse files Browse the repository at this point in the history
* Fix JSON-RPC parse failure

* update version
  • Loading branch information
its-saeed authored Jun 18, 2024
1 parent d7b344d commit a6ef068
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zilliqa-rs"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
description = "A Rust SDK for Zilliqa blockchain"
license = "MIT"
Expand Down
11 changes: 10 additions & 1 deletion src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod types;
pub mod units;

use bech32::{FromBase32, ToBase32, Variant};
use primitive_types::H160;
pub use types::*;
pub use units::*;

Expand Down Expand Up @@ -260,7 +261,7 @@ impl ZilAddress {

fn to_checksum_address(address: &str) -> Result<String, Error> {
let address = address.replace("0x", "");
if !ZilAddress::is_address(&address) {
if !Self::is_address(&address) {
return Err(Error::InvalidAddress(address.to_string()));
}

Expand Down Expand Up @@ -335,6 +336,14 @@ impl FromStr for ZilAddress {
}
}

impl TryFrom<H160> for ZilAddress {
type Error = Error;

fn try_from(value: H160) -> Result<Self, Self::Error> {
Self::from_str(&hex::encode(value))
}
}

impl Display for ZilAddress {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
Expand Down
6 changes: 3 additions & 3 deletions src/core/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! JSON-RPC related data types.
use std::fmt;
use std::{collections::BTreeMap, fmt};

use primitive_types::H160;
use prost::Message;
Expand Down Expand Up @@ -433,7 +433,7 @@ pub struct TransactionReceipt {
pub exceptions: Option<Vec<ExceptionEntry>>,
pub success: bool,
pub transitions: Option<Vec<TransitionEntry>>,
pub errors: Option<String>,
pub errors: Option<BTreeMap<u64, Vec<u64>>>,
}

impl TransactionReceipt {
Expand Down Expand Up @@ -537,7 +537,7 @@ pub struct SmartContractCode {
}

#[derive(Deserialize, Debug, Clone)]
pub struct SmartContracts(Vec<SmartContractAddress>);
pub struct SmartContracts(pub Vec<SmartContractAddress>);

#[derive(Deserialize, Debug, Clone)]
pub struct SmartContractAddress {
Expand Down

0 comments on commit a6ef068

Please sign in to comment.