Skip to content

Commit

Permalink
Update scale-info and parity-scale-codec requirements (#462)
Browse files Browse the repository at this point in the history
* Update scale-info and parity-scale-codec requirements

* Update CHANGELOG

* Update frame-metadata

* Update bitvec

* Fix test

* Update bitvec event decoding

* More bitvec updates

* Update substrate primitives dependencies

* Fix up bitvec errors and decode error

* Fix up bitvec errors

* Update polkadot codegen
  • Loading branch information
ascjones authored Mar 1, 2022
1 parent 1334736 commit 11f24d7
Show file tree
Hide file tree
Showing 12 changed files with 216 additions and 172 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Update scale-info and parity-scale-codec requirements ([#462](https://github.com/paritytech/subxt/pull/462))

## [0.17.0] - 2022-02-04

### Added
Expand Down
4 changes: 2 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ serde_json = "1.0.68"
# hex encoded metadata to bytes
hex = "0.4.3"
# actual metadata types
frame-metadata = { version = "14.0.0", features = ["v14", "std"] }
frame-metadata = { version = "15.0.0", features = ["v14", "std"] }
# decode bytes into the metadata types
scale = { package = "parity-scale-codec", version = "2.3.0", default-features = false }
scale = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
# handle urls to communicate with substrate nodes
url = { version = "2.2.2", features = ["serde"] }
# generate the item mod for codegen
Expand Down
8 changes: 4 additions & 4 deletions codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ description = "Generate an API for interacting with a substrate node from FRAME

[dependencies]
async-trait = "0.1.49"
codec = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full", "bit-vec"] }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "full", "bit-vec"] }
darling = "0.13.0"
frame-metadata = "14.0"
frame-metadata = "15.0.0"
heck = "0.4.0"
proc-macro2 = "1.0.24"
proc-macro-crate = "0.1.5"
proc-macro-error = "1.0.4"
quote = "1.0.8"
syn = "1.0.58"
scale-info = { version = "1.0.0", features = ["bit-vec"] }
scale-info = { version = "2.0.0", features = ["bit-vec"] }

[dev-dependencies]
bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] }
pretty_assertions = "1.0.0"
8 changes: 4 additions & 4 deletions codegen/src/types/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,8 @@ fn generate_bitvec() {
#[allow(unused)]
#[derive(TypeInfo)]
struct S {
lsb: BitVec<Lsb0, u8>,
msb: BitVec<Msb0, u16>,
lsb: BitVec<u8, Lsb0>,
msb: BitVec<u16, Msb0>,
}

let mut registry = Registry::new();
Expand All @@ -710,8 +710,8 @@ fn generate_bitvec() {
use super::root;
#[derive(::subxt::codec::Encode, ::subxt::codec::Decode, Debug)]
pub struct S {
pub lsb: ::subxt::bitvec::vec::BitVec<root::bitvec::order::Lsb0, ::core::primitive::u8>,
pub msb: ::subxt::bitvec::vec::BitVec<root::bitvec::order::Msb0, ::core::primitive::u16>,
pub lsb: ::subxt::bitvec::vec::BitVec<::core::primitive::u8, root::bitvec::order::Lsb0>,
pub msb: ::subxt::bitvec::vec::BitVec<::core::primitive::u16, root::bitvec::order::Msb0>,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/types/type_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl TypePathType {
let bit_order_type = &self.params[0];
let bit_store_type = &self.params[1];

let type_path = parse_quote! { ::subxt::bitvec::vec::BitVec<#bit_order_type, #bit_store_type> };
let type_path = parse_quote! { ::subxt::bitvec::vec::BitVec<#bit_store_type, #bit_order_type> };

syn::Type::Path(type_path)
}
Expand Down
4 changes: 2 additions & 2 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ description = "Subxt example usage"
[dev-dependencies]
subxt = { path = "../subxt" }
async-std = { version = "1.9.0", features = ["attributes", "tokio1"] }
sp-keyring = "5.0.0"
sp-keyring = "6.0.0"
env_logger = "0.9.0"
futures = "0.3.13"
codec = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full", "bit-vec"] }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "full", "bit-vec"] }
hex = "0.4.3"
8 changes: 4 additions & 4 deletions macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ proc-macro = true

[dependencies]
async-trait = "0.1.49"
codec = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full"] }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "full"] }
darling = "0.13.0"
frame-metadata = "14.0"
frame-metadata = "15.0.0"
heck = "0.4.0"
proc-macro2 = "1.0.24"
proc-macro-crate = "0.1.5"
proc-macro-error = "1.0.4"
quote = "1.0.8"
syn = "1.0.58"
scale-info = "1.0.0"
scale-info = "2.0.0"

subxt-codegen = { path = "../codegen", version = "0.17.0" }

[dev-dependencies]
pretty_assertions = "1.0.0"
subxt = { path = "../subxt" }
trybuild = "1.0.38"
sp-keyring = "5.0.0"
sp-keyring = "6.0.0"
18 changes: 9 additions & 9 deletions subxt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ keywords = ["parity", "substrate", "blockchain"]

[dependencies]
async-trait = "0.1.49"
bitvec = { version = "0.20.1", default-features = false, features = ["alloc"] }
codec = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full", "bit-vec"] }
bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "full", "bit-vec"] }
chameleon = "0.1.0"
scale-info = { version = "1.0.0", features = ["bit-vec"] }
scale-info = { version = "2.0.0", features = ["bit-vec"] }
futures = "0.3.13"
hex = "0.4.3"
jsonrpsee = { version = "0.8.0", features = ["async-client", "client-ws-transport"] }
Expand All @@ -29,20 +29,20 @@ thiserror = "1.0.24"

subxt-macro = { version = "0.17.0", path = "../macro" }

sp-core = { version = "5.0.0", default-features = false }
sp-runtime = "5.0.0"
sp-version = "4.0.0"
sp-core = { version = "6.0.0", default-features = false }
sp-runtime = "6.0.0"
sp-version = "5.0.0"

frame-metadata = "14.0.0"
frame-metadata = "15.0.0"
derivative = "2.2.0"

[dev-dependencies]
sp-arithmetic = { version = "4.0.0", default-features = false }
sp-arithmetic = { version = "5.0.0", default-features = false }
assert_matches = "1.5.0"
async-std = { version = "1.9.0", features = ["attributes", "tokio1"] }
env_logger = "0.9.0"
tempdir = "0.3.7"
wabt = "0.10.0"
which = "4.0.2"
test-runtime = { path = "../test-runtime" }
sp-keyring = "5.0.0"
sp-keyring = "6.0.0"
26 changes: 13 additions & 13 deletions subxt/src/events/decoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,16 @@ pub fn decode_and_consume_type(
// used lines up in terms of the number of bytes it will take to encode/decode it.
match bit_store_def {
TypeDef::Primitive(TypeDefPrimitive::U8) => {
consume_type::<BitVec<Lsb0, u8>>(input)
consume_type::<BitVec<u8, Lsb0>>(input)
}
TypeDef::Primitive(TypeDefPrimitive::U16) => {
consume_type::<BitVec<Lsb0, u16>>(input)
consume_type::<BitVec<u16, Lsb0>>(input)
}
TypeDef::Primitive(TypeDefPrimitive::U32) => {
consume_type::<BitVec<Lsb0, u32>>(input)
consume_type::<BitVec<u32, Lsb0>>(input)
}
TypeDef::Primitive(TypeDefPrimitive::U64) => {
consume_type::<BitVec<Lsb0, u64>>(input)
consume_type::<BitVec<u64, Lsb0>>(input)
}
store => {
return Err(EventsDecodingError::InvalidBitSequenceType(format!(
Expand Down Expand Up @@ -272,31 +272,31 @@ mod tests {
use bitvec::order::Msb0;

decode_and_consume_type_consumes_all_bytes(
bitvec::bitvec![Lsb0, u8; 0, 1, 1, 0, 1],
bitvec::bitvec![u8, Lsb0; 0, 1, 1, 0, 1],
);
decode_and_consume_type_consumes_all_bytes(
bitvec::bitvec![Msb0, u8; 0, 1, 1, 0, 1, 0, 1, 0, 0],
bitvec::bitvec![u8, Msb0; 0, 1, 1, 0, 1, 0, 1, 0, 0],
);

decode_and_consume_type_consumes_all_bytes(
bitvec::bitvec![Lsb0, u16; 0, 1, 1, 0, 1],
bitvec::bitvec![u16, Lsb0; 0, 1, 1, 0, 1],
);
decode_and_consume_type_consumes_all_bytes(
bitvec::bitvec![Msb0, u16; 0, 1, 1, 0, 1, 0, 1, 0, 0],
bitvec::bitvec![u16, Msb0; 0, 1, 1, 0, 1, 0, 1, 0, 0],
);

decode_and_consume_type_consumes_all_bytes(
bitvec::bitvec![Lsb0, u32; 0, 1, 1, 0, 1],
bitvec::bitvec![u32, Lsb0; 0, 1, 1, 0, 1],
);
decode_and_consume_type_consumes_all_bytes(
bitvec::bitvec![Msb0, u32; 0, 1, 1, 0, 1, 0, 1, 0, 0],
bitvec::bitvec![u32, Msb0; 0, 1, 1, 0, 1, 0, 1, 0, 0],
);

decode_and_consume_type_consumes_all_bytes(
bitvec::bitvec![Lsb0, u64; 0, 1, 1, 0, 1],
bitvec::bitvec![u64, Lsb0; 0, 1, 1, 0, 1],
);
decode_and_consume_type_consumes_all_bytes(
bitvec::bitvec![Msb0, u64; 0, 1, 1, 0, 1, 0, 1, 0, 0],
bitvec::bitvec![u64, Msb0; 0, 1, 1, 0, 1, 0, 1, 0, 0],
);
}

Expand Down Expand Up @@ -434,7 +434,7 @@ mod tests {
});
decode_and_consume_type_consumes_all_bytes(CompositeV3 {
id: 10,
extra: bitvec::bitvec![Lsb0, u8; 0, 1, 1, 0, 1],
extra: bitvec::bitvec![u8, Lsb0; 0, 1, 1, 0, 1],
});
decode_and_consume_type_consumes_all_bytes(CompositeV3 {
id: 10,
Expand Down
2 changes: 1 addition & 1 deletion subxt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl<T: Decode> WrapperKeepOpaque<T> {
///
/// Returns `None` if the decoding failed.
pub fn try_decode(&self) -> Option<T> {
T::decode_all(&self.data[..]).ok()
T::decode_all(&mut &self.data[..]).ok()
}

/// Returns the length of the encoded `T`.
Expand Down
Loading

0 comments on commit 11f24d7

Please sign in to comment.