Skip to content
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
32 changes: 16 additions & 16 deletions pallets/transaction-fee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ where

fn withdraw_fee(
who: &AccountIdOf<T>,
call: &CallOf<T>,
_call: &CallOf<T>,
_dispatch_info: &DispatchInfoOf<CallOf<T>>,
fee: Self::Balance,
_tip: Self::Balance,
Expand All @@ -327,20 +327,20 @@ where
) {
Ok(imbalance) => Ok(Some(WithdrawnFee::Tao(imbalance))),
Err(_) => {
let alpha_vec = Self::fees_in_alpha::<T>(who, call);
if !alpha_vec.is_empty() {
let fee_u64: u64 = fee.into();
OU::withdraw_in_alpha(who, &alpha_vec, fee_u64);
return Ok(Some(WithdrawnFee::Alpha));
}
// let alpha_vec = Self::fees_in_alpha::<T>(who, call);
// if !alpha_vec.is_empty() {
// let fee_u64: u64 = fee.into();
// OU::withdraw_in_alpha(who, &alpha_vec, fee_u64);
// return Ok(Some(WithdrawnFee::Alpha));
// }
Err(InvalidTransaction::Payment.into())
}
}
}

fn can_withdraw_fee(
who: &AccountIdOf<T>,
call: &CallOf<T>,
_call: &CallOf<T>,
_dispatch_info: &DispatchInfoOf<CallOf<T>>,
fee: Self::Balance,
_tip: Self::Balance,
Expand All @@ -353,14 +353,14 @@ where
match F::can_withdraw(who, fee) {
WithdrawConsequence::Success => Ok(()),
_ => {
// Fallback to fees in Alpha if possible
let alpha_vec = Self::fees_in_alpha::<T>(who, call);
if !alpha_vec.is_empty() {
let fee_u64: u64 = fee.into();
if OU::can_withdraw_in_alpha(who, &alpha_vec, fee_u64) {
return Ok(());
}
}
// // Fallback to fees in Alpha if possible
// let alpha_vec = Self::fees_in_alpha::<T>(who, call);
// if !alpha_vec.is_empty() {
// let fee_u64: u64 = fee.into();
// if OU::can_withdraw_in_alpha(who, &alpha_vec, fee_u64) {
// return Ok(());
// }
// }
Err(InvalidTransaction::Payment.into())
}
}
Expand Down
15 changes: 15 additions & 0 deletions pallets/transaction-fee/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ fn test_remove_stake_fees_tao() {

// cargo test --package subtensor-transaction-fee --lib -- tests::test_remove_stake_fees_alpha --exact --show-output
#[test]
#[ignore]
fn test_remove_stake_fees_alpha() {
new_test_ext().execute_with(|| {
let stake_amount = TAO;
Expand Down Expand Up @@ -142,6 +143,7 @@ fn test_remove_stake_fees_alpha() {
//
// cargo test --package subtensor-transaction-fee --lib -- tests::test_remove_stake_root --exact --show-output
#[test]
#[ignore]
fn test_remove_stake_root() {
new_test_ext().execute_with(|| {
let stake_amount = TAO;
Expand Down Expand Up @@ -200,6 +202,7 @@ fn test_remove_stake_root() {
//
// cargo test --package subtensor-transaction-fee --lib -- tests::test_remove_stake_completely_root --exact --show-output
#[test]
#[ignore]
fn test_remove_stake_completely_root() {
new_test_ext().execute_with(|| {
let stake_amount = TAO;
Expand Down Expand Up @@ -251,6 +254,7 @@ fn test_remove_stake_completely_root() {

// cargo test --package subtensor-transaction-fee --lib -- tests::test_remove_stake_completely_fees_alpha --exact --show-output
#[test]
#[ignore]
fn test_remove_stake_completely_fees_alpha() {
new_test_ext().execute_with(|| {
let stake_amount = TAO;
Expand Down Expand Up @@ -381,6 +385,7 @@ fn test_remove_stake_not_enough_balance_for_fees() {
//
// cargo test --package subtensor-transaction-fee --lib -- tests::test_remove_stake_edge_alpha --exact --show-output
#[test]
#[ignore]
fn test_remove_stake_edge_alpha() {
new_test_ext().execute_with(|| {
let stake_amount = TAO;
Expand Down Expand Up @@ -519,6 +524,7 @@ fn test_remove_stake_failing_transaction_tao_fees() {
//
// cargo test --package subtensor-transaction-fee --lib -- tests::test_remove_stake_failing_transaction_alpha_fees --exact --show-output
#[test]
#[ignore]
fn test_remove_stake_failing_transaction_alpha_fees() {
new_test_ext().execute_with(|| {
let stake_amount = TAO;
Expand Down Expand Up @@ -584,6 +590,7 @@ fn test_remove_stake_failing_transaction_alpha_fees() {

// cargo test --package subtensor-transaction-fee --lib -- tests::test_remove_stake_limit_fees_alpha --exact --show-output
#[test]
#[ignore]
fn test_remove_stake_limit_fees_alpha() {
new_test_ext().execute_with(|| {
let stake_amount = TAO;
Expand Down Expand Up @@ -651,6 +658,7 @@ fn test_remove_stake_limit_fees_alpha() {

// cargo test --package subtensor-transaction-fee --lib -- tests::test_unstake_all_fees_alpha --exact --show-output
#[test]
#[ignore]
fn test_unstake_all_fees_alpha() {
new_test_ext().execute_with(|| {
let stake_amount = TAO;
Expand Down Expand Up @@ -723,6 +731,7 @@ fn test_unstake_all_fees_alpha() {

// cargo test --package subtensor-transaction-fee --lib -- tests::test_unstake_all_alpha_fees_alpha --exact --show-output
#[test]
#[ignore]
fn test_unstake_all_alpha_fees_alpha() {
new_test_ext().execute_with(|| {
let stake_amount = TAO;
Expand Down Expand Up @@ -790,6 +799,7 @@ fn test_unstake_all_alpha_fees_alpha() {

// cargo test --package subtensor-transaction-fee --lib -- tests::test_move_stake_fees_alpha --exact --show-output
#[test]
#[ignore]
fn test_move_stake_fees_alpha() {
new_test_ext().execute_with(|| {
let stake_amount = TAO;
Expand Down Expand Up @@ -861,6 +871,7 @@ fn test_move_stake_fees_alpha() {

// cargo test --package subtensor-transaction-fee --lib -- tests::test_transfer_stake_fees_alpha --exact --show-output
#[test]
#[ignore]
fn test_transfer_stake_fees_alpha() {
new_test_ext().execute_with(|| {
let destination_coldkey = U256::from(100000);
Expand Down Expand Up @@ -933,6 +944,7 @@ fn test_transfer_stake_fees_alpha() {

// cargo test --package subtensor-transaction-fee --lib -- tests::test_swap_stake_fees_alpha --exact --show-output
#[test]
#[ignore]
fn test_swap_stake_fees_alpha() {
new_test_ext().execute_with(|| {
let stake_amount = TAO;
Expand Down Expand Up @@ -1003,6 +1015,7 @@ fn test_swap_stake_fees_alpha() {

// cargo test --package subtensor-transaction-fee --lib -- tests::test_swap_stake_limit_fees_alpha --exact --show-output
#[test]
#[ignore]
fn test_swap_stake_limit_fees_alpha() {
new_test_ext().execute_with(|| {
let stake_amount = TAO;
Expand Down Expand Up @@ -1075,6 +1088,7 @@ fn test_swap_stake_limit_fees_alpha() {

// cargo test --package subtensor-transaction-fee --lib -- tests::test_burn_alpha_fees_alpha --exact --show-output
#[test]
#[ignore]
fn test_burn_alpha_fees_alpha() {
new_test_ext().execute_with(|| {
let stake_amount = TAO;
Expand Down Expand Up @@ -1136,6 +1150,7 @@ fn test_burn_alpha_fees_alpha() {

// cargo test --package subtensor-transaction-fee --lib -- tests::test_recycle_alpha_fees_alpha --exact --show-output
#[test]
#[ignore]
fn test_recycle_alpha_fees_alpha() {
new_test_ext().execute_with(|| {
let stake_amount = TAO;
Expand Down
Loading