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
46 changes: 32 additions & 14 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ fc-traits-tracks = { git = "https://github.com/virto-network/frame-contrib", def

pallet-gas-transaction-payment = { git = "https://github.com/virto-network/frame-contrib", default-features = false, package = "fc-pallet-gas-transaction-payment" }
pallet-listings = { git = "https://github.com/virto-network/frame-contrib", default-features = false, package = "fc-pallet-listings" }
pallet-orders = { git = "https://github.com/virto-network/frame-contrib", default-features = false, package = "fc-pallet-orders" }
pallet-payments = { git = "https://github.com/virto-network/frame-contrib", default-features = false, package = "fc-pallet-payments" }
pallet-pass = { git = "https://github.com/virto-network/frame-contrib", default-features = false, package = "fc-pallet-pass" }
pallet-referenda-tracks = { git = "https://github.com/virto-network/frame-contrib", default-features = false, package = "fc-pallet-referenda-tracks" }
Expand Down
16 changes: 10 additions & 6 deletions runtime/kreivo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ kreivo-apis = { workspace = true, features = ["runtime"] }

pallet-communities = { workspace = true, features = ["xcm"] }
pallet-communities-manager.workspace = true
pallet-payments.workspace = true

# Local: Common
runtime-common.workspace = true
Expand All @@ -44,10 +43,10 @@ frame-system.workspace = true
frame-system-benchmarking = { workspace = true, optional = true }
frame-system-rpc-runtime-api.workspace = true
frame-try-runtime = { workspace = true, optional = true }
pallet-assets-freezer.workspace = true
pallet-assets-holder.workspace = true
pallet-asset-tx-payment.workspace = true
pallet-assets.workspace = true
pallet-assets-freezer.workspace = true
pallet-assets-holder.workspace = true
pallet-aura.workspace = true
pallet-authorship.workspace = true
pallet-balances.workspace = true
Expand Down Expand Up @@ -115,7 +114,9 @@ fc-traits-gas-tank.workspace = true
fc-traits-memberships.workspace = true
pallet-gas-transaction-payment.workspace = true
pallet-listings.workspace = true
pallet-orders.workspace = true
pallet-pass.workspace = true
pallet-payments.workspace = true
pallet-referenda-tracks.workspace = true
pass-webauthn = { workspace = true, features = ["runtime"] }

Expand Down Expand Up @@ -208,7 +209,8 @@ std = [
"pallet-listings/std",
"pallet-vesting/std",
"serde_json/std",
"pallet-assets-holder/std"
"pallet-assets-holder/std",
"pallet-orders/std"
]

runtime-benchmarks = [
Expand Down Expand Up @@ -263,7 +265,8 @@ runtime-benchmarks = [
"fc-traits-gas-tank/runtime-benchmarks",
"fc-traits-memberships/runtime-benchmarks",
"pallet-vesting/runtime-benchmarks",
"pallet-assets-holder/runtime-benchmarks"
"pallet-assets-holder/runtime-benchmarks",
"pallet-orders/runtime-benchmarks"
]

try-runtime = [
Expand Down Expand Up @@ -312,5 +315,6 @@ try-runtime = [
"sp-runtime/try-runtime",
"pallet-listings/try-runtime",
"pallet-vesting/try-runtime",
"pallet-assets-holder/try-runtime"
"pallet-assets-holder/try-runtime",
"pallet-orders/try-runtime"
]
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use super::*;
use frame_support::traits::MapSuccess;

use pallet_listings::{InventoryId, InventoryIdFor, ItemIdOf};
use sp_runtime::traits::{AccountIdConversion, Verify};

#[cfg(not(feature = "runtime-benchmarks"))]
use frame_system::EnsureNever;
use frame_system::EnsureSigned;
use sp_runtime::morph_types;

parameter_types! {
pub KeyLimit: u32 = 64;
Expand Down Expand Up @@ -41,7 +44,7 @@

#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin(InventoryId(community_id, _): &InventoryId<CommunityId, Id>) -> Result<RuntimeOrigin, ()> {
Ok(RuntimeOrigin::signed(Communities::community_account(&community_id)))

Check warning on line 47 in runtime/kreivo/src/config/listings_orders.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> runtime/kreivo/src/config/listings_orders.rs:47:59 | 47 | Ok(RuntimeOrigin::signed(Communities::community_account(&community_id))) | ^^^^^^^^^^^^^ help: change this to: `community_id` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
}
}

Expand All @@ -62,7 +65,7 @@
type InventoryId = KreivoInventoryId;
type ItemSKU = ItemSKU;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = benchmarks::ListingsBenchmarkHelper<Self, ListingsInstance>;
type BenchmarkHelper = benchmarks::ListingsBenchmarkHelper;
}

// #[runtime::pallet_index(62)]
Expand Down Expand Up @@ -98,49 +101,69 @@
type OffchainSignature = Signature;
type OffchainPublic = <Signature as Verify>::Signer;
#[cfg(feature = "runtime-benchmarks")]
type Helper = benchmarks::ListingsCatalogBenchmarkHelper<Self, ListingsInstance>;
type Helper = benchmarks::ListingsCatalogBenchmarkHelper;
type WeightInfo = ();
}

morph_types! {
pub type MaxCartsForRegularUsers = |id: AccountId| -> (AccountId, u32) { (id, 5) };
pub type MaxItemsForRegularUsers = |id: AccountId| -> (AccountId, u32) { (id, 64) };
}

parameter_types! {
pub MaxLifetimeForCheckoutOrder: BlockNumber = 30 * MINUTES;
pub MaxCartLen: u32 = 5;
pub MaxItemLen: u32 = 64;
}

impl pallet_orders::Config<ListingsInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall;
type WeightInfo = ();
type CreateOrigin = MapSuccess<EnsureSigned<AccountId>, MaxCartsForRegularUsers>;
type OrderAdminOrigin = MapSuccess<EnsureSigned<AccountId>, MaxItemsForRegularUsers>;
type PaymentOrigin = EnsureSigned<AccountId>;
type OrderId = u64;
type Listings = Listings;
type Payments = Payments;
type Scheduler = Scheduler;
type MaxLifetimeForCheckoutOrder = MaxLifetimeForCheckoutOrder;
type MaxCartLen = MaxCartLen;
type MaxItemLen = MaxItemLen;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = benchmarks::OrdersBenchmarkHelper;
}

#[cfg(feature = "runtime-benchmarks")]
mod benchmarks {
use super::*;
use core::marker::PhantomData;
use pallet_orders::InventoryIdOf;

pub struct ListingsBenchmarkHelper<T, I>(PhantomData<(T, I)>);
pub struct ListingsBenchmarkHelper;

impl<T, I: 'static> pallet_listings::BenchmarkHelper<InventoryIdFor<T, I>> for ListingsBenchmarkHelper<T, I>
where
T: pallet_listings::Config<I>,
<T as pallet_listings::Config<I>>::MerchantId: From<u16>,
<T as pallet_listings::Config<I>>::InventoryId: From<u16>,
{
fn inventory_id() -> InventoryIdFor<T, I> {
InventoryId(0.into(), 1.into())
impl pallet_listings::BenchmarkHelper<InventoryIdFor<Runtime, ListingsInstance>> for ListingsBenchmarkHelper {
fn inventory_id() -> InventoryIdFor<Runtime, ListingsInstance> {
InventoryId(0, 1)
}
}

pub struct ListingsCatalogBenchmarkHelper<T, I>(PhantomData<(T, I)>);
pub struct ListingsCatalogBenchmarkHelper;

impl<T, I: 'static>
impl
pallet_nfts::BenchmarkHelper<
InventoryIdFor<T, I>,
ItemIdOf<T, I>,
InventoryIdFor<Runtime, ListingsInstance>,
ItemIdOf<Runtime, ListingsInstance>,
sp_runtime::MultiSigner,
sp_runtime::AccountId32,
sp_runtime::MultiSignature,
> for ListingsCatalogBenchmarkHelper<T, I>
where
T: pallet_nfts::Config<I> + pallet_listings::Config<I>,
<T as pallet_listings::Config<I>>::MerchantId: From<u16>,
<T as pallet_listings::Config<I>>::InventoryId: From<u16>,
<T as pallet_listings::Config<I>>::ItemSKU: From<u16>,
> for ListingsCatalogBenchmarkHelper
{
fn collection(i: u16) -> InventoryIdFor<T, I> {
InventoryId(i.into(), 0.into())
fn collection(i: u16) -> InventoryIdFor<Runtime, ListingsInstance> {
InventoryId(i.into(), 0)

Check warning on line 163 in runtime/kreivo/src/config/listings_orders.rs

View workflow job for this annotation

GitHub Actions / clippy

useless conversion to the same type: `u16`

warning: useless conversion to the same type: `u16` --> runtime/kreivo/src/config/listings_orders.rs:163:16 | 163 | InventoryId(i.into(), 0) | ^^^^^^^^ help: consider removing `.into()`: `i` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
}

fn item(i: u16) -> ItemIdOf<T, I> {
fn item(i: u16) -> ItemIdOf<Runtime, ListingsInstance> {
i.into()
}

Expand All @@ -164,4 +187,24 @@
>>::sign(signer, message)
}
}

type MerchantIdOf<T, I> = <T as pallet_listings::Config<I>>::MerchantId;

pub struct OrdersBenchmarkHelper;

impl pallet_orders::BenchmarkHelper<Runtime, ListingsInstance> for OrdersBenchmarkHelper {
type Balances = Balances;
type Assets = Assets;

fn inventory_id() -> (
MerchantIdOf<Runtime, ListingsInstance>,
InventoryIdOf<Runtime, ListingsInstance>,
) {
(0, 0)
}

fn item_id(i: usize) -> ItemIdOf<Runtime, ListingsInstance> {
i as u64
}
}
}
2 changes: 1 addition & 1 deletion runtime/kreivo/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub mod communities;
pub mod governance;
// Virto toolchain
pub mod contracts;
mod listings;
mod listings_orders;
pub mod payments;

pub use collator_support::{ConsensusHook, SLOT_DURATION};
Expand Down
2 changes: 2 additions & 0 deletions runtime/kreivo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ mod runtime {
pub type Listings = pallet_listings<Instance1>;
#[runtime::pallet_index(62)]
pub type ListingsCatalog = pallet_nfts<Instance1>;
#[runtime::pallet_index(63)]
pub type Orders = pallet_orders<Instance1>;

// Communities at Kreivo
#[runtime::pallet_index(71)]
Expand Down
Loading