mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 08:51:09 +00:00
Submit (& sign) extrinsics from the runtime. (#3514)
* Abstract constructing extrinsic and signing. * Initial impl of signer. * Implement get payload. * Clean up the code. * Improve docs. * Bump version. * Update core/sr-primitives/src/generic/unchecked_extrinsic.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Fix tests & address grumbles. * Fix build. * Fix runtime tests. * Fix bound test. * Fix bound test.
This commit is contained in:
committed by
Gavin Wood
parent
0cae7217d8
commit
feecfc856d
@@ -29,7 +29,7 @@ use primitives::{
|
||||
use codec::{Encode, Decode};
|
||||
use sr_primitives::generic::Era;
|
||||
use node_primitives::{Balance, Index, Hash};
|
||||
use node_runtime::{Call, UncheckedExtrinsic, BalancesCall, Runtime};
|
||||
use node_runtime::{Call, UncheckedExtrinsic, SignedPayload, BalancesCall, Runtime, VERSION};
|
||||
|
||||
mod vanity;
|
||||
|
||||
@@ -182,22 +182,21 @@ fn execute<C: Crypto>(matches: clap::ArgMatches) where
|
||||
|
||||
println!("Using a genesis hash of {}", HexDisplay::from(&genesis_hash.as_ref()));
|
||||
|
||||
let raw_payload = (
|
||||
let raw_payload = SignedPayload::from_raw(
|
||||
function,
|
||||
extra(index, 0),
|
||||
(&genesis_hash, &genesis_hash),
|
||||
(VERSION.spec_version as u32, genesis_hash, genesis_hash, (), (), ()),
|
||||
);
|
||||
let signature = raw_payload.using_encoded(|payload| if payload.len() > 256 {
|
||||
signer.sign(&blake2_256(payload)[..])
|
||||
} else {
|
||||
let signature = raw_payload.using_encoded(|payload| {
|
||||
println!("Signing {}", HexDisplay::from(&payload));
|
||||
signer.sign(payload)
|
||||
});
|
||||
let (function, extra, _) = raw_payload.deconstruct();
|
||||
let extrinsic = UncheckedExtrinsic::new_signed(
|
||||
raw_payload.0,
|
||||
function,
|
||||
signer.public().into(),
|
||||
signature.into(),
|
||||
extra(index, 0),
|
||||
extra,
|
||||
);
|
||||
println!("0x{}", hex::encode(&extrinsic.encode()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user