Skip to content

Commit

Permalink
scale-type-resolver integration (#1460)
Browse files Browse the repository at this point in the history
* start migrating, broken

* first iteration of updating

* fmt and clippy

* add Composite<u32> decoding via scale value patch

* bump scale type gen versions

* fix decoding with new scale decode

* fix js-sys versions

* add nit comments
  • Loading branch information
tadeohepperle authored Mar 13, 2024
1 parent 952cde3 commit 8bdd276
Show file tree
Hide file tree
Showing 22 changed files with 257 additions and 240 deletions.
49 changes: 30 additions & 19 deletions Cargo.lock

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

21 changes: 14 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ members = [
# We exclude any crates that would depend on non mutually
# exclusive feature flags and thus can't compile with the
# workspace:
exclude = ["testing/no-std-tests", "testing/wasm-rpc-tests", "testing/wasm-lightclient-tests", "signer/wasm-tests", "examples/wasm-example", "examples/parachain-example"]
exclude = [
"testing/no-std-tests",
"testing/wasm-rpc-tests",
"testing/wasm-lightclient-tests",
"signer/wasm-tests",
"examples/wasm-example",
"examples/parachain-example"
]
resolver = "2"

[workspace.package]
Expand Down Expand Up @@ -81,10 +88,10 @@ proc-macro2 = "1.0.78"
quote = "1.0.35"
regex = "1.10.3"
scale-info = { version = "2.10.0", default-features = false }
scale-value = "0.13.0"
scale-bits = "0.4.0"
scale-decode = "0.10.0"
scale-encode = "0.5.0"
scale-value = "0.14.1"
scale-bits = "0.5.0"
scale-decode = "0.11.1"
scale-encode = "0.6.0"
serde = { version = "1.0.197" }
serde_json = { version = "1.0.114" }
syn = { version = "2.0.15", features = ["full", "extra-traits"] }
Expand All @@ -98,8 +105,8 @@ url = "2.5.0"
wabt = "0.10.0"
wasm-bindgen-test = "0.3.24"
which = "5.0.0"
scale-typegen-description = "0.1.0"
scale-typegen = "0.1.1"
scale-typegen-description = "0.2.0"
scale-typegen = "0.2.0"
strip-ansi-escapes = "0.2.0"

# Light client support:
Expand Down
7 changes: 5 additions & 2 deletions cli/src/commands/explore/pallets/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ pub fn explore_constants(
.highlight();

// value
let value =
scale_value::scale::decode_as_type(&mut constant.value(), constant.ty(), metadata.types())?;
let value = scale_value::scale::decode_as_type(
&mut constant.value(),
&constant.ty(),
metadata.types(),
)?;
let value = format_scale_value(&value).indent(4);

writedoc!(
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/explore/pallets/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub async fn explore_storage(
{value_str}
"}?;

let key_bytes = value.encode_as_type(type_id, metadata.types())?;
let key_bytes = value.encode_as_type(&type_id, metadata.types())?;
let bytes_composite = Value::from_bytes(key_bytes);
vec![bytes_composite]
}
Expand Down
5 changes: 2 additions & 3 deletions cli/src/commands/explore/runtime_apis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@ pub async fn run<'a>(
{value_str}
"}?;
// encode, then decode. This ensures that the scale value is of the correct shape for the param:
let bytes = value.encode_as_type(ty.ty, metadata.types())?;
let value = Value::decode_as_type(&mut &bytes[..], ty.ty, metadata.types())?
.map_context(|_| ());
let bytes = value.encode_as_type(&ty.ty, metadata.types())?;
let value = Value::decode_as_type(&mut &bytes[..], &ty.ty, metadata.types())?;
Ok(value)
})
.collect::<color_eyre::Result<Vec<Value>>>()?;
Expand Down
Loading

0 comments on commit 8bdd276

Please sign in to comment.