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
+4 -8
View File
@@ -22,18 +22,16 @@ pub(crate) use crate::{
use sp_core::sr25519::Pair;
use sp_keyring::AccountKeyring;
use subxt::{
extrinsic::ChargeAssetTxPayment,
Client,
DefaultConfig,
DefaultExtraWithTxPayment,
PairSigner,
SubstrateExtrinsicParams,
};
/// substrate node should be installed on the $PATH
const SUBSTRATE_NODE_PATH: &str = "substrate";
pub type NodeRuntimeSignedExtra =
DefaultExtraWithTxPayment<DefaultConfig, ChargeAssetTxPayment<DefaultConfig>>;
pub type NodeRuntimeParams = SubstrateExtrinsicParams<DefaultConfig>;
pub async fn test_node_process_with(
key: AccountKeyring,
@@ -60,7 +58,7 @@ pub async fn test_node_process() -> TestNodeProcess<DefaultConfig> {
pub struct TestContext {
pub node_proc: TestNodeProcess<DefaultConfig>,
pub api: node_runtime::RuntimeApi<DefaultConfig, NodeRuntimeSignedExtra>,
pub api: node_runtime::RuntimeApi<DefaultConfig, NodeRuntimeParams>,
}
impl TestContext {
@@ -76,8 +74,6 @@ pub async fn test_context() -> TestContext {
TestContext { node_proc, api }
}
pub fn pair_signer(
pair: Pair,
) -> PairSigner<DefaultConfig, NodeRuntimeSignedExtra, Pair> {
pub fn pair_signer(pair: Pair) -> PairSigner<DefaultConfig, Pair> {
PairSigner::new(pair)
}