Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix migration types #1040

Merged
merged 2 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration-tests/bifrost-kusama/src/slp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ delegate/undelegate/redelegate confirm_validators_by_delegator_query_response
use bifrost_kusama_runtime::{NativeCurrencyId, VtokenMinting};
use bifrost_slp::{primitives::UnlockChunk, Delays, Ledger, MinimumsMaximums, SubstrateLedger};
use frame_support::{assert_ok, BoundedVec};
use node_primitives::{TimeUnit, XcmInterfaceOperation as XcmOperation};
use node_primitives::{TimeUnit, XcmOperationType as XcmOperation};
use orml_traits::MultiCurrency;
use pallet_staking::{Nominations, StakingLedger};
use sp_runtime::Permill;
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/bifrost-kusama/src/statemine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use crate::{kusama_integration_tests::*, kusama_test_net::*};
use bifrost_asset_registry::AssetMetadata;
use frame_support::assert_ok;
use node_primitives::XcmInterfaceOperation as XcmOperation;
use node_primitives::XcmOperationType as XcmOperation;
use polkadot_parachain::primitives::Sibling;
use sp_runtime::traits::AccountIdConversion;
use xcm::{
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/bifrost-kusama/src/vtoken_voting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use frame_support::{
traits::{schedule::DispatchTime, StorePreimage},
weights::Weight,
};
use node_primitives::{currency::VKSM, XcmInterfaceOperation as XcmOperation};
use node_primitives::{currency::VKSM, XcmOperationType as XcmOperation};
use pallet_conviction_voting::{Conviction, Vote};
use xcm::v3::Parent;
use xcm_emulator::TestExt;
Expand Down
2 changes: 1 addition & 1 deletion node/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl SendXcm for DoNothingRouter {
}

#[derive(Encode, Decode, Eq, PartialEq, Copy, Clone, RuntimeDebug, TypeInfo)]
pub enum XcmInterfaceOperation {
pub enum XcmOperationType {
// SALP operations
UmpContributeTransact,
// Statemine operations
Expand Down
10 changes: 5 additions & 5 deletions node/primitives/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

use crate::{
AssetIds, DerivativeIndex, ExtraFeeInfo, LeasePeriod, ParaId, PoolId, RedeemType, TokenId,
TokenSymbol, XcmInterfaceOperation,
TokenSymbol, XcmOperationType,
};
use codec::{Decode, Encode, FullCodec};
use frame_support::{
Expand Down Expand Up @@ -430,12 +430,12 @@ where
{
fn get_operation_weight_and_fee(
token: CurrencyId,
operation: XcmInterfaceOperation,
operation: XcmOperationType,
) -> Option<(Weight, Balance)>;

fn set_xcm_dest_weight_and_fee(
currency_id: CurrencyId,
operation: XcmInterfaceOperation,
operation: XcmOperationType,
weight_and_fee: Option<(Weight, Balance)>,
) -> DispatchResult;
}
Expand All @@ -446,14 +446,14 @@ where
{
fn get_operation_weight_and_fee(
_token: CurrencyId,
_operation: XcmInterfaceOperation,
_operation: XcmOperationType,
) -> Option<(Weight, Balance)> {
Some((Zero::zero(), Zero::zero()))
}

fn set_xcm_dest_weight_and_fee(
_currency_id: CurrencyId,
_operation: XcmInterfaceOperation,
_operation: XcmOperationType,
_weight_and_fee: Option<(Weight, Balance)>,
) -> DispatchResult {
Ok(())
Expand Down
13 changes: 6 additions & 7 deletions pallets/flexible-fee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use frame_support::{
use frame_system::pallet_prelude::*;
use node_primitives::{
traits::{FeeGetter, XcmDestWeightAndFeeHandler},
CurrencyId, ExtraFeeName, TryConvertFrom, XcmInterfaceOperation, BNC,
CurrencyId, ExtraFeeName, TryConvertFrom, XcmOperationType, BNC,
};
use orml_traits::MultiCurrency;
pub use pallet::*;
Expand Down Expand Up @@ -273,27 +273,26 @@ impl<T: Config> Pallet<T> {
// pay extra fee
let (currency_id, operation) = match fee_info.extra_fee_name {
ExtraFeeName::SalpContribute =>
(fee_info.extra_fee_currency, XcmInterfaceOperation::UmpContributeTransact),
(fee_info.extra_fee_currency, XcmOperationType::UmpContributeTransact),
ExtraFeeName::StatemineTransfer =>
(fee_info.extra_fee_currency, XcmInterfaceOperation::StatemineTransfer),
(fee_info.extra_fee_currency, XcmOperationType::StatemineTransfer),
ExtraFeeName::VoteVtoken => {
// We define error code 77 for conversion failure error
let fee_currency = fee_info
.extra_fee_currency
.to_token()
.map_err(|_| Error::<T>::ConversionError)?;
(fee_currency, XcmInterfaceOperation::Vote)
(fee_currency, XcmOperationType::Vote)
},
ExtraFeeName::VoteRemoveDelegatorVote => {
// We define error code 77 for conversion failure error
let fee_currency = fee_info
.extra_fee_currency
.to_token()
.map_err(|_| Error::<T>::ConversionError)?;
(fee_currency, XcmInterfaceOperation::RemoveVote)
(fee_currency, XcmOperationType::RemoveVote)
},
ExtraFeeName::NoExtraFee =>
(fee_info.extra_fee_currency, XcmInterfaceOperation::Any),
ExtraFeeName::NoExtraFee => (fee_info.extra_fee_currency, XcmOperationType::Any),
};

// We define error code 55 for WeightAndFeeNotSet error
Expand Down
4 changes: 2 additions & 2 deletions pallets/flexible-fee/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@ pub struct XcmDestWeightAndFee;
impl XcmDestWeightAndFeeHandler<CurrencyId, Balance> for XcmDestWeightAndFee {
fn get_operation_weight_and_fee(
_token: CurrencyId,
_operation: XcmInterfaceOperation,
_operation: XcmOperationType,
) -> Option<(Weight, Balance)> {
Some((Weight::from_parts(100, 100), 100u32.into()))
}

fn set_xcm_dest_weight_and_fee(
_currency_id: CurrencyId,
_operation: XcmInterfaceOperation,
_operation: XcmOperationType,
_weight_and_fee: Option<(Weight, Balance)>,
) -> DispatchResult {
Ok(())
Expand Down
24 changes: 12 additions & 12 deletions pallets/slp/src/agents/astar_agent/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ use crate::{
traits::{QueryResponseManager, StakingAgent, XcmBuilder},
AccountIdOf, BalanceOf, Config, CurrencyDelays, DelegatorLedgerXcmUpdateQueue,
DelegatorLedgers, DelegatorsMultilocation2Index, LedgerUpdateEntry, MinimumsAndMaximums,
Pallet, TimeUnit, Validators, XcmOperation, XcmWeight,
Pallet, TimeUnit, Validators, XcmWeight,
};
use codec::Encode;
use core::marker::PhantomData;
pub use cumulus_primitives_core::ParaId;
use frame_support::{ensure, traits::Get};
use frame_system::pallet_prelude::BlockNumberFor;
use node_primitives::{
CurrencyId, VtokenMintingOperator, XcmDestWeightAndFeeHandler, ASTR_TOKEN_ID,
CurrencyId, VtokenMintingOperator, XcmDestWeightAndFeeHandler, XcmOperationType, ASTR_TOKEN_ID,
};
use polkadot_parachain::primitives::Sibling;
use sp_runtime::{
Expand Down Expand Up @@ -139,7 +139,7 @@ impl<T: Config>
// Wrap the xcm message as it is sent from a subaccount of the parachain account, and
// send it out.
let (query_id, timeout, xcm_message) = Self::construct_xcm_as_subaccount_with_query_id(
XcmOperation::Bond,
XcmOperationType::Bond,
call,
who,
currency_id,
Expand Down Expand Up @@ -214,7 +214,7 @@ impl<T: Config>
// Wrap the xcm message as it is sent from a subaccount of the parachain account, and
// send it out.
let (query_id, timeout, xcm_message) = Self::construct_xcm_as_subaccount_with_query_id(
XcmOperation::Unbond,
XcmOperationType::Unbond,
call,
who,
currency_id,
Expand Down Expand Up @@ -305,7 +305,7 @@ impl<T: Config>
// Wrap the xcm message as it is sent from a subaccount of the parachain account, and
// send it out.
Self::construct_xcm_and_send_as_subaccount_without_query_id(
XcmOperation::Payout,
XcmOperationType::Payout,
call,
who,
currency_id,
Expand Down Expand Up @@ -335,7 +335,7 @@ impl<T: Config>
// Wrap the xcm message as it is sent from a subaccount of the parachain account, and
// send it out.
let (query_id, timeout, xcm_message) = Self::construct_xcm_as_subaccount_with_query_id(
XcmOperation::Liquidize,
XcmOperationType::Liquidize,
call,
who,
currency_id,
Expand Down Expand Up @@ -412,7 +412,7 @@ impl<T: Config>

let (weight_limit, _) = T::XcmWeightAndFeeHandler::get_operation_weight_and_fee(
currency_id,
XcmOperation::TransferBack,
XcmOperationType::TransferBack,
)
.ok_or(Error::<T>::WeightAndFeeNotExists)?;

Expand All @@ -428,7 +428,7 @@ impl<T: Config>
// Wrap the xcm message as it is sent from a subaccount of the parachain account, and
// send it out.
Self::construct_xcm_and_send_as_subaccount_without_query_id(
XcmOperation::TransferBack,
XcmOperationType::TransferBack,
call,
from,
currency_id,
Expand Down Expand Up @@ -644,7 +644,7 @@ impl<T: Config> AstarAgent<T> {
}

fn prepare_send_as_subaccount_call(
operation: XcmOperation,
operation: XcmOperationType,
call: AstarCall<T>,
who: &MultiLocation,
currency_id: CurrencyId,
Expand All @@ -666,7 +666,7 @@ impl<T: Config> AstarAgent<T> {
}

fn construct_xcm_as_subaccount_with_query_id(
operation: XcmOperation,
operation: XcmOperationType,
call: AstarCall<T>,
who: &MultiLocation,
currency_id: CurrencyId,
Expand All @@ -678,7 +678,7 @@ impl<T: Config> AstarAgent<T> {

// Generate query_id need( responder,callback, timeout)
let query_id = match operation {
XcmOperation::Bond | XcmOperation::Unbond | XcmOperation::Liquidize =>
XcmOperationType::Bond | XcmOperationType::Unbond | XcmOperationType::Liquidize =>
T::SubstrateResponseManager::create_query_record(
&responder,
Some(Pallet::<T>::confirm_delegator_ledger_call()),
Expand All @@ -705,7 +705,7 @@ impl<T: Config> AstarAgent<T> {
}

fn construct_xcm_and_send_as_subaccount_without_query_id(
operation: XcmOperation,
operation: XcmOperationType,
call: AstarCall<T>,
who: &MultiLocation,
currency_id: CurrencyId,
Expand Down
4 changes: 2 additions & 2 deletions pallets/slp/src/agents/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{
Event,
Junction::{AccountId32, Parachain},
Junctions::{Here, X1},
MinimumsAndMaximums, MultiLocation, Pallet, Validators, Xcm, XcmOperation, Zero,
MinimumsAndMaximums, MultiLocation, Pallet, Validators, Xcm, XcmOperationType, Zero,
};
use frame_support::{ensure, traits::Len};
use node_primitives::{CurrencyId, VtokenMintingOperator, XcmDestWeightAndFeeHandler};
Expand Down Expand Up @@ -246,7 +246,7 @@ impl<T: Config> Pallet<T> {

let (weight, fee_amount) = T::XcmWeightAndFeeHandler::get_operation_weight_and_fee(
currency_id,
XcmOperation::TransferTo,
XcmOperationType::TransferTo,
)
.ok_or(Error::<T>::WeightAndFeeNotExists)?;

Expand Down
38 changes: 19 additions & 19 deletions pallets/slp/src/agents/moonbeam_agent/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use crate::{
AccountIdOf, BalanceOf, Config, CurrencyDelays, DelegationsOccupied,
DelegatorLedgerXcmUpdateQueue, DelegatorLedgers, DelegatorsMultilocation2Index, FeeSources,
LedgerUpdateEntry, MinimumsAndMaximums, Pallet, TimeUnit, Validators,
ValidatorsByDelegatorUpdateEntry, XcmOperation,
ValidatorsByDelegatorUpdateEntry,
};
use codec::{alloc::collections::BTreeMap, Encode};
use core::marker::PhantomData;
Expand All @@ -40,7 +40,7 @@ use frame_support::{ensure, traits::Get};
use frame_system::pallet_prelude::BlockNumberFor;
use node_primitives::{
currency::{GLMR, GLMR_TOKEN_ID, MOVR},
CurrencyId, TokenSymbol, VtokenMintingOperator, XcmDestWeightAndFeeHandler,
CurrencyId, TokenSymbol, VtokenMintingOperator, XcmDestWeightAndFeeHandler, XcmOperationType,
};
use orml_traits::MultiCurrency;
use polkadot_parachain::primitives::Sibling;
Expand Down Expand Up @@ -218,7 +218,7 @@ impl<T: Config>
// send it out.
let (query_id, timeout, fee, xcm_message) =
Self::construct_xcm_as_subaccount_with_query_id(
XcmOperation::Bond,
XcmOperationType::Bond,
call,
who,
currency_id,
Expand Down Expand Up @@ -297,7 +297,7 @@ impl<T: Config>
// send it out.
let (query_id, timeout, fee, xcm_message) =
Self::construct_xcm_as_subaccount_with_query_id(
XcmOperation::BondExtra,
XcmOperationType::BondExtra,
call,
who,
currency_id,
Expand Down Expand Up @@ -384,7 +384,7 @@ impl<T: Config>
// send it out.
let (query_id, timeout, fee, xcm_message) =
Self::construct_xcm_as_subaccount_with_query_id(
XcmOperation::Unbond,
XcmOperationType::Unbond,
call,
who,
currency_id,
Expand Down Expand Up @@ -469,7 +469,7 @@ impl<T: Config>
// send it out.
let (query_id, timeout, fee, xcm_message) =
Self::construct_xcm_as_subaccount_with_query_id(
XcmOperation::Rebond,
XcmOperationType::Rebond,
call,
who,
currency_id,
Expand Down Expand Up @@ -541,7 +541,7 @@ impl<T: Config>
// send it out.
let (query_id, timeout, fee, xcm_message) =
Self::construct_xcm_as_subaccount_with_query_id(
XcmOperation::Undelegate,
XcmOperationType::Undelegate,
call,
who,
currency_id,
Expand Down Expand Up @@ -636,7 +636,7 @@ impl<T: Config>

let (query_id, timeout, fee, xcm_message) =
Self::construct_xcm_as_subaccount_with_query_id(
XcmOperation::Liquidize,
XcmOperationType::Liquidize,
call.clone(),
who,
currency_id,
Expand Down Expand Up @@ -723,7 +723,7 @@ impl<T: Config>
// Wrap the xcm message as it is sent from a subaccount of the parachain account, and
// send it out.
let fee = Self::construct_xcm_and_send_as_subaccount_without_query_id(
XcmOperation::TransferBack,
XcmOperationType::TransferBack,
call,
from,
currency_id,
Expand Down Expand Up @@ -947,7 +947,7 @@ impl<T: Config> MoonbeamAgent<T> {
}

fn construct_xcm_as_subaccount_with_query_id(
operation: XcmOperation,
operation: XcmOperationType,
call: MoonbeamCall<T>,
who: &MultiLocation,
currency_id: CurrencyId,
Expand All @@ -957,12 +957,12 @@ impl<T: Config> MoonbeamAgent<T> {
let now = frame_system::Pallet::<T>::block_number();
let timeout = T::BlockNumber::from(TIMEOUT_BLOCKS).saturating_add(now);
let query_id = match operation {
XcmOperation::Bond |
XcmOperation::BondExtra |
XcmOperation::Unbond |
XcmOperation::Rebond |
XcmOperation::Undelegate |
XcmOperation::Liquidize => T::SubstrateResponseManager::create_query_record(
XcmOperationType::Bond |
XcmOperationType::BondExtra |
XcmOperationType::Unbond |
XcmOperationType::Rebond |
XcmOperationType::Undelegate |
XcmOperationType::Liquidize => T::SubstrateResponseManager::create_query_record(
&responder,
Some(Pallet::<T>::confirm_delegator_ledger_call()),
timeout,
Expand All @@ -988,7 +988,7 @@ impl<T: Config> MoonbeamAgent<T> {
}

fn construct_xcm_and_send_as_subaccount_without_query_id(
operation: XcmOperation,
operation: XcmOperationType,
call: MoonbeamCall<T>,
who: &MultiLocation,
currency_id: CurrencyId,
Expand All @@ -1006,7 +1006,7 @@ impl<T: Config> MoonbeamAgent<T> {
}

fn prepare_send_as_subaccount_call(
operation: XcmOperation,
operation: XcmOperationType,
call: MoonbeamCall<T>,
who: &MultiLocation,
currency_id: CurrencyId,
Expand Down Expand Up @@ -1104,7 +1104,7 @@ impl<T: Config> MoonbeamAgent<T> {

let (weight, fee_amount) = T::XcmWeightAndFeeHandler::get_operation_weight_and_fee(
currency_id,
XcmOperation::TransferTo,
XcmOperationType::TransferTo,
)
.ok_or(Error::<T>::WeightAndFeeNotExists)?;

Expand Down
Loading