mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 04:01:02 +00:00
backport changes from polkadot-sdk (#2872)
This commit is contained in:
committed by
Bastian Köcher
parent
4bfd7807e7
commit
8bb0bfa524
@@ -16,7 +16,7 @@ codec = { package = "parity-scale-codec", version = "3.1.5" }
|
||||
env_logger = "0.11"
|
||||
futures = "0.3.30"
|
||||
hex = "0.4"
|
||||
log = "0.4.21"
|
||||
log = { workspace = true }
|
||||
num-format = "0.4"
|
||||
num-traits = "0.2"
|
||||
rbtag = "0.3"
|
||||
|
||||
@@ -125,18 +125,6 @@ impl relay_substrate_client::ChainWithTransactions for RococoAsPolkadot {
|
||||
unsigned.switch_chain(),
|
||||
)
|
||||
}
|
||||
|
||||
fn is_signed(tx: &Self::SignedTransaction) -> bool {
|
||||
relay_rococo_client::Rococo::is_signed(tx)
|
||||
}
|
||||
|
||||
fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool {
|
||||
relay_rococo_client::Rococo::is_signed_by(signer, tx)
|
||||
}
|
||||
|
||||
fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> {
|
||||
relay_rococo_client::Rococo::parse_transaction(tx).map(|tx| tx.switch_chain())
|
||||
}
|
||||
}
|
||||
|
||||
impl CliChain for RococoAsPolkadot {
|
||||
@@ -232,19 +220,6 @@ impl relay_substrate_client::ChainWithTransactions for BridgeHubRococoAsBridgeHu
|
||||
unsigned.switch_chain(),
|
||||
)
|
||||
}
|
||||
|
||||
fn is_signed(tx: &Self::SignedTransaction) -> bool {
|
||||
relay_bridge_hub_rococo_client::BridgeHubRococo::is_signed(tx)
|
||||
}
|
||||
|
||||
fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool {
|
||||
relay_bridge_hub_rococo_client::BridgeHubRococo::is_signed_by(signer, tx)
|
||||
}
|
||||
|
||||
fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> {
|
||||
relay_bridge_hub_rococo_client::BridgeHubRococo::parse_transaction(tx)
|
||||
.map(|tx| tx.switch_chain())
|
||||
}
|
||||
}
|
||||
|
||||
impl relay_substrate_client::ChainWithMessages for BridgeHubRococoAsBridgeHubPolkadot {
|
||||
|
||||
@@ -392,7 +392,7 @@ pub mod api {
|
||||
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
|
||||
pub struct RefundBridgedParachainMessages;
|
||||
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
|
||||
pub struct RefundSignedExtensionAdapter<_0>(pub _0);
|
||||
pub struct RefundTransactionExtensionAdapter<_0>(pub _0);
|
||||
}
|
||||
}
|
||||
pub mod cumulus_pallet_dmp_queue {
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
pub mod codegen_runtime;
|
||||
|
||||
use bp_bridge_hub_kusama::{SignedExtension, AVERAGE_BLOCK_INTERVAL};
|
||||
use bp_polkadot::SuffixedCommonSignedExtensionExt;
|
||||
use bp_bridge_hub_kusama::{TransactionExtension, AVERAGE_BLOCK_INTERVAL};
|
||||
use bp_polkadot::SuffixedCommonTransactionExtensionExt;
|
||||
use codec::Encode;
|
||||
use relay_substrate_client::{
|
||||
calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages,
|
||||
@@ -36,7 +36,8 @@ pub type RuntimeCall = runtime_types::bridge_hub_kusama_runtime::RuntimeCall;
|
||||
pub type BridgeMessagesCall = runtime_types::pallet_bridge_messages::pallet::Call;
|
||||
pub type BridgeGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call;
|
||||
pub type BridgeParachainCall = runtime_types::pallet_bridge_parachains::pallet::Call;
|
||||
type UncheckedExtrinsic = bp_bridge_hub_kusama::UncheckedExtrinsic<RuntimeCall, SignedExtension>;
|
||||
type UncheckedExtrinsic =
|
||||
bp_bridge_hub_kusama::UncheckedExtrinsic<RuntimeCall, TransactionExtension>;
|
||||
type UtilityCall = runtime_types::pallet_utility::pallet::Call;
|
||||
|
||||
/// Kusama chain definition
|
||||
@@ -86,7 +87,7 @@ impl ChainWithTransactions for BridgeHubKusama {
|
||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
||||
let raw_payload = SignedPayload::new(
|
||||
unsigned.call,
|
||||
SignedExtension::from_params(
|
||||
TransactionExtension::from_params(
|
||||
param.spec_version,
|
||||
param.transaction_version,
|
||||
unsigned.era,
|
||||
@@ -108,24 +109,6 @@ impl ChainWithTransactions for BridgeHubKusama {
|
||||
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 == bp_bridge_hub_kusama::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()))
|
||||
}
|
||||
}
|
||||
|
||||
impl ChainWithMessages for BridgeHubKusama {
|
||||
@@ -137,34 +120,3 @@ impl ChainWithMessages for BridgeHubKusama {
|
||||
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
|
||||
bp_bridge_hub_kusama::FROM_BRIDGE_HUB_KUSAMA_MESSAGE_DETAILS_METHOD;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use relay_substrate_client::TransactionEra;
|
||||
|
||||
type SystemCall = runtime_types::frame_system::pallet::Call;
|
||||
|
||||
#[test]
|
||||
fn parse_transaction_works() {
|
||||
let unsigned = UnsignedTransaction {
|
||||
call: RuntimeCall::System(SystemCall::remark { remark: b"Hello world!".to_vec() })
|
||||
.into(),
|
||||
nonce: 777,
|
||||
tip: 888,
|
||||
era: TransactionEra::immortal(),
|
||||
};
|
||||
let signed_transaction = BridgeHubKusama::sign_transaction(
|
||||
SignParam {
|
||||
spec_version: 42,
|
||||
transaction_version: 50000,
|
||||
genesis_hash: [42u8; 32].into(),
|
||||
signer: sp_core::sr25519::Pair::from_seed_slice(&[1u8; 32]).unwrap(),
|
||||
},
|
||||
unsigned.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
let parsed_transaction = BridgeHubKusama::parse_transaction(signed_transaction).unwrap();
|
||||
assert_eq!(parsed_transaction, unsigned);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
use codec::{Decode, Encode};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
pub use bp_bridge_hub_kusama::SignedExtension;
|
||||
pub use bp_bridge_hub_kusama::TransactionExtension;
|
||||
pub use bp_header_chain::BridgeGrandpaCallOf;
|
||||
pub use bp_parachains::BridgeParachainCall;
|
||||
pub use bridge_runtime_common::messages::BridgeMessagesCallOf;
|
||||
pub use relay_substrate_client::calls::{SystemCall, UtilityCall};
|
||||
|
||||
/// Unchecked BridgeHubKusama extrinsic.
|
||||
pub type UncheckedExtrinsic = bp_bridge_hub_kusama::UncheckedExtrinsic<Call, SignedExtension>;
|
||||
pub type UncheckedExtrinsic = bp_bridge_hub_kusama::UncheckedExtrinsic<Call, TransactionExtension>;
|
||||
|
||||
// The indirect pallet call used to sync `Polkadot` GRANDPA finality to `BHKusama`.
|
||||
pub type BridgePolkadotGrandpaCall = BridgeGrandpaCallOf<bp_polkadot::Polkadot>;
|
||||
|
||||
@@ -392,7 +392,7 @@ pub mod api {
|
||||
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
|
||||
pub struct RefundBridgedParachainMessages;
|
||||
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
|
||||
pub struct RefundSignedExtensionAdapter<_0>(pub _0);
|
||||
pub struct RefundTransactionExtensionAdapter<_0>(pub _0);
|
||||
}
|
||||
}
|
||||
pub mod cumulus_pallet_dmp_queue {
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
pub mod codegen_runtime;
|
||||
|
||||
use bp_bridge_hub_polkadot::{SignedExtension, AVERAGE_BLOCK_INTERVAL};
|
||||
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
|
||||
use bp_bridge_hub_polkadot::{TransactionExtension, AVERAGE_BLOCK_INTERVAL};
|
||||
use bp_polkadot_core::SuffixedCommonTransactionExtensionExt;
|
||||
use codec::Encode;
|
||||
use relay_substrate_client::{
|
||||
calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages,
|
||||
@@ -40,7 +40,8 @@ pub type BridgeKusamaMessagesCall = runtime_types::pallet_bridge_messages::palle
|
||||
pub type BridgePolkadotBulletinGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call;
|
||||
pub type BridgeKusamaGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call;
|
||||
pub type BridgeParachainCall = runtime_types::pallet_bridge_parachains::pallet::Call;
|
||||
type UncheckedExtrinsic = bp_bridge_hub_polkadot::UncheckedExtrinsic<RuntimeCall, SignedExtension>;
|
||||
type UncheckedExtrinsic =
|
||||
bp_bridge_hub_polkadot::UncheckedExtrinsic<RuntimeCall, TransactionExtension>;
|
||||
type UtilityCall = runtime_types::pallet_utility::pallet::Call;
|
||||
|
||||
/// Polkadot chain definition
|
||||
@@ -90,7 +91,7 @@ impl ChainWithTransactions for BridgeHubPolkadot {
|
||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
||||
let raw_payload = SignedPayload::new(
|
||||
unsigned.call,
|
||||
SignedExtension::from_params(
|
||||
TransactionExtension::from_params(
|
||||
param.spec_version,
|
||||
param.transaction_version,
|
||||
unsigned.era,
|
||||
@@ -112,24 +113,6 @@ impl ChainWithTransactions for BridgeHubPolkadot {
|
||||
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 == bp_bridge_hub_polkadot::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()))
|
||||
}
|
||||
}
|
||||
|
||||
impl ChainWithMessages for BridgeHubPolkadot {
|
||||
@@ -141,34 +124,3 @@ impl ChainWithMessages for BridgeHubPolkadot {
|
||||
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
|
||||
bp_bridge_hub_polkadot::FROM_BRIDGE_HUB_POLKADOT_MESSAGE_DETAILS_METHOD;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use relay_substrate_client::TransactionEra;
|
||||
|
||||
type SystemCall = runtime_types::frame_system::pallet::Call;
|
||||
|
||||
#[test]
|
||||
fn parse_transaction_works() {
|
||||
let unsigned = UnsignedTransaction {
|
||||
call: RuntimeCall::System(SystemCall::remark { remark: b"Hello world!".to_vec() })
|
||||
.into(),
|
||||
nonce: 777,
|
||||
tip: 888,
|
||||
era: TransactionEra::immortal(),
|
||||
};
|
||||
let signed_transaction = BridgeHubPolkadot::sign_transaction(
|
||||
SignParam {
|
||||
spec_version: 42,
|
||||
transaction_version: 50000,
|
||||
genesis_hash: [42u8; 32].into(),
|
||||
signer: sp_core::sr25519::Pair::from_seed_slice(&[1u8; 32]).unwrap(),
|
||||
},
|
||||
unsigned.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
let parsed_transaction = BridgeHubPolkadot::parse_transaction(signed_transaction).unwrap();
|
||||
assert_eq!(parsed_transaction, unsigned);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
use codec::{Decode, Encode};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
pub use bp_bridge_hub_polkadot::SignedExtension;
|
||||
pub use bp_bridge_hub_polkadot::TransactionExtension;
|
||||
pub use bp_header_chain::BridgeGrandpaCallOf;
|
||||
pub use bp_parachains::BridgeParachainCall;
|
||||
pub use bridge_runtime_common::messages::BridgeMessagesCallOf;
|
||||
pub use relay_substrate_client::calls::{SystemCall, UtilityCall};
|
||||
|
||||
/// Unchecked BridgeHubPolkadot extrinsic.
|
||||
pub type UncheckedExtrinsic = bp_bridge_hub_polkadot::UncheckedExtrinsic<Call, SignedExtension>;
|
||||
pub type UncheckedExtrinsic = bp_bridge_hub_polkadot::UncheckedExtrinsic<Call, TransactionExtension>;
|
||||
|
||||
/// The indirect pallet call used to sync `Kusama` GRANDPA finality to `BHPolkadot`.
|
||||
pub type BridgeKusamaGrandpaCall = BridgeGrandpaCallOf<bp_kusama::Kusama>;
|
||||
|
||||
@@ -463,7 +463,7 @@ pub mod api {
|
||||
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
|
||||
pub struct RefundBridgedParachainMessages;
|
||||
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
|
||||
pub struct RefundSignedExtensionAdapter<_0>(pub _0);
|
||||
pub struct RefundTransactionExtensionAdapter<_0>(pub _0);
|
||||
}
|
||||
}
|
||||
pub mod cumulus_pallet_parachain_system {
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
pub mod codegen_runtime;
|
||||
|
||||
use bp_bridge_hub_rococo::{SignedExtension, AVERAGE_BLOCK_INTERVAL};
|
||||
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
|
||||
use bp_bridge_hub_rococo::{TransactionExtension, AVERAGE_BLOCK_INTERVAL};
|
||||
use bp_polkadot_core::SuffixedCommonTransactionExtensionExt;
|
||||
use codec::Encode;
|
||||
use relay_substrate_client::{
|
||||
calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages,
|
||||
@@ -38,7 +38,8 @@ pub type BridgeBulletinMessagesCall = runtime_types::pallet_bridge_messages::pal
|
||||
pub type BridgeGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call;
|
||||
pub type BridgeBulletinGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call2;
|
||||
pub type BridgeParachainCall = runtime_types::pallet_bridge_parachains::pallet::Call;
|
||||
type UncheckedExtrinsic = bp_bridge_hub_rococo::UncheckedExtrinsic<RuntimeCall, SignedExtension>;
|
||||
type UncheckedExtrinsic =
|
||||
bp_bridge_hub_rococo::UncheckedExtrinsic<RuntimeCall, TransactionExtension>;
|
||||
type UtilityCall = runtime_types::pallet_utility::pallet::Call;
|
||||
|
||||
/// Rococo chain definition
|
||||
@@ -88,7 +89,7 @@ impl ChainWithTransactions for BridgeHubRococo {
|
||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
||||
let raw_payload = SignedPayload::new(
|
||||
unsigned.call,
|
||||
SignedExtension::from_params(
|
||||
TransactionExtension::from_params(
|
||||
param.spec_version,
|
||||
param.transaction_version,
|
||||
unsigned.era,
|
||||
@@ -110,24 +111,6 @@ impl ChainWithTransactions for BridgeHubRococo {
|
||||
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 == bp_bridge_hub_rococo::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()))
|
||||
}
|
||||
}
|
||||
|
||||
impl ChainWithMessages for BridgeHubRococo {
|
||||
@@ -139,34 +122,3 @@ impl ChainWithMessages for BridgeHubRococo {
|
||||
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
|
||||
bp_bridge_hub_rococo::FROM_BRIDGE_HUB_ROCOCO_MESSAGE_DETAILS_METHOD;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use relay_substrate_client::TransactionEra;
|
||||
|
||||
type SystemCall = runtime_types::frame_system::pallet::Call;
|
||||
|
||||
#[test]
|
||||
fn parse_transaction_works() {
|
||||
let unsigned = UnsignedTransaction {
|
||||
call: RuntimeCall::System(SystemCall::remark { remark: b"Hello world!".to_vec() })
|
||||
.into(),
|
||||
nonce: 777,
|
||||
tip: 888,
|
||||
era: TransactionEra::immortal(),
|
||||
};
|
||||
let signed_transaction = BridgeHubRococo::sign_transaction(
|
||||
SignParam {
|
||||
spec_version: 42,
|
||||
transaction_version: 50000,
|
||||
genesis_hash: [42u8; 32].into(),
|
||||
signer: sp_core::sr25519::Pair::from_seed_slice(&[1u8; 32]).unwrap(),
|
||||
},
|
||||
unsigned.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
let parsed_transaction = BridgeHubRococo::parse_transaction(signed_transaction).unwrap();
|
||||
assert_eq!(parsed_transaction, unsigned);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ pub mod api {
|
||||
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
|
||||
pub struct RefundBridgedParachainMessages;
|
||||
#[derive(:: codec :: Decode, :: codec :: Encode, Clone, Debug, PartialEq)]
|
||||
pub struct RefundSignedExtensionAdapter<_0>(pub _0);
|
||||
pub struct RefundTransactionExtensionAdapter<_0>(pub _0);
|
||||
}
|
||||
}
|
||||
pub mod cumulus_pallet_parachain_system {
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
pub mod codegen_runtime;
|
||||
|
||||
use bp_bridge_hub_westend::{SignedExtension, AVERAGE_BLOCK_INTERVAL};
|
||||
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
|
||||
use bp_bridge_hub_westend::{TransactionExtension, AVERAGE_BLOCK_INTERVAL};
|
||||
use bp_polkadot_core::SuffixedCommonTransactionExtensionExt;
|
||||
use codec::Encode;
|
||||
use relay_substrate_client::{
|
||||
calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages,
|
||||
@@ -36,7 +36,8 @@ pub type RuntimeCall = runtime_types::bridge_hub_westend_runtime::RuntimeCall;
|
||||
pub type BridgeMessagesCall = runtime_types::pallet_bridge_messages::pallet::Call;
|
||||
pub type BridgeGrandpaCall = runtime_types::pallet_bridge_grandpa::pallet::Call;
|
||||
pub type BridgeParachainCall = runtime_types::pallet_bridge_parachains::pallet::Call;
|
||||
type UncheckedExtrinsic = bp_bridge_hub_westend::UncheckedExtrinsic<RuntimeCall, SignedExtension>;
|
||||
type UncheckedExtrinsic =
|
||||
bp_bridge_hub_westend::UncheckedExtrinsic<RuntimeCall, TransactionExtension>;
|
||||
type UtilityCall = runtime_types::pallet_utility::pallet::Call;
|
||||
|
||||
/// Westend chain definition
|
||||
@@ -86,7 +87,7 @@ impl ChainWithTransactions for BridgeHubWestend {
|
||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
||||
let raw_payload = SignedPayload::new(
|
||||
unsigned.call,
|
||||
SignedExtension::from_params(
|
||||
TransactionExtension::from_params(
|
||||
param.spec_version,
|
||||
param.transaction_version,
|
||||
unsigned.era,
|
||||
@@ -108,24 +109,6 @@ impl ChainWithTransactions for BridgeHubWestend {
|
||||
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 == bp_bridge_hub_westend::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()))
|
||||
}
|
||||
}
|
||||
|
||||
impl ChainWithMessages for BridgeHubWestend {
|
||||
@@ -137,34 +120,3 @@ impl ChainWithMessages for BridgeHubWestend {
|
||||
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
|
||||
bp_bridge_hub_westend::FROM_BRIDGE_HUB_WESTEND_MESSAGE_DETAILS_METHOD;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use relay_substrate_client::TransactionEra;
|
||||
|
||||
type SystemCall = runtime_types::frame_system::pallet::Call;
|
||||
|
||||
#[test]
|
||||
fn parse_transaction_works() {
|
||||
let unsigned = UnsignedTransaction {
|
||||
call: RuntimeCall::System(SystemCall::remark { remark: b"Hello world!".to_vec() })
|
||||
.into(),
|
||||
nonce: 777,
|
||||
tip: 888,
|
||||
era: TransactionEra::immortal(),
|
||||
};
|
||||
let signed_transaction = BridgeHubWestend::sign_transaction(
|
||||
SignParam {
|
||||
spec_version: 42,
|
||||
transaction_version: 50000,
|
||||
genesis_hash: [42u8; 32].into(),
|
||||
signer: sp_core::sr25519::Pair::from_seed_slice(&[1u8; 32]).unwrap(),
|
||||
},
|
||||
unsigned.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
let parsed_transaction = BridgeHubWestend::parse_transaction(signed_transaction).unwrap();
|
||||
assert_eq!(parsed_transaction, unsigned);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,8 +99,10 @@ impl ChainWithBalances for PolkadotBulletin {
|
||||
|
||||
impl ChainWithTransactions for PolkadotBulletin {
|
||||
type AccountKeyPair = sp_core::sr25519::Pair;
|
||||
type SignedTransaction =
|
||||
bp_polkadot_bulletin::UncheckedExtrinsic<Self::Call, bp_polkadot_bulletin::SignedExtension>;
|
||||
type SignedTransaction = bp_polkadot_bulletin::UncheckedExtrinsic<
|
||||
Self::Call,
|
||||
bp_polkadot_bulletin::TransactionExtension,
|
||||
>;
|
||||
|
||||
fn sign_transaction(
|
||||
param: SignParam<Self>,
|
||||
@@ -108,7 +110,7 @@ impl ChainWithTransactions for PolkadotBulletin {
|
||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
||||
let raw_payload = SignedPayload::new(
|
||||
unsigned.call,
|
||||
bp_polkadot_bulletin::SignedExtension::from_params(
|
||||
bp_polkadot_bulletin::TransactionExtension::from_params(
|
||||
param.spec_version,
|
||||
param.transaction_version,
|
||||
unsigned.era,
|
||||
@@ -128,20 +130,4 @@ impl ChainWithTransactions for PolkadotBulletin {
|
||||
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()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
mod codegen_runtime;
|
||||
|
||||
use bp_polkadot::{AccountInfoStorageMapKeyProvider, POLKADOT_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 Polkadot {
|
||||
impl ChainWithTransactions for Polkadot {
|
||||
type AccountKeyPair = sp_core::sr25519::Pair;
|
||||
type SignedTransaction =
|
||||
bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_polkadot::SignedExtension>;
|
||||
bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_polkadot::TransactionExtension>;
|
||||
|
||||
fn sign_transaction(
|
||||
param: SignParam<Self>,
|
||||
@@ -91,7 +91,7 @@ impl ChainWithTransactions for Polkadot {
|
||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
||||
let raw_payload = SignedPayload::new(
|
||||
unsigned.call,
|
||||
bp_polkadot::SignedExtension::from_params(
|
||||
bp_polkadot::TransactionExtension::from_params(
|
||||
param.spec_version,
|
||||
param.transaction_version,
|
||||
unsigned.era,
|
||||
@@ -113,20 +113,4 @@ impl ChainWithTransactions for Polkadot {
|
||||
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()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
pub mod codegen_runtime;
|
||||
|
||||
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
|
||||
use bp_polkadot_core::SuffixedCommonTransactionExtensionExt;
|
||||
use bp_rococo::ROCOCO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
||||
use codec::Encode;
|
||||
use relay_substrate_client::{
|
||||
@@ -83,7 +83,7 @@ impl RelayChain for Rococo {
|
||||
impl ChainWithTransactions for Rococo {
|
||||
type AccountKeyPair = sp_core::sr25519::Pair;
|
||||
type SignedTransaction =
|
||||
bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_rococo::SignedExtension>;
|
||||
bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_rococo::TransactionExtension>;
|
||||
|
||||
fn sign_transaction(
|
||||
param: SignParam<Self>,
|
||||
@@ -91,7 +91,7 @@ impl ChainWithTransactions for Rococo {
|
||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
||||
let raw_payload = SignedPayload::new(
|
||||
unsigned.call,
|
||||
bp_rococo::SignedExtension::from_params(
|
||||
bp_rococo::TransactionExtension::from_params(
|
||||
param.spec_version,
|
||||
param.transaction_version,
|
||||
unsigned.era,
|
||||
@@ -113,20 +113,4 @@ impl ChainWithTransactions for Rococo {
|
||||
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()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ async-trait = "0.1"
|
||||
codec = { package = "parity-scale-codec", version = "3.1.5" }
|
||||
futures = "0.3.30"
|
||||
jsonrpsee = { version = "0.17", features = ["macros", "ws-client"] }
|
||||
log = "0.4.21"
|
||||
log = { workspace = true }
|
||||
num-traits = "0.2"
|
||||
rand = "0.8"
|
||||
scale-info = { version = "2.10.0", features = ["derive"] }
|
||||
tokio = { version = "1.36", features = ["rt-multi-thread"] }
|
||||
thiserror = "1.0.57"
|
||||
thiserror = { workspace = true }
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
|
||||
@@ -203,17 +203,6 @@ pub trait ChainWithTransactions: Chain {
|
||||
) -> Result<Self::SignedTransaction, crate::Error>
|
||||
where
|
||||
Self: Sized;
|
||||
|
||||
/// Returns true if transaction is signed.
|
||||
fn is_signed(tx: &Self::SignedTransaction) -> bool;
|
||||
|
||||
/// Returns true if transaction is signed by given signer.
|
||||
fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool;
|
||||
|
||||
/// Parse signed transaction into its unsigned part.
|
||||
///
|
||||
/// Returns `None` if signed transaction has unsupported format.
|
||||
fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>>;
|
||||
}
|
||||
|
||||
/// Sign transaction parameters
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
pub mod codegen_runtime;
|
||||
|
||||
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
|
||||
use bp_polkadot_core::SuffixedCommonTransactionExtensionExt;
|
||||
use bp_westend::WESTEND_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
|
||||
use codec::Encode;
|
||||
use relay_substrate_client::{
|
||||
@@ -83,7 +83,7 @@ impl ChainWithBalances for Westend {
|
||||
impl ChainWithTransactions for Westend {
|
||||
type AccountKeyPair = sp_core::sr25519::Pair;
|
||||
type SignedTransaction =
|
||||
bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_westend::SignedExtension>;
|
||||
bp_polkadot_core::UncheckedExtrinsic<Self::Call, bp_westend::TransactionExtension>;
|
||||
|
||||
fn sign_transaction(
|
||||
param: SignParam<Self>,
|
||||
@@ -91,7 +91,7 @@ impl ChainWithTransactions for Westend {
|
||||
) -> Result<Self::SignedTransaction, SubstrateError> {
|
||||
let raw_payload = SignedPayload::new(
|
||||
unsigned.call,
|
||||
bp_westend::SignedExtension::from_params(
|
||||
bp_westend::TransactionExtension::from_params(
|
||||
param.spec_version,
|
||||
param.transaction_version,
|
||||
unsigned.era,
|
||||
@@ -113,20 +113,4 @@ impl ChainWithTransactions for Westend {
|
||||
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()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,6 @@ bp-header-chain = { path = "../../primitives/header-chain" }
|
||||
finality-relay = { path = "../finality" }
|
||||
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
|
||||
futures = "0.3.30"
|
||||
log = "0.4.21"
|
||||
log = { workspace = true }
|
||||
num-traits = "0.2"
|
||||
relay-utils = { path = "../utils" }
|
||||
|
||||
@@ -15,7 +15,7 @@ async-trait = "0.1"
|
||||
backoff = "0.4"
|
||||
bp-header-chain = { path = "../../primitives/header-chain" }
|
||||
futures = "0.3.30"
|
||||
log = "0.4.21"
|
||||
log = { workspace = true }
|
||||
num-traits = "0.2"
|
||||
relay-utils = { path = "../utils" }
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
thiserror = "1.0.57"
|
||||
thiserror = { workspace = true }
|
||||
async-std = "1.9.0"
|
||||
async-trait = "0.1"
|
||||
codec = { package = "parity-scale-codec", version = "3.1.5" }
|
||||
futures = "0.3.30"
|
||||
hex = "0.4"
|
||||
num-traits = "0.2"
|
||||
log = "0.4.21"
|
||||
log = { workspace = true }
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ async-trait = "0.1"
|
||||
env_logger = "0.11"
|
||||
futures = "0.3.30"
|
||||
hex = "0.4"
|
||||
log = "0.4.21"
|
||||
log = { workspace = true }
|
||||
num-traits = "0.2"
|
||||
parking_lot = "0.12.1"
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ workspace = true
|
||||
async-std = "1.6.5"
|
||||
async-trait = "0.1"
|
||||
futures = "0.3.30"
|
||||
log = "0.4.21"
|
||||
log = { workspace = true }
|
||||
relay-utils = { path = "../utils" }
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
@@ -18,13 +18,13 @@ isahc = "1.2"
|
||||
env_logger = "0.11.3"
|
||||
futures = "0.3.30"
|
||||
jsonpath_lib = "0.3"
|
||||
log = "0.4.21"
|
||||
log = { workspace = true }
|
||||
num-traits = "0.2"
|
||||
serde_json = "1.0"
|
||||
serde_json = { workspace = true, default-features = true }
|
||||
sysinfo = "0.30"
|
||||
time = { version = "0.3", features = ["formatting", "local-offset", "std"] }
|
||||
tokio = { version = "1.36", features = ["rt"] }
|
||||
thiserror = "1.0.57"
|
||||
thiserror = { workspace = true }
|
||||
|
||||
# Bridge dependencies
|
||||
|
||||
|
||||
Reference in New Issue
Block a user