backport changes from polkadot-sdk (#2872)

This commit is contained in:
Svyatoslav Nikolsky
2024-03-12 14:53:52 +03:00
committed by Bastian Köcher
parent 4bfd7807e7
commit 8bb0bfa524
53 changed files with 364 additions and 588 deletions
+3 -19
View File
@@ -19,7 +19,7 @@
pub mod codegen_runtime;
use bp_kusama::{AccountInfoStorageMapKeyProvider, KUSAMA_SYNCED_HEADERS_GRANDPA_INFO_METHOD};
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
use bp_polkadot_core::SuffixedCommonTransactionExtensionExt;
use codec::Encode;
use relay_substrate_client::{
Chain, ChainWithBalances, ChainWithGrandpa, ChainWithTransactions, Error as SubstrateError,
@@ -83,7 +83,7 @@ impl RelayChain for Kusama {
impl ChainWithTransactions for Kusama {
type AccountKeyPair = sp_core::sr25519::Pair;
type SignedTransaction =
bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_kusama::SignedExtension>;
bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_kusama::TransactionExtension>;
fn sign_transaction(
param: SignParam<Self>,
@@ -91,7 +91,7 @@ impl ChainWithTransactions for Kusama {
) -> Result<Self::SignedTransaction, SubstrateError> {
let raw_payload = SignedPayload::new(
unsigned.call,
bp_kusama::SignedExtension::from_params(
bp_kusama::TransactionExtension::from_params(
param.spec_version,
param.transaction_version,
unsigned.era,
@@ -113,20 +113,4 @@ impl ChainWithTransactions for Kusama {
extra,
))
}
fn is_signed(tx: &Self::SignedTransaction) -> bool {
tx.signature.is_some()
}
fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool {
tx.signature
.as_ref()
.map(|(address, _, _)| *address == Address::Id(signer.public().into()))
.unwrap_or(false)
}
fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> {
let extra = &tx.signature.as_ref()?.2;
Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip()))
}
}