Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prototypes of the interface #1

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Cargo.lock

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

19 changes: 19 additions & 0 deletions contracts/auctions/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "phoenix-nft-auctions"
version = { workspace = true }
authors = ["Jakub <[email protected]>"]
repository = { workspace = true }
edition = { workspace = true }
license = { workspace = true }

[lib]
crate-type = ["cdylib"]

[features]
testutils = ["soroban-sdk/testutils"]

[dependencies]
soroban-sdk = { workspace = true }

[dev_dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
20 changes: 20 additions & 0 deletions contracts/auctions/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
default: all

all: lint build test

test: build # because of token dependency
cargo test

build:
cargo build --target wasm32-unknown-unknown --release

lint: fmt clippy

fmt:
cargo fmt --all

clippy: build
cargo clippy --all-targets -- -D warnings

clean:
cargo clean
82 changes: 82 additions & 0 deletions contracts/auctions/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#![no_std]

use soroban_sdk::{contract, Address, BytesN, Env, Vec};

#[derive(Clone)]
pub struct Auction {
pub id: u64,
pub item_address: Address, // Can be an NFT contract address or a collection contract address
pub seller: Address,
pub highest_bid: u64,
pub highest_bidder: Address,
pub buy_now_price: u64,
pub end_time: u64,
pub status: AuctionStatus,
}

#[derive(Clone, PartialEq)]
pub enum AuctionStatus {
Active,
Ended,
Cancelled,
}

#[contract]
pub struct MarketplaceContract;

#[contractimpl]
impl MarketplaceContract {
fn generate_auction_id(env: &Env) -> u64 {
todo!()
}

pub fn create_auction(
env: Env,
item_address: Address,
seller: Address,
buy_now_price: u64,
duration: u64,
) -> Auction {
todo!()
}

pub fn place_bid(env: Env, auction_id: u64, bidder: Address, bid_amount: u64) {
todo!()
}

pub fn finalize_auction(env: Env, auction_id: u64) {
todo!()
}

pub fn buy_now(env: Env, auction_id: u64, buyer: Address) {
todo!()
}

fn distribute_funds(env: Env, auction: Auction) {
todo!()
}

pub fn pause(env: Env) {
todo!()
}

pub fn unpause(env: Env) {
todo!()
}

pub fn get_auction(env: Env, auction_id: u64) -> Auction {
todo!()
}

pub fn get_active_auctions(env: Env) -> Vec<Auction> {
todo!()
}

pub fn get_auctions_by_seller(env: Env, seller: Address) -> Vec<Auction> {
todo!()
}

pub fn get_highest_bid(env: Env, auction_id: u64) -> (u64, Address) {
todo!()
}
}
19 changes: 19 additions & 0 deletions contracts/collections/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "phoenix-nft-collections"
version = { workspace = true }
authors = ["Jakub <[email protected]>"]
repository = { workspace = true }
edition = { workspace = true }
license = { workspace = true }

[lib]
crate-type = ["cdylib"]

[features]
testutils = ["soroban-sdk/testutils"]

[dependencies]
soroban-sdk = { workspace = true }

[dev_dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
20 changes: 20 additions & 0 deletions contracts/collections/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
default: all

all: lint build test

test: build # because of token dependency
cargo test

build:
cargo build --target wasm32-unknown-unknown --release

lint: fmt clippy

fmt:
cargo fmt --all

clippy: build
cargo clippy --all-targets -- -D warnings

clean:
cargo clean
43 changes: 43 additions & 0 deletions contracts/collections/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#![no_std]

use soroban_sdk::{contract, contractimpl, contracttype, Address, Env, Symbol, Vec};

#[derive(Clone)]
#[contracttype]
pub struct Collection {
pub id: u64,
pub name: Symbol,
pub description: Symbol,
pub creator: Address,
pub nft_contracts: Vec<Address>, // List of NFT contract addresses
}

#[contract]
pub struct CollectionContract;

#[contractimpl]
impl CollectionContract {
fn generate_id(env: &Env) -> u64 {
todo!()
}

pub fn initialize(env: Env, name: Symbol, description: Symbol, creator: Address) -> Collection {
todo!()
}

pub fn add_nft(env: Env, collection_id: u64, nft_contract_address: Address) {
todo!()
}

pub fn remove_nft(env: Env, collection_id: u64, nft_contract_address: Address) {
todo!()
}

pub fn get_details(env: Env, collection_id: u64) -> Collection {
todo!()
}

pub fn get_nfts(env: Env, collection_id: u64) -> Vec<Address> {
todo!()
}
}
10 changes: 1 addition & 9 deletions contracts/nft/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#![no_std]

// mod admin;
// mod approval;
// mod balance;
mod contract;
// mod event;
mod interface;
// mod metadata;
// mod owner;
mod storage_types;
use soroban_sdk::{contract, Address, Bytes, Env, Symbol, Vec};
Loading