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
+10 -13
View File
@@ -32,10 +32,7 @@ use sp_core::{
Pair,
};
use sp_keyring::AccountKeyring;
use subxt::{
Error,
Signer,
};
use subxt::Error;
/// Helper function to generate a crypto pair from seed
fn get_from_seed(seed: &str) -> sr25519::Pair {
@@ -58,7 +55,7 @@ async fn validate_with_controller_account() {
.tx()
.staking()
.validate(default_validator_prefs())
.sign_and_submit_then_watch(&alice)
.sign_and_submit_then_watch_default(&alice)
.await
.unwrap()
.wait_for_finalized_success()
@@ -75,7 +72,7 @@ async fn validate_not_possible_for_stash_account() -> Result<(), Error<DispatchE
.tx()
.staking()
.validate(default_validator_prefs())
.sign_and_submit_then_watch(&alice_stash)
.sign_and_submit_then_watch_default(&alice_stash)
.await?
.wait_for_finalized_success()
.await;
@@ -96,7 +93,7 @@ async fn nominate_with_controller_account() {
.tx()
.staking()
.nominate(vec![bob.account_id().clone().into()])
.sign_and_submit_then_watch(&alice)
.sign_and_submit_then_watch_default(&alice)
.await
.unwrap()
.wait_for_finalized_success()
@@ -115,7 +112,7 @@ async fn nominate_not_possible_for_stash_account() -> Result<(), Error<DispatchE
.tx()
.staking()
.nominate(vec![bob.account_id().clone().into()])
.sign_and_submit_then_watch(&alice_stash)
.sign_and_submit_then_watch_default(&alice_stash)
.await?
.wait_for_finalized_success()
.await;
@@ -139,7 +136,7 @@ async fn chill_works_for_controller_only() -> Result<(), Error<DispatchError>> {
.tx()
.staking()
.nominate(vec![bob_stash.account_id().clone().into()])
.sign_and_submit_then_watch(&alice)
.sign_and_submit_then_watch_default(&alice)
.await?
.wait_for_finalized_success()
.await?;
@@ -158,7 +155,7 @@ async fn chill_works_for_controller_only() -> Result<(), Error<DispatchError>> {
.tx()
.staking()
.chill()
.sign_and_submit_then_watch(&alice_stash)
.sign_and_submit_then_watch_default(&alice_stash)
.await?
.wait_for_finalized_success()
.await;
@@ -173,7 +170,7 @@ async fn chill_works_for_controller_only() -> Result<(), Error<DispatchError>> {
.tx()
.staking()
.chill()
.sign_and_submit_then_watch(&alice)
.sign_and_submit_then_watch_default(&alice)
.await?
.wait_for_finalized_success()
.await?
@@ -197,7 +194,7 @@ async fn tx_bond() -> Result<(), Error<DispatchError>> {
100_000_000_000_000,
RewardDestination::Stash,
)
.sign_and_submit_then_watch(&alice)
.sign_and_submit_then_watch_default(&alice)
.await?
.wait_for_finalized_success()
.await;
@@ -213,7 +210,7 @@ async fn tx_bond() -> Result<(), Error<DispatchError>> {
100_000_000_000_000,
RewardDestination::Stash,
)
.sign_and_submit_then_watch(&alice)
.sign_and_submit_then_watch_default(&alice)
.await?
.wait_for_finalized_success()
.await;