Skip to content

Commit

Permalink
Merge pull request #9 from DeAccountSystems/develop
Browse files Browse the repository at this point in the history
feat: implement secondary market
  • Loading branch information
linkdesu authored Oct 18, 2021
2 parents 66bc5bd + 104e029 commit 7717330
Show file tree
Hide file tree
Showing 86 changed files with 6,744 additions and 4,559 deletions.
42 changes: 33 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ members = [
"contracts/income-cell-type",
"contracts/pre-account-cell-type",
"contracts/proposal-cell-type",
"contracts/account-sale-cell-type",
"contracts/account-auction-cell-type",
"tools/calculator",
]

Expand Down
17 changes: 17 additions & 0 deletions contracts/account-auction-cell-type/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "account-auction-cell-type"
version = "1.0.0"
edition = "2018"

[features]
dev = ["das-core/dev"]
local = ["das-core/local"]
testnet = ["das-core/testnet"]
mainnet = ["das-core/mainnet"]

[dependencies]
ckb-std = "0.7.1"
das-map = { path = "../../libs/das-map" }
das-core = { path = "../../libs/das-core", default-features = false }
das-types = { path = "../../../das-types/rust", default-features = false }
chrono = { version = "0.4", default-features = false }
50 changes: 50 additions & 0 deletions contracts/account-auction-cell-type/src/entry.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
use ckb_std::ckb_constants::Source;
use das_core::{constants::*, debug, error::Error, util, witness_parser::WitnessesParser};

pub fn main() -> Result<(), Error> {
debug!("====== Running account-auction-cell-type ======");
let mut parser = WitnessesParser::new()?;
let action_opt = parser.parse_action_with_params()?;
if action_opt.is_none() {
return Err(Error::ActionNotSupported);
}

let (action_raw, _params_raw) = action_opt.unwrap();
let action = action_raw.as_reader().raw_data();
// let params = params_raw.iter().map(|param| param.as_reader()).collect::<Vec<_>>();

util::is_system_off(&mut parser)?;
parser.parse_cell()?;

if action == b"start_account_auction"
|| action == b"edit_account_auction"
|| action == b"cancel_account_auction"
|| action == b"bid_account_auction"
|| action == b"confirm_account_auction"
{
// let timestamp = util::load_oracle_data(OracleCellType::Time)?;
// let config_main_reader = parser.configs.main()?;
// let config_secondary_market_reader = parser.configs.secondary_market()?;
// let (input_auction_cell, output_auction_cell) = load_auction_cell()?;

if action == b"start_account_auction" {
debug!("Route to start_account_auction action ...");
} else if action == b"cancel_account_auction" {
debug!("Route to cancel_account_auction action ...");
} else if action == b"bid_account_auction" {
debug!("Route to bid_account_auction action ...");
} else if action == b"confirm_account_auction" {
debug!("Route to confirm_account_auction action ...");
}
} else if action == b"force_recover_account_status" {
util::require_type_script(
&mut parser,
TypeScript::AccountCellType,
Source::Input,
Error::InvalidTransactionStructure,
)?;
} else {
return Err(Error::ActionNotSupported);
}
Ok(())
}
28 changes: 28 additions & 0 deletions contracts/account-auction-cell-type/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! Generated by capsule
//!
//! `main.rs` is used to define rust lang items and modules.
//! See `entry.rs` for the `main` function.
//! See `error.rs` for the `Error` type.

#![no_std]
#![no_main]
#![feature(lang_items)]
#![feature(alloc_error_handler)]
#![feature(panic_info_message)]

// define modules
mod entry;

use ckb_std::default_alloc;

ckb_std::entry!(program_entry);
default_alloc!();

/// program entry
fn program_entry() -> i8 {
// Call main function and return error code
match entry::main() {
Ok(_) => 0,
Err(err) => err as i8,
}
}
2 changes: 1 addition & 1 deletion contracts/account-cell-type/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "account-cell-type"
version = "1.2.1"
version = "1.3.1"
edition = "2018"

[features]
Expand Down
Loading

0 comments on commit 7717330

Please sign in to comment.