Remove codec::Encode and codec::Decode derives from generated APIs by default (#2008)

* Remove codec::Encode and codec::Decode from generated APIs by default

* clippy fixes

* clippy

* More fixes, and CompactAs only if Encode/Decode

* revert println in example

* fix lightclient test

* fix docs

* Fix another rust doc comment

* Fix failing storage test

* Remove now-unnecessary test

* clippy

* clippy

* Remove pointless clone
This commit is contained in:
James Wilson
2025-05-29 14:43:42 +01:00
committed by GitHub
parent 0473cfd292
commit ed25a3ac26
22 changed files with 627 additions and 8974 deletions
@@ -72,15 +72,16 @@ async fn storage_n_mapish_key_is_properly_created() -> Result<(), subxt::Error>
// This is what the generated code hashes a `session().key_owner(..)` key into:
let actual_key = node_runtime::storage()
.session()
.key_owner(KeyTypeId([1, 2, 3, 4]), [5u8, 6, 7, 8]);
.key_owner(KeyTypeId([1, 2, 3, 4]), vec![5, 6, 7, 8]);
let actual_key_bytes = api.storage().address_bytes(&actual_key)?;
// Let's manually hash to what we assume it should be and compare:
let expected_key_bytes = {
// Hash the prefix to the storage entry:
let mut bytes = sp_core::twox_128("Session".as_bytes()).to_vec();
bytes.extend(&sp_core::twox_128("KeyOwner".as_bytes())[..]);
// Both keys, use twox64_concat hashers:
let key1 = KeyTypeId([1, 2, 3, 4]).encode();
let key1 = [1u8, 2, 3, 4].encode();
let key2 = vec![5u8, 6, 7, 8].encode();
bytes.extend(sp_core::twox_64(&key1));
bytes.extend(&key1);
@@ -88,7 +89,6 @@ async fn storage_n_mapish_key_is_properly_created() -> Result<(), subxt::Error>
bytes.extend(&key2);
bytes
};
dbg!(&expected_key_bytes);
assert_eq!(actual_key_bytes, expected_key_bytes);
Ok(())
@@ -196,7 +196,6 @@ async fn storage_partial_lookup() -> Result<(), subxt::Error> {
let mut approvals = Vec::new();
while let Some(Ok(kv)) = results.next().await {
assert!(kv.key_bytes.starts_with(&addr_bytes));
assert!(kv.keys.decoded().is_ok());
approvals.push(kv.value);
}
assert_eq!(approvals.len(), 1);