Skip to content

Commit

Permalink
fix(kreivo-runtime): add selector to filter out tanks for memberships…
Browse files Browse the repository at this point in the history
… that are not expired
  • Loading branch information
pandres95 committed Dec 19, 2024
1 parent 94123d9 commit dee90d5
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 44 deletions.
96 changes: 54 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 18 additions & 2 deletions runtime/kreivo/src/configuration/monetary_stuff.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use super::*;

use fc_traits_gas_tank::NonFungibleGasTank;
use fc_traits_gas_tank::{NonFungibleGasTank, SelectNonFungibleItem};

use pallet_asset_tx_payment::FungiblesAdapter;
use pallet_assets::BalanceToAssetBalance;
use pallet_transaction_payment::FungibleAdapter;
use runtime_common::impls::AssetsToBlockAuthor;
use virto_common::MembershipId;

// #[runtime::pallet_index(10)]
// pub type Balances
Expand Down Expand Up @@ -136,7 +137,22 @@ impl pallet_skip_feeless_payment::Config for Runtime {

// #[runtime::pallet_index(17)]
// pub type GasTxPayment
pub type MembershipsGasTank = NonFungibleGasTank<Runtime, CommunityMemberships, pallet_nfts::ItemConfig>;

parameter_types! {
pub MembershipIsNotExpired: Box<dyn SelectNonFungibleItem<CommunityId, MembershipId>> =
Box::new(|community, membership| {
use frame_support::traits::nonfungibles_v2::Inspect;
const MEMBERSHIP_EXPIRATION: &[u8] = &*b"membership_expiration";
CommunityMemberships::typed_system_attribute(&community, Some(&membership), MEMBERSHIP_EXPIRATION)
// If there's an expiration date, check it against block number
.map(|expiration| System::block_number() <= expiration)
// Otherwise, the membership will not expire
.unwrap_or(true)
});
}

pub type MembershipsGasTank =
NonFungibleGasTank<Runtime, CommunityMemberships, pallet_nfts::ItemConfig, MembershipIsNotExpired>;

impl pallet_gas_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
Expand Down

0 comments on commit dee90d5

Please sign in to comment.