Introduce Backend trait to allow different RPC (or other) backends to be implemented (#1126)

* WIP backend trait

* WIP converting higher level stuff to using Backend impl

* more implementing new backend trait, mainly storage focused

* Get core code compiling with new backend bits

* subxt crate checks passing

* fix tests

* cargo fmt

* clippy/fixes

* merging and other fixes

* fix test

* fix lightclient code

* Fix some broken doc links

* another book link fix

* fix broken test when moving default_rpc_client

* fix dry_run test

* fix more tests; lightclient and wasm

* fix wasm tests

* fix some doc examples

* use next() instead of next_item()

* missing next_item() -> next()s

* move legacy RPc methods to LegacyRpcMethods type to host generic param instead of RpcClient

* standardise on all RpcClient types prefixed with Rpc, and 'raw' trait types prefixed with RawRpc so it's less ocnfusing which is which

* rename fixes

* doc fixes

* Add back system_dryRun RPC method and rename tx.dry_run() to tx.validate(), to signal that the calls are different

* Add a test that we return the correct extrinsic hash from submit()

* add TransactionValid details back, and protect against out of range bytes

* add test for decoding transaction validation from empty bytes

* fix clippy warning
This commit is contained in:
James Wilson
2023-08-22 12:32:22 +01:00
committed by GitHub
parent 7e15e96e52
commit d7124b56f7
61 changed files with 2627 additions and 3150 deletions
@@ -11,6 +11,7 @@ use crate::{
},
test_context, TestContext,
};
use subxt::ext::futures::StreamExt;
use subxt::{tx::TxProgress, utils::MultiAddress, Config, Error, OnlineClient, SubstrateConfig};
use subxt_signer::sr25519::{self, dev};
@@ -202,8 +203,7 @@ async fn tx_call() {
let info_addr = node_runtime::storage()
.contracts()
.contract_info_of(&contract);
let info_addr_bytes = cxt.client().storage().address_bytes(&info_addr).unwrap();
let info_addr_iter = node_runtime::storage().contracts().contract_info_of_iter();
let contract_info = cxt
.client()
@@ -215,19 +215,20 @@ async fn tx_call() {
.await;
assert!(contract_info.is_ok());
let keys = cxt
let keys_and_values = cxt
.client()
.storage()
.at_latest()
.await
.unwrap()
.fetch_keys(&info_addr_bytes, 10, None)
.iter(info_addr_iter)
.await
.unwrap()
.iter()
.map(|key| hex::encode(&key.0))
.collect::<Vec<_>>();
println!("keys post: {keys:?}");
.collect::<Vec<_>>()
.await;
assert_eq!(keys_and_values.len(), 1);
println!("keys+values post: {keys_and_values:?}");
let executed = cxt.call(contract, vec![]).await;