Skip to content

Commit

Permalink
near: update borsh dependency from 0.9.3 to 0.10.3 (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
mina86 authored Oct 27, 2023
1 parent 1448ca5 commit 17bd639
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
27 changes: 9 additions & 18 deletions 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 light-clients/ics13-near/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mocks = ["clock", "std", "sha3", "ripemd", "ibc/mocks"]

[dependencies]
# Proto definitions for all IBC-related interfaces, e.g., connections or channels.
borsh = { version = "0.9.3", default-features = false }
borsh = { version = "0.10.3", default-features = false }
ibc = { path = "../../ibc/modules", default-features = false }
ibc-proto = { path = "../../ibc/proto", default-features = false }
ibc-derive = { path = "../../ibc/derive", default-features = false }
Expand Down
29 changes: 19 additions & 10 deletions light-clients/ics13-near/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
// limitations under the License.

use alloc::vec::Vec;
use borsh::maybestd::{io::Write, string::String};

use borsh::{BorshDeserialize, BorshSerialize};
use borsh::{
maybestd::{io, string::String},
BorshDeserialize, BorshSerialize,
};
use sp_core::ed25519::{Public as Ed25519Public, Signature as Ed25519Signature};

use crate::client_def::HostFunctions;
Expand Down Expand Up @@ -238,15 +240,15 @@ pub struct MerklePathItem {
}

impl BorshDeserialize for Signature {
fn deserialize(buf: &mut &[u8]) -> Result<Self, borsh::maybestd::io::Error> {
let _key_type: [u8; 1] = BorshDeserialize::deserialize(buf)?;
let array: [u8; Self::LEN] = BorshDeserialize::deserialize(buf)?;
fn deserialize_reader<R: io::Read>(rd: &mut R) -> io::Result<Self> {
read_key_type(rd)?;
let array = BorshDeserialize::deserialize_reader(rd)?;
Ok(Signature::Ed25519(Ed25519Signature::from_raw(array)))
}
}

impl BorshSerialize for Signature {
fn serialize<W: Write>(&self, writer: &mut W) -> Result<(), borsh::maybestd::io::Error> {
fn serialize<W: io::Write>(&self, writer: &mut W) -> io::Result<()> {
match self {
Signature::Ed25519(signature) => {
BorshSerialize::serialize(&0u8, writer)?;
Expand All @@ -258,17 +260,24 @@ impl BorshSerialize for Signature {
}

impl BorshSerialize for PublicKey {
fn serialize<W: Write>(&self, writer: &mut W) -> Result<(), borsh::maybestd::io::Error> {
fn serialize<W: io::Write>(&self, writer: &mut W) -> io::Result<()> {
BorshSerialize::serialize(&0u8, writer)?;
writer.write_all(&self.0)?;
Ok(())
}
}

impl BorshDeserialize for PublicKey {
fn deserialize(buf: &mut &[u8]) -> Result<Self, borsh::maybestd::io::Error> {
let _key_type: [u8; 1] = BorshDeserialize::deserialize(buf)?;
Ok(Self(BorshDeserialize::deserialize(buf)?))
fn deserialize_reader<R: io::Read>(rd: &mut R) -> io::Result<Self> {
read_key_type(rd)?;
BorshDeserialize::deserialize_reader(rd).map(Self)
}
}

fn read_key_type<R: io::Read>(rd: &mut R) -> io::Result<()> {
match u8::deserialize_reader(rd)? {
8 => Ok(()),
key_type => Err(io::ErrorKind::InvalidData.into()),

Check warning on line 280 in light-clients/ics13-near/src/types.rs

View workflow job for this annotation

GitHub Actions / Linters

unused variable: `key_type`
}
}

Expand Down

0 comments on commit 17bd639

Please sign in to comment.