diff --git a/Cargo.lock b/Cargo.lock index 7c504db8..1c13ea93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10341,7 +10341,6 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "virto-primitives", ] [[package]] diff --git a/pallets/payment/Cargo.toml b/pallets/payment/Cargo.toml index c78da626..6c2c8a27 100644 --- a/pallets/payment/Cargo.toml +++ b/pallets/payment/Cargo.toml @@ -13,13 +13,12 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] } +parity-scale-codec = { default-features = false, features = ['derive'], version = "2.0.0" } frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.13", default-features = false } frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.13", default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.13", default-features = false } frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.13", default-features = false, optional = true } orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.13", default-features = false } -virto-primitives = { version = "0.3.0", path = "../../primitives" } scale-info = { version = "1.0.0", default-features = false, features = ["derive"] } [dev-dependencies] @@ -31,7 +30,7 @@ orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-li [features] default = ['std'] std = [ - 'codec/std', + 'parity-scale-codec/std', 'frame-support/std', 'frame-system/std', 'sp-runtime/std', diff --git a/pallets/payment/src/benchmarking.rs b/pallets/payment/src/benchmarking.rs index ac9993b0..a2d08258 100644 --- a/pallets/payment/src/benchmarking.rs +++ b/pallets/payment/src/benchmarking.rs @@ -1,13 +1,12 @@ use super::*; -use crate::Pallet as Payment; +use crate::{Pallet as Payment, PaymentState}; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller}; use frame_system::RawOrigin; use orml_traits::MultiCurrency; -use virto_primitives::{Asset, NetworkAsset, PaymentState}; const SEED: u32 = 0; -const CURRENCY_ID: Asset = Asset::Network(NetworkAsset::KSM); +const CURRENCY_ID: u32 = 1u32; const INITIAL_AMOUNT: u32 = 100; const SOME_AMOUNT: u32 = 80; @@ -22,7 +21,7 @@ fn assert_last_event(generic_event: ::Event) { benchmarks! { where_clause { where T::Asset: MultiCurrency< ::AccountId, - CurrencyId = Asset, Balance = u32 + CurrencyId = u32, Balance = u32 > } // create a new payment succesfully diff --git a/pallets/payment/src/lib.rs b/pallets/payment/src/lib.rs index e8764f4d..45b6da6a 100644 --- a/pallets/payment/src/lib.rs +++ b/pallets/payment/src/lib.rs @@ -11,13 +11,15 @@ mod tests; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; +mod types; + #[frame_support::pallet] pub mod pallet { + pub use crate::types::{DisputeResolver, PaymentDetail, PaymentHandler, PaymentState}; use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*}; use frame_system::pallet_prelude::*; use orml_traits::{MultiCurrency, MultiReservableCurrency}; use sp_runtime::Percent; - use virto_primitives::{DisputeResolver, PaymentDetail, PaymentHandler, PaymentState}; type BalanceOf = <::Asset as MultiCurrency<::AccountId>>::Balance; diff --git a/pallets/payment/src/mock.rs b/pallets/payment/src/mock.rs index 2a9dcacd..e22ce942 100644 --- a/pallets/payment/src/mock.rs +++ b/pallets/payment/src/mock.rs @@ -11,14 +11,13 @@ use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, Percent, }; -use virto_primitives::{Asset, DisputeResolver, NetworkAsset}; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; pub type AccountId = u8; pub const PAYMENT_CREATOR: AccountId = 10; pub const PAYMENT_RECIPENT: AccountId = 11; -pub const CURRENCY_ID: Asset = Asset::Network(NetworkAsset::KSM); +pub const CURRENCY_ID: u32 = 1u32; pub const RESOLVER_ACCOUNT: AccountId = 12; frame_support::construct_runtime!( @@ -65,7 +64,7 @@ impl system::Config for Test { } parameter_type_with_key! { - pub ExistentialDeposits: |_currency_id: Asset| -> u32 { + pub ExistentialDeposits: |_currency_id: u32| -> u32 { 0u32 }; } @@ -83,7 +82,7 @@ impl Contains for MockDustRemovalWhitelist { impl orml_tokens::Config for Test { type Amount = i64; type Balance = u32; - type CurrencyId = Asset; + type CurrencyId = u32; type Event = Event; type ExistentialDeposits = ExistentialDeposits; type OnDust = (); @@ -93,7 +92,7 @@ impl orml_tokens::Config for Test { } pub struct MockDisputeResolver; -impl DisputeResolver for MockDisputeResolver { +impl crate::types::DisputeResolver for MockDisputeResolver { fn get_origin() -> AccountId { RESOLVER_ACCOUNT } diff --git a/pallets/payment/src/tests.rs b/pallets/payment/src/tests.rs index 1de676a4..68906855 100644 --- a/pallets/payment/src/tests.rs +++ b/pallets/payment/src/tests.rs @@ -1,7 +1,10 @@ -use crate::{mock::*, Payment as PaymentStore}; +use crate::{ + mock::*, + types::{PaymentDetail, PaymentState}, + Payment as PaymentStore, +}; use frame_support::{assert_noop, assert_ok}; use orml_traits::MultiCurrency; -use virto_primitives::{PaymentDetail, PaymentState}; #[test] fn test_create_payment_works() { diff --git a/primitives/src/payment.rs b/pallets/payment/src/types.rs similarity index 100% rename from primitives/src/payment.rs rename to pallets/payment/src/types.rs diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 445f889a..cf48cae1 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -5,7 +5,5 @@ #![cfg_attr(not(feature = "std"), no_std)] mod asset; -mod payment; pub use asset::*; -pub use payment::*; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 3ee0055f..74aa1172 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -63,7 +63,7 @@ mod proxy_type; use currency_id_convert::CurrencyIdConvert; use orml_traits::{arithmetic::Zero, parameter_type_with_key}; use proxy_type::ProxyType; -use virto_primitives::{Asset, DisputeResolver}; +use virto_primitives::Asset; /// Alias to 512-bit hash when used in the context of a transaction signature on the chain. pub type Signature = MultiSignature; @@ -596,7 +596,7 @@ impl orml_unknown_tokens::Config for Runtime { } pub struct VirtoDisputeResolver; -impl DisputeResolver for VirtoDisputeResolver { +impl virto_payment::DisputeResolver for VirtoDisputeResolver { fn get_origin() -> AccountId { Sudo::key() }