mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 08:41:02 +00:00
remove account derivation functions (#1498)
This commit is contained in:
committed by
Bastian Köcher
parent
d327b25724
commit
ceefd1b05d
@@ -15,7 +15,6 @@
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::cli::CliChain;
|
||||
use bp_runtime::{AccountIdOf, SourceAccount};
|
||||
use relay_substrate_client::{AccountKeyPairOf, Chain, TransactionSignScheme};
|
||||
use strum::{EnumString, EnumVariantNames};
|
||||
use substrate_relay_helper::{
|
||||
@@ -82,11 +81,6 @@ pub trait MessagesCliBridge: CliBridgeBase {
|
||||
SourceTransactionSignScheme = Self::Source,
|
||||
TargetTransactionSignScheme = Self::Target,
|
||||
>;
|
||||
|
||||
/// We use this to get the account on the target which is derived from the source account.
|
||||
fn derive_account_from_id(
|
||||
id: SourceAccount<AccountIdOf<Self::Source>>,
|
||||
) -> AccountIdOf<Self::Target>;
|
||||
}
|
||||
|
||||
//// `Millau` to `Rialto` bridge definition.
|
||||
@@ -105,12 +99,6 @@ impl MessagesCliBridge for MillauToRialtoCliBridge {
|
||||
const ESTIMATE_MESSAGE_FEE_METHOD: &'static str =
|
||||
bp_rialto::TO_RIALTO_ESTIMATE_MESSAGE_FEE_METHOD;
|
||||
type MessagesLane = crate::chains::millau_messages_to_rialto::MillauMessagesToRialto;
|
||||
|
||||
fn derive_account_from_id(
|
||||
id: SourceAccount<AccountIdOf<Self::Source>>,
|
||||
) -> AccountIdOf<Self::Target> {
|
||||
bp_rialto::derive_account_from_millau_id(id)
|
||||
}
|
||||
}
|
||||
|
||||
//// `Rialto` to `Millau` bridge definition.
|
||||
@@ -129,14 +117,6 @@ impl MessagesCliBridge for RialtoToMillauCliBridge {
|
||||
const ESTIMATE_MESSAGE_FEE_METHOD: &'static str =
|
||||
bp_millau::TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD;
|
||||
type MessagesLane = crate::chains::rialto_messages_to_millau::RialtoMessagesToMillau;
|
||||
|
||||
/// We use this to get the account on the target chain which is derived from
|
||||
/// the source chain account.
|
||||
fn derive_account_from_id(
|
||||
id: SourceAccount<AccountIdOf<Self::Source>>,
|
||||
) -> AccountIdOf<Self::Target> {
|
||||
bp_millau::derive_account_from_rialto_id(id)
|
||||
}
|
||||
}
|
||||
|
||||
//// `Westend` to `Millau` bridge definition.
|
||||
@@ -169,12 +149,6 @@ impl MessagesCliBridge for MillauToRialtoParachainCliBridge {
|
||||
bp_rialto_parachain::TO_RIALTO_PARACHAIN_ESTIMATE_MESSAGE_FEE_METHOD;
|
||||
type MessagesLane =
|
||||
crate::chains::millau_messages_to_rialto_parachain::MillauMessagesToRialtoParachain;
|
||||
|
||||
fn derive_account_from_id(
|
||||
id: SourceAccount<AccountIdOf<Self::Source>>,
|
||||
) -> AccountIdOf<Self::Target> {
|
||||
bp_rialto_parachain::derive_account_from_millau_id(id)
|
||||
}
|
||||
}
|
||||
|
||||
//// `RialtoParachain` to `Millau` bridge definition.
|
||||
@@ -190,12 +164,6 @@ impl MessagesCliBridge for RialtoParachainToMillauCliBridge {
|
||||
bp_millau::TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD;
|
||||
type MessagesLane =
|
||||
crate::chains::rialto_parachain_messages_to_millau::RialtoParachainMessagesToMillau;
|
||||
|
||||
fn derive_account_from_id(
|
||||
id: SourceAccount<AccountIdOf<Self::Source>>,
|
||||
) -> AccountIdOf<Self::Target> {
|
||||
bp_millau::derive_account_from_rialto_parachain_id(id)
|
||||
}
|
||||
}
|
||||
|
||||
//// `WestendParachain` to `Millau` bridge definition.
|
||||
|
||||
@@ -77,9 +77,6 @@ pub struct HeadersAndMessagesSharedParams {
|
||||
lane: Vec<HexLaneId>,
|
||||
#[structopt(long, possible_values = RelayerMode::VARIANTS, case_insensitive = true, default_value = "rational")]
|
||||
relayer_mode: RelayerMode,
|
||||
/// Create relayers fund accounts on both chains, if it does not exists yet.
|
||||
#[structopt(long)]
|
||||
create_relayers_fund_accounts: bool,
|
||||
/// If passed, only mandatory headers (headers that are changing the GRANDPA authorities set)
|
||||
/// are relayed.
|
||||
#[structopt(long)]
|
||||
@@ -185,9 +182,6 @@ macro_rules! select_bridge {
|
||||
type Left = relay_millau_client::Millau;
|
||||
type Right = relay_rialto_client::Rialto;
|
||||
|
||||
type LeftAccountIdConverter = bp_millau::AccountIdConverter;
|
||||
type RightAccountIdConverter = bp_rialto::AccountIdConverter;
|
||||
|
||||
use crate::chains::{
|
||||
millau_messages_to_rialto::MillauMessagesToRialto as LeftToRightMessageLane,
|
||||
rialto_messages_to_millau::RialtoMessagesToMillau as RightToLeftMessageLane,
|
||||
@@ -222,22 +216,6 @@ macro_rules! select_bridge {
|
||||
).await
|
||||
}
|
||||
|
||||
async fn left_create_account(
|
||||
_left_client: Client<Left>,
|
||||
_left_sign: <Left as TransactionSignScheme>::AccountKeyPair,
|
||||
_account_id: AccountIdOf<Left>,
|
||||
) -> anyhow::Result<()> {
|
||||
Err(anyhow::format_err!("Account creation is not supported by this bridge"))
|
||||
}
|
||||
|
||||
async fn right_create_account(
|
||||
_right_client: Client<Right>,
|
||||
_right_sign: <Right as TransactionSignScheme>::AccountKeyPair,
|
||||
_account_id: AccountIdOf<Right>,
|
||||
) -> anyhow::Result<()> {
|
||||
Err(anyhow::format_err!("Account creation is not supported by this bridge"))
|
||||
}
|
||||
|
||||
$generic
|
||||
},
|
||||
RelayHeadersAndMessages::MillauRialtoParachain(_) => {
|
||||
@@ -246,9 +224,6 @@ macro_rules! select_bridge {
|
||||
type Left = relay_millau_client::Millau;
|
||||
type Right = relay_rialto_parachain_client::RialtoParachain;
|
||||
|
||||
type LeftAccountIdConverter = bp_millau::AccountIdConverter;
|
||||
type RightAccountIdConverter = bp_rialto_parachain::AccountIdConverter;
|
||||
|
||||
use crate::chains::{
|
||||
millau_messages_to_rialto_parachain::MillauMessagesToRialtoParachain as LeftToRightMessageLane,
|
||||
rialto_parachain_messages_to_millau::RialtoParachainMessagesToMillau as RightToLeftMessageLane,
|
||||
@@ -290,22 +265,6 @@ macro_rules! select_bridge {
|
||||
).await
|
||||
}
|
||||
|
||||
async fn left_create_account(
|
||||
_left_client: Client<Left>,
|
||||
_left_sign: <Left as TransactionSignScheme>::AccountKeyPair,
|
||||
_account_id: AccountIdOf<Left>,
|
||||
) -> anyhow::Result<()> {
|
||||
Err(anyhow::format_err!("Account creation is not supported by this bridge"))
|
||||
}
|
||||
|
||||
async fn right_create_account(
|
||||
_right_client: Client<Right>,
|
||||
_right_sign: <Right as TransactionSignScheme>::AccountKeyPair,
|
||||
_account_id: AccountIdOf<Right>,
|
||||
) -> anyhow::Result<()> {
|
||||
Err(anyhow::format_err!("Account creation is not supported by this bridge"))
|
||||
}
|
||||
|
||||
$generic
|
||||
},
|
||||
}
|
||||
@@ -445,45 +404,6 @@ impl RelayHeadersAndMessages {
|
||||
});
|
||||
}
|
||||
|
||||
// optionally, create relayers fund account
|
||||
if params.shared.create_relayers_fund_accounts {
|
||||
let relayer_fund_acount_id = pallet_bridge_messages::relayer_fund_account_id::<
|
||||
AccountIdOf<Left>,
|
||||
LeftAccountIdConverter,
|
||||
>();
|
||||
let relayers_fund_account_balance =
|
||||
left_client.free_native_balance(relayer_fund_acount_id.clone()).await;
|
||||
if let Err(relay_substrate_client::Error::AccountDoesNotExist) =
|
||||
relayers_fund_account_balance
|
||||
{
|
||||
log::info!(target: "bridge", "Going to create relayers fund account at {}.", Left::NAME);
|
||||
left_create_account(
|
||||
left_client.clone(),
|
||||
left_sign.clone(),
|
||||
relayer_fund_acount_id,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
let relayer_fund_acount_id = pallet_bridge_messages::relayer_fund_account_id::<
|
||||
AccountIdOf<Right>,
|
||||
RightAccountIdConverter,
|
||||
>();
|
||||
let relayers_fund_account_balance =
|
||||
right_client.free_native_balance(relayer_fund_acount_id.clone()).await;
|
||||
if let Err(relay_substrate_client::Error::AccountDoesNotExist) =
|
||||
relayers_fund_account_balance
|
||||
{
|
||||
log::info!(target: "bridge", "Going to create relayers fund account at {}.", Right::NAME);
|
||||
right_create_account(
|
||||
right_client.clone(),
|
||||
right_sign.clone(),
|
||||
relayer_fund_acount_id,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
// start on-demand header relays
|
||||
let (left_to_right_on_demand_headers, right_to_left_on_demand_headers) =
|
||||
start_on_demand_relays(
|
||||
@@ -785,7 +705,6 @@ mod tests {
|
||||
HexLaneId([0x73, 0x77, 0x61, 0x70])
|
||||
],
|
||||
relayer_mode: RelayerMode::Rational,
|
||||
create_relayers_fund_accounts: false,
|
||||
only_mandatory_headers: false,
|
||||
prometheus_params: PrometheusParams {
|
||||
no_prometheus: false,
|
||||
@@ -899,7 +818,6 @@ mod tests {
|
||||
shared: HeadersAndMessagesSharedParams {
|
||||
lane: vec![HexLaneId([0x00, 0x00, 0x00, 0x00])],
|
||||
relayer_mode: RelayerMode::Rational,
|
||||
create_relayers_fund_accounts: false,
|
||||
only_mandatory_headers: false,
|
||||
prometheus_params: PrometheusParams {
|
||||
no_prometheus: false,
|
||||
|
||||
Reference in New Issue
Block a user