Simplify creating and signing extrinsics (#490)

* WIP extrinsic api updates

* First pass done; now to get things compiling again

* document and tweak new structs/traits

* cargo check --all-targets now compiles without issue

* Polkadot and Substrate take different extra params; support both

* Fix transaction format (missing byte from AccountId -> Address) and fmt

* Tweak Signer trait

* Tweak comments and such in extrinsic params

* check all examples against newer polkadot, add new one with params, import path tweaks

* clippy fix, and save an allocation when signing

* Remove unnecessary Default clauses

* Tidy up and fix comments. Panic if payload size >4GB

* fix typo
This commit is contained in:
James Wilson
2022-03-30 18:53:54 +02:00
committed by GitHub
parent 82f304005b
commit 3d669f97c6
32 changed files with 2064 additions and 1114 deletions
+6 -6
View File
@@ -28,7 +28,7 @@ use crate::{
DispatchError,
},
test_context,
NodeRuntimeSignedExtra,
NodeRuntimeParams,
TestContext,
};
use sp_core::sr25519::Pair;
@@ -44,7 +44,7 @@ use subxt::{
struct ContractsTestContext {
cxt: TestContext,
signer: PairSigner<DefaultConfig, NodeRuntimeSignedExtra, Pair>,
signer: PairSigner<DefaultConfig, Pair>,
}
type Hash = <DefaultConfig as Config>::Hash;
@@ -62,7 +62,7 @@ impl ContractsTestContext {
self.cxt.client()
}
fn contracts_tx(&self) -> TransactionApi<DefaultConfig, NodeRuntimeSignedExtra> {
fn contracts_tx(&self) -> TransactionApi<DefaultConfig, NodeRuntimeParams> {
self.cxt.api.tx().contracts()
}
@@ -91,7 +91,7 @@ impl ContractsTestContext {
vec![], // data
vec![], // salt
)
.sign_and_submit_then_watch(&self.signer)
.sign_and_submit_then_watch_default(&self.signer)
.await?
.wait_for_finalized_success()
.await?;
@@ -131,7 +131,7 @@ impl ContractsTestContext {
data,
salt,
)
.sign_and_submit_then_watch(&self.signer)
.sign_and_submit_then_watch_default(&self.signer)
.await?
.wait_for_finalized_success()
.await?;
@@ -162,7 +162,7 @@ impl ContractsTestContext {
None, // storage_deposit_limit
input_data,
)
.sign_and_submit_then_watch(&self.signer)
.sign_and_submit_then_watch_default(&self.signer)
.await?;
log::info!("Call result: {:?}", result);