Make sp_core and sp_runtime dependencies optional, and bump to latest (#760)

* begin porting over traits; remove Config use of Hash

* port over the Header bits that we need

* sp_core_hashing where possible, move Verify to PairSigner, remove unused errors

* tidy up Config things and move related bits into one place

* fix codegen

* copy Era over

* move AccountId, Address, Signer to Signer trait and a pass over fixing examples

* impl MultiAddress, MultiSignature, AccountId32 and add back to Config (for decoding later)

* Copy over StorageKey, StorageData, StorageChangeSet

* subxt core compiling with no sp_core or sp_runtime

* Get examples compiling

* pass over fixing tests

* cargo fmt

* clippy tweaks and update polkadot.rs

* fix codegen docs

* port over special DigestItem encoding/decoding

* clippy and doc fixes

* cargo fmt and example fix

* more cargo fmt-ing...

* substrate-extra to substrate-compat

* cargo.toml comments

* simplify PairSigner trait bounds

* move RPC types to a separate file

* fix docs

* Add some tests for things and other PR feedback

* bump to latest sp deps

* avoid needing substrate-compat feature in a test
This commit is contained in:
James Wilson
2023-01-10 12:02:41 +00:00
committed by GitHub
parent ea5daa444f
commit b316301d61
47 changed files with 2658 additions and 1736 deletions
+7 -11
View File
@@ -17,7 +17,10 @@ use sp_core::{
Pair,
};
use sp_keyring::AccountKeyring;
use subxt::error::DispatchError;
use subxt::{
error::DispatchError,
rpc::types::DryRunError,
};
#[tokio::test]
async fn insert_key() {
@@ -162,8 +165,7 @@ async fn dry_run_passes() {
.dry_run(None)
.await
.expect("dryrunning failed")
.expect("expected dryrunning to be successful")
.unwrap();
.expect("dry run should be successful");
signed_extrinsic
.submit_and_watch()
@@ -198,15 +200,9 @@ async fn dry_run_fails() {
let dry_run_res = signed_extrinsic
.dry_run(None)
.await
.expect("dryrunning failed")
.expect("expected dryrun transaction to be valid");
.expect("dryrunning failed");
if let Err(sp_runtime::DispatchError::Module(module_error)) = dry_run_res {
assert_eq!(module_error.index, 6);
assert_eq!(module_error.error, [2, 0, 0, 0]);
} else {
panic!("expected a module error when dryrunning");
}
assert_eq!(dry_run_res, Err(DryRunError::DispatchError));
let res = signed_extrinsic
.submit_and_watch()