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
138 changes: 77 additions & 61 deletions Cargo.lock

Large diffs are not rendered by default.

37 changes: 19 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,29 @@ fc-traits-tracks = { path = "./traits/tracks", default-features = false }
fc-pallet-listings = { path = "./pallets/listings", default-features = false }
fc-pallet-payments = { path = "./pallets/payments", default-features = false }

frame-benchmarking = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
frame-support = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
frame-system = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
frame-benchmarking = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
frame-support = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
frame-system = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }

mock-helpers = { path = "./mock-helpers", default-features = false }

sp-core = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
sp-io = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
sp-keystore = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
sp-runtime = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
sp-std = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
sp-core = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
sp-io = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
sp-keystore = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
sp-runtime = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
sp-std = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }

pallet-assets = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
pallet-babe = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
pallet-balances = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
pallet-nfts = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
pallet-preimage = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
pallet-referenda = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
pallet-scheduler = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
pallet-timestamp = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
pallet-transaction-payment = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
pallet-utility = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409", default-features = false }
pallet-assets = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
pallet-assets-holder = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
pallet-babe = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
pallet-balances = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
pallet-nfts = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
pallet-preimage = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
pallet-referenda = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
pallet-scheduler = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
pallet-timestamp = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
pallet-transaction-payment = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }
pallet-utility = { git = "https://github.com/virto-network/polkadot-sdk", branch = "release-virto-stable2409-6", default-features = false }

[workspace]
resolver = "2"
Expand Down
4 changes: 4 additions & 0 deletions pallets/orders/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fc-pallet-listings.workspace = true
fc-pallet-payments.workspace = true
mock-helpers = { workspace = true, features = ["pallet-assets", "pallet-balances", "fc-pallet-listings"] }
pallet-assets.workspace = true
pallet-assets-holder.workspace = true
pallet-balances.workspace = true
pallet-nfts.workspace = true
pallet-preimage.workspace = true
Expand All @@ -48,6 +49,7 @@ runtime-benchmarks = [
"pallet-preimage/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"pallet-assets-holder/runtime-benchmarks"
]

std = [
Expand All @@ -69,6 +71,7 @@ std = [
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"pallet-assets-holder/std"
]

try-runtime = [
Expand All @@ -82,4 +85,5 @@ try-runtime = [
"pallet-preimage/try-runtime",
"pallet-scheduler/try-runtime",
"sp-runtime/try-runtime",
"pallet-assets-holder/try-runtime"
]
18 changes: 14 additions & 4 deletions pallets/orders/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
//! Test environment for template pallet.

use crate::{self as fc_pallet_orders, Config, InventoryIdOf};
use crate::{self as fc_pallet_orders, Config};
use codec::{Decode, Encode, MaxEncodedLen};
use core::cell::Cell;

#[cfg(feature = "runtime-benchmarks")]
use fc_pallet_listings::InventoryId;
use {
crate::types::{InventoryIdOf, MerchantIdOf},
fc_pallet_listings::InventoryId,
};

use crate::types::MerchantIdOf;
use fc_pallet_listings::{InventoryIdFor, ItemIdOf, ItemPrice};
use frame_support::{
derive_impl,
Expand Down Expand Up @@ -60,6 +62,8 @@ mod runtime {
pub type Balances = pallet_balances;
#[runtime::pallet_index(11)]
pub type Assets = pallet_assets;
#[runtime::pallet_index(12)]
pub type AssetsHolder = pallet_assets_holder;
#[runtime::pallet_index(20)]
pub type Listings = fc_pallet_listings;
#[runtime::pallet_index(21)]
Expand Down Expand Up @@ -115,6 +119,12 @@ impl pallet_assets::Config for Test {
type ForceOrigin = EnsureRoot<AccountId>;
type CreateOrigin = EnsureSigned<AccountId>;
type Freezer = ();
type Holder = AssetsHolder;
}

impl pallet_assets_holder::Config for Test {
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeEvent = RuntimeEvent;
}

pub type AccountIdBytes = [u8; 32];
Expand Down Expand Up @@ -266,7 +276,7 @@ impl fc_pallet_payments::Config for Test {
type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall;
type Assets = Assets;
type AssetsHold = Assets;
type AssetsHold = AssetsHolder;
type FeeHandler = ();
type SenderOrigin = EnsureSigned<AccountId>;
type BeneficiaryOrigin = EnsureSigned<AccountId>;
Expand Down
4 changes: 2 additions & 2 deletions pallets/orders/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ mod pay {
// The balances hold (pun intended).
let price = 15;
assert_eq!(Assets::balance(ASSET_A, &BOB), bob_asset_b_balance - price);
assert_eq!(Assets::total_balance_on_hold(ASSET_A, &ALICE), price);
assert_eq!(AssetsHolder::total_balance_on_hold(ASSET_A, &ALICE), price);

// Once BOB releases the payment (since CHARLIE received the payment), the item will be
// unlocked.
Expand All @@ -690,7 +690,7 @@ mod pay {
));
assert!(Listings::transferable(&inventory_id, &item_id));
assert_eq!(Assets::balance(ASSET_A, &ALICE), alice_balance + price);
assert_eq!(Assets::total_balance_on_hold(ASSET_A, &ALICE), 0);
assert_eq!(AssetsHolder::total_balance_on_hold(ASSET_A, &ALICE), 0);

// Since all the items have been delivered, the order is now completed
assert!(matches!(
Expand Down
4 changes: 4 additions & 0 deletions pallets/payments/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ log.workspace = true
serde.workspace = true
pallet-balances.workspace = true
pallet-assets.workspace = true
pallet-assets-holder.workspace = true
sp-keystore.workspace = true
pallet-preimage.workspace = true
pallet-scheduler.workspace = true
Expand All @@ -41,6 +42,7 @@ runtime-benchmarks = [
"pallet-preimage/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"pallet-assets-holder/runtime-benchmarks"
]
std = [
"codec/std",
Expand All @@ -59,6 +61,7 @@ std = [
"sp-io/std",
"sp-keystore/std",
"sp-runtime/std",
"pallet-assets-holder/std"
]
try-runtime = [
"frame-support/try-runtime",
Expand All @@ -68,4 +71,5 @@ try-runtime = [
"pallet-preimage/try-runtime",
"pallet-scheduler/try-runtime",
"sp-runtime/try-runtime",
"pallet-assets-holder/try-runtime"
]
14 changes: 11 additions & 3 deletions pallets/payments/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ mod runtime {
pub type Balances = pallet_balances;
#[runtime::pallet_index(11)]
pub type Assets = pallet_assets;
#[runtime::pallet_index(12)]
pub type AssetsHolder = pallet_assets_holder;

#[runtime::pallet_index(20)]
pub type Payments = pallet_payments;
}
Expand Down Expand Up @@ -99,10 +102,15 @@ impl pallet_balances::Config for Test {
#[derive_impl(pallet_assets::config_preludes::TestDefaultConfig as pallet_assets::DefaultConfig)]
impl pallet_assets::Config for Test {
type Currency = Balances;
type CreateOrigin = AsEnsureOriginWithArg<frame_system::EnsureSigned<u64>>;
type ForceOrigin = frame_system::EnsureRoot<u64>;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<u64>>;
type ForceOrigin = EnsureRoot<u64>;
type Freezer = ();
type Holder = AssetsHolder;
}

impl pallet_assets_holder::Config for Test {
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeEvent = RuntimeEvent;
}

impl pallet_preimage::Config for Test {
Expand Down Expand Up @@ -243,7 +251,7 @@ impl Config for Test {
type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall;
type Assets = Assets;
type AssetsHold = Assets;
type AssetsHold = AssetsHolder;
type FeeHandler = MockFeeHandler;
type SenderOrigin = EnsureSigned<AccountId>;
type BeneficiaryOrigin = EnsureSigned<AccountId>;
Expand Down
4 changes: 2 additions & 2 deletions pallets/payments/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ fn build_payment(assert_payment_creation: bool) -> Fees<Test> {
);

assert_eq!(
<Assets as fungibles::InspectHold<_>>::balance_on_hold(
<AssetsHolder as fungibles::InspectHold<_>>::balance_on_hold(
ASSET_ID,
reason,
&PAYMENT_BENEFICIARY
),
PAYMENT_AMOUNT
);
assert_eq!(
<Assets as fungibles::InspectHold<_>>::balance_on_hold(
<AssetsHolder as fungibles::InspectHold<_>>::balance_on_hold(
ASSET_ID,
reason,
&SENDER_ACCOUNT
Expand Down
5 changes: 3 additions & 2 deletions traits/tracks/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#![cfg_attr(not(feature = "std"), no_std)]

use core::fmt::Debug;
use frame_support::dispatch::DispatchResult;
use pallet_referenda::{TrackInfo, TracksInfo};

pub use crate::Mutate as MutateTracks;

pub trait Mutate<Balance, Moment>: TracksInfo<Balance, Moment>
where
Balance: Clone + 'static,
Moment: Clone + 'static,
Balance: Clone + Debug + Eq + 'static,
Moment: Clone + Debug + Eq + 'static,
{
/// Inserts a new track into the tracks storage.
fn insert(
Expand Down
Loading