diff --git a/pallets/certifications/Cargo.toml b/pallets/certifications/Cargo.toml index aa010893..035cfb73 100644 --- a/pallets/certifications/Cargo.toml +++ b/pallets/certifications/Cargo.toml @@ -25,7 +25,7 @@ sp-std = { default-features = false, version = '3.0.0' } traits-certifications = { path = '../../traits/certifications', default-features = false } [dev-dependencies] -serde = { version = "1.0.119" } +serde = { default-features = false, version = "1.0.119" } sp-core = { default-features = false, version = '3.0.0' } sp-io = { default-features = false, version = '3.0.0' } sp-runtime = { default-features = false, version = '3.0.0' } @@ -36,5 +36,6 @@ std = [ 'codec/std', 'frame-support/std', 'frame-system/std', + 'sp-io/std', 'traits-certifications/std', ] diff --git a/pallets/doctor-certifications/Cargo.toml b/pallets/doctor-certifications/Cargo.toml index 77fc1f29..daeb5316 100644 --- a/pallets/doctor-certifications/Cargo.toml +++ b/pallets/doctor-certifications/Cargo.toml @@ -25,7 +25,7 @@ sp-std = { default-features = false, version = '3.0.0' } traits-doctor-certifications = { path = '../../traits/doctor-certifications', default-features = false } [dev-dependencies] -serde = { version = "1.0.119" } +serde = { default-features = false, version = "1.0.119" } sp-core = { default-features = false, version = '3.0.0' } sp-io = { default-features = false, version = '3.0.0' } sp-runtime = { default-features = false, version = '3.0.0' } @@ -34,6 +34,8 @@ sp-runtime = { default-features = false, version = '3.0.0' } default = ['std'] std = [ 'codec/std', + 'sp-std/std', + 'sp-io/std', 'frame-support/std', 'frame-system/std', 'traits-doctor-certifications/std', diff --git a/pallets/doctors/Cargo.toml b/pallets/doctors/Cargo.toml index 7e26747e..8a4368d6 100644 --- a/pallets/doctors/Cargo.toml +++ b/pallets/doctors/Cargo.toml @@ -26,7 +26,7 @@ traits-user-profile = { path = '../../traits/user-profile', default-features = f traits-doctor-certifications = { path = '../../traits/doctor-certifications', default-features = false } [dev-dependencies] -serde = { version = "1.0.119" } +serde = { default-features = false, version = "1.0.119" } sp-core = { default-features = false, version = '3.0.0' } sp-io = { default-features = false, version = '3.0.0' } sp-runtime = { default-features = false, version = '3.0.0' } @@ -38,6 +38,7 @@ std = [ 'frame-support/std', 'frame-system/std', 'sp-std/std', + 'sp-io/std', 'traits-user-profile/std', 'traits-doctor-certifications/std', ] diff --git a/pallets/electronic-medical-record/Cargo.toml b/pallets/electronic-medical-record/Cargo.toml index 9443d7e8..0bd06edd 100644 --- a/pallets/electronic-medical-record/Cargo.toml +++ b/pallets/electronic-medical-record/Cargo.toml @@ -26,7 +26,7 @@ pallet-timestamp = { default-features = false, version = '3.0.0' } traits-electronic-medical-record = { path = '../../traits/electronic-medical-record', default-features = false } [dev-dependencies] -serde = { version = "1.0.119" } +serde = { default-features = false, version = "1.0.119" } sp-core = { default-features = false, version = '3.0.0' } sp-io = { default-features = false, version = '3.0.0' } sp-runtime = { default-features = false, version = '3.0.0' } @@ -34,9 +34,12 @@ sp-runtime = { default-features = false, version = '3.0.0' } [features] default = ['std'] std = [ + 'codec/std', 'frame-support/std', 'frame-system/std', 'sp-std/std', + 'sp-io/std', + 'pallet-timestamp/std', 'traits-electronic-medical-record/std', ] diff --git a/pallets/genetic-testing/Cargo.toml b/pallets/genetic-testing/Cargo.toml index fe28aa41..7774e899 100644 --- a/pallets/genetic-testing/Cargo.toml +++ b/pallets/genetic-testing/Cargo.toml @@ -24,7 +24,7 @@ traits-genetic-testing = { path = '../../traits/genetic-testing', default-featur traits-order = { path = '../../traits/order', default-features = false } [dev-dependencies] -serde = { version = "1.0.119" } +serde = { default-features = false, version = "1.0.119" } sp-core = { default-features = false, version = '3.0.0' } sp-io = { default-features = false, version = '3.0.0' } sp-runtime = { default-features = false, version = '3.0.0' } @@ -35,6 +35,7 @@ std = [ 'codec/std', 'frame-support/std', 'frame-system/std', + 'pallet-timestamp/std', 'sp-std/std', 'traits-genetic-testing/std', 'traits-order/std', diff --git a/pallets/hospital-certifications/Cargo.toml b/pallets/hospital-certifications/Cargo.toml index 5e49664f..51f394ca 100644 --- a/pallets/hospital-certifications/Cargo.toml +++ b/pallets/hospital-certifications/Cargo.toml @@ -25,7 +25,7 @@ sp-std = { default-features = false, version = '3.0.0' } traits-hospital-certifications = { path = '../../traits/hospital-certifications', default-features = false } [dev-dependencies] -serde = { version = "1.0.119" } +serde = { default-features = false, version = "1.0.119" } sp-core = { default-features = false, version = '3.0.0' } sp-io = { default-features = false, version = '3.0.0' } sp-runtime = { default-features = false, version = '3.0.0' } @@ -36,5 +36,7 @@ std = [ 'codec/std', 'frame-support/std', 'frame-system/std', + 'sp-std/std', + 'sp-io/std', 'traits-hospital-certifications/std', ] diff --git a/pallets/hospitals/Cargo.toml b/pallets/hospitals/Cargo.toml index 80ffe3af..424102ec 100644 --- a/pallets/hospitals/Cargo.toml +++ b/pallets/hospitals/Cargo.toml @@ -26,7 +26,7 @@ traits-user-profile = { path = '../../traits/user-profile', default-features = f traits-hospital-certifications = { path = '../../traits/hospital-certifications', default-features = false } [dev-dependencies] -serde = { version = "1.0.119" } +serde = { default-features = false, version = "1.0.119" } sp-core = { default-features = false, version = '3.0.0' } sp-io = { default-features = false, version = '3.0.0' } sp-runtime = { default-features = false, version = '3.0.0' } @@ -38,6 +38,7 @@ std = [ 'frame-support/std', 'frame-system/std', 'sp-std/std', + 'sp-io/std', 'traits-user-profile/std', 'traits-hospital-certifications/std', ] diff --git a/pallets/labs/Cargo.toml b/pallets/labs/Cargo.toml index eadefa9b..bd750d79 100644 --- a/pallets/labs/Cargo.toml +++ b/pallets/labs/Cargo.toml @@ -27,7 +27,7 @@ traits-certifications = { path = '../../traits/certifications', default-features traits-user-profile = { path = '../../traits/user-profile', default-features = false } [dev-dependencies] -serde = { version = "1.0.119" } +serde = { default-features = false, version = "1.0.119" } sp-core = { default-features = false, version = '3.0.0' } sp-io = { default-features = false, version = '3.0.0' } sp-runtime = { default-features = false, version = '3.0.0' } @@ -39,6 +39,7 @@ std = [ 'frame-support/std', 'frame-system/std', 'sp-std/std', + 'sp-io/std', 'traits-services/std', 'traits-certifications/std', 'traits-user-profile/std', diff --git a/pallets/labs/src/lib.rs b/pallets/labs/src/lib.rs index 0e7fcaff..40285a10 100644 --- a/pallets/labs/src/lib.rs +++ b/pallets/labs/src/lib.rs @@ -172,7 +172,7 @@ pub mod pallet { /// Because this pallet emits events, it depends on the runtime's definition of an event. type Event: From> + IsType<::Event>; type Currency: Currency; - type Services: ServicesProvider; + type Services: ServicesProvider>; type Certifications: CertificationsProvider; type EthereumAddress: Clone + Copy + PartialEq + Eq + Encode + EncodeLike + Decode + Default + sp_std::fmt::Debug; type UserProfile: UserProfileProvider; @@ -194,6 +194,8 @@ pub mod pallet { pub type LabOf = Lab, HashOf>; pub type CountryRegionCode = Vec; // country_code-region_code -> XX-YYYY pub type CityCode = Vec; // city_code -> ZZZZ + pub type CurrencyOf = ::Currency; + pub type BalanceOf = as Currency>>::Balance; // ----- Storage ------------------ /// Get Lab by account id @@ -518,4 +520,4 @@ impl CertificationOwner for Pallet { } }); } -} \ No newline at end of file +} diff --git a/pallets/orders/Cargo.toml b/pallets/orders/Cargo.toml index 1c792385..1308e381 100644 --- a/pallets/orders/Cargo.toml +++ b/pallets/orders/Cargo.toml @@ -21,7 +21,7 @@ package = 'parity-scale-codec' version = '2.0.0' [dependencies] -serde = { version = "1.0.101", optional = true } +serde = { default-features = false, version = "1.0.119", features = ["derive"] } frame-support = { default-features = false, version = '3.0.0' } frame-system = { default-features = false, version = '3.0.0' } pallet-timestamp = { default-features = false, version = '3.0.0' } @@ -41,12 +41,13 @@ sp-runtime = { default-features = false, version = '3.0.0' } [features] default = ['std'] std = [ - 'serde', + 'serde/std', 'codec/std', 'frame-support/std', 'frame-system/std', 'sp-std/std', 'sp-core/std', + 'sp-io/std', 'pallet-timestamp/std', 'services/std', 'chrono/std', diff --git a/pallets/orders/src/lib.rs b/pallets/orders/src/lib.rs index 6a099e23..946b8603 100644 --- a/pallets/orders/src/lib.rs +++ b/pallets/orders/src/lib.rs @@ -4,12 +4,12 @@ pub mod interface; use interface::OrderInterface; pub use pallet::*; +use frame_support::traits::{ Currency }; use frame_support::codec::{Encode, Decode}; use frame_support::pallet_prelude::*; use sp_std::prelude::*; use traits_services::{ServicesProvider, ServiceInfo}; use traits_genetic_testing::{GeneticTestingProvider, DnaSampleTracking}; -use traits_user_profile::{UserProfileProvider}; use traits_order::{OrderEventEmitter}; @@ -26,29 +26,27 @@ impl Default for OrderStatus { } #[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq, Eq)] -pub struct Order { +pub struct Order { pub id: Hash, pub service_id: Hash, pub customer_id: AccountId, pub customer_box_public_key: Hash, pub seller_id: AccountId, - pub customer_eth_address: EthAddress, - pub seller_eth_address: EthAddress, pub dna_sample_tracking_id: Vec, + pub price: Balance, pub status: OrderStatus, pub created_at: Moment, pub updated_at: Moment, } -impl Order { +impl Order { pub fn new( id: Hash, service_id: Hash, customer_id: AccountId, customer_box_public_key: Hash, seller_id: AccountId, - customer_eth_address: EthAddress, - seller_eth_address: EthAddress, dna_sample_tracking_id: Vec, + price: Balance, created_at: Moment, updated_at: Moment, ) @@ -60,9 +58,8 @@ impl Order> + IsType<::Event>; - type Services: ServicesProvider; + type Services: ServicesProvider>; type GeneticTesting: GeneticTestingProvider; - type EthereumAddress: Clone + Copy + PartialEq + Eq + Encode + Decode + Default + sp_std::fmt::Debug; - type UserProfile: UserProfileProvider; + type Currency: Currency<::AccountId>; } @@ -114,8 +110,9 @@ pub mod pallet { type AccountIdOf = ::AccountId; pub type MomentOf = ::Moment; pub type HashOf = ::Hash; - type EthereumAddressOf = ::EthereumAddress; - pub type OrderOf = Order, AccountIdOf, MomentOf, EthereumAddressOf>; + pub type CurrencyOf = ::Currency; + pub type BalanceOf = as Currency>>::Balance; + pub type OrderOf = Order, AccountIdOf, BalanceOf, MomentOf>; type OrderIdsOf = Vec>; // ------------------------------------------------------- @@ -299,6 +296,7 @@ impl OrderInterface for Pallet { let service = service.unwrap(); let order_id = Self::generate_order_id(customer_id, service_id); let seller_id = service.get_owner_id(); + let price = service.get_price(); let now = pallet_timestamp::Pallet::::get(); // Initialize DnaSample @@ -308,27 +306,14 @@ impl OrderInterface for Pallet { } let dna_sample = dna_sample.ok().unwrap(); - let customer_eth_address = T::UserProfile::get_eth_address_by_account_id(customer_id); - if customer_eth_address.is_none() { - return Err(Error::::CustomerEthAddressNotFound); - } - let customer_eth_address = customer_eth_address.unwrap(); - - let seller_eth_address = T::UserProfile::get_eth_address_by_account_id(seller_id); - if seller_eth_address.is_none() { - return Err(Error::::SellerEthAddressNotFound); - } - let seller_eth_address = seller_eth_address.unwrap(); - let order = Order::new( order_id.clone(), service_id.clone(), customer_id.clone(), customer_box_public_key.clone(), seller_id.clone(), - customer_eth_address as T::EthereumAddress, - seller_eth_address as T::EthereumAddress, dna_sample.get_tracking_id().clone(), + price.clone(), now, now ); @@ -429,7 +414,7 @@ impl Pallet { } pub fn update_order_status(order_id: &T::Hash, status: OrderStatus) - -> Option> + -> Option, T::Moment>> { Orders::::mutate(order_id, |order| { match order { diff --git a/pallets/services/Cargo.toml b/pallets/services/Cargo.toml index 95ff9054..4d794ce7 100644 --- a/pallets/services/Cargo.toml +++ b/pallets/services/Cargo.toml @@ -25,7 +25,7 @@ sp-std = { default-features = false, version = '3.0.0' } traits-services = { path = '../../traits/services', default-features = false } [dev-dependencies] -serde = { version = "1.0.119" } +serde = { default-features = false, version = "1.0.119" } sp-core = { default-features = false, version = '3.0.0' } sp-io = { default-features = false, version = '3.0.0' } sp-runtime = { default-features = false, version = '3.0.0' } @@ -34,6 +34,8 @@ sp-runtime = { default-features = false, version = '3.0.0' } default = ['std'] std = [ 'codec/std', + 'sp-std/std', + 'sp-io/std', 'frame-support/std', 'frame-system/std', 'traits-services/std', diff --git a/pallets/services/src/lib.rs b/pallets/services/src/lib.rs index 59ce42c3..a30d2eda 100644 --- a/pallets/services/src/lib.rs +++ b/pallets/services/src/lib.rs @@ -54,8 +54,8 @@ impl Service { } } -impl ServiceInfoT for Service - where T: frame_system::Config +impl ServiceInfoT for Service + where T: frame_system::Config, { fn get_id(&self) -> &Hash { self.get_id() @@ -63,6 +63,9 @@ impl ServiceInfoT for Service &AccountId { self.get_owner_id() } + fn get_price(&self) -> &Balance { + self.get_price() + } } #[frame_support::pallet] @@ -318,9 +321,10 @@ impl Pallet { } /// ServicesProvider Trait Implementation -impl ServicesProvider for Pallet { +impl ServicesProvider for Pallet + where ServiceOf: traits_services::ServiceInfo +{ type Error = Error; - type Balance = pallet::BalanceOf; type Service = ServiceOf; fn service_by_id(id: &T::Hash) -> Option> { diff --git a/pallets/user-profile/Cargo.toml b/pallets/user-profile/Cargo.toml index f31a1d2e..4d00c0a4 100644 --- a/pallets/user-profile/Cargo.toml +++ b/pallets/user-profile/Cargo.toml @@ -18,7 +18,7 @@ version = '2.0.0' frame-support = { default-features = false, version = '3.0.0' } frame-system = { default-features = false, version = '3.0.0' } sp-std = { default-features = false, version = '3.0.0' } -serde = { version = "1.0.123" } +serde = { default-features = false, version = "1.0.119", features = ["derive"] } rustc-hex = { version = "2.1.0", default-features = false } traits-user-profile = { path = '../../traits/user-profile', default-features = false } @@ -34,6 +34,7 @@ std = [ 'frame-support/std', 'frame-system/std', 'sp-std/std', + 'sp-io/std', 'serde/std', 'rustc-hex/std', 'traits-user-profile/std', diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 2965e05e..062cb7ed 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -274,29 +274,33 @@ impl pallet_sudo::Config for Runtime { type Call = Call; } +// ------------------------------ +// Debio Pallets +// ------------------------------ + impl labs::Config for Runtime { type Event = Event; type Currency = Balances; type Services = Services; - type Certifications = Certifications; - type EthereumAddress = EthereumAddress; - type UserProfile = UserProfile; + type Certifications = Certifications; + type EthereumAddress = EthereumAddress; + type UserProfile = UserProfile; } impl hospitals::Config for Runtime { type Event = Event; type Currency = Balances; - type HospitalCertifications = HospitalCertifications; - type EthereumAddress = EthereumAddress; - type UserProfile = UserProfile; + type HospitalCertifications = HospitalCertifications; + type EthereumAddress = EthereumAddress; + type UserProfile = UserProfile; } impl doctors::Config for Runtime { type Event = Event; type Currency = Balances; - type DoctorCertifications = DoctorCertifications; - type EthereumAddress = EthereumAddress; - type UserProfile = UserProfile; + type DoctorCertifications = DoctorCertifications; + type EthereumAddress = EthereumAddress; + type UserProfile = UserProfile; } impl services::Config for Runtime { @@ -309,8 +313,7 @@ impl orders::Config for Runtime { type Event = Event; type Services = Services; type GeneticTesting = GeneticTesting; - type EthereumAddress = EthereumAddress; - type UserProfile = UserProfile; + type Currency = Balances; } impl genetic_testing::Config for Runtime { @@ -321,27 +324,27 @@ impl genetic_testing::Config for Runtime { impl user_profile::Config for Runtime { type Event = Event; - type EthereumAddress = EthereumAddress; + type EthereumAddress = EthereumAddress; } impl electronic_medical_record::Config for Runtime { type Event = Event; - type ElectronicMedicalRecord = ElectronicMedicalRecord; + type ElectronicMedicalRecord = ElectronicMedicalRecord; } impl certifications::Config for Runtime { type Event = Event; - type CertificationOwner = Labs; + type CertificationOwner = Labs; } impl doctor_certifications::Config for Runtime { type Event = Event; - type DoctorCertificationOwner = Doctors; + type DoctorCertificationOwner = Doctors; } impl hospital_certifications::Config for Runtime { type Event = Event; - type HospitalCertificationOwner = Hospitals; + type HospitalCertificationOwner = Hospitals; } // Create the runtime by composing the FRAME pallets that were previously configured. diff --git a/traits/electronic-medical-record/Cargo.toml b/traits/electronic-medical-record/Cargo.toml index d300fc9a..27edf159 100644 --- a/traits/electronic-medical-record/Cargo.toml +++ b/traits/electronic-medical-record/Cargo.toml @@ -22,6 +22,7 @@ frame-support = { default-features = false, version = '3.0.0' } default = ['std'] std = [ 'sp-std/std', + 'pallet-timestamp/std', 'frame-system/std', 'frame-support/std', ] diff --git a/traits/services/src/lib.rs b/traits/services/src/lib.rs index 83e1f67a..75ba70f4 100644 --- a/traits/services/src/lib.rs +++ b/traits/services/src/lib.rs @@ -3,15 +3,15 @@ use frame_system::Config; //use sp_std::prelude::*; -pub trait ServiceInfo { +pub trait ServiceInfo { fn get_id(&self) -> &T::Hash; fn get_owner_id(&self) -> &T::AccountId; + fn get_price(&self) -> &Balance; } -pub trait ServicesProvider { +pub trait ServicesProvider { type Error; - type Balance; - type Service: ServiceInfo + sp_std::fmt::Debug; + type Service: ServiceInfo + sp_std::fmt::Debug; fn delete_service(owner_id: &T::AccountId, id: &T::Hash) -> Result; fn service_by_id(id: &T::Hash) -> Option; diff --git a/types.json b/types.json index 934e7b5f..d73bbf03 100644 --- a/types.json +++ b/types.json @@ -75,9 +75,8 @@ "customer_id": "AccountId", "customer_box_public_key": "H256", "seller_id": "AccountId", - "customer_eth_address": "EthereumAddress", - "seller_eth_address": "EthereumAddress", "dna_sample_tracking_id": "Text", + "price": "u128", "status": "OrderStatus", "created_at": "u64", "updated_at": "u64"