diff --git a/contracts/coretime-market/Cargo.toml b/contracts/coretime-market/Cargo.toml index 3b31a3c..4518d36 100755 --- a/contracts/coretime-market/Cargo.toml +++ b/contracts/coretime-market/Cargo.toml @@ -14,16 +14,19 @@ scale-info = { version = "2.6", default-features = false, features = ["derive"], # OpenBrush dependency openbrush = { git = "https://github.com/Brushfam/openbrush-contracts", branch = "develop", default-features = false, features=["psp34"] } +primitives = { path = "../../primitives", default-features = false } + [dev-dependencies] ink_e2e = "4.2.1" [lib] -path = "lib.rs" +path = "src/lib.rs" [features] default = ["std"] std = [ "ink/std", + "primitives/std", "scale/std", "scale-info/std", "openbrush/std", diff --git a/contracts/coretime-market/src/lib.rs b/contracts/coretime-market/src/lib.rs new file mode 100755 index 0000000..b078789 --- /dev/null +++ b/contracts/coretime-market/src/lib.rs @@ -0,0 +1,97 @@ +// 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 . + +#![cfg_attr(not(feature = "std"), no_std, no_main)] +#![feature(min_specialization)] + +mod types; + +#[openbrush::contract] +pub mod coretime_market { + use crate::types::MarketError; + use openbrush::traits::Storage; + use primitives::{coretime::RawRegionId, Version}; + + #[ink(storage)] + #[derive(Default, Storage)] + pub struct CoretimeMarket { + // FIXME: ink! smart contract boilerplate + foo: u8, + } + + impl CoretimeMarket { + #[ink(constructor)] + pub fn new() -> Self { + Default::default() + } + + /// A function for listing a region on sale. + /// + /// ## Arguments: + /// - `region_id`: The `u128` encoded identifier of the region that the caller intends to + /// list for sale. + /// - `bit_price`: The price for the smallest unit of the region. This is the price for a + /// single bit of the region's coremask, i.e., 1/80th of the total price. + #[ink(message)] + pub fn list_region( + &self, + _region_id: RawRegionId, + _bit_price: Balance, + ) -> Result<(), MarketError> { + todo!() + } + + /// A function for unlisting a region on sale. + /// + /// ## Arguments: + /// - `region_id`: The `u128` encoded identifier of the region that the caller intends to + /// unlist from sale. + #[ink(message)] + pub fn unlist_region(&self, _region_id: RawRegionId) -> Result<(), MarketError> { + todo!() + } + + /// A function for updating a listed region's bit price. + /// + /// ## Arguments: + /// - `region_id`: The `u128` encoded identifier of the region being listed for sale. + /// - `bit_price`: The new price for the smallest unit of the region. This is the price for + /// a single bit of the region's coremask, i.e., 1/80th of the total price. + #[ink(message)] + pub fn update_region_price( + &self, + _region_id: RawRegionId, + _new_bit_price: Balance, + ) -> Result<(), MarketError> { + todo!() + } + + /// A function for purchasing a region listed on sale. + /// + /// ## Arguments: + /// - `region_id`: The `u128` encoded identifier of the region being listed for sale. + /// - `metadata_version`: The required metadata version for the region. If the + /// `metadata_version` does not match the current version stored in the xc-regions + /// contract the purchase will fail. + #[ink(message)] + pub fn purchase_region( + &self, + _region_id: RawRegionId, + _metadata_version: Version, + ) -> Result<(), MarketError> { + todo!() + } + } +} diff --git a/contracts/coretime-market/lib.rs b/contracts/coretime-market/src/types.rs old mode 100755 new mode 100644 similarity index 58% rename from contracts/coretime-market/lib.rs rename to contracts/coretime-market/src/types.rs index 29a3f72..e20f4d3 --- a/contracts/coretime-market/lib.rs +++ b/contracts/coretime-market/src/types.rs @@ -13,28 +13,16 @@ // You should have received a copy of the GNU General Public License // along with RegionX. If not, see . -#![cfg_attr(not(feature = "std"), no_std, no_main)] -#![feature(min_specialization)] - -#[openbrush::contract] -pub mod coretime_market { - use openbrush::traits::Storage; - - #[ink(storage)] - #[derive(Default, Storage)] - pub struct CoretimeMarket { - // FIXME: ink! smart contract boilerplate - foo: u8, - } +#[derive(scale::Decode, scale::Encode, Debug, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] +pub enum MarketError { + Foo, +} - impl CoretimeMarket { - #[ink(constructor)] - pub fn new() -> Self { - Default::default() +impl core::fmt::Display for MarketError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + MarketError::Foo => write!(f, "Foo"), } - - // FIXME: ink! smart contract boilerplate - #[ink(message)] - pub fn foo(&self) {} } }