From 0cdbe144821af21ae4e6e1c1ba0c3758da8a8a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Andr=C3=A9s=20Dorado=20Su=C3=A1rez?= Date: Wed, 18 Dec 2024 22:51:06 -0500 Subject: [PATCH] fix(kreivo-runtime): add selector to filter out tanks for memberships that are not expired --- Cargo.lock | 96 +++++++++++-------- .../src/configuration/monetary_stuff.rs | 20 +++- 2 files changed, 72 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e3f50013..29e471cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -972,7 +972,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ "termcolor", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -1008,15 +1008,15 @@ dependencies = [ [[package]] name = "console" -version = "0.15.8" +version = "0.15.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" dependencies = [ "encode_unicode", - "lazy_static", "libc", - "unicode-width", - "windows-sys 0.52.0", + "once_cell", + "unicode-width 0.2.0", + "windows-sys 0.59.0", ] [[package]] @@ -1523,9 +1523,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.134" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5a32d755fe20281b46118ee4b507233311fb7a48a0cfd42f554b93640521a2f" +checksum = "4d44ff199ff93242c3afe480ab588d544dd08d72e92885e152ffebc670f076ad" dependencies = [ "cc", "cxxbridge-cmd", @@ -1537,9 +1537,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.134" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11645536ada5d1c8804312cbffc9ab950f2216154de431de930da47ca6955199" +checksum = "66fd8f17ad454fc1e4f4ab83abffcc88a532e90350d3ffddcb73030220fcbd52" dependencies = [ "cc", "codespan-reporting", @@ -1551,9 +1551,9 @@ dependencies = [ [[package]] name = "cxxbridge-cmd" -version = "1.0.134" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebcc9c78e3c7289665aab921a2b394eaffe8bdb369aa18d81ffc0f534fd49385" +checksum = "4717c9c806a9e07fdcb34c84965a414ea40fafe57667187052cf1eb7f5e8a8a9" dependencies = [ "clap", "codespan-reporting", @@ -1564,15 +1564,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.134" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a22a87bd9e78d7204d793261470a4c9d585154fddd251828d8aefbb5f74c3bf" +checksum = "2f6515329bf3d98f4073101c7866ff2bec4e635a13acb82e3f3753fff0bf43cb" [[package]] name = "cxxbridge-macro" -version = "1.0.134" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dfdb020ff8787c5daf6e0dca743005cc8782868faeadfbabb8824ede5cb1c72" +checksum = "fb93e6a7ce8ec985c02bbb758237a31598b340acbbc3c19c5a4fa6adaaac92ab" dependencies = [ "proc-macro2", "quote", @@ -1922,9 +1922,9 @@ dependencies = [ [[package]] name = "encode_unicode" -version = "0.3.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" [[package]] name = "enum-as-inner" @@ -2079,7 +2079,7 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fc-pallet-gas-transaction-payment" version = "1.0.0" -source = "git+https://github.com/virto-network/frame-contrib#71d38dc81bcfb032a1bf2cbecc08362baa2ed0f8" +source = "git+https://github.com/virto-network/frame-contrib#f79db1a00df0bd25a5d0da545f239a2435d29e3a" dependencies = [ "fc-traits-gas-tank", "frame-support", @@ -2092,7 +2092,7 @@ dependencies = [ [[package]] name = "fc-pallet-pass" version = "1.0.0" -source = "git+https://github.com/virto-network/frame-contrib#71d38dc81bcfb032a1bf2cbecc08362baa2ed0f8" +source = "git+https://github.com/virto-network/frame-contrib#f79db1a00df0bd25a5d0da545f239a2435d29e3a" dependencies = [ "fc-traits-authn", "frame-benchmarking", @@ -2110,7 +2110,7 @@ dependencies = [ [[package]] name = "fc-pallet-referenda-tracks" version = "1.0.0" -source = "git+https://github.com/virto-network/frame-contrib#71d38dc81bcfb032a1bf2cbecc08362baa2ed0f8" +source = "git+https://github.com/virto-network/frame-contrib#f79db1a00df0bd25a5d0da545f239a2435d29e3a" dependencies = [ "fc-traits-tracks", "frame-benchmarking", @@ -2129,7 +2129,7 @@ dependencies = [ [[package]] name = "fc-traits-authn" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#71d38dc81bcfb032a1bf2cbecc08362baa2ed0f8" +source = "git+https://github.com/virto-network/frame-contrib#f79db1a00df0bd25a5d0da545f239a2435d29e3a" dependencies = [ "fc-traits-authn-proc", "frame-support", @@ -2141,7 +2141,7 @@ dependencies = [ [[package]] name = "fc-traits-authn-proc" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#71d38dc81bcfb032a1bf2cbecc08362baa2ed0f8" +source = "git+https://github.com/virto-network/frame-contrib#f79db1a00df0bd25a5d0da545f239a2435d29e3a" dependencies = [ "quote", "syn 2.0.90", @@ -2150,8 +2150,9 @@ dependencies = [ [[package]] name = "fc-traits-gas-tank" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#71d38dc81bcfb032a1bf2cbecc08362baa2ed0f8" +source = "git+https://github.com/virto-network/frame-contrib#f79db1a00df0bd25a5d0da545f239a2435d29e3a" dependencies = [ + "fc-traits-nonfungibles-helpers", "frame-support", "frame-system", "parity-scale-codec", @@ -2161,17 +2162,22 @@ dependencies = [ [[package]] name = "fc-traits-memberships" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#71d38dc81bcfb032a1bf2cbecc08362baa2ed0f8" +source = "git+https://github.com/virto-network/frame-contrib#f79db1a00df0bd25a5d0da545f239a2435d29e3a" dependencies = [ "frame-support", "parity-scale-codec", "scale-info", ] +[[package]] +name = "fc-traits-nonfungibles-helpers" +version = "0.1.0" +source = "git+https://github.com/virto-network/frame-contrib#f79db1a00df0bd25a5d0da545f239a2435d29e3a" + [[package]] name = "fc-traits-tracks" version = "0.1.0" -source = "git+https://github.com/virto-network/frame-contrib#71d38dc81bcfb032a1bf2cbecc08362baa2ed0f8" +source = "git+https://github.com/virto-network/frame-contrib#f79db1a00df0bd25a5d0da545f239a2435d29e3a" dependencies = [ "frame-support", "pallet-referenda", @@ -2941,11 +2947,11 @@ dependencies = [ [[package]] name = "home" -version = "0.5.9" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3035,9 +3041,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.31" +version = "0.14.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" dependencies = [ "bytes", "futures-channel", @@ -3059,9 +3065,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" dependencies = [ "bytes", "futures-channel", @@ -3087,7 +3093,7 @@ dependencies = [ "futures-util", "http 1.2.0", "http-body 1.0.1", - "hyper 1.5.1", + "hyper 1.5.2", "pin-project-lite", "tokio", ] @@ -3329,7 +3335,7 @@ dependencies = [ "bytes", "futures", "http 0.2.12", - "hyper 0.14.31", + "hyper 0.14.32", "log", "rand", "tokio", @@ -4467,9 +4473,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ "adler2", ] @@ -7766,9 +7772,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.1" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" +checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" dependencies = [ "core-foundation-sys", "libc", @@ -8956,7 +8962,7 @@ version = "0.17.0" source = "git+https://github.com/virto-network/polkadot-sdk?branch=release-virto-stable2409#d13cf291bef64b5ab713ed864df18ce763a799fc" dependencies = [ "http-body-util", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-util", "log", "prometheus", @@ -9538,9 +9544,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" [[package]] name = "unicode-ident" @@ -9563,6 +9569,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.6" diff --git a/runtime/kreivo/src/configuration/monetary_stuff.rs b/runtime/kreivo/src/configuration/monetary_stuff.rs index 36601e26..4ae439bd 100644 --- a/runtime/kreivo/src/configuration/monetary_stuff.rs +++ b/runtime/kreivo/src/configuration/monetary_stuff.rs @@ -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 @@ -136,7 +137,22 @@ impl pallet_skip_feeless_payment::Config for Runtime { // #[runtime::pallet_index(17)] // pub type GasTxPayment -pub type MembershipsGasTank = NonFungibleGasTank; + +parameter_types! { + pub MembershipIsNotExpired: Box> = + Box::new(|community, membership| { + use frame_support::traits::nonfungibles_v2::Inspect; + let membership_expiration = 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; impl pallet_gas_transaction_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent;