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

adjust vBNC can be used as a flexible fee on the Polkadot side #1588

Merged
merged 1 commit into from
Jan 6, 2025
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
4 changes: 2 additions & 2 deletions pallets/flexible-fee/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mod benchmarks {
}
impl_benchmark_test_suite!(
Pallet,
crate::mock::new_test_ext_benchmark(),
crate::mock::Test
crate::mocks::kusama_mock::new_test_ext_benchmark(),
crate::mocks::kusama_mock::Test
);
}
12 changes: 8 additions & 4 deletions pallets/flexible-fee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ use zenlink_protocol::{AssetId, ExportZenlink};
mod benchmarking;
pub mod impls;
pub mod migrations;
mod mock;
mod mock_price;
mod mocks;
mod tests;
pub mod weights;

Expand Down Expand Up @@ -126,6 +125,9 @@ pub mod pallet {
type PalletId: Get<PalletId>;
// asset registry to get asset metadata
type AssetIdMaps: CurrencyIdMapping<CurrencyId, AssetMetadata<BalanceOf<Self>>>;
/// The `AllowVBNCAsFee` constant determines whether VBNC is allowed as a fee currency.
#[pallet::constant]
type AllowVBNCAsFee: Get<bool>;
}

#[pallet::hooks]
Expand Down Expand Up @@ -247,8 +249,10 @@ pub mod pallet {
let who = ensure_signed(origin)?;

if let Some(fee_currency) = &currency_id {
// VBNC is not supported.
ensure!(fee_currency != &VBNC, Error::<T>::CurrencyNotSupport);
if !T::AllowVBNCAsFee::get() {
// VBNC is not supported.
ensure!(fee_currency != &VBNC, Error::<T>::CurrencyNotSupport);
}

UserDefaultFeeCurrency::<T>::insert(&who, fee_currency);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#![cfg(test)]

use super::*;
use crate::{self as flexible_fee, mock_price::MockOraclePriceProvider};
use crate::*;
use crate::{self as flexible_fee, mocks::mock_price::MockOraclePriceProvider};
use bifrost_asset_registry::AssetIdMaps;
use bifrost_currencies::BasicCurrencyAdapter;
use bifrost_primitives::{
Expand Down Expand Up @@ -175,6 +175,7 @@ impl pallet_evm_accounts::Config for Test {
parameter_types! {
pub const TreasuryAccount: AccountId32 = TREASURY_ACCOUNT;
pub const MaxFeeCurrencyOrderListLen: u32 = 50;
pub AllowVBNCAsFee: bool = false;
}

impl crate::Config for Test {
Expand All @@ -196,6 +197,7 @@ impl crate::Config for Test {
type InspectEvmAccounts = EVMAccounts;
type EvmPermit = PermitDispatchHandler;
type AssetIdMaps = AssetIdMaps<Test>;
type AllowVBNCAsFee = AllowVBNCAsFee;
}

pub struct XcmDestWeightAndFee;
Expand Down
22 changes: 22 additions & 0 deletions pallets/flexible-fee/src/mocks/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This file is part of Bifrost.

// Copyright (C) Liebi Technologies PTE. LTD.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

pub mod kusama_mock;
pub mod polkadot_mock;

mod mock_price;
Loading