Skip to content

Commit

Permalink
init coretime-market
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Jan 15, 2024
1 parent db176c7 commit 7c7863b
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 22 deletions.
5 changes: 4 additions & 1 deletion contracts/coretime-market/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
97 changes: 97 additions & 0 deletions contracts/coretime-market/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.

#![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!()
}
}
}
30 changes: 9 additions & 21 deletions contracts/coretime-market/lib.rs → contracts/coretime-market/src/types.rs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,16 @@
// You should have received a copy of the GNU General Public License
// along with RegionX. If not, see <https://www.gnu.org/licenses/>.

#![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) {}
}
}

0 comments on commit 7c7863b

Please sign in to comment.