mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 23:21:06 +00:00
Extensible transactions (and tips) (#3102)
* Make extrinsics extensible. Also Remove old extrinsic types. * Rest of mockup. Add tips. * Fix some build issues * Runtiem builds :) * Substrate builds. * Fix a doc test * Compact encoding * Extract out the era logic into an extension * Weight Check signed extension. (#3115) * Weight signed extension. * Revert a bit + test for check era. * Update Cargo.toml * Update node/cli/src/factory_impl.rs * Update node/executor/src/lib.rs * Update node/executor/src/lib.rs * Don't use len for weight - use data. * Operational Transaction; second attempt (#3138) * working poc added. * some fixes. * Update doc. * Fix all tests + final logic. * more refactoring. * nits. * System block limit in bytes. * Silent the storage macro warnings. * More logic more tests. * Fix import. * Refactor names. * Fix build. * Update srml/balances/src/lib.rs * Final refactor. * Bump transaction version * Fix weight mult test. * Fix more tests and improve doc. * Bump. * Make some tests work again. * Fix subkey. * Remove todos + bump. * Ignore expensive test. * Bump.
This commit is contained in:
@@ -23,8 +23,8 @@ use hex_literal::hex;
|
||||
use clap::load_yaml;
|
||||
use bip39::{Mnemonic, Language, MnemonicType};
|
||||
use substrate_primitives::{
|
||||
ed25519, sr25519, hexdisplay::HexDisplay, Pair, Public,
|
||||
crypto::{Ss58Codec, set_default_ss58_version, Ss58AddressFormat}, blake2_256
|
||||
ed25519, sr25519, hexdisplay::HexDisplay, Pair, Public, blake2_256,
|
||||
crypto::{Ss58Codec, set_default_ss58_version, Ss58AddressFormat}
|
||||
};
|
||||
use parity_codec::{Encode, Decode, Compact};
|
||||
use sr_primitives::generic::Era;
|
||||
@@ -90,6 +90,14 @@ fn execute<C: Crypto>(matches: clap::ArgMatches) where
|
||||
<<C as Crypto>::Pair as Pair>::Signature: AsRef<[u8]> + AsMut<[u8]> + Default,
|
||||
<<C as Crypto>::Pair as Pair>::Public: Sized + AsRef<[u8]> + Ss58Codec + AsRef<<<C as Crypto>::Pair as Pair>::Public>,
|
||||
{
|
||||
// let extra = |i: Index, f: Balance| {
|
||||
// (
|
||||
// system::CheckEra::<Runtime>::from(Era::Immortal),
|
||||
// system::CheckNonce::<Runtime>::from(i),
|
||||
// system::CheckWeight::<Runtime>::from(),
|
||||
// balances::TakeFees::<Runtime>::from(f),
|
||||
// )
|
||||
// };
|
||||
let password = matches.value_of("password");
|
||||
let maybe_network = matches.value_of("network");
|
||||
if let Some(network) = maybe_network {
|
||||
@@ -162,8 +170,7 @@ fn execute<C: Crypto>(matches: clap::ArgMatches) where
|
||||
|
||||
println!("Using a genesis hash of {}", HexDisplay::from(&genesis_hash.as_ref()));
|
||||
|
||||
let era = Era::immortal();
|
||||
let raw_payload = (Compact(index), function, era, genesis_hash);
|
||||
let raw_payload = (function, extra(index, 0), genesis_hash);
|
||||
let signature = raw_payload.using_encoded(|payload| if payload.len() > 256 {
|
||||
signer.sign(&blake2_256(payload)[..])
|
||||
} else {
|
||||
@@ -171,11 +178,10 @@ fn execute<C: Crypto>(matches: clap::ArgMatches) where
|
||||
signer.sign(payload)
|
||||
});
|
||||
let extrinsic = UncheckedExtrinsic::new_signed(
|
||||
raw_payload.1,
|
||||
raw_payload.0,
|
||||
signer.public().into(),
|
||||
signature.into(),
|
||||
era,
|
||||
(CheckNonce(index), TakeFees(0)),
|
||||
extra(index, 0),
|
||||
);
|
||||
println!("0x{}", hex::encode(&extrinsic.encode()));
|
||||
}
|
||||
@@ -202,7 +208,7 @@ fn execute<C: Crypto>(matches: clap::ArgMatches) where
|
||||
|
||||
let era = Era::immortal();
|
||||
|
||||
let raw_payload = (Compact(index), function, era, prior_block_hash);
|
||||
let raw_payload = (function, era, prior_block_hash, extra(index, 0));
|
||||
let signature = raw_payload.using_encoded(|payload|
|
||||
if payload.len() > 256 {
|
||||
signer.sign(&blake2_256(payload)[..])
|
||||
@@ -212,11 +218,10 @@ fn execute<C: Crypto>(matches: clap::ArgMatches) where
|
||||
);
|
||||
|
||||
let extrinsic = UncheckedExtrinsic::new_signed(
|
||||
raw_payload.1,
|
||||
raw_payload.0,
|
||||
signer.public().into(),
|
||||
signature.into(),
|
||||
era,
|
||||
(CheckNonce(index), TakeFees(0)),
|
||||
extra(index, 0),
|
||||
);
|
||||
|
||||
println!("0x{}", hex::encode(&extrinsic.encode()));
|
||||
|
||||
Reference in New Issue
Block a user