mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 23:21:02 +00:00
Fixed referenced balance in rialto_messages.rs (#509)
* fixed referenced balance in rialto_messages * names Co-authored-by: Hernando Castano <castano.ha@gmail.com>
This commit is contained in:
committed by
Bastian Köcher
parent
23f5f3cdd6
commit
20fc30404a
@@ -104,16 +104,16 @@ impl MessageBridge for WithRialtoMessageBridge {
|
|||||||
0 // TODO: https://github.com/paritytech/parity-bridges-common/issues/391
|
0 // TODO: https://github.com/paritytech/parity-bridges-common/issues/391
|
||||||
}
|
}
|
||||||
|
|
||||||
fn this_weight_to_balance(weight: Weight) -> bp_rialto::Balance {
|
fn this_weight_to_this_balance(weight: Weight) -> bp_millau::Balance {
|
||||||
<crate::Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight)
|
<crate::Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bridged_weight_to_balance(weight: Weight) -> bp_millau::Balance {
|
fn bridged_weight_to_bridged_balance(weight: Weight) -> bp_rialto::Balance {
|
||||||
// we're using the same weights in both chains now
|
// we're using the same weights in both chains now
|
||||||
<crate::Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight)
|
<crate::Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn this_chain_balance_to_bridged_chain_balance(this_balance: bp_rialto::Balance) -> bp_millau::Balance {
|
fn this_balance_to_bridged_balance(this_balance: bp_millau::Balance) -> bp_rialto::Balance {
|
||||||
// 1:1 conversion that will probably change in the future
|
// 1:1 conversion that will probably change in the future
|
||||||
this_balance
|
this_balance
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,16 +104,16 @@ impl MessageBridge for WithMillauMessageBridge {
|
|||||||
0 // TODO: https://github.com/paritytech/parity-bridges-common/issues/391
|
0 // TODO: https://github.com/paritytech/parity-bridges-common/issues/391
|
||||||
}
|
}
|
||||||
|
|
||||||
fn this_weight_to_balance(weight: Weight) -> bp_rialto::Balance {
|
fn this_weight_to_this_balance(weight: Weight) -> bp_rialto::Balance {
|
||||||
<crate::Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight)
|
<crate::Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bridged_weight_to_balance(weight: Weight) -> bp_millau::Balance {
|
fn bridged_weight_to_bridged_balance(weight: Weight) -> bp_millau::Balance {
|
||||||
// we're using the same weights in both chains now
|
// we're using the same weights in both chains now
|
||||||
<crate::Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight)
|
<crate::Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn this_chain_balance_to_bridged_chain_balance(this_balance: bp_rialto::Balance) -> bp_millau::Balance {
|
fn this_balance_to_bridged_balance(this_balance: bp_rialto::Balance) -> bp_millau::Balance {
|
||||||
// 1:1 conversion that will probably change in the future
|
// 1:1 conversion that will probably change in the future
|
||||||
this_balance
|
this_balance
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,15 +61,13 @@ pub trait MessageBridge {
|
|||||||
fn weight_of_reward_confirmation_transaction_on_target_chain() -> WeightOf<BridgedChain<Self>>;
|
fn weight_of_reward_confirmation_transaction_on_target_chain() -> WeightOf<BridgedChain<Self>>;
|
||||||
|
|
||||||
/// Convert weight of This chain to the fee (paid in Balance) of This chain.
|
/// Convert weight of This chain to the fee (paid in Balance) of This chain.
|
||||||
fn this_weight_to_balance(weight: WeightOf<ThisChain<Self>>) -> BalanceOf<ThisChain<Self>>;
|
fn this_weight_to_this_balance(weight: WeightOf<ThisChain<Self>>) -> BalanceOf<ThisChain<Self>>;
|
||||||
|
|
||||||
/// Convert weight of the Bridged chain to the fee (paid in Balance) of the Bridged chain.
|
/// Convert weight of the Bridged chain to the fee (paid in Balance) of the Bridged chain.
|
||||||
fn bridged_weight_to_balance(weight: WeightOf<BridgedChain<Self>>) -> BalanceOf<BridgedChain<Self>>;
|
fn bridged_weight_to_bridged_balance(weight: WeightOf<BridgedChain<Self>>) -> BalanceOf<BridgedChain<Self>>;
|
||||||
|
|
||||||
/// Convert This chain Balance into Bridged chain Balance.
|
/// Convert This chain Balance into Bridged chain Balance.
|
||||||
fn this_chain_balance_to_bridged_chain_balance(
|
fn this_balance_to_bridged_balance(this_balance: BalanceOf<ThisChain<Self>>) -> BalanceOf<BridgedChain<Self>>;
|
||||||
this_balance: BalanceOf<ThisChain<Self>>,
|
|
||||||
) -> BalanceOf<BridgedChain<Self>>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Chain that has `message-lane` and `call-dispatch` modules.
|
/// Chain that has `message-lane` and `call-dispatch` modules.
|
||||||
@@ -152,8 +150,7 @@ pub mod source {
|
|||||||
estimate_message_dispatch_and_delivery_fee::<B>(payload, B::RELAYER_FEE_PERCENT)?;
|
estimate_message_dispatch_and_delivery_fee::<B>(payload, B::RELAYER_FEE_PERCENT)?;
|
||||||
|
|
||||||
// compare with actual fee paid
|
// compare with actual fee paid
|
||||||
let actual_fee_in_bridged_tokens =
|
let actual_fee_in_bridged_tokens = B::this_balance_to_bridged_balance(*delivery_and_dispatch_fee);
|
||||||
B::this_chain_balance_to_bridged_chain_balance(*delivery_and_dispatch_fee);
|
|
||||||
if actual_fee_in_bridged_tokens < minimal_fee_in_bridged_tokens {
|
if actual_fee_in_bridged_tokens < minimal_fee_in_bridged_tokens {
|
||||||
return Err("Too low fee paid");
|
return Err("Too low fee paid");
|
||||||
}
|
}
|
||||||
@@ -171,13 +168,13 @@ pub mod source {
|
|||||||
relayer_fee_percent: u32,
|
relayer_fee_percent: u32,
|
||||||
) -> Result<BalanceOf<BridgedChain<B>>, &'static str> {
|
) -> Result<BalanceOf<BridgedChain<B>>, &'static str> {
|
||||||
// the fee (in Bridged tokens) of all transactions that are made on the Bridged chain
|
// the fee (in Bridged tokens) of all transactions that are made on the Bridged chain
|
||||||
let delivery_fee = B::bridged_weight_to_balance(B::weight_of_delivery_transaction());
|
let delivery_fee = B::bridged_weight_to_bridged_balance(B::weight_of_delivery_transaction());
|
||||||
let dispatch_fee = B::bridged_weight_to_balance(payload.weight.into());
|
let dispatch_fee = B::bridged_weight_to_bridged_balance(payload.weight.into());
|
||||||
let reward_confirmation_fee =
|
let reward_confirmation_fee =
|
||||||
B::bridged_weight_to_balance(B::weight_of_reward_confirmation_transaction_on_target_chain());
|
B::bridged_weight_to_bridged_balance(B::weight_of_reward_confirmation_transaction_on_target_chain());
|
||||||
|
|
||||||
// the fee (in Bridged tokens) of all transactions that are made on This chain
|
// the fee (in Bridged tokens) of all transactions that are made on This chain
|
||||||
let delivery_confirmation_fee = B::this_chain_balance_to_bridged_chain_balance(B::this_weight_to_balance(
|
let delivery_confirmation_fee = B::this_balance_to_bridged_balance(B::this_weight_to_this_balance(
|
||||||
B::weight_of_delivery_confirmation_transaction_on_this_chain(),
|
B::weight_of_delivery_confirmation_transaction_on_this_chain(),
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -444,15 +441,15 @@ mod tests {
|
|||||||
REWARD_CONFIRMATION_TRANSACTION_WEIGHT
|
REWARD_CONFIRMATION_TRANSACTION_WEIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
fn this_weight_to_balance(weight: Weight) -> ThisChainBalance {
|
fn this_weight_to_this_balance(weight: Weight) -> ThisChainBalance {
|
||||||
ThisChainBalance(weight as u32 * THIS_CHAIN_WEIGHT_TO_BALANCE_RATE as u32)
|
ThisChainBalance(weight as u32 * THIS_CHAIN_WEIGHT_TO_BALANCE_RATE as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bridged_weight_to_balance(weight: Weight) -> BridgedChainBalance {
|
fn bridged_weight_to_bridged_balance(weight: Weight) -> BridgedChainBalance {
|
||||||
BridgedChainBalance(weight as u32 * BRIDGED_CHAIN_WEIGHT_TO_BALANCE_RATE as u32)
|
BridgedChainBalance(weight as u32 * BRIDGED_CHAIN_WEIGHT_TO_BALANCE_RATE as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn this_chain_balance_to_bridged_chain_balance(this_balance: ThisChainBalance) -> BridgedChainBalance {
|
fn this_balance_to_bridged_balance(this_balance: ThisChainBalance) -> BridgedChainBalance {
|
||||||
BridgedChainBalance(this_balance.0 * THIS_CHAIN_TO_BRIDGED_CHAIN_BALANCE_RATE as u32)
|
BridgedChainBalance(this_balance.0 * THIS_CHAIN_TO_BRIDGED_CHAIN_BALANCE_RATE as u32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -483,15 +480,15 @@ mod tests {
|
|||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn this_weight_to_balance(_weight: Weight) -> BridgedChainBalance {
|
fn this_weight_to_this_balance(_weight: Weight) -> BridgedChainBalance {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bridged_weight_to_balance(_weight: Weight) -> ThisChainBalance {
|
fn bridged_weight_to_bridged_balance(_weight: Weight) -> ThisChainBalance {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn this_chain_balance_to_bridged_chain_balance(_this_balance: BridgedChainBalance) -> ThisChainBalance {
|
fn this_balance_to_bridged_balance(_this_balance: BridgedChainBalance) -> ThisChainBalance {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user