Skip to content

Commit

Permalink
Update scale-bits and scale-encode (#599)
Browse files Browse the repository at this point in the history
* update scale-bits and scale-encode

* add Box import

* fix scale-decode
  • Loading branch information
haerdib committed Jun 29, 2023
1 parent 3162233 commit bb24966
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
34 changes: 12 additions & 22 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions node-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ either = { version = "1.6.1", default-features = false }
frame-metadata = { version = "15.1", default-features = false, features = ["v14", "v15-unstable", "serde_full", "decode"] }
hex = { version = "0.4.3", default-features = false }
log = { version = "0.4.14", default-features = false }
scale-bits = { version = "0.4.0", default-features = false, features = ["scale-info", "serde"] }
scale-info = { version = "2.0.1", features = ["derive", "decode", "bitvec"], default-features = false }
serde = { version = "1.0.136", features = ["derive"], default-features = false }
serde_json = { version = "1.0.79", default-features = false, features = ["alloc"] }

# scale
scale-bits = { default-features = false, features = ["scale-info", "serde"], git = "https://github.com/haerdib/scale-bits.git", branch = "bh/no-std" }
scale-decode = { default-features = false, features = ["primitive-types", "derive"], git = "https://github.com/scs/scale-decode.git", branch = "no-std" }
scale-encode = { default-features = false, features = ["bits", "primitive-types", "derive"], git = "https://github.com/scs/scale-encode.git", branch = "no-std" }
scale-encode = { default-features = false, features = ["bits", "primitive-types", "derive"], git = "https://github.com/paritytech/scale-encode.git" }

# substrate
sp-core = { default-features = false, features = ["full_crypto", "serde"], git = "https://github.com/paritytech/substrate.git", branch = "master" }
Expand Down
6 changes: 4 additions & 2 deletions node-api/src/scale_value/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! Based on https://github.com/paritytech/scale-value/blob/430bfaf8f302dfcfc45d8d63c687628fd9b7fc25/src/scale_impls/encode.rs

use crate::scale_value::{Composite, Primitive, Value, ValueDef, Variant};
use alloc::{string::ToString, vec::Vec};
use alloc::{boxed::Box, string::ToString, vec::Vec};
use codec::{Compact, Encode};
use scale_encode::{
error::{ErrorKind, Kind},
Expand Down Expand Up @@ -45,7 +45,9 @@ impl<T> EncodeAsFields for Value<T> {
) -> Result<(), Error> {
match &self.value {
ValueDef::Composite(composite) => composite.encode_as_fields_to(fields, types, out),
_ => Err(Error::custom("Cannot encode non-composite Value shape into fields")),
_ => Err(Error::new(ErrorKind::Custom(Box::new(
"Cannot encode non-composite Value shape into fields".to_string(),
)))),
}
}
}
Expand Down

0 comments on commit bb24966

Please sign in to comment.