Skip to content

Commit

Permalink
adjust vBNC can be used as a flexible fee on the Polkadot side
Browse files Browse the repository at this point in the history
  • Loading branch information
SunTiebing committed Jan 6, 2025
1 parent 623db31 commit 2e0dfb6
Show file tree
Hide file tree
Showing 11 changed files with 560 additions and 10 deletions.
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
File renamed without changes.
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

0 comments on commit 2e0dfb6

Please sign in to comment.