Skip to content
Draft
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
931 changes: 862 additions & 69 deletions Cargo.lock

Large diffs are not rendered by default.

116 changes: 73 additions & 43 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
[package]
name = "pegasus"
version = "2.0.0"
[workspace]
members = [
"contracts/*",
"packages/*",
# "scripts",
]
# Enable the version 2 feature resolver, which avoids unifying features for targets that are not being built
#
# Critically this prevents dev-dependencies from enabling features even when not building a target that
# uses dev-dependencies, e.g. the library crate. This in turn ensures that we can catch invalid feature
# flag combinations that would otherwise only surface in dependent crates
#
# Reference - https://doc.rust-lang.org/nightly/cargo/reference/features.html#feature-resolver-version-2
# See - https://github.com/apache/arrow-rs/pull/1822/files
resolver = "2"

[workspace.package]
version = "0.2.0"
authors = [
"Maurits Bos <mb.brains@gmail.com>",
"Josef Leventon <josef.leventon@gmail.com>",
]
edition = "2018"

edition = "2021"


exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
Expand All @@ -15,54 +32,67 @@ exclude = [

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]
doctest = false
# Keep as is until TendermintStake updates.
[workspace.dependencies]
# abstract-sdk = { version = "0.12.0", git = "https://github.com/Abstract-OS/contracts.git" }
# abstract-api = { version = "0.12.0", git = "https://github.com/Abstract-OS/contracts.git" }
# abstract-app = { version = "0.12.0", git = "https://github.com/Abstract-OS/contracts.git" }
# abstract-os = { version = "0.12.0", git = "https://github.com/Abstract-OS/contracts.git" }
abstract-boot = { version = "0.13.0", git = "https://github.com/Abstract-OS/contracts.git" }
# abstract-testing = { version = "0.12.0", git = "https://github.com/Abstract-OS/contracts.git" }

[profile.release]
opt-level = 3
debug = false
rpath = false
lto = true
debug-assertions = false
codegen-units = 1
panic = 'abort'
incremental = false
overflow-checks = true

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []
# dex = { git = "https://github.com/Abstract-OS/apis.git" }
# cw-staking = { git = "https://github.com/Abstract-OS/apis.git" }
# # cw-staking = { path = "../../abstract/Apis/contracts/cw-staking" }

[package.metadata.scripts]
optimize = """docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.8
"""
# forty-two = { version = "0.3.11", path = "packages/forty-two" }
# forty-two-boot = { version = "0.3.11", path = "packages/forty-two-boot" }

[dependencies]
cosmwasm-std = { version = "1.1.0" }
cosmwasm-storage = { version = "1.1.0" }
pegasus = { path = "packages/pegasus" }
pegasus-boot = { path = "packages/pegasus-boot" }
cosmwasm-std = { version = "1.1" }
cosmwasm-schema = { version = "1.1" }
cw-asset = { version = "3.0" }
schemars = "0.8"
serde = { version = "1.0", default-features = false, features = ["derive"] }
thiserror = { version = "1.0" }
cw-storage-plus = "0.13.4"
cw2 = "0.13.4"
cw20 = "0.13.4"
cw-controllers = "1.0.1"
cw-paginate = { git = "https://github.com/DA0-DA0/dao-contracts.git", tag = "v1.0.0" }
cosmwasm-storage = { version = "1.1" }
cw-utils = "1.0.1"
cw721 = "0.13.4"
cw721-base = { version = "0.13.4", features = ["library"] }
schemars = "0.8.8"
serde = { version = "1.0.133", default-features = false, features = ["derive"] }
sg721 = { version = "0.12.0", features = ["library"] }
thiserror = { version = "1.0.30" }
sg-std = "0.12.1"
cw-utils = "0.13.4"
cw20 = "1.0.1"
cw2 = "1.0.1"
cw20-base = "1.0.1"
anyhow = { version = "1.0.51" }
cw-multi-test = "0.16.2"
rstest = "0.16.0"
speculoos = "0.11.0"
sg1 = "0.14.0"
sg-controllers = "0.12.1"
semver = "1.0.14"
cosmwasm-schema = "1.2.0"

# dev dependencies
tokio = { version = "1.4", features = ["full"] }
semver = { version = "1.0" }
dotenv = "0.15.0"
env_logger = "0.10.0"
log = "0.4.14"
clap = { version = "4.0.32", features = ["derive"] }
boot-core = { version = "0.8.0" }
boot-cw-plus = { version = "0.8.0" }
sg-multi-test = { version = "0.14.0" }

[dev-dependencies]
cw-multi-test = "0.13.4"
sg-multi-test = "0.14.0"
[profile.release]
rpath = false
lto = true
overflow-checks = true
opt-level = 3
debug = false
debug-assertions = false
panic = "abort"
codegen-units = 1
incremental = false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

### version 1.0.0 is currently available on Stargaze Mainnet
You can interact with it using our dedicated UI here: [pegasus-trade.zone](https://pegasus-trade.zone/).
You can interact with it using our dedicated UI here: [pegasus.zone](https://pegasus.zone/).
The contract interaction can be found on mintscan: https://www.mintscan.io/stargaze/wasm/code/14

# Peer-2-Peer NFT trade contract
Expand Down
71 changes: 71 additions & 0 deletions contracts/cw721-trade/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[package]
name = "cw721-trade"
version.workspace = true
authors.workspace = true
edition.workspace = true
publish = false
exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]
doctest = false

[profile.release]
opt-level = "s"
debug = false
rpath = false
lto = true
debug-assertions = false
codegen-units = 1
panic = 'abort'
incremental = false
overflow-checks = false

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[package.metadata.scripts]
optimize = """docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.8
"""

[dependencies]
cosmwasm-std = { workspace = true }
cosmwasm-storage = { workspace = true }
cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
cw20 = { workspace = true }
cw721 = { workspace = true }
cw721-base = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
sg721.workspace = true
sg-std = { workspace = true }
cw-utils = { workspace = true }
sg1 = { workspace = true }
sg-controllers = { workspace = true }
semver = { workspace = true }
cosmwasm-schema = { workspace = true }
pegasus = { workspace = true }
pegasus-boot = { workspace = true }
thiserror.workspace = true
abstract-boot = "0.13.0"


[dev-dependencies]
anyhow.workspace = true
boot-core.workspace = true
cw-multi-test.workspace = true
sg-multi-test = { workspace = true }
sg721.workspace = true
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_schema::write_api;
use pegasus::msg::{ExecuteMsg, InstantiateMsg, QueryMsg, SudoMsg};
use pegasus::cw721_trade::{ExecuteMsg, InstantiateMsg, QueryMsg, SudoMsg};

fn main() {
write_api! {
Expand Down
6 changes: 3 additions & 3 deletions src/contract.rs → contracts/cw721-trade/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use crate::execute::{
execute_accept_offer, execute_create_offer, execute_reject_offer, execute_remove_offer,
execute_remove_stale_offer,
};
use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg, SudoMsg};
use crate::query::{query_offer, query_offers_by_peer, query_offers_by_sender, query_params};
use crate::state::{SudoParams, MAX_EXPIRY, MIN_EXPIRY, SUDO_PARAMS};
use crate::state::{MAX_EXPIRY, MIN_EXPIRY, SUDO_PARAMS};
use crate::sudo::{sudo_update_params, ParamInfo};
use crate::ExpiryRangeError;
use pegasus::cw721_trade::{ExecuteMsg, InstantiateMsg, QueryMsg, SudoMsg};
use pegasus::cw721_trade::{ExpiryRangeError, SudoParams};

// use crate::query::{query_offers_by_sender};

Expand Down
2 changes: 1 addition & 1 deletion src/error.rs → contracts/cw721-trade/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use cosmwasm_std::StdError;
use cw_utils::PaymentError;
use thiserror::Error;

use crate::helpers::ExpiryRangeError;
use pegasus::cw721_trade::ExpiryRangeError;

#[derive(Error, Debug, PartialEq)]
pub enum ContractError {
Expand Down
4 changes: 2 additions & 2 deletions src/execute.rs → contracts/cw721-trade/src/execute.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::error::ContractError;
use crate::msg::TokenMsg;
use crate::query::query_offers_by_sender;
use crate::state::{next_offer_id, offers, Offer, Royalty, Token, SUDO_PARAMS};
use crate::state::{next_offer_id, offers, SUDO_PARAMS};
use pegasus::cw721_trade::{Offer, Royalty, Token, TokenMsg};
// use crate::query::{query_offers_by_sender};

use cosmwasm_std::{
Expand Down
24 changes: 24 additions & 0 deletions contracts/cw721-trade/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{to_binary, Addr, BlockInfo, StdError, StdResult, Timestamp, WasmMsg};
use pegasus::cw721_trade::ExecuteMsg;
use sg_std::CosmosMsg;

/// MarketplaceContract is a wrapper around Addr that provides a lot of helpers
#[cw_serde]
pub struct MarketplaceContract(pub Addr);

impl MarketplaceContract {
pub fn addr(&self) -> Addr {
self.0.clone()
}

pub fn call<T: Into<ExecuteMsg>>(&self, msg: T) -> StdResult<CosmosMsg> {
let msg = to_binary(&msg.into())?;
Ok(WasmMsg::Execute {
contract_addr: self.addr().into(),
msg,
funds: vec![],
}
.into())
}
}
2 changes: 0 additions & 2 deletions src/lib.rs → contracts/cw721-trade/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pub mod contract;
mod error;
mod execute;
mod helpers;
pub mod msg;
mod query;
pub mod state;
mod sudo;
Expand All @@ -12,4 +11,3 @@ mod multitest;
#[cfg(test)]
mod unit_tests;
pub use error::ContractError;
pub use helpers::{ExpiryRange, ExpiryRangeError, MarketplaceContract};
5 changes: 3 additions & 2 deletions src/multitest.rs → contracts/cw721-trade/src/multitest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use cosmwasm_std::{coins, Addr, Coin, Empty, Timestamp};
use cw721::{Cw721QueryMsg, OwnerOfResponse};
use cw721_base::msg::{ExecuteMsg as Cw721ExecuteMsg, MintMsg};
use cw_utils::Expiration;
use pegasus::cw721_trade::ExpiryRange;
use sg721::msg::InstantiateMsg as Sg721InstantiateMsg;
use sg721::state::CollectionInfo;

Expand All @@ -11,8 +12,8 @@ use sg_multi_test::StargazeApp;

use sg_std::{StargazeMsgWrapper, NATIVE_DENOM};

use crate::msg::{ExecuteMsg, OffersResponse, QueryMsg, TokenMsg};
use crate::ContractError;
use pegasus::cw721_trade::{ExecuteMsg, OffersResponse, QueryMsg, TokenMsg};

const CREATOR: &str = "creator";
const COLLECTION_A: &str = "collection-a";
Expand Down Expand Up @@ -64,7 +65,7 @@ fn setup_contracts(
// Instantiate marketplace contract
let p2p_contract_id = router.store_code(contract_p2p_trade());
let msg = crate::msg::InstantiateMsg {
offer_expiry: crate::ExpiryRange {
offer_expiry: ExpiryRange {
min: MIN_EXPIRY,
max: MAX_EXPIRY,
},
Expand Down
2 changes: 1 addition & 1 deletion src/query.rs → contracts/cw721-trade/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::msg::{OfferResponse, OffersResponse, ParamsResponse};
use crate::state::{offers, SUDO_PARAMS};
use cosmwasm_std::{Addr, Deps, Order, StdResult};
use pegasus::cw721_trade::{OfferResponse, OffersResponse, ParamsResponse};

// Query limits
// const DEFAULT_QUERY_LIMIT: u32 = 10;
Expand Down
Loading