diff --git a/Cargo.lock b/Cargo.lock index 978945901b..467dd253fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3471,38 +3471,38 @@ dependencies = [ [[package]] name = "scale-bits" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "036575c29af9b6e4866ffb7fa055dbf623fe7a9cc159b33786de6013a6969d89" +checksum = "662d10dcd57b1c2a3c41c9cf68f71fb09747ada1ea932ad961aca7e2ca28315f" dependencies = [ "parity-scale-codec", "scale-info", + "scale-type-resolver", "serde", ] [[package]] name = "scale-decode" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7caaf753f8ed1ab4752c6afb20174f03598c664724e0e32628e161c21000ff76" +checksum = "afc79ba56a1c742f5aeeed1f1801f3edf51f7e818f0a54582cac6f131364ea7b" dependencies = [ "derive_more", "parity-scale-codec", "primitive-types", "scale-bits", "scale-decode-derive", - "scale-info", + "scale-type-resolver", "smallvec", ] [[package]] name = "scale-decode-derive" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3475108a1b62c7efd1b5c65974f30109a598b2f45f23c9ae030acb9686966db" +checksum = "5398fdb3c7bea3cb419bac4983aadacae93fe1a7b5f693f4ebd98c3821aad7a5" dependencies = [ "darling 0.14.4", - "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -3510,24 +3510,24 @@ dependencies = [ [[package]] name = "scale-encode" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d70cb4b29360105483fac1ed567ff95d65224a14dd275b6303ed0a654c78de5" +checksum = "628800925a33794fb5387781b883b5e14d130fece9af5a63613867b8de07c5c7" dependencies = [ "derive_more", "parity-scale-codec", "primitive-types", "scale-bits", "scale-encode-derive", - "scale-info", + "scale-type-resolver", "smallvec", ] [[package]] name = "scale-encode-derive" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "995491f110efdc6bea96d6a746140e32bfceb4ea47510750a5467295a4707a25" +checksum = "7a304e1af7cdfbe7a24e08b012721456cc8cecdedadc14b3d10513eada63233c" dependencies = [ "darling 0.14.4", "proc-macro-crate 1.3.1", @@ -3563,10 +3563,20 @@ dependencies = [ ] [[package]] -name = "scale-typegen" +name = "scale-type-resolver" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00860983481ac590ac87972062909bef0d6a658013b592ccc0f2feb272feab11" +checksum = "10b800069bfd43374e0f96f653e0d46882a2cb16d6d961ac43bea80f26c76843" +dependencies = [ + "scale-info", + "smallvec", +] + +[[package]] +name = "scale-typegen" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6108609f017741c78d35967c7afe4aeaa3999b848282581041428e10d23b63" dependencies = [ "proc-macro2", "quote", @@ -3577,9 +3587,9 @@ dependencies = [ [[package]] name = "scale-typegen-description" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae69c1dfd81e9859a5fb42c1b560369e6ed82d2c5b5cb4cac3bba1962a73f017" +checksum = "479f0b8b0d75cce8d284ace5a9b7f5a12c523c94387c710835695e8b194a17bb" dependencies = [ "anyhow", "peekmore", @@ -3595,9 +3605,9 @@ dependencies = [ [[package]] name = "scale-value" -version = "0.13.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58223c7691bf0bd46b43c9aea6f0472d1067f378d574180232358d7c6e0a8089" +checksum = "c07ccfee963104335c971aaf8b7b0e749be8569116322df23f1f75c4ca9e4a28" dependencies = [ "base58", "blake2", @@ -3609,6 +3619,7 @@ dependencies = [ "scale-decode", "scale-encode", "scale-info", + "scale-type-resolver", "serde", "yap", ] diff --git a/Cargo.toml b/Cargo.toml index 2d6f43c04f..4fe151c2ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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] @@ -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"] } @@ -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: diff --git a/cli/src/commands/explore/pallets/constants.rs b/cli/src/commands/explore/pallets/constants.rs index dd5e5faddc..a267c401f8 100644 --- a/cli/src/commands/explore/pallets/constants.rs +++ b/cli/src/commands/explore/pallets/constants.rs @@ -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!( diff --git a/cli/src/commands/explore/pallets/storage.rs b/cli/src/commands/explore/pallets/storage.rs index 0c932c8f1a..543406bd57 100644 --- a/cli/src/commands/explore/pallets/storage.rs +++ b/cli/src/commands/explore/pallets/storage.rs @@ -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] } diff --git a/cli/src/commands/explore/runtime_apis/mod.rs b/cli/src/commands/explore/runtime_apis/mod.rs index cdd5681e26..e3fed9ac01 100644 --- a/cli/src/commands/explore/runtime_apis/mod.rs +++ b/cli/src/commands/explore/runtime_apis/mod.rs @@ -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::>>()?; diff --git a/examples/wasm-example/Cargo.lock b/examples/wasm-example/Cargo.lock index f46412c7b8..69aa797f9a 100644 --- a/examples/wasm-example/Cargo.lock +++ b/examples/wasm-example/Cargo.lock @@ -476,12 +476,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.6" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c376d08ea6aa96aafe61237c7200d1241cb177b7d3a542d791f2d118e9cbb955" +checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" dependencies = [ - "darling_core 0.20.6", - "darling_macro 0.20.6", + "darling_core 0.20.8", + "darling_macro 0.20.8", ] [[package]] @@ -500,9 +500,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.6" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33043dcd19068b8192064c704b3f83eb464f91f1ff527b44a4e2b08d9cdb8855" +checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" dependencies = [ "fnv", "ident_case", @@ -525,11 +525,11 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.6" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5a91391accf613803c2a9bf9abccdbaa07c54b4244a5b64883f9c3c137c86be" +checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ - "darling_core 0.20.6", + "darling_core 0.20.8", "quote", "syn 2.0.48", ] @@ -1329,9 +1329,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -1713,18 +1713,18 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", @@ -2084,38 +2084,38 @@ checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "scale-bits" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "036575c29af9b6e4866ffb7fa055dbf623fe7a9cc159b33786de6013a6969d89" +checksum = "662d10dcd57b1c2a3c41c9cf68f71fb09747ada1ea932ad961aca7e2ca28315f" dependencies = [ "parity-scale-codec", "scale-info", + "scale-type-resolver", "serde", ] [[package]] name = "scale-decode" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7caaf753f8ed1ab4752c6afb20174f03598c664724e0e32628e161c21000ff76" +checksum = "afc79ba56a1c742f5aeeed1f1801f3edf51f7e818f0a54582cac6f131364ea7b" dependencies = [ "derive_more", "parity-scale-codec", "primitive-types", "scale-bits", "scale-decode-derive", - "scale-info", + "scale-type-resolver", "smallvec", ] [[package]] name = "scale-decode-derive" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3475108a1b62c7efd1b5c65974f30109a598b2f45f23c9ae030acb9686966db" +checksum = "5398fdb3c7bea3cb419bac4983aadacae93fe1a7b5f693f4ebd98c3821aad7a5" dependencies = [ "darling 0.14.4", - "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2123,24 +2123,24 @@ dependencies = [ [[package]] name = "scale-encode" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d70cb4b29360105483fac1ed567ff95d65224a14dd275b6303ed0a654c78de5" +checksum = "628800925a33794fb5387781b883b5e14d130fece9af5a63613867b8de07c5c7" dependencies = [ "derive_more", "parity-scale-codec", "primitive-types", "scale-bits", "scale-encode-derive", - "scale-info", + "scale-type-resolver", "smallvec", ] [[package]] name = "scale-encode-derive" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "995491f110efdc6bea96d6a746140e32bfceb4ea47510750a5467295a4707a25" +checksum = "7a304e1af7cdfbe7a24e08b012721456cc8cecdedadc14b3d10513eada63233c" dependencies = [ "darling 0.14.4", "proc-macro-crate 1.3.1", @@ -2176,10 +2176,20 @@ dependencies = [ ] [[package]] -name = "scale-typegen" +name = "scale-type-resolver" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00860983481ac590ac87972062909bef0d6a658013b592ccc0f2feb272feab11" +checksum = "10b800069bfd43374e0f96f653e0d46882a2cb16d6d961ac43bea80f26c76843" +dependencies = [ + "scale-info", + "smallvec", +] + +[[package]] +name = "scale-typegen" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6108609f017741c78d35967c7afe4aeaa3999b848282581041428e10d23b63" dependencies = [ "proc-macro2", "quote", @@ -2190,9 +2200,9 @@ dependencies = [ [[package]] name = "scale-value" -version = "0.13.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58223c7691bf0bd46b43c9aea6f0472d1067f378d574180232358d7c6e0a8089" +checksum = "c07ccfee963104335c971aaf8b7b0e749be8569116322df23f1f75c4ca9e4a28" dependencies = [ "base58", "blake2", @@ -2204,6 +2214,7 @@ dependencies = [ "scale-decode", "scale-encode", "scale-info", + "scale-type-resolver", "serde", "yap", ] @@ -2659,7 +2670,7 @@ dependencies = [ name = "subxt-macro" version = "0.34.0" dependencies = [ - "darling 0.20.6", + "darling 0.20.8", "parity-scale-codec", "proc-macro-error", "quote", @@ -3011,9 +3022,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3021,9 +3032,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", @@ -3048,9 +3059,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3058,9 +3069,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", @@ -3071,9 +3082,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-example" @@ -3135,9 +3146,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/examples/wasm-example/Cargo.toml b/examples/wasm-example/Cargo.toml index 80d3be6ce7..6aaf175b54 100644 --- a/examples/wasm-example/Cargo.toml +++ b/examples/wasm-example/Cargo.toml @@ -9,10 +9,10 @@ edition = "2021" futures = "0.3.28" subxt = { path = "../../subxt", default-features = false, features = ["jsonrpsee", "web"], target_arch = "wasm32" } yew = { version = "0.20.0", features = ["csr"] } -web-sys = "0.3.63" +web-sys = "0.3.69" hex = "0.4.3" yew-router = "0.17.0" -js-sys = "0.3.63" +js-sys = "0.3.69" wasm-bindgen = "0.2.86" wasm-bindgen-futures = "0.4.36" anyhow = "1.0.71" diff --git a/subxt/Cargo.toml b/subxt/Cargo.toml index 4a18bb2b41..67c553fa50 100644 --- a/subxt/Cargo.toml +++ b/subxt/Cargo.toml @@ -154,4 +154,4 @@ features = ["default", "substrate-compat", "unstable-light-client"] rustdoc-args = ["--cfg", "docsrs"] [package.metadata.playground] -features = ["default", "substrate-compat", "unstable-light-client"] +features = ["default", "substrate-compat", "unstable-light-client"] \ No newline at end of file diff --git a/subxt/src/blocks/extrinsic_types.rs b/subxt/src/blocks/extrinsic_types.rs index 333ee5bfe8..32bdb057e9 100644 --- a/subxt/src/blocks/extrinsic_types.rs +++ b/subxt/src/blocks/extrinsic_types.rs @@ -245,27 +245,27 @@ where // Skip over the address, signature and extra fields. scale_decode::visitor::decode_with_visitor( cursor, - ids.address, + &ids.address, metadata.types(), - scale_decode::visitor::IgnoreVisitor, + scale_decode::visitor::IgnoreVisitor::new(), ) .map_err(scale_decode::Error::from)?; let address_end_idx = bytes.len() - cursor.len(); scale_decode::visitor::decode_with_visitor( cursor, - ids.signature, + &ids.signature, metadata.types(), - scale_decode::visitor::IgnoreVisitor, + scale_decode::visitor::IgnoreVisitor::new(), ) .map_err(scale_decode::Error::from)?; let signature_end_idx = bytes.len() - cursor.len(); scale_decode::visitor::decode_with_visitor( cursor, - ids.extra, + &ids.extra, metadata.types(), - scale_decode::visitor::IgnoreVisitor, + scale_decode::visitor::IgnoreVisitor::new(), ) .map_err(scale_decode::Error::from)?; let extra_end_idx = bytes.len() - cursor.len(); @@ -420,9 +420,7 @@ where /// Decode and provide the extrinsic fields back in the form of a [`scale_value::Composite`] /// type which represents the named or unnamed fields that were present in the extrinsic. - pub fn field_values( - &self, - ) -> Result, Error> { + pub fn field_values(&self) -> Result, Error> { let bytes = &mut self.field_bytes(); let extrinsic_metadata = self.extrinsic_metadata()?; @@ -430,12 +428,9 @@ where .variant .fields .iter() - .map(|f| scale_decode::Field::new(f.ty.id, f.name.as_deref())); - let decoded = >::decode_as_fields( - bytes, - &mut fields, - self.metadata.types(), - )?; + .map(|f| scale_decode::Field::new(&f.ty.id, f.name.as_deref())); + let decoded = + scale_value::scale::decode_as_fields(bytes, &mut fields, self.metadata.types())?; Ok(decoded) } @@ -451,7 +446,7 @@ where .variant .fields .iter() - .map(|f| scale_decode::Field::new(f.ty.id, f.name.as_deref())); + .map(|f| scale_decode::Field::new(&f.ty.id, f.name.as_deref())); let decoded = E::decode_as_fields(&mut self.field_bytes(), &mut fields, self.metadata.types())?; Ok(Some(decoded)) @@ -466,7 +461,7 @@ where pub fn as_root_extrinsic(&self) -> Result { let decoded = E::decode_as_type( &mut &self.call_bytes()[..], - self.metadata.outer_enums().call_enum_ty(), + &self.metadata.outer_enums().call_enum_ty(), self.metadata.types(), )?; @@ -651,9 +646,9 @@ impl<'a, T: Config> ExtrinsicSignedExtensions<'a, T> { let cursor = &mut &bytes[byte_start_idx..]; if let Err(err) = scale_decode::visitor::decode_with_visitor( cursor, - ty_id, + &ty_id, metadata.types(), - scale_decode::visitor::IgnoreVisitor, + scale_decode::visitor::IgnoreVisitor::new(), ) .map_err(|e| Error::Decode(e.into())) { @@ -748,7 +743,12 @@ impl<'a, T: Config> ExtrinsicSignedExtension<'a, T> { /// Signed Extension as a [`scale_value::Value`] pub fn value(&self) -> Result { - self.as_type() + let value = scale_value::scale::decode_as_type( + &mut &self.bytes[..], + &self.ty_id, + self.metadata.types(), + )?; + Ok(value) } /// Decodes the bytes of this Signed Extension into its associated `Decoded` type. @@ -762,7 +762,7 @@ impl<'a, T: Config> ExtrinsicSignedExtension<'a, T> { } fn as_type(&self) -> Result { - let value = E::decode_as_type(&mut &self.bytes[..], self.ty_id, self.metadata.types())?; + let value = E::decode_as_type(&mut &self.bytes[..], &self.ty_id, self.metadata.types())?; Ok(value) } } diff --git a/subxt/src/dynamic.rs b/subxt/src/dynamic.rs index 2801feb683..c405450481 100644 --- a/subxt/src/dynamic.rs +++ b/subxt/src/dynamic.rs @@ -17,7 +17,7 @@ pub use scale_value::{At, Value}; /// regarding what type was used to decode each part of it. This implements /// [`crate::metadata::DecodeWithMetadata`], and is used as a return type /// for dynamic requests. -pub type DecodedValue = scale_value::Value; +pub type DecodedValue = scale_value::Value; // Submit dynamic transactions. pub use crate::tx::dynamic as tx; @@ -68,9 +68,9 @@ impl DecodedValueThunk { } /// Decode the SCALE encoded storage entry into a dynamic [`DecodedValue`] type. pub fn to_value(&self) -> Result { - let val = DecodedValue::decode_as_type( + let val = scale_value::scale::decode_as_type( &mut &*self.scale_bytes, - self.type_id, + &self.type_id, self.metadata.types(), )?; Ok(val) @@ -79,7 +79,7 @@ impl DecodedValueThunk { pub fn as_type(&self) -> Result { T::decode_as_type( &mut &self.scale_bytes[..], - self.type_id, + &self.type_id, self.metadata.types(), ) } diff --git a/subxt/src/error/dispatch_error.rs b/subxt/src/error/dispatch_error.rs index 3f0c54db56..6de0792dc0 100644 --- a/subxt/src/error/dispatch_error.rs +++ b/subxt/src/error/dispatch_error.rs @@ -7,8 +7,9 @@ use crate::metadata::{DecodeWithMetadata, Metadata}; use core::fmt::Debug; -use scale_decode::{visitor::DecodeAsTypeResult, DecodeAsType}; -use std::borrow::Cow; +use scale_decode::{visitor::DecodeAsTypeResult, DecodeAsType, TypeResolver}; + +use std::{borrow::Cow, marker::PhantomData}; use super::{Error, MetadataError}; @@ -209,7 +210,7 @@ impl ModuleError { pub fn as_root_error(&self) -> Result { let decoded = E::decode_as_type( &mut &self.bytes[..], - self.metadata.outer_enums().error_enum_ty(), + &self.metadata.outer_enums().error_enum_ty(), self.metadata.types(), )?; @@ -262,24 +263,27 @@ impl DispatchError { // a legacy format of 2 bytes, or a newer format of 5 bytes. So, just grab the bytes // out when decoding to manually work with them. struct DecodedModuleErrorBytes(Vec); - struct DecodedModuleErrorBytesVisitor; - impl scale_decode::Visitor for DecodedModuleErrorBytesVisitor { + struct DecodedModuleErrorBytesVisitor(PhantomData); + impl scale_decode::Visitor for DecodedModuleErrorBytesVisitor { type Error = scale_decode::Error; type Value<'scale, 'info> = DecodedModuleErrorBytes; + type TypeResolver = R; + fn unchecked_decode_as_type<'scale, 'info>( self, input: &mut &'scale [u8], - _type_id: scale_decode::visitor::TypeId, - _types: &'info scale_info::PortableRegistry, + _type_id: &R::TypeId, + _types: &'info R, ) -> DecodeAsTypeResult, Self::Error>> { DecodeAsTypeResult::Decoded(Ok(DecodedModuleErrorBytes(input.to_vec()))) } } + impl scale_decode::IntoVisitor for DecodedModuleErrorBytes { - type Visitor = DecodedModuleErrorBytesVisitor; - fn into_visitor() -> Self::Visitor { - DecodedModuleErrorBytesVisitor + type AnyVisitor = DecodedModuleErrorBytesVisitor; + fn into_visitor() -> DecodedModuleErrorBytesVisitor { + DecodedModuleErrorBytesVisitor(PhantomData) } } diff --git a/subxt/src/error/mod.rs b/subxt/src/error/mod.rs index 4534585efc..5dbf1c5897 100644 --- a/subxt/src/error/mod.rs +++ b/subxt/src/error/mod.rs @@ -99,6 +99,12 @@ impl From for Error { } } +impl From for Error { + fn from(value: scale_decode::visitor::DecodeError) -> Self { + Error::Decode(value.into()) + } +} + impl Error { /// Checks whether the error was caused by a RPC re-connection. pub fn is_disconnected_will_reconnect(&self) -> bool { diff --git a/subxt/src/events/events_type.rs b/subxt/src/events/events_type.rs index 831268ad00..6818a84815 100644 --- a/subxt/src/events/events_type.rs +++ b/subxt/src/events/events_type.rs @@ -228,9 +228,9 @@ impl EventDetails { // Skip over the bytes for this field: scale_decode::visitor::decode_with_visitor( input, - field_metadata.ty.id, + &field_metadata.ty.id, metadata.types(), - scale_decode::visitor::IgnoreVisitor, + scale_decode::visitor::IgnoreVisitor::new(), ) .map_err(scale_decode::Error::from)?; } @@ -321,9 +321,7 @@ impl EventDetails { /// Decode and provide the event fields back in the form of a [`scale_value::Composite`] /// type which represents the named or unnamed fields that were present in the event. - pub fn field_values( - &self, - ) -> Result, Error> { + pub fn field_values(&self) -> Result, Error> { let bytes = &mut self.field_bytes(); let event_metadata = self.event_metadata(); @@ -331,14 +329,10 @@ impl EventDetails { .variant .fields .iter() - .map(|f| scale_decode::Field::new(f.ty.id, f.name.as_deref())); + .map(|f| scale_decode::Field::new(&f.ty.id, f.name.as_deref())); - use scale_decode::DecodeAsFields; - let decoded = >::decode_as_fields( - bytes, - &mut fields, - self.metadata.types(), - )?; + let decoded = + scale_value::scale::decode_as_fields(bytes, &mut fields, self.metadata.types())?; Ok(decoded) } @@ -352,7 +346,7 @@ impl EventDetails { .variant .fields .iter() - .map(|f| scale_decode::Field::new(f.ty.id, f.name.as_deref())); + .map(|f| scale_decode::Field::new(&f.ty.id, f.name.as_deref())); let decoded = E::decode_as_fields(&mut self.field_bytes(), &mut fields, self.metadata.types())?; Ok(Some(decoded)) @@ -369,7 +363,7 @@ impl EventDetails { let decoded = E::decode_as_type( &mut &bytes[..], - self.metadata.outer_enums().event_enum_ty(), + &self.metadata.outer_enums().event_enum_ty(), self.metadata.types(), )?; diff --git a/subxt/src/metadata/decode_encode_traits.rs b/subxt/src/metadata/decode_encode_traits.rs index 81dbaea131..8b8d4077fa 100644 --- a/subxt/src/metadata/decode_encode_traits.rs +++ b/subxt/src/metadata/decode_encode_traits.rs @@ -21,7 +21,7 @@ impl DecodeWithMetadata for T { type_id: u32, metadata: &Metadata, ) -> Result { - let val = T::decode_as_type(bytes, type_id, metadata.types())?; + let val = T::decode_as_type(bytes, &type_id, metadata.types())?; Ok(val) } } @@ -45,7 +45,7 @@ impl EncodeWithMetadata for T { metadata: &Metadata, bytes: &mut Vec, ) -> Result<(), Error> { - self.encode_as_type_to(type_id, metadata.types(), bytes)?; + self.encode_as_type_to(&type_id, metadata.types(), bytes)?; Ok(()) } } diff --git a/subxt/src/runtime_api/runtime_payload.rs b/subxt/src/runtime_api/runtime_payload.rs index ff776eb14f..128440b98d 100644 --- a/subxt/src/runtime_api/runtime_payload.rs +++ b/subxt/src/runtime_api/runtime_payload.rs @@ -103,7 +103,7 @@ impl RuntimeApiPayload .ok_or_else(|| MetadataError::RuntimeMethodNotFound((*self.method_name).to_owned()))?; let mut fields = api_method .inputs() - .map(|input| scale_encode::Field::named(input.ty, &input.name)); + .map(|input| scale_encode::Field::named(&input.ty, &input.name)); self.args_data .encode_as_fields_to(&mut fields, metadata.types(), out)?; diff --git a/subxt/src/storage/storage_key.rs b/subxt/src/storage/storage_key.rs index a8bffab329..71ecafde9d 100644 --- a/subxt/src/storage/storage_key.rs +++ b/subxt/src/storage/storage_key.rs @@ -2,7 +2,7 @@ use crate::{ error::{Error, MetadataError, StorageAddressError}, utils::{Encoded, Static}, }; -use scale_decode::{visitor::IgnoreVisitor, DecodeAsType}; +use scale_decode::visitor::IgnoreVisitor; use scale_encode::EncodeAsType; use scale_info::{PortableRegistry, TypeDef}; use scale_value::Value; @@ -203,7 +203,7 @@ impl StorageKey for StaticStorageKey { types: &PortableRegistry, ) -> Result<(), Error> { let (hasher, ty_id) = hashers.next_or_err()?; - let encoded_value = self.bytes.encode_as_type(ty_id, types)?; + let encoded_value = self.bytes.encode_as_type(&ty_id, types)?; hash_bytes(&encoded_value, hasher, bytes); Ok(()) } @@ -242,7 +242,7 @@ impl StorageKey for Vec { ) -> Result<(), Error> { for value in self.iter() { let (hasher, ty_id) = hashers.next_or_err()?; - let encoded_value = value.encode_as_type(ty_id, types)?; + let encoded_value = value.encode_as_type(&ty_id, types)?; hash_bytes(&encoded_value, hasher, bytes); } Ok(()) @@ -260,7 +260,8 @@ impl StorageKey for Vec { for (hasher, ty_id) in hashers.by_ref() { match consume_hash_returning_key_bytes(bytes, hasher, ty_id, types)? { Some(value_bytes) => { - let value = Value::decode_as_type(&mut &*value_bytes, ty_id, types)?; + let value = + scale_value::scale::decode_as_type(&mut &*value_bytes, &ty_id, types)?; result.push(value.remove_context()); } None => { @@ -296,8 +297,13 @@ fn consume_hash_returning_key_bytes<'a>( // Now, find the bytes representing the key, consuming them. let before_key = *bytes; if hasher.ends_with_key() { - scale_decode::visitor::decode_with_visitor(bytes, ty_id, types, IgnoreVisitor) - .map_err(|err| Error::Decode(err.into()))?; + scale_decode::visitor::decode_with_visitor( + bytes, + &ty_id, + types, + IgnoreVisitor::::new(), + ) + .map_err(|err| Error::Decode(err.into()))?; // Return the key bytes, having advanced the input cursor past them. let key_bytes = &before_key[..before_key.len() - bytes.len()]; diff --git a/subxt/src/tx/mod.rs b/subxt/src/tx/mod.rs index 0bb2d9f3eb..c48cf1382b 100644 --- a/subxt/src/tx/mod.rs +++ b/subxt/src/tx/mod.rs @@ -28,6 +28,6 @@ pub use self::{ PartialExtrinsic, SubmittableExtrinsic, TransactionInvalid, TransactionUnknown, TxClient, ValidationResult, }, - tx_payload::{dynamic, BoxedPayload, DynamicPayload, Payload, TxPayload}, + tx_payload::{dynamic, DynamicPayload, Payload, TxPayload}, tx_progress::{TxInBlock, TxProgress, TxStatus}, }; diff --git a/subxt/src/tx/tx_payload.rs b/subxt/src/tx/tx_payload.rs index ff9c71fd21..c2a1dbe65c 100644 --- a/subxt/src/tx/tx_payload.rs +++ b/subxt/src/tx/tx_payload.rs @@ -14,7 +14,7 @@ use codec::Encode; use derivative::Derivative; use scale_encode::EncodeAsFields; use scale_value::{Composite, ValueDef, Variant}; -use std::{borrow::Cow, sync::Arc}; +use std::borrow::Cow; /// This represents a transaction payload that can be submitted /// to a node. @@ -65,10 +65,6 @@ pub struct Payload { validation_hash: Option<[u8; 32]>, } -/// A boxed transaction payload. -// Dev Note: Arc used to enable easy cloning (given that we can't have dyn Clone). -pub type BoxedPayload = Payload>; - /// The type of a payload typically used for dynamic transaction payloads. pub type DynamicPayload = Payload>; @@ -104,19 +100,6 @@ impl Payload { } } - /// Box the payload. - pub fn boxed(self) -> BoxedPayload - where - CallData: EncodeAsFields + Send + Sync + 'static, - { - BoxedPayload { - pallet_name: self.pallet_name, - call_name: self.call_name, - call_data: Arc::new(self.call_data), - validation_hash: self.validation_hash, - } - } - /// Do not validate this call prior to submitting it. pub fn unvalidated(self) -> Self { Self { @@ -174,7 +157,7 @@ impl TxPayload for Payload { let mut fields = call .fields .iter() - .map(|f| scale_encode::Field::new(f.ty.id, f.name.as_deref())); + .map(|f| scale_encode::Field::new(&f.ty.id, f.name.as_deref())); self.call_data .encode_as_fields_to(&mut fields, metadata.types(), out)?; diff --git a/subxt/src/utils/bits.rs b/subxt/src/utils/bits.rs index ed830a0dea..6c334d701c 100644 --- a/subxt/src/utils/bits.rs +++ b/subxt/src/utils/bits.rs @@ -9,7 +9,8 @@ use scale_bits::{ scale::format::{Format, OrderFormat, StoreFormat}, Bits, }; -use scale_decode::IntoVisitor; +use scale_decode::{IntoVisitor, TypeResolver}; + use std::marker::PhantomData; /// Associates `bitvec::store::BitStore` trait with corresponding, type-erased `scale_bits::StoreFormat` enum. @@ -144,45 +145,43 @@ impl codec::Encode for DecodedBits(std::marker::PhantomData<(S, O)>); -impl scale_decode::Visitor for DecodedBitsVisitor { +pub struct DecodedBitsVisitor(std::marker::PhantomData<(S, O, R)>); + +impl scale_decode::Visitor for DecodedBitsVisitor { type Value<'scale, 'info> = DecodedBits; type Error = scale_decode::Error; + type TypeResolver = R; fn unchecked_decode_as_type<'scale, 'info>( self, input: &mut &'scale [u8], - type_id: scale_decode::visitor::TypeId, - types: &'info scale_info::PortableRegistry, + type_id: &R::TypeId, + types: &'info R, ) -> scale_decode::visitor::DecodeAsTypeResult< Self, Result, Self::Error>, > { - let res = scale_decode::visitor::decode_with_visitor( - input, - type_id.0, - types, - Bits::into_visitor(), - ) - .map(|bits| DecodedBits { - bits, - _marker: PhantomData, - }); + let res = + scale_decode::visitor::decode_with_visitor(input, type_id, types, Bits::into_visitor()) + .map(|bits| DecodedBits { + bits, + _marker: PhantomData, + }); scale_decode::visitor::DecodeAsTypeResult::Decoded(res) } } impl scale_decode::IntoVisitor for DecodedBits { - type Visitor = DecodedBitsVisitor; - fn into_visitor() -> Self::Visitor { + type AnyVisitor = DecodedBitsVisitor; + fn into_visitor() -> DecodedBitsVisitor { DecodedBitsVisitor(PhantomData) } } impl scale_encode::EncodeAsType for DecodedBits { - fn encode_as_type_to( + fn encode_as_type_to( &self, - type_id: u32, - types: &scale_info::PortableRegistry, + type_id: &R::TypeId, + types: &R, out: &mut Vec, ) -> Result<(), scale_encode::Error> { self.bits.encode_as_type_to(type_id, types, out) diff --git a/subxt/src/utils/static_type.rs b/subxt/src/utils/static_type.rs index 2d13e61eba..6cf1285f8b 100644 --- a/subxt/src/utils/static_type.rs +++ b/subxt/src/utils/static_type.rs @@ -3,7 +3,7 @@ // see LICENSE for license details. use codec::{Decode, Encode}; -use scale_decode::{visitor::DecodeAsTypeResult, IntoVisitor, Visitor}; +use scale_decode::{visitor::DecodeAsTypeResult, IntoVisitor, TypeResolver, Visitor}; use scale_encode::EncodeAsType; /// If the type inside this implements [`Encode`], this will implement [`scale_encode::EncodeAsType`]. @@ -18,10 +18,10 @@ use scale_encode::EncodeAsType; pub struct Static(pub T); impl EncodeAsType for Static { - fn encode_as_type_to( + fn encode_as_type_to( &self, - _type_id: u32, - _types: &scale_decode::PortableRegistry, + _type_id: &R::TypeId, + _types: &R, out: &mut Vec, ) -> Result<(), scale_encode::Error> { self.0.encode_to(out); @@ -29,17 +29,18 @@ impl EncodeAsType for Static { } } -pub struct StaticDecodeAsTypeVisitor(std::marker::PhantomData); +pub struct StaticDecodeAsTypeVisitor(std::marker::PhantomData<(T, R)>); -impl Visitor for StaticDecodeAsTypeVisitor { +impl Visitor for StaticDecodeAsTypeVisitor { type Value<'scale, 'info> = Static; type Error = scale_decode::Error; + type TypeResolver = R; fn unchecked_decode_as_type<'scale, 'info>( self, input: &mut &'scale [u8], - _type_id: scale_decode::visitor::TypeId, - _types: &'info scale_info::PortableRegistry, + _type_id: &R::TypeId, + _types: &'info R, ) -> DecodeAsTypeResult, Self::Error>> { use scale_decode::{visitor::DecodeError, Error}; let decoded = T::decode(input) @@ -50,8 +51,8 @@ impl Visitor for StaticDecodeAsTypeVisitor { } impl IntoVisitor for Static { - type Visitor = StaticDecodeAsTypeVisitor; - fn into_visitor() -> Self::Visitor { + type AnyVisitor = StaticDecodeAsTypeVisitor; + fn into_visitor() -> StaticDecodeAsTypeVisitor { StaticDecodeAsTypeVisitor(std::marker::PhantomData) } } diff --git a/subxt/src/utils/unchecked_extrinsic.rs b/subxt/src/utils/unchecked_extrinsic.rs index 882b490bed..14ad39e790 100644 --- a/subxt/src/utils/unchecked_extrinsic.rs +++ b/subxt/src/utils/unchecked_extrinsic.rs @@ -12,7 +12,7 @@ use std::marker::PhantomData; use codec::{Decode, Encode}; -use scale_decode::{visitor::DecodeAsTypeResult, DecodeAsType, IntoVisitor, Visitor}; +use scale_decode::{visitor::DecodeAsTypeResult, DecodeAsType, IntoVisitor, TypeResolver, Visitor}; use super::{Encoded, Static}; @@ -52,10 +52,10 @@ impl Decode impl scale_encode::EncodeAsType for UncheckedExtrinsic { - fn encode_as_type_to( + fn encode_as_type_to( &self, - type_id: u32, - types: &scale_info::PortableRegistry, + type_id: &R::TypeId, + types: &R, out: &mut Vec, ) -> Result<(), scale_encode::Error> { self.0.encode_as_type_to(type_id, types, out) @@ -78,32 +78,35 @@ impl From( - PhantomData<(Address, Call, Signature, Extra)>, +pub struct UncheckedExtrinsicDecodeAsTypeVisitor( + PhantomData<(Address, Call, Signature, Extra, R)>, ); -impl Visitor - for UncheckedExtrinsicDecodeAsTypeVisitor +impl Visitor + for UncheckedExtrinsicDecodeAsTypeVisitor { type Value<'scale, 'info> = UncheckedExtrinsic; type Error = scale_decode::Error; + type TypeResolver = R; fn unchecked_decode_as_type<'scale, 'info>( self, input: &mut &'scale [u8], - type_id: scale_decode::visitor::TypeId, - types: &'info scale_info::PortableRegistry, + type_id: &R::TypeId, + types: &'info R, ) -> DecodeAsTypeResult, Self::Error>> { - DecodeAsTypeResult::Decoded(Self::Value::decode_as_type(input, type_id.0, types)) + DecodeAsTypeResult::Decoded(Self::Value::decode_as_type(input, type_id, types)) } } impl IntoVisitor for UncheckedExtrinsic { - type Visitor = UncheckedExtrinsicDecodeAsTypeVisitor; + type AnyVisitor = + UncheckedExtrinsicDecodeAsTypeVisitor; - fn into_visitor() -> Self::Visitor { + fn into_visitor( + ) -> UncheckedExtrinsicDecodeAsTypeVisitor { UncheckedExtrinsicDecodeAsTypeVisitor(PhantomData) } } diff --git a/subxt/src/utils/wrapper_opaque.rs b/subxt/src/utils/wrapper_opaque.rs index 9257405715..7888dee47f 100644 --- a/subxt/src/utils/wrapper_opaque.rs +++ b/subxt/src/utils/wrapper_opaque.rs @@ -5,7 +5,7 @@ use super::PhantomDataSendSync; use codec::{Compact, Decode, DecodeAll, Encode}; use derivative::Derivative; -use scale_decode::{IntoVisitor, Visitor}; +use scale_decode::{ext::scale_type_resolver::visitor, IntoVisitor, TypeResolver, Visitor}; use scale_encode::EncodeAsType; /// A wrapper for any type `T` which implement encode/decode in a way compatible with `Vec`. @@ -74,57 +74,47 @@ impl WrapperKeepOpaque { } impl EncodeAsType for WrapperKeepOpaque { - fn encode_as_type_to( + fn encode_as_type_to( &self, - type_id: u32, - types: &scale_info::PortableRegistry, + type_id: &R::TypeId, + types: &R, out: &mut Vec, ) -> Result<(), scale_encode::Error> { use scale_encode::error::{Error, ErrorKind, Kind}; - let Some(ty) = types.resolve(type_id) else { - return Err(Error::new(ErrorKind::TypeNotFound(type_id))); - }; - - // Do a basic check that the target shape lines up. - let scale_info::TypeDef::Composite(_) = &ty.type_def else { - return Err(Error::new(ErrorKind::WrongShape { + let visitor = visitor::new(out, |_, _| { + // Check that the target shape lines up: any other shape but the composite is wrong. + Err(Error::new(ErrorKind::WrongShape { actual: Kind::Struct, - expected: type_id, - })); - }; - - // Check that the name also lines up. - if ty.path.ident().as_deref() != Some("WrapperKeepOpaque") { - return Err(Error::new(ErrorKind::WrongShape { - actual: Kind::Struct, - expected: type_id, - })); - } - - // Just blat the bytes out. - self.data.encode_to(out); - Ok(()) + expected_id: format!("{:?}", type_id), + })) + }) + .visit_composite(|out, _fields| { + self.data.encode_to(out); + Ok(()) + }); + + types + .resolve_type(type_id, visitor) + .map_err(|_| Error::new(ErrorKind::TypeNotFound(format!("{:?}", type_id))))? } } -pub struct WrapperKeepOpaqueVisitor(std::marker::PhantomData); -impl Visitor for WrapperKeepOpaqueVisitor { +pub struct WrapperKeepOpaqueVisitor(std::marker::PhantomData<(T, R)>); +impl Visitor for WrapperKeepOpaqueVisitor { type Value<'scale, 'info> = WrapperKeepOpaque; type Error = scale_decode::Error; + type TypeResolver = R; fn visit_composite<'scale, 'info>( self, - value: &mut scale_decode::visitor::types::Composite<'scale, 'info>, - _type_id: scale_decode::visitor::TypeId, + value: &mut scale_decode::visitor::types::Composite<'scale, 'info, R>, + _type_id: &R::TypeId, ) -> Result, Self::Error> { use scale_decode::error::{Error, ErrorKind}; - if value.path().ident().as_deref() != Some("WrapperKeepOpaque") { - return Err(Error::custom_str( - "Type to decode is not 'WrapperTypeKeepOpaque'", - )); - } + // TODO: When `scale-type-resolver` [provides struct names](https://github.com/paritytech/scale-type-resolver/issues/4), check that this struct name is `WrapperKeepOpaque` + if value.remaining() != 2 { return Err(Error::new(ErrorKind::WrongLength { actual_len: value.remaining(), @@ -151,8 +141,8 @@ impl Visitor for WrapperKeepOpaqueVisitor { } impl IntoVisitor for WrapperKeepOpaque { - type Visitor = WrapperKeepOpaqueVisitor; - fn into_visitor() -> Self::Visitor { + type AnyVisitor = WrapperKeepOpaqueVisitor; + fn into_visitor() -> WrapperKeepOpaqueVisitor { WrapperKeepOpaqueVisitor(std::marker::PhantomData) } } @@ -205,7 +195,7 @@ mod test { let (type_id, types) = make_type::(); let scale_codec_encoded = t.encode(); - let encode_as_type_encoded = t.encode_as_type(type_id, &types).unwrap(); + let encode_as_type_encoded = t.encode_as_type(&type_id, &types).unwrap(); assert_eq!( scale_codec_encoded, encode_as_type_encoded, @@ -213,7 +203,7 @@ mod test { ); let decode_as_type_bytes = &mut &*scale_codec_encoded; - let decoded_as_type = T::decode_as_type(decode_as_type_bytes, type_id, &types) + let decoded_as_type = T::decode_as_type(decode_as_type_bytes, &type_id, &types) .expect("decode-as-type decodes"); let decode_scale_codec_bytes = &mut &*scale_codec_encoded;