diff --git a/Cargo.lock b/Cargo.lock index 90c768cf..f91e2e16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6989,6 +6989,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", + "sp-api", "sp-core", "sp-io", "sp-runtime", diff --git a/pallets/orders/Cargo.toml b/pallets/orders/Cargo.toml index 50f698c4..66224d4f 100644 --- a/pallets/orders/Cargo.toml +++ b/pallets/orders/Cargo.toml @@ -19,6 +19,7 @@ cumulus-primitives-core = { workspace = true, default-features = false } frame-benchmarking = { workspace = true, default-features = false, optional = true } frame-support = { workspace = true, default-features = false } frame-system = { workspace = true, default-features = false } +sp-api = { workspace = true, default-features = false } sp-io = { workspace = true, default-features = false } sp-core = { workspace = true, default-features = false } sp-runtime = { workspace = true, default-features = false } @@ -41,6 +42,7 @@ std = [ "codec/std", "cumulus-primitives-core/std", "scale-info/std", + "sp-api/std", "sp-io/std", "sp-core/std", "sp-runtime/std", diff --git a/pallets/orders/src/lib.rs b/pallets/orders/src/lib.rs index f7d5902a..bcb77168 100644 --- a/pallets/orders/src/lib.rs +++ b/pallets/orders/src/lib.rs @@ -39,6 +39,8 @@ pub use crate::types::*; pub mod weights; pub use weights::WeightInfo; +pub mod runtime_api; + pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; diff --git a/pallets/orders/src/runtime_api.rs b/pallets/orders/src/runtime_api.rs new file mode 100644 index 00000000..971580ae --- /dev/null +++ b/pallets/orders/src/runtime_api.rs @@ -0,0 +1,27 @@ +// This file is part of RegionX. +// +// RegionX is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// RegionX is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with RegionX. If not, see . + +use codec::Codec; +use order_primitives::OrderId; + +sp_api::decl_runtime_apis! { + pub trait OrdersApi + where + AccountId: Codec + { + /// Returns the account of an order. + fn order_account(order_id: OrderId) -> AccountId; + } +} diff --git a/runtime/cocos/src/lib.rs b/runtime/cocos/src/lib.rs index 8876252c..31153ce2 100644 --- a/runtime/cocos/src/lib.rs +++ b/runtime/cocos/src/lib.rs @@ -194,7 +194,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("regionx-parachain"), impl_name: create_runtime_str!("regionx-parachain"), authoring_version: 1, - spec_version: 2_001_000, + spec_version: 2_002_000, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -1126,6 +1126,12 @@ impl_runtime_apis! { } } + impl pallet_orders::runtime_api::OrdersApi for Runtime { + fn order_account(order_id: OrderId) -> AccountId { + ::OrderToAccountId::convert(order_id) + } + } + #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {