From 89ec1ef52329f15ff0141eb272f0c9dd7495d0bc Mon Sep 17 00:00:00 2001 From: Maurits Bos Date: Fri, 31 Mar 2023 13:38:05 +0200 Subject: [PATCH 1/4] refactored for boot --- Cargo.lock | 270 +++++++++++++++---- Cargo.toml | 115 +++++--- contracts/pegasus/Cargo.toml | 66 +++++ {src => contracts/pegasus/src}/bin/schema.rs | 2 +- {src => contracts/pegasus/src}/contract.rs | 6 +- {src => contracts/pegasus/src}/error.rs | 2 +- {src => contracts/pegasus/src}/execute.rs | 4 +- contracts/pegasus/src/helpers.rs | 24 ++ {src => contracts/pegasus/src}/lib.rs | 2 - {src => contracts/pegasus/src}/multitest.rs | 3 +- {src => contracts/pegasus/src}/query.rs | 2 +- {src => contracts/pegasus/src}/state.rs | 65 +---- {src => contracts/pegasus/src}/sudo.rs | 3 +- {src => contracts/pegasus/src}/unit_tests.rs | 9 +- packages/interfaces/Cargo.toml | 9 + packages/interfaces/src/lib.rs | 14 + packages/pegasus-trade/Cargo.toml | 12 + packages/pegasus-trade/src/lib.rs | 1 + packages/pegasus-trade/src/pegasus.rs | 194 +++++++++++++ src/helpers.rs | 72 ----- src/msg.rs | 89 ------ 21 files changed, 619 insertions(+), 345 deletions(-) create mode 100644 contracts/pegasus/Cargo.toml rename {src => contracts/pegasus/src}/bin/schema.rs (70%) rename {src => contracts/pegasus/src}/contract.rs (96%) rename {src => contracts/pegasus/src}/error.rs (97%) rename {src => contracts/pegasus/src}/execute.rs (99%) create mode 100644 contracts/pegasus/src/helpers.rs rename {src => contracts/pegasus/src}/lib.rs (68%) rename {src => contracts/pegasus/src}/multitest.rs (99%) rename {src => contracts/pegasus/src}/query.rs (93%) rename {src => contracts/pegasus/src}/state.rs (53%) rename {src => contracts/pegasus/src}/sudo.rs (96%) rename {src => contracts/pegasus/src}/unit_tests.rs (97%) create mode 100644 packages/interfaces/Cargo.toml create mode 100644 packages/interfaces/src/lib.rs create mode 100644 packages/pegasus-trade/Cargo.toml create mode 100644 packages/pegasus-trade/src/lib.rs create mode 100644 packages/pegasus-trade/src/pegasus.rs delete mode 100644 src/helpers.rs delete mode 100644 src/msg.rs diff --git a/Cargo.lock b/Cargo.lock index 00b3fda..d1ec841 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,6 +44,46 @@ dependencies = [ "generic-array", ] +[[package]] +name = "boot-contract-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6710d266d584cbd27ed9ad98b03beba25cc6312decf53e165954acc7334e5286" +dependencies = [ + "quote", + "syn 1.0.99", +] + +[[package]] +name = "boot-core" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c1da1a219c4d6b79f133f836e032bce4cda4bb0998c95bc3fe6ac7dfb50cd2" +dependencies = [ + "anyhow", + "boot-contract-derive", + "boot-fns-derive", + "cosmwasm-std", + "cw-multi-test 0.16.2", + "log", + "schemars", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "boot-fns-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68b4307f1c27ffe0dcdfa63882069bdc1f8c3246e706a4b1ce45e126a1ff4bcf" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "syn 1.0.99", +] + [[package]] name = "byteorder" version = "1.4.3" @@ -68,11 +108,20 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "cosmwasm-crypto" -version = "1.2.0" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb56fffc2233212e9546df66e01267277173d55f6237ab939690ef2c5cfd50c2" +checksum = "f22add0f9b2a5416df98c1d0248a8d8eedb882c38fbf0c5052b64eebe865df6d" dependencies = [ "digest 0.10.6", "ed25519-zebra", @@ -83,18 +132,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.2.0" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e26a78e202d602a23fd5d13dff898732814ebe7a8bde20f1bf71eb0209d56d56" +checksum = "c2e64f710a18ef90d0a632cf27842e98ffc2d005a38a6f76c12fd0bc03bc1a2d" dependencies = [ - "syn", + "syn 1.0.99", ] [[package]] name = "cosmwasm-schema" -version = "1.2.0" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a3dfcfa0c6f4b9aef8820c0a999410f239828a4503a388ce8e55f59fe3ac863" +checksum = "fe5ad2e23a971b9e4cd57b20cee3e2e79c33799bed4b128e473aca3702bfe5dd" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -105,20 +154,20 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.2.0" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19cd48063eef5b92a0aabcf0687705802178ae175571dfdc5f3b925d0741d39" +checksum = "2926d159a9bb1a716a592b40280f1663f2491a9de3b6da77c0933cee2a2655b8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] name = "cosmwasm-std" -version = "1.2.0" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b50f4deaed6196047a3ceec9bc23e85d4292b73442d77af63723842d8b6049d" +checksum = "76fee88ff5bf7bef55bd37ac0619974701b99bf6bd4b16cf56ee8810718abd71" dependencies = [ "base64", "cosmwasm-crypto", @@ -136,9 +185,9 @@ dependencies = [ [[package]] name = "cosmwasm-storage" -version = "1.2.0" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c91b9880577b6fa389f60bbcc8daab202996150c51ed0d14e6532a87a764a7d5" +checksum = "639bc36408bc1ac45e3323166ceeb8f0b91b55a941c4ad59d389829002fbbd94" dependencies = [ "cosmwasm-std", "serde", @@ -203,10 +252,29 @@ dependencies = [ "anyhow", "cosmwasm-std", "cosmwasm-storage", - "cw-storage-plus", - "cw-utils", + "cw-storage-plus 0.13.4", + "cw-utils 0.13.4", + "derivative", + "itertools", + "prost", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "cw-multi-test" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2eb84554bbfa6b66736abcd6a9bfdf237ee0ecb83910f746dff7f799093c80a" +dependencies = [ + "anyhow", + "cosmwasm-std", + "cw-storage-plus 1.0.1", + "cw-utils 1.0.1", "derivative", "itertools", + "k256", "prost", "schemars", "serde", @@ -224,6 +292,17 @@ dependencies = [ "serde", ] +[[package]] +name = "cw-storage-plus" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053a5083c258acd68386734f428a5a171b29f7d733151ae83090c6fcc9417ffa" +dependencies = [ + "cosmwasm-std", + "schemars", + "serde", +] + [[package]] name = "cw-utils" version = "0.13.4" @@ -236,6 +315,21 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cw-utils" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c80e93d1deccb8588db03945016a292c3c631e6325d349ebb35d2db6f4f946f7" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw2 1.0.1", + "schemars", + "semver", + "serde", + "thiserror", +] + [[package]] name = "cw2" version = "0.13.4" @@ -243,19 +337,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04cf4639517490dd36b333bbd6c4fbd92e325fd0acf4683b41753bc5eb63bfc1" dependencies = [ "cosmwasm-std", - "cw-storage-plus", + "cw-storage-plus 0.13.4", + "schemars", + "serde", +] + +[[package]] +name = "cw2" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fb70cee2cf0b4a8ff7253e6bc6647107905e8eb37208f87d54f67810faa62f8" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 1.0.1", "schemars", "serde", ] [[package]] name = "cw20" -version = "0.13.4" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cb782b8f110819a4eb5dbbcfed25ffba49ec16bbe32b4ad8da50a5ce68fec05" +checksum = "91666da6c7b40c8dd5ff94df655a28114efc10c79b70b4d06f13c31e37d60609" dependencies = [ + "cosmwasm-schema", "cosmwasm-std", - "cw-utils", + "cw-utils 1.0.1", "schemars", "serde", ] @@ -267,7 +375,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "035818368a74c07dd9ed5c5a93340199ba251530162010b9f34c3809e3b97df1" dependencies = [ "cosmwasm-std", - "cw-utils", + "cw-utils 0.13.4", "schemars", "serde", ] @@ -279,9 +387,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "423d4efe8b649d228d1533e141c238415f49aa8a9ee4e40fce192d7a93ffd057" dependencies = [ "cosmwasm-std", - "cw-storage-plus", - "cw-utils", - "cw2", + "cw-storage-plus 0.13.4", + "cw-utils 0.13.4", + "cw2 0.13.4", "cw721", "schemars", "serde", @@ -306,7 +414,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] @@ -483,6 +591,13 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "interfaces" +version = "0.1.0" +dependencies = [ + "boot-core", +] + [[package]] name = "itertools" version = "0.10.3" @@ -516,6 +631,15 @@ version = "0.2.132" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + [[package]] name = "matches" version = "0.1.9" @@ -530,18 +654,19 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "pegasus" -version = "2.0.0" +version = "0.2.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", - "cw-multi-test", - "cw-storage-plus", - "cw-utils", - "cw2", + "cw-multi-test 0.16.2", + "cw-storage-plus 0.13.4", + "cw-utils 1.0.1", + "cw2 1.0.1", "cw20", "cw721", "cw721-base", + "pegasus-trade", "schemars", "semver", "serde", @@ -553,6 +678,16 @@ dependencies = [ "thiserror", ] +[[package]] +name = "pegasus-trade" +version = "0.1.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 0.13.4", + "thiserror", +] + [[package]] name = "percent-encoding" version = "2.1.0" @@ -571,9 +706,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.43" +version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" +checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534" dependencies = [ "unicode-ident", ] @@ -598,14 +733,14 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] name = "quote" -version = "1.0.21" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] @@ -647,9 +782,9 @@ checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] name = "schemars" -version = "0.8.10" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1847b767a3d62d95cbf3d8a9f0e421cf57a0d8aa4f411d4b16525afb0284d4ed" +checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" dependencies = [ "dyn-clone", "schemars_derive", @@ -659,14 +794,14 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.10" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4d7e1b012cb3d9129567661a63755ea4b8a7386d339dc945ae187e403c6743" +checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn", + "syn 1.0.99", ] [[package]] @@ -691,9 +826,9 @@ checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" [[package]] name = "serde" -version = "1.0.144" +version = "1.0.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860" +checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" dependencies = [ "serde_derive", ] @@ -709,13 +844,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.144" +version = "1.0.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00" +checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.12", ] [[package]] @@ -726,7 +861,7 @@ checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] @@ -747,7 +882,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f15d56b2de4fd96bf55b73b6d533b3521873d51004c822f50e9f5f099dae47c" dependencies = [ "cosmwasm-std", - "cw-storage-plus", + "cw-storage-plus 0.13.4", "schemars", "serde", "sg-std", @@ -762,7 +897,7 @@ checksum = "5957430ba35756401a05081054cff7de27fd1b38fa600960c7a5c6586b22a326" dependencies = [ "anyhow", "cosmwasm-std", - "cw-multi-test", + "cw-multi-test 0.13.4", "schemars", "serde", "sg-std", @@ -775,7 +910,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07130302e5e6cf53351196e70f04b0c86b45b886ab93120bc6884596e1aeb782" dependencies = [ "cosmwasm-std", - "cw-utils", + "cw-utils 0.13.4", "cw721", "cw721-base", "schemars", @@ -790,7 +925,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b9b26273bdcfd32e1f8adfd99a4d168717fa5adc570c8b67b4081037791e212" dependencies = [ "cosmwasm-std", - "cw-utils", + "cw-utils 0.13.4", "serde", "sg-std", "thiserror", @@ -803,7 +938,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c1673ed8ac3ed540cb091cd350cf7c6f1f162587254ed04ae9947f54af98710" dependencies = [ "cosmwasm-std", - "cw-utils", + "cw-utils 0.13.4", "serde", "sg-std", "thiserror", @@ -817,9 +952,9 @@ checksum = "10578a37c6be874e4db80d9d9231d834c751154c6b2c8f1e5facff03edf4ab08" dependencies = [ "cosmwasm-std", "cosmwasm-storage", - "cw-storage-plus", - "cw-utils", - "cw2", + "cw-storage-plus 0.13.4", + "cw-utils 0.13.4", + "cw2 0.13.4", "cw721", "cw721-base", "schemars", @@ -897,24 +1032,35 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "thiserror" -version = "1.0.32" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.32" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.12", ] [[package]] @@ -971,6 +1117,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + [[package]] name = "url" version = "2.2.2" diff --git a/Cargo.toml b/Cargo.toml index c51d42d..5e3ad67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 ", "Josef Leventon ", ] -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. @@ -15,54 +32,66 @@ 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-trade = { path = "packages/pegasus-trade" } +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" +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 diff --git a/contracts/pegasus/Cargo.toml b/contracts/pegasus/Cargo.toml new file mode 100644 index 0000000..0cdb135 --- /dev/null +++ b/contracts/pegasus/Cargo.toml @@ -0,0 +1,66 @@ +[package] +name = "pegasus" +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-trade = { workspace = true } +thiserror.workspace = true + + +[dev-dependencies] +cw-multi-test = { workspace = true } +sg-multi-test = { workspace = true } diff --git a/src/bin/schema.rs b/contracts/pegasus/src/bin/schema.rs similarity index 70% rename from src/bin/schema.rs rename to contracts/pegasus/src/bin/schema.rs index 7e307b6..0a92e19 100644 --- a/src/bin/schema.rs +++ b/contracts/pegasus/src/bin/schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use pegasus::msg::{ExecuteMsg, InstantiateMsg, QueryMsg, SudoMsg}; +use pegasus_trade::pegasus::{ExecuteMsg, InstantiateMsg, QueryMsg, SudoMsg}; fn main() { write_api! { diff --git a/src/contract.rs b/contracts/pegasus/src/contract.rs similarity index 96% rename from src/contract.rs rename to contracts/pegasus/src/contract.rs index 08af276..f2dd5f1 100644 --- a/src/contract.rs +++ b/contracts/pegasus/src/contract.rs @@ -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_trade::pegasus::{ExecuteMsg, InstantiateMsg, QueryMsg, SudoMsg}; +use pegasus_trade::pegasus::{ExpiryRangeError, SudoParams}; // use crate::query::{query_offers_by_sender}; diff --git a/src/error.rs b/contracts/pegasus/src/error.rs similarity index 97% rename from src/error.rs rename to contracts/pegasus/src/error.rs index 3792b54..4546dc3 100644 --- a/src/error.rs +++ b/contracts/pegasus/src/error.rs @@ -2,7 +2,7 @@ use cosmwasm_std::StdError; use cw_utils::PaymentError; use thiserror::Error; -use crate::helpers::ExpiryRangeError; +use pegasus_trade::pegasus::ExpiryRangeError; #[derive(Error, Debug, PartialEq)] pub enum ContractError { diff --git a/src/execute.rs b/contracts/pegasus/src/execute.rs similarity index 99% rename from src/execute.rs rename to contracts/pegasus/src/execute.rs index 85250cb..b4a150d 100644 --- a/src/execute.rs +++ b/contracts/pegasus/src/execute.rs @@ -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_trade::pegasus::{Offer, Royalty, Token, TokenMsg}; // use crate::query::{query_offers_by_sender}; use cosmwasm_std::{ diff --git a/contracts/pegasus/src/helpers.rs b/contracts/pegasus/src/helpers.rs new file mode 100644 index 0000000..4c6ef97 --- /dev/null +++ b/contracts/pegasus/src/helpers.rs @@ -0,0 +1,24 @@ +use cosmwasm_schema::cw_serde; +use cosmwasm_std::{to_binary, Addr, BlockInfo, StdError, StdResult, Timestamp, WasmMsg}; +use pegasus_trade::pegasus::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>(&self, msg: T) -> StdResult { + let msg = to_binary(&msg.into())?; + Ok(WasmMsg::Execute { + contract_addr: self.addr().into(), + msg, + funds: vec![], + } + .into()) + } +} diff --git a/src/lib.rs b/contracts/pegasus/src/lib.rs similarity index 68% rename from src/lib.rs rename to contracts/pegasus/src/lib.rs index 0c1395c..32e1ccd 100644 --- a/src/lib.rs +++ b/contracts/pegasus/src/lib.rs @@ -2,7 +2,6 @@ pub mod contract; mod error; mod execute; mod helpers; -pub mod msg; mod query; pub mod state; mod sudo; @@ -12,4 +11,3 @@ mod multitest; #[cfg(test)] mod unit_tests; pub use error::ContractError; -pub use helpers::{ExpiryRange, ExpiryRangeError, MarketplaceContract}; diff --git a/src/multitest.rs b/contracts/pegasus/src/multitest.rs similarity index 99% rename from src/multitest.rs rename to contracts/pegasus/src/multitest.rs index 3a16a87..085bdca 100644 --- a/src/multitest.rs +++ b/contracts/pegasus/src/multitest.rs @@ -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_trade::pegasus::ExpiryRange; use sg721::msg::InstantiateMsg as Sg721InstantiateMsg; use sg721::state::CollectionInfo; @@ -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, }, diff --git a/src/query.rs b/contracts/pegasus/src/query.rs similarity index 93% rename from src/query.rs rename to contracts/pegasus/src/query.rs index 3fe1a4f..8ca8340 100644 --- a/src/query.rs +++ b/contracts/pegasus/src/query.rs @@ -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_trade::pegasus::{OfferResponse, OffersResponse, ParamsResponse}; // Query limits // const DEFAULT_QUERY_LIMIT: u32 = 10; diff --git a/src/state.rs b/contracts/pegasus/src/state.rs similarity index 53% rename from src/state.rs rename to contracts/pegasus/src/state.rs index 22e2c81..98b72b1 100644 --- a/src/state.rs +++ b/contracts/pegasus/src/state.rs @@ -1,75 +1,14 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Coin, StdResult, Storage, Timestamp}; use cw_storage_plus::{Index, IndexList, IndexedMap, Item, MultiIndex, UniqueIndex}; - -use crate::helpers::ExpiryRange; - +use pegasus_trade::pegasus::{ExpiryRange, Offer, SudoParams}; pub const MIN_EXPIRY: u64 = 3600 * 24; // seconds -> one day -pub const MAX_EXPIRY: u64 = 3600 * 24 * 28; // seconds -> one month - -#[cw_serde] -pub struct SudoParams { - /// Valid time range for Offers - /// (min, max) in seconds - pub offer_expiry: ExpiryRange, - - /// Developer address - pub maintainer: Addr, - - /// Maximum amount of offers a user can send - pub max_offers: u64, - - /// Maximum amount of NFTs in bundle - pub bundle_limit: u64, -} +pub const MAX_EXPIRY: u64 = 3600 * 24 * 28; // seconds -> one monthst M pub const SUDO_PARAMS: Item = Item::new("sudo-params"); - -pub type TokenId = u32; - -/// Represents a token that can be offered -#[cw_serde] -pub struct Token { - pub collection: Addr, - pub token_id: TokenId, -} - -/// Represents a set of royalties to be paid out to a creator -#[cw_serde] -pub struct Royalty { - pub creator: Addr, - pub amount: Coin, -} - -/// Represents an ask on the marketplace -#[cw_serde] -pub struct Offer { - /// Unique identifier - pub id: u64, - - /// Arrays of offered & wanted NFTs, both defined by the sender - pub offered_nfts: Vec, - pub wanted_nfts: Vec, - - /// Array of offered native/ibc tokens, defined by sender - pub offered_balances: Vec, - - /// Optional text message from the sender - pub message: Option, - - /// Royalties to be paid out to creators when native/ibc tokens are involved - pub royalties: Vec, - - pub sender: Addr, - pub peer: Addr, - pub created_at: Timestamp, - pub expires_at: Timestamp, -} - // Incrementing ID counter pub const OFFER_ID_COUNTER: Item = Item::new("offer_id_counter"); -// Get next incrementing ID pub fn next_offer_id(store: &mut dyn Storage) -> StdResult { let id: u64 = OFFER_ID_COUNTER.may_load(store)?.unwrap_or_default() + 1; OFFER_ID_COUNTER.save(store, &id)?; diff --git a/src/sudo.rs b/contracts/pegasus/src/sudo.rs similarity index 96% rename from src/sudo.rs rename to contracts/pegasus/src/sudo.rs index e79e968..e551717 100644 --- a/src/sudo.rs +++ b/contracts/pegasus/src/sudo.rs @@ -1,8 +1,7 @@ -use crate::helpers::ExpiryRange; use crate::state::{MAX_EXPIRY, SUDO_PARAMS}; -use crate::ExpiryRangeError; use crate::{error::ContractError, state::MIN_EXPIRY}; use cosmwasm_std::{DepsMut, Env}; +use pegasus_trade::pegasus::{ExpiryRange, ExpiryRangeError}; use sg_std::Response; pub struct ParamInfo { diff --git a/src/unit_tests.rs b/contracts/pegasus/src/unit_tests.rs similarity index 97% rename from src/unit_tests.rs rename to contracts/pegasus/src/unit_tests.rs index c291b32..b1ec399 100644 --- a/src/unit_tests.rs +++ b/contracts/pegasus/src/unit_tests.rs @@ -2,13 +2,10 @@ use crate::error::ContractError; use crate::contract::{execute, instantiate, sudo}; -use crate::msg::{ExecuteMsg, SudoMsg}; use crate::query::{query_offers_by_peer, query_offers_by_sender}; use crate::state::{offers, MAX_EXPIRY, MIN_EXPIRY}; -use crate::{ - msg::InstantiateMsg, - state::{Offer, Token}, - ExpiryRange, +use pegasus_trade::pegasus::{ + ExecuteMsg, ExpiryRange, ExpiryRangeError, InstantiateMsg, Offer, SudoMsg, Token, }; use cosmwasm_std::{testing::*, Addr, Coin, DepsMut, StdError, Timestamp}; @@ -185,7 +182,7 @@ fn test_sudo_update() { let err = sudo(deps.as_mut(), env, sudo_msg).unwrap_err(); assert_eq!( err, - ContractError::ExpiryRange(crate::ExpiryRangeError::InvalidExpirationRange {}) + ContractError::ExpiryRange(ExpiryRangeError::InvalidExpirationRange {}) ); } diff --git a/packages/interfaces/Cargo.toml b/packages/interfaces/Cargo.toml new file mode 100644 index 0000000..73de947 --- /dev/null +++ b/packages/interfaces/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "interfaces" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +boot-core.workspace = true diff --git a/packages/interfaces/src/lib.rs b/packages/interfaces/src/lib.rs new file mode 100644 index 0000000..7d12d9a --- /dev/null +++ b/packages/interfaces/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/packages/pegasus-trade/Cargo.toml b/packages/pegasus-trade/Cargo.toml new file mode 100644 index 0000000..a904093 --- /dev/null +++ b/packages/pegasus-trade/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "pegasus-trade" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +cosmwasm-schema = { workspace = true } +cosmwasm-std = { workspace = true } +cw-storage-plus = { workspace = true } +thiserror = { version = "1.0.30" } diff --git a/packages/pegasus-trade/src/lib.rs b/packages/pegasus-trade/src/lib.rs new file mode 100644 index 0000000..12227a4 --- /dev/null +++ b/packages/pegasus-trade/src/lib.rs @@ -0,0 +1 @@ +pub mod pegasus; diff --git a/packages/pegasus-trade/src/pegasus.rs b/packages/pegasus-trade/src/pegasus.rs new file mode 100644 index 0000000..7597d7c --- /dev/null +++ b/packages/pegasus-trade/src/pegasus.rs @@ -0,0 +1,194 @@ +use cosmwasm_schema::{cw_serde, QueryResponses}; +use cosmwasm_std::{Addr, BlockInfo, Coin, StdError, Timestamp}; +use thiserror::Error; + +#[cw_serde] +pub struct InstantiateMsg { + /// Valid time range for Offers + /// (min, max) in seconds + pub offer_expiry: ExpiryRange, + + /// Developer address + pub maintainer: String, + + /// Maximum amount of offers that can be sent by a user + pub max_offers: u64, + + /// Maximum amount of NFTs in bundle + pub bundle_limit: u64, +} + +#[cw_serde] +pub struct TokenMsg { + pub collection: String, + pub token_id: u32, +} + +#[cw_serde] +pub enum ExecuteMsg { + /// Create a new offer + CreateOffer { + offered_nfts: Vec, + wanted_nfts: Vec, + offered_balances: Vec, + message: Option, + peer: String, + expires_at: Option, + }, + /// Remove an offer (called by sender) + RemoveOffer { id: u64 }, + /// Accept an existing offer (called by peer) + AcceptOffer { id: u64 }, + /// Reject an existing offer (called by peer) + RejectOffer { id: u64 }, + /// Operation to remove stale offers (called by anyone & incentivized) + RemoveStaleOffer { id: u64 }, +} + +#[cw_serde] +pub enum SudoMsg { + /// Update the contract parameters + /// Can only be called by governance + UpdateParams { + offer_expiry: Option, + maintainer: Option, + max_offers: Option, + bundle_limit: Option, + }, +} + +#[cw_serde] +#[derive(QueryResponses)] +pub enum QueryMsg { + #[returns(OfferResponse)] + Offer { id: u64 }, + #[returns(OffersResponse)] + OffersBySender { sender: String }, + #[returns(OffersResponse)] + OffersByPeer { peer: String }, + #[returns(ParamsResponse)] + Params {}, +} + +#[cw_serde] +pub struct OfferResponse { + pub offer: Option, +} + +#[cw_serde] +pub struct OffersResponse { + pub offers: Vec, +} + +#[cw_serde] +pub struct ParamsResponse { + pub params: SudoParams, +} + +#[cw_serde] +pub struct SudoParams { + /// Valid time range for Offers + /// (min, max) in seconds + pub offer_expiry: ExpiryRange, + + /// Developer address + pub maintainer: Addr, + + /// Maximum amount of offers a user can send + pub max_offers: u64, + + /// Maximum amount of NFTs in bundle + pub bundle_limit: u64, +} + +pub type TokenId = u32; + +/// Represents a token that can be offered +#[cw_serde] +pub struct Token { + pub collection: Addr, + pub token_id: TokenId, +} + +/// Represents a set of royalties to be paid out to a creator +#[cw_serde] +pub struct Royalty { + pub creator: Addr, + pub amount: Coin, +} + +/// Represents an ask on the marketplace +#[cw_serde] +pub struct Offer { + /// Unique identifier + pub id: u64, + + /// Arrays of offered & wanted NFTs, both defined by the sender + pub offered_nfts: Vec, + pub wanted_nfts: Vec, + + /// Array of offered native/ibc tokens, defined by sender + pub offered_balances: Vec, + + /// Optional text message from the sender + pub message: Option, + + /// Royalties to be paid out to creators when native/ibc tokens are involved + pub royalties: Vec, + + pub sender: Addr, + pub peer: Addr, + pub created_at: Timestamp, + pub expires_at: Timestamp, +} + +// Incrementing ID counter + +// Get next incrementing ID + +#[derive(Error, Debug, PartialEq)] +pub enum ExpiryRangeError { + #[error("{0}")] + Std(#[from] StdError), + + #[error("Invalid expiration range")] + InvalidExpirationRange {}, + + #[error("Expiry min > max")] + InvalidExpiry {}, +} + +#[cw_serde] +pub struct ExpiryRange { + pub min: u64, + pub max: u64, +} + +impl ExpiryRange { + pub fn new(min: u64, max: u64) -> Self { + ExpiryRange { min, max } + } + + /// Validates if given expires time is within the allowable range + pub fn is_valid( + &self, + block: &BlockInfo, + created_at: Timestamp, + expires: Timestamp, + ) -> Result<(), ExpiryRangeError> { + let now = block.time; + if !(expires > created_at.plus_seconds(self.min) && expires <= now.plus_seconds(self.max)) { + return Err(ExpiryRangeError::InvalidExpirationRange {}); + } + + Ok(()) + } + + pub fn validate(&self) -> Result<(), ExpiryRangeError> { + if self.min > self.max { + return Err(ExpiryRangeError::InvalidExpiry {}); + } + + Ok(()) + } +} diff --git a/src/helpers.rs b/src/helpers.rs deleted file mode 100644 index 8cad92b..0000000 --- a/src/helpers.rs +++ /dev/null @@ -1,72 +0,0 @@ -use crate::msg::ExecuteMsg; -use cosmwasm_schema::cw_serde; -use cosmwasm_std::{to_binary, Addr, BlockInfo, StdError, StdResult, Timestamp, WasmMsg}; -use sg_std::CosmosMsg; -use thiserror::Error; - -/// 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>(&self, msg: T) -> StdResult { - let msg = to_binary(&msg.into())?; - Ok(WasmMsg::Execute { - contract_addr: self.addr().into(), - msg, - funds: vec![], - } - .into()) - } -} - -#[derive(Error, Debug, PartialEq)] -pub enum ExpiryRangeError { - #[error("{0}")] - Std(#[from] StdError), - - #[error("Invalid expiration range")] - InvalidExpirationRange {}, - - #[error("Expiry min > max")] - InvalidExpiry {}, -} - -#[cw_serde] -pub struct ExpiryRange { - pub min: u64, - pub max: u64, -} - -impl ExpiryRange { - pub fn new(min: u64, max: u64) -> Self { - ExpiryRange { min, max } - } - - /// Validates if given expires time is within the allowable range - pub fn is_valid( - &self, - block: &BlockInfo, - created_at: Timestamp, - expires: Timestamp, - ) -> Result<(), ExpiryRangeError> { - let now = block.time; - if !(expires > created_at.plus_seconds(self.min) && expires <= now.plus_seconds(self.max)) { - return Err(ExpiryRangeError::InvalidExpirationRange {}); - } - - Ok(()) - } - - pub fn validate(&self) -> Result<(), ExpiryRangeError> { - if self.min > self.max { - return Err(ExpiryRangeError::InvalidExpiry {}); - } - - Ok(()) - } -} diff --git a/src/msg.rs b/src/msg.rs deleted file mode 100644 index 86ecc0d..0000000 --- a/src/msg.rs +++ /dev/null @@ -1,89 +0,0 @@ -use crate::{ - helpers::ExpiryRange, - state::{Offer, SudoParams}, -}; -use cosmwasm_schema::{cw_serde, QueryResponses}; -use cosmwasm_std::{Coin, Timestamp}; - -#[cw_serde] -pub struct InstantiateMsg { - /// Valid time range for Offers - /// (min, max) in seconds - pub offer_expiry: ExpiryRange, - - /// Developer address - pub maintainer: String, - - /// Maximum amount of offers that can be sent by a user - pub max_offers: u64, - - /// Maximum amount of NFTs in bundle - pub bundle_limit: u64, -} - -#[cw_serde] -pub struct TokenMsg { - pub collection: String, - pub token_id: u32, -} - -#[cw_serde] -pub enum ExecuteMsg { - /// Create a new offer - CreateOffer { - offered_nfts: Vec, - wanted_nfts: Vec, - offered_balances: Vec, - message: Option, - peer: String, - expires_at: Option, - }, - /// Remove an offer (called by sender) - RemoveOffer { id: u64 }, - /// Accept an existing offer (called by peer) - AcceptOffer { id: u64 }, - /// Reject an existing offer (called by peer) - RejectOffer { id: u64 }, - /// Operation to remove stale offers (called by anyone & incentivized) - RemoveStaleOffer { id: u64 }, -} - -#[cw_serde] -pub enum SudoMsg { - /// Update the contract parameters - /// Can only be called by governance - UpdateParams { - offer_expiry: Option, - maintainer: Option, - max_offers: Option, - bundle_limit: Option, - }, -} - -#[cw_serde] -#[derive(QueryResponses)] -pub enum QueryMsg { - #[returns(OfferResponse)] - Offer { id: u64 }, - #[returns(OffersResponse)] - OffersBySender { sender: String }, - #[returns(OffersResponse)] - OffersByPeer { peer: String }, - #[returns(ParamsResponse)] - Params {}, -} - -#[cw_serde] -pub struct OfferResponse { - pub offer: Option, -} - -#[cw_serde] -pub struct OffersResponse { - pub offers: Vec, -} - -#[cw_serde] -pub struct ParamsResponse { - pub params: SudoParams, -} From 1fbfed168aa5fea98729a02a15b2e12cf78b9c78 Mon Sep 17 00:00:00 2001 From: Maurits Bos Date: Fri, 31 Mar 2023 14:37:19 +0200 Subject: [PATCH 2/4] renamed --- Cargo.lock | 61 ++++++++++--------- Cargo.toml | 2 +- README.md | 2 +- contracts/{pegasus => cw721-trade}/Cargo.toml | 4 +- .../src/bin/schema.rs | 2 +- .../{pegasus => cw721-trade}/src/contract.rs | 4 +- .../{pegasus => cw721-trade}/src/error.rs | 2 +- .../{pegasus => cw721-trade}/src/execute.rs | 2 +- .../{pegasus => cw721-trade}/src/helpers.rs | 2 +- contracts/{pegasus => cw721-trade}/src/lib.rs | 0 .../{pegasus => cw721-trade}/src/multitest.rs | 2 +- .../{pegasus => cw721-trade}/src/query.rs | 2 +- .../{pegasus => cw721-trade}/src/state.rs | 2 +- .../{pegasus => cw721-trade}/src/sudo.rs | 2 +- .../src/unit_tests.rs | 2 +- packages/interfaces/src/lib.rs | 14 ----- .../{interfaces => pegasus-boot}/Cargo.toml | 7 ++- packages/pegasus-boot/src/cw721_trade.rs | 18 ++++++ packages/pegasus-boot/src/lib.rs | 2 + packages/pegasus-trade/src/lib.rs | 1 - .../{pegasus-trade => pegasus}/Cargo.toml | 2 +- .../pegasus.rs => pegasus/src/cw721_trade.rs} | 13 ++++ packages/pegasus/src/lib.rs | 1 + 23 files changed, 85 insertions(+), 64 deletions(-) rename contracts/{pegasus => cw721-trade}/Cargo.toml (97%) rename contracts/{pegasus => cw721-trade}/src/bin/schema.rs (70%) rename contracts/{pegasus => cw721-trade}/src/contract.rs (97%) rename contracts/{pegasus => cw721-trade}/src/error.rs (97%) rename contracts/{pegasus => cw721-trade}/src/execute.rs (99%) rename contracts/{pegasus => cw721-trade}/src/helpers.rs (94%) rename contracts/{pegasus => cw721-trade}/src/lib.rs (100%) rename contracts/{pegasus => cw721-trade}/src/multitest.rs (99%) rename contracts/{pegasus => cw721-trade}/src/query.rs (93%) rename contracts/{pegasus => cw721-trade}/src/state.rs (96%) rename contracts/{pegasus => cw721-trade}/src/sudo.rs (96%) rename contracts/{pegasus => cw721-trade}/src/unit_tests.rs (99%) delete mode 100644 packages/interfaces/src/lib.rs rename packages/{interfaces => pegasus-boot}/Cargo.toml (56%) create mode 100644 packages/pegasus-boot/src/cw721_trade.rs create mode 100644 packages/pegasus-boot/src/lib.rs delete mode 100644 packages/pegasus-trade/src/lib.rs rename packages/{pegasus-trade => pegasus}/Cargo.toml (93%) rename packages/{pegasus-trade/src/pegasus.rs => pegasus/src/cw721_trade.rs} (89%) create mode 100644 packages/pegasus/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index d1ec841..ac5ec0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -396,6 +396,32 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cw721-trade" +version = "0.2.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cosmwasm-storage", + "cw-multi-test 0.16.2", + "cw-storage-plus 0.13.4", + "cw-utils 1.0.1", + "cw2 1.0.1", + "cw20", + "cw721", + "cw721-base", + "pegasus", + "schemars", + "semver", + "serde", + "sg-controllers", + "sg-multi-test", + "sg-std", + "sg1 0.14.0", + "sg721", + "thiserror", +] + [[package]] name = "der" version = "0.6.1" @@ -591,13 +617,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "interfaces" -version = "0.1.0" -dependencies = [ - "boot-core", -] - [[package]] name = "itertools" version = "0.10.3" @@ -654,38 +673,20 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "pegasus" -version = "0.2.0" +version = "0.1.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cosmwasm-storage", - "cw-multi-test 0.16.2", "cw-storage-plus 0.13.4", - "cw-utils 1.0.1", - "cw2 1.0.1", - "cw20", - "cw721", - "cw721-base", - "pegasus-trade", - "schemars", - "semver", - "serde", - "sg-controllers", - "sg-multi-test", - "sg-std", - "sg1 0.14.0", - "sg721", "thiserror", ] [[package]] -name = "pegasus-trade" -version = "0.1.0" +name = "pegasus-boot" +version = "0.2.0" dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 0.13.4", - "thiserror", + "boot-core", + "pegasus", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 5e3ad67..a644a5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ abstract-boot = { version = "0.13.0", git = "https://github.com/Abstract-OS/cont # forty-two = { version = "0.3.11", path = "packages/forty-two" } # forty-two-boot = { version = "0.3.11", path = "packages/forty-two-boot" } -pegasus-trade = { path = "packages/pegasus-trade" } +pegasus = { path = "packages/pegasus" } cosmwasm-std = { version = "1.1" } cosmwasm-schema = { version = "1.1" } cw-asset = { version = "3.0" } diff --git a/README.md b/README.md index 013cab1..9e97322 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/contracts/pegasus/Cargo.toml b/contracts/cw721-trade/Cargo.toml similarity index 97% rename from contracts/pegasus/Cargo.toml rename to contracts/cw721-trade/Cargo.toml index 0cdb135..486c4d2 100644 --- a/contracts/pegasus/Cargo.toml +++ b/contracts/cw721-trade/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "pegasus" +name = "cw721-trade" version.workspace = true authors.workspace = true edition.workspace = true @@ -57,7 +57,7 @@ sg1 = { workspace = true } sg-controllers = { workspace = true } semver = { workspace = true } cosmwasm-schema = { workspace = true } -pegasus-trade = { workspace = true } +pegasus = { workspace = true } thiserror.workspace = true diff --git a/contracts/pegasus/src/bin/schema.rs b/contracts/cw721-trade/src/bin/schema.rs similarity index 70% rename from contracts/pegasus/src/bin/schema.rs rename to contracts/cw721-trade/src/bin/schema.rs index 0a92e19..3df9662 100644 --- a/contracts/pegasus/src/bin/schema.rs +++ b/contracts/cw721-trade/src/bin/schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use pegasus_trade::pegasus::{ExecuteMsg, InstantiateMsg, QueryMsg, SudoMsg}; +use pegasus::cw721_trade::{ExecuteMsg, InstantiateMsg, QueryMsg, SudoMsg}; fn main() { write_api! { diff --git a/contracts/pegasus/src/contract.rs b/contracts/cw721-trade/src/contract.rs similarity index 97% rename from contracts/pegasus/src/contract.rs rename to contracts/cw721-trade/src/contract.rs index f2dd5f1..bd9e72b 100644 --- a/contracts/pegasus/src/contract.rs +++ b/contracts/cw721-trade/src/contract.rs @@ -6,8 +6,8 @@ use crate::execute::{ use crate::query::{query_offer, query_offers_by_peer, query_offers_by_sender, query_params}; use crate::state::{MAX_EXPIRY, MIN_EXPIRY, SUDO_PARAMS}; use crate::sudo::{sudo_update_params, ParamInfo}; -use pegasus_trade::pegasus::{ExecuteMsg, InstantiateMsg, QueryMsg, SudoMsg}; -use pegasus_trade::pegasus::{ExpiryRangeError, SudoParams}; +use pegasus::cw721_trade::{ExecuteMsg, InstantiateMsg, QueryMsg, SudoMsg}; +use pegasus::cw721_trade::{ExpiryRangeError, SudoParams}; // use crate::query::{query_offers_by_sender}; diff --git a/contracts/pegasus/src/error.rs b/contracts/cw721-trade/src/error.rs similarity index 97% rename from contracts/pegasus/src/error.rs rename to contracts/cw721-trade/src/error.rs index 4546dc3..3b0d82e 100644 --- a/contracts/pegasus/src/error.rs +++ b/contracts/cw721-trade/src/error.rs @@ -2,7 +2,7 @@ use cosmwasm_std::StdError; use cw_utils::PaymentError; use thiserror::Error; -use pegasus_trade::pegasus::ExpiryRangeError; +use pegasus::cw721_trade::ExpiryRangeError; #[derive(Error, Debug, PartialEq)] pub enum ContractError { diff --git a/contracts/pegasus/src/execute.rs b/contracts/cw721-trade/src/execute.rs similarity index 99% rename from contracts/pegasus/src/execute.rs rename to contracts/cw721-trade/src/execute.rs index b4a150d..8420f7c 100644 --- a/contracts/pegasus/src/execute.rs +++ b/contracts/cw721-trade/src/execute.rs @@ -1,7 +1,7 @@ use crate::error::ContractError; use crate::query::query_offers_by_sender; use crate::state::{next_offer_id, offers, SUDO_PARAMS}; -use pegasus_trade::pegasus::{Offer, Royalty, Token, TokenMsg}; +use pegasus::cw721_trade::{Offer, Royalty, Token, TokenMsg}; // use crate::query::{query_offers_by_sender}; use cosmwasm_std::{ diff --git a/contracts/pegasus/src/helpers.rs b/contracts/cw721-trade/src/helpers.rs similarity index 94% rename from contracts/pegasus/src/helpers.rs rename to contracts/cw721-trade/src/helpers.rs index 4c6ef97..e33fd43 100644 --- a/contracts/pegasus/src/helpers.rs +++ b/contracts/cw721-trade/src/helpers.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{to_binary, Addr, BlockInfo, StdError, StdResult, Timestamp, WasmMsg}; -use pegasus_trade::pegasus::ExecuteMsg; +use pegasus::cw721_trade::ExecuteMsg; use sg_std::CosmosMsg; /// MarketplaceContract is a wrapper around Addr that provides a lot of helpers diff --git a/contracts/pegasus/src/lib.rs b/contracts/cw721-trade/src/lib.rs similarity index 100% rename from contracts/pegasus/src/lib.rs rename to contracts/cw721-trade/src/lib.rs diff --git a/contracts/pegasus/src/multitest.rs b/contracts/cw721-trade/src/multitest.rs similarity index 99% rename from contracts/pegasus/src/multitest.rs rename to contracts/cw721-trade/src/multitest.rs index 085bdca..7733e05 100644 --- a/contracts/pegasus/src/multitest.rs +++ b/contracts/cw721-trade/src/multitest.rs @@ -3,7 +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_trade::pegasus::ExpiryRange; +use pegasus::cw721_trade::ExpiryRange; use sg721::msg::InstantiateMsg as Sg721InstantiateMsg; use sg721::state::CollectionInfo; diff --git a/contracts/pegasus/src/query.rs b/contracts/cw721-trade/src/query.rs similarity index 93% rename from contracts/pegasus/src/query.rs rename to contracts/cw721-trade/src/query.rs index 8ca8340..cacefe3 100644 --- a/contracts/pegasus/src/query.rs +++ b/contracts/cw721-trade/src/query.rs @@ -1,6 +1,6 @@ use crate::state::{offers, SUDO_PARAMS}; use cosmwasm_std::{Addr, Deps, Order, StdResult}; -use pegasus_trade::pegasus::{OfferResponse, OffersResponse, ParamsResponse}; +use pegasus::cw721_trade::{OfferResponse, OffersResponse, ParamsResponse}; // Query limits // const DEFAULT_QUERY_LIMIT: u32 = 10; diff --git a/contracts/pegasus/src/state.rs b/contracts/cw721-trade/src/state.rs similarity index 96% rename from contracts/pegasus/src/state.rs rename to contracts/cw721-trade/src/state.rs index 98b72b1..69183ca 100644 --- a/contracts/pegasus/src/state.rs +++ b/contracts/cw721-trade/src/state.rs @@ -1,7 +1,7 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Coin, StdResult, Storage, Timestamp}; use cw_storage_plus::{Index, IndexList, IndexedMap, Item, MultiIndex, UniqueIndex}; -use pegasus_trade::pegasus::{ExpiryRange, Offer, SudoParams}; +use pegasus::cw721_trade::{ExpiryRange, Offer, SudoParams}; pub const MIN_EXPIRY: u64 = 3600 * 24; // seconds -> one day pub const MAX_EXPIRY: u64 = 3600 * 24 * 28; // seconds -> one monthst M diff --git a/contracts/pegasus/src/sudo.rs b/contracts/cw721-trade/src/sudo.rs similarity index 96% rename from contracts/pegasus/src/sudo.rs rename to contracts/cw721-trade/src/sudo.rs index e551717..c3eeb80 100644 --- a/contracts/pegasus/src/sudo.rs +++ b/contracts/cw721-trade/src/sudo.rs @@ -1,7 +1,7 @@ use crate::state::{MAX_EXPIRY, SUDO_PARAMS}; use crate::{error::ContractError, state::MIN_EXPIRY}; use cosmwasm_std::{DepsMut, Env}; -use pegasus_trade::pegasus::{ExpiryRange, ExpiryRangeError}; +use pegasus::cw721_trade::{ExpiryRange, ExpiryRangeError}; use sg_std::Response; pub struct ParamInfo { diff --git a/contracts/pegasus/src/unit_tests.rs b/contracts/cw721-trade/src/unit_tests.rs similarity index 99% rename from contracts/pegasus/src/unit_tests.rs rename to contracts/cw721-trade/src/unit_tests.rs index b1ec399..f5e0953 100644 --- a/contracts/pegasus/src/unit_tests.rs +++ b/contracts/cw721-trade/src/unit_tests.rs @@ -4,7 +4,7 @@ use crate::error::ContractError; use crate::contract::{execute, instantiate, sudo}; use crate::query::{query_offers_by_peer, query_offers_by_sender}; use crate::state::{offers, MAX_EXPIRY, MIN_EXPIRY}; -use pegasus_trade::pegasus::{ +use pegasus::cw721_trade::{ ExecuteMsg, ExpiryRange, ExpiryRangeError, InstantiateMsg, Offer, SudoMsg, Token, }; diff --git a/packages/interfaces/src/lib.rs b/packages/interfaces/src/lib.rs deleted file mode 100644 index 7d12d9a..0000000 --- a/packages/interfaces/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} diff --git a/packages/interfaces/Cargo.toml b/packages/pegasus-boot/Cargo.toml similarity index 56% rename from packages/interfaces/Cargo.toml rename to packages/pegasus-boot/Cargo.toml index 73de947..cae8390 100644 --- a/packages/interfaces/Cargo.toml +++ b/packages/pegasus-boot/Cargo.toml @@ -1,9 +1,10 @@ [package] -name = "interfaces" -version = "0.1.0" +name = "pegasus-boot" +version = "0.2.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -boot-core.workspace = true +boot-core = { workspace = true } +pegasus = { path = "../pegasus" } diff --git a/packages/pegasus-boot/src/cw721_trade.rs b/packages/pegasus-boot/src/cw721_trade.rs new file mode 100644 index 0000000..bee6555 --- /dev/null +++ b/packages/pegasus-boot/src/cw721_trade.rs @@ -0,0 +1,18 @@ +use boot_core::*; +use pegasus::cw721_trade::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; + +#[boot_contract(InstantiateMsg, ExecuteMsg, QueryMsg, MigrateMsg)] +pub struct Cw721Trade; + +impl Cw721Trade +where + TxResponse: IndexResponse, +{ + pub fn new(name: &str, chain: Chain) -> Self { + Self(Contract::new(name, chain).with_wasm_path("cw721_trade")) + } + + pub fn load(chain: Chain, address: &Addr) -> Self { + Self(Contract::new("cw721_trade", chain).with_address(Some(address))) + } +} diff --git a/packages/pegasus-boot/src/lib.rs b/packages/pegasus-boot/src/lib.rs new file mode 100644 index 0000000..3ec47e8 --- /dev/null +++ b/packages/pegasus-boot/src/lib.rs @@ -0,0 +1,2 @@ + +pub mod cw721_trade; diff --git a/packages/pegasus-trade/src/lib.rs b/packages/pegasus-trade/src/lib.rs deleted file mode 100644 index 12227a4..0000000 --- a/packages/pegasus-trade/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod pegasus; diff --git a/packages/pegasus-trade/Cargo.toml b/packages/pegasus/Cargo.toml similarity index 93% rename from packages/pegasus-trade/Cargo.toml rename to packages/pegasus/Cargo.toml index a904093..f63efb9 100644 --- a/packages/pegasus-trade/Cargo.toml +++ b/packages/pegasus/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "pegasus-trade" +name = "pegasus" version = "0.1.0" edition = "2021" diff --git a/packages/pegasus-trade/src/pegasus.rs b/packages/pegasus/src/cw721_trade.rs similarity index 89% rename from packages/pegasus-trade/src/pegasus.rs rename to packages/pegasus/src/cw721_trade.rs index 7597d7c..5ac2622 100644 --- a/packages/pegasus-trade/src/pegasus.rs +++ b/packages/pegasus/src/cw721_trade.rs @@ -2,7 +2,11 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; use cosmwasm_std::{Addr, BlockInfo, Coin, StdError, Timestamp}; use thiserror::Error; +pub const CW721_TRADE: &str = "cw721-trade"; + #[cw_serde] +#[cfg_attr(feature = "boot", derive(boot_core::ExecuteFns))] +#[cfg_attr(feature = "boot", impl_into(ExecuteMsg))] pub struct InstantiateMsg { /// Valid time range for Offers /// (min, max) in seconds @@ -25,6 +29,8 @@ pub struct TokenMsg { } #[cw_serde] +#[cfg_attr(feature = "boot", derive(boot_core::ExecuteFns))] +#[cfg_attr(feature = "boot", impl_into(ExecuteMsg))] pub enum ExecuteMsg { /// Create a new offer CreateOffer { @@ -46,6 +52,8 @@ pub enum ExecuteMsg { } #[cw_serde] +#[cfg_attr(feature = "boot", derive(boot_core::SudoMsgFns))] +#[cfg_attr(feature = "boot", impl_into(SudoMsg))] pub enum SudoMsg { /// Update the contract parameters /// Can only be called by governance @@ -58,6 +66,11 @@ pub enum SudoMsg { } #[cw_serde] +pub enum MigrateMsg {} + +#[cw_serde] +#[cfg_attr(feature = "boot", derive(boot_core::QueryFns))] +#[cfg_attr(feature = "boot", impl_into(QueryMsg))] #[derive(QueryResponses)] pub enum QueryMsg { #[returns(OfferResponse)] diff --git a/packages/pegasus/src/lib.rs b/packages/pegasus/src/lib.rs new file mode 100644 index 0000000..2bfd690 --- /dev/null +++ b/packages/pegasus/src/lib.rs @@ -0,0 +1 @@ +pub mod cw721_trade; From cda17184d33825140b40e55cff669f08f8f179c0 Mon Sep 17 00:00:00 2001 From: Maurits Bos Date: Fri, 31 Mar 2023 15:17:18 +0200 Subject: [PATCH 3/4] added tests dir --- Cargo.lock | 3 +++ contracts/cw721-trade/Cargo.toml | 3 ++- contracts/cw721-trade/src/state.rs | 1 - contracts/cw721-trade/tests/integration.rs | 0 packages/pegasus/Cargo.toml | 4 ++++ 5 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 contracts/cw721-trade/tests/integration.rs diff --git a/Cargo.lock b/Cargo.lock index ac5ec0b..a6a1822 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -400,6 +400,7 @@ dependencies = [ name = "cw721-trade" version = "0.2.0" dependencies = [ + "boot-core", "cosmwasm-schema", "cosmwasm-std", "cosmwasm-storage", @@ -675,8 +676,10 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" name = "pegasus" version = "0.1.0" dependencies = [ + "boot-core", "cosmwasm-schema", "cosmwasm-std", + "cw-multi-test 0.16.2", "cw-storage-plus 0.13.4", "thiserror", ] diff --git a/contracts/cw721-trade/Cargo.toml b/contracts/cw721-trade/Cargo.toml index 486c4d2..2e049da 100644 --- a/contracts/cw721-trade/Cargo.toml +++ b/contracts/cw721-trade/Cargo.toml @@ -62,5 +62,6 @@ thiserror.workspace = true [dev-dependencies] -cw-multi-test = { workspace = true } +boot-core.workspace = true +cw-multi-test.workspace = true sg-multi-test = { workspace = true } diff --git a/contracts/cw721-trade/src/state.rs b/contracts/cw721-trade/src/state.rs index 69183ca..a49b6bc 100644 --- a/contracts/cw721-trade/src/state.rs +++ b/contracts/cw721-trade/src/state.rs @@ -1,4 +1,3 @@ -use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Coin, StdResult, Storage, Timestamp}; use cw_storage_plus::{Index, IndexList, IndexedMap, Item, MultiIndex, UniqueIndex}; use pegasus::cw721_trade::{ExpiryRange, Offer, SudoParams}; diff --git a/contracts/cw721-trade/tests/integration.rs b/contracts/cw721-trade/tests/integration.rs new file mode 100644 index 0000000..e69de29 diff --git a/packages/pegasus/Cargo.toml b/packages/pegasus/Cargo.toml index f63efb9..e81931a 100644 --- a/packages/pegasus/Cargo.toml +++ b/packages/pegasus/Cargo.toml @@ -10,3 +10,7 @@ cosmwasm-schema = { workspace = true } cosmwasm-std = { workspace = true } cw-storage-plus = { workspace = true } thiserror = { version = "1.0.30" } + +[dev-dependencies] +boot-core.workspace = true +cw-multi-test.workspace = true From 1c6e7f3126bd73e50113eea13650c4502a3dfa18 Mon Sep 17 00:00:00 2001 From: Maurits Bos Date: Tue, 4 Apr 2023 18:32:29 +0200 Subject: [PATCH 4/4] tried to implement boot for integration tests --- Cargo.lock | 637 ++++++++++++++++++ Cargo.toml | 3 +- contracts/cw721-trade/Cargo.toml | 6 +- contracts/cw721-trade/src/multitest.rs | 2 +- contracts/cw721-trade/tests/integration.rs | 131 ++++ contracts/cw721-trade/tests/suite.rs | 117 ++++ .../cw721-trade/tests/test_utils/Pegasus.rs | 0 packages/pegasus-boot/Cargo.toml | 3 + packages/pegasus-boot/src/cw721_trade.rs | 61 +- packages/pegasus-boot/src/lib.rs | 1 - 10 files changed, 955 insertions(+), 6 deletions(-) create mode 100644 contracts/cw721-trade/tests/suite.rs create mode 100644 contracts/cw721-trade/tests/test_utils/Pegasus.rs diff --git a/Cargo.lock b/Cargo.lock index a6a1822..55eeaa2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,12 +2,240 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "abstract-account-factory" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af8078710df4549d3c2e4c1143b9898c1604a8b3acc493217241ffa2208305c0" +dependencies = [ + "abstract-core", + "abstract-macros", + "abstract-sdk", + "cosmwasm-schema", + "cosmwasm-std", + "cw-asset", + "cw-controllers", + "cw-storage-plus 1.0.1", + "cw2 1.0.1", + "cw20", + "protobuf", + "semver", + "serde", + "thiserror", +] + +[[package]] +name = "abstract-ans-host" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7803f8811671d132d0f2b309e21ca9b28523fdf437e415b3c2bb635acdf15b5c" +dependencies = [ + "abstract-core", + "abstract-macros", + "abstract-sdk", + "cosmwasm-std", + "cw-asset", + "cw-controllers", + "cw-storage-plus 1.0.1", + "cw2 1.0.1", + "semver", + "serde", + "thiserror", +] + +[[package]] +name = "abstract-boot" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f01d671b8b7abe45d8279c9cddfd694ba9b2ff7c60cc052088b615d1562fe54d" +dependencies = [ + "abstract-account-factory", + "abstract-ans-host", + "abstract-core", + "abstract-manager", + "abstract-module-factory", + "abstract-proxy", + "abstract-version-control", + "boot-core", + "cosmwasm-schema", + "cosmwasm-std", + "cw-asset", + "cw-controllers", + "cw-storage-plus 1.0.1", + "cw2 1.0.1", + "log", + "schemars", + "semver", + "serde", + "serde_json", + "speculoos", + "thiserror", + "tokio", +] + +[[package]] +name = "abstract-core" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6164ca27964d89f00c949acea18f8e840a212a83c6ffbce939e17ec833d3eb4e" +dependencies = [ + "abstract-ica", + "boot-core", + "cosmwasm-schema", + "cosmwasm-std", + "cw-asset", + "cw-controllers", + "cw-semver", + "cw-storage-plus 1.0.1", + "cw-utils 1.0.1", + "cw2 1.0.1", + "cw20", + "cw20-base", + "schemars", + "semver", + "serde", + "thiserror", +] + +[[package]] +name = "abstract-ica" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b17407c8eefa07d715f70251426a577942b9b7c45690bdb42c22c0f0e07b1c" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "schemars", + "serde", + "thiserror", +] + +[[package]] +name = "abstract-macros" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f954ccb9f24be40ee1a24b86bf6b3dadea3ba228afee8bebfa05450497c310" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.99", +] + +[[package]] +name = "abstract-manager" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20e2e019c4fc14c3961848db5e5597d903504d4d17dd85b1943fcedbd0701ff3" +dependencies = [ + "abstract-core", + "abstract-macros", + "abstract-sdk", + "cosmwasm-schema", + "cosmwasm-std", + "cw-asset", + "cw-controllers", + "cw-semver", + "cw-storage-plus 1.0.1", + "cw2 1.0.1", + "cw20", + "schemars", + "semver", + "serde", + "thiserror", +] + +[[package]] +name = "abstract-module-factory" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31ebe6bdd82b3d67768645d1b2b279f8cdeed661794402cf939ea491e08c1f09" +dependencies = [ + "abstract-core", + "abstract-macros", + "abstract-sdk", + "cosmwasm-schema", + "cosmwasm-std", + "cw-asset", + "cw-controllers", + "cw-storage-plus 1.0.1", + "cw2 1.0.1", + "protobuf", + "semver", + "thiserror", +] + +[[package]] +name = "abstract-proxy" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07d5d5810402c63d89e3b87102e65f20ad99bd3e31e015353bdc360b9293bc66" +dependencies = [ + "abstract-core", + "abstract-macros", + "abstract-sdk", + "cosmwasm-schema", + "cosmwasm-std", + "cw-asset", + "cw-controllers", + "cw-storage-plus 1.0.1", + "cw2 1.0.1", + "cw20", + "schemars", + "semver", + "serde", + "thiserror", +] + +[[package]] +name = "abstract-sdk" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca39dbd7abdf9cb9dfa5bbad3af5bd620b23242345791e5f4cc4025e30efc02" +dependencies = [ + "abstract-core", + "abstract-macros", + "cosmwasm-std", + "cw-asset", + "cw-controllers", + "cw-storage-plus 1.0.1", + "cw2 1.0.1", + "cw20", + "schemars", + "semver", + "serde", + "thiserror", +] + +[[package]] +name = "abstract-version-control" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9477bec64bde7dd96c86900358f3582ba52a8f6aa26e98f0cf840151ab129bcd" +dependencies = [ + "abstract-core", + "abstract-macros", + "abstract-sdk", + "cosmwasm-std", + "cw-controllers", + "cw-semver", + "cw-storage-plus 1.0.1", + "cw2 1.0.1", + "serde", + "thiserror", +] + [[package]] name = "anyhow" version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1485d4d2cc45e7b201ee3767015c96faa5904387c9d87c6efdd0fb511f12d305" +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + [[package]] name = "base16ct" version = "0.1.1" @@ -26,6 +254,12 @@ version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea2b2456fd614d856680dcd9fcc660a51a820fa09daef2e49772b56a193c8474" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "block-buffer" version = "0.9.0" @@ -243,6 +477,44 @@ dependencies = [ "zeroize", ] +[[package]] +name = "cw-address-like" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "451a4691083a88a3c0630a8a88799e9d4cd6679b7ce8ff22b8da2873ff31d380" +dependencies = [ + "cosmwasm-std", +] + +[[package]] +name = "cw-asset" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64e2cf17accdcafe71859a683b6ed3f18311634a769550aacf4829b50151b221" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-address-like", + "cw-storage-plus 1.0.1", + "cw20", + "thiserror", +] + +[[package]] +name = "cw-controllers" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91440ce8ec4f0642798bc8c8cb6b9b53c1926c6dadaf0eed267a5145cd529071" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 1.0.1", + "cw-utils 1.0.1", + "schemars", + "serde", + "thiserror", +] + [[package]] name = "cw-multi-test" version = "0.13.4" @@ -281,6 +553,15 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cw-semver" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45fe7f7983e2e37363f440e68ae6e686d1e3f5c611ab5bb692410d88baffd3f6" +dependencies = [ + "serde", +] + [[package]] name = "cw-storage-plus" version = "0.13.4" @@ -368,6 +649,24 @@ dependencies = [ "serde", ] +[[package]] +name = "cw20-base" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afcd279230b08ed8afd8be5828221622bd5b9ce25d0b01d58bad626c6ce0169c" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 1.0.1", + "cw-utils 1.0.1", + "cw2 1.0.1", + "cw20", + "schemars", + "semver", + "serde", + "thiserror", +] + [[package]] name = "cw721" version = "0.13.4" @@ -400,6 +699,8 @@ dependencies = [ name = "cw721-trade" version = "0.2.0" dependencies = [ + "abstract-boot", + "anyhow", "boot-core", "cosmwasm-schema", "cosmwasm-std", @@ -412,6 +713,7 @@ dependencies = [ "cw721", "cw721-base", "pegasus", + "pegasus-boot", "schemars", "semver", "serde", @@ -592,6 +894,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + [[package]] name = "hex" version = "0.4.3" @@ -651,6 +962,16 @@ version = "0.2.132" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.17" @@ -666,12 +987,139 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "mio" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys", +] + +[[package]] +name = "num" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "opaque-debug" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + [[package]] name = "pegasus" version = "0.1.0" @@ -689,7 +1137,10 @@ name = "pegasus-boot" version = "0.2.0" dependencies = [ "boot-core", + "cw721", + "cw721-base", "pegasus", + "sg721", ] [[package]] @@ -698,6 +1149,12 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + [[package]] name = "pkcs8" version = "0.9.0" @@ -740,6 +1197,15 @@ dependencies = [ "syn 1.0.99", ] +[[package]] +name = "protobuf" +version = "2.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" +dependencies = [ + "bytes", +] + [[package]] name = "quote" version = "1.0.26" @@ -767,6 +1233,15 @@ dependencies = [ "getrandom 0.2.7", ] +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + [[package]] name = "rfc6979" version = "0.3.1" @@ -808,6 +1283,12 @@ dependencies = [ "syn 1.0.99", ] +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + [[package]] name = "sec1" version = "0.3.0" @@ -827,6 +1308,9 @@ name = "semver" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" +dependencies = [ + "serde", +] [[package]] name = "serde" @@ -993,6 +1477,15 @@ dependencies = [ "digest 0.10.6", ] +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + [[package]] name = "signature" version = "1.6.4" @@ -1003,6 +1496,31 @@ dependencies = [ "rand_core 0.6.3", ] +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "speculoos" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65881c9270d6157f30a09233305da51bed97eef9192d0ea21e57b1c8f05c3620" +dependencies = [ + "num", +] + [[package]] name = "spki" version = "0.6.0" @@ -1082,6 +1600,37 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +[[package]] +name = "tokio" +version = "1.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys", +] + +[[package]] +name = "tokio-macros" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.99", +] + [[package]] name = "typenum" version = "1.15.0" @@ -1157,6 +1706,94 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "zeroize" version = "1.5.7" diff --git a/Cargo.toml b/Cargo.toml index a644a5b..9977216 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,7 @@ abstract-boot = { version = "0.13.0", git = "https://github.com/Abstract-OS/cont # forty-two-boot = { version = "0.3.11", path = "packages/forty-two-boot" } 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" } @@ -68,7 +69,7 @@ cw20 = "1.0.1" cw2 = "1.0.1" cw20-base = "1.0.1" anyhow = { version = "1.0.51" } -cw-multi-test = "0.16" +cw-multi-test = "0.16.2" rstest = "0.16.0" speculoos = "0.11.0" sg1 = "0.14.0" diff --git a/contracts/cw721-trade/Cargo.toml b/contracts/cw721-trade/Cargo.toml index 2e049da..d55f6a9 100644 --- a/contracts/cw721-trade/Cargo.toml +++ b/contracts/cw721-trade/Cargo.toml @@ -50,7 +50,7 @@ cw721 = { workspace = true } cw721-base = { workspace = true } schemars = { workspace = true } serde = { workspace = true } -sg721 = { workspace = true } +sg721.workspace = true sg-std = { workspace = true } cw-utils = { workspace = true } sg1 = { workspace = true } @@ -58,10 +58,14 @@ 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 diff --git a/contracts/cw721-trade/src/multitest.rs b/contracts/cw721-trade/src/multitest.rs index 7733e05..bb4433c 100644 --- a/contracts/cw721-trade/src/multitest.rs +++ b/contracts/cw721-trade/src/multitest.rs @@ -12,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"; diff --git a/contracts/cw721-trade/tests/integration.rs b/contracts/cw721-trade/tests/integration.rs index e69de29..260a7bb 100644 --- a/contracts/cw721-trade/tests/integration.rs +++ b/contracts/cw721-trade/tests/integration.rs @@ -0,0 +1,131 @@ +use std::str::FromStr; + +use abstract_boot::boot_core::*; +use boot_core::Mock; +use cosmwasm_std::{Addr, Decimal, Empty}; + +use cw721_base::InstantiateMsg as Cw721InstantiateMsg; +use cw_multi_test::{App, ContractWrapper, Executor}; + +use pegasus_boot::cw721_trade::{Cw721Trade, Sg721}; + +pub fn setup_cw721() -> anyhow::Result> { + let owner = Addr::unchecked("owner"); + + let (_, mock_chain) = instantiate_default_mock_env(&owner)?; + + let mut cw721_contract = Sg721::new("cw721", mock_chain); + let app = mock_chain.app.borrow_mut(); + let cw721_id = store_sg721(&mut app); + + let cw721 = app.instantiate_contract( + cw721_id, + owner.clone(), + &Cw721InstantiateMsg { + name: "ColA".to_string(), + symbol: "A".to_string(), + minter: None, + }, + &vec![], + "cw721", + Some(owner.to_string()), + )?; + + cw721_contract.as_instance_mut().set_mock(Box::new( + ContractWrapper::new_with_empty( + sg721::contract::execute, + sg721::contract::instantiate, + sg721::contract::query, + ) + .into(), + )); + + cw721_contract.upload(); + Ok(cw721_contract) +} + +// fn setup_contracts( +// router: &mut StargazeApp, +// creator: &Addr, +// ) -> Result<(Addr, Addr, Addr), ContractError> { +// // Instantiate marketplace contract +// let p2p_contract_id = router.store_code(contract_p2p_trade()); +// let msg = crate::msg::InstantiateMsg { +// offer_expiry: ExpiryRange { +// min: MIN_EXPIRY, +// max: MAX_EXPIRY, +// }, +// maintainer: CREATOR.to_string(), +// max_offers: 16, +// bundle_limit: 3, +// }; +// let p2p_trade = router +// .instantiate_contract( +// p2p_contract_id, +// creator.clone(), +// &msg, +// &[], +// "p2pTrade", +// Some(CREATOR.to_string()), +// ) +// .unwrap(); +// println!("marketplace: {:?}", p2p_trade); + +// // Setup media contract +// let sg721_id = router.store_code(contract_sg721()); +// let msg = Sg721InstantiateMsg { +// name: COLLECTION_A.to_string(), +// symbol: "MAU".to_string(), +// minter: CREATOR.to_string(), +// collection_info: CollectionInfo { +// creator: CREATOR.to_string(), +// description: "test".to_string(), +// image: "ipfs://test".to_string(), +// external_link: None, +// royalty_info: None, +// }, +// }; + +// let collection_a = router +// .instantiate_contract( +// sg721_id, +// creator.clone(), +// &msg, +// &coins(1_000_000_000, NATIVE_DENOM), +// "NFT", +// Some(creator.to_string()), +// ) +// .unwrap(); + +// // Setup media contract +// let sg721_id = router.store_code(contract_sg721()); +// let msg = Sg721InstantiateMsg { +// name: COLLECTION_A.to_string(), +// symbol: "MAU".to_string(), +// minter: CREATOR.to_string(), +// collection_info: CollectionInfo { +// creator: CREATOR.to_string(), +// description: "test".to_string(), +// image: "ipfs://test".to_string(), +// external_link: None, +// royalty_info: None, +// }, +// }; +// let collection_b = router +// .instantiate_contract( +// sg721_id, +// creator.clone(), +// &msg, +// &coins(1_000_000_000, NATIVE_DENOM), +// "NFT", +// Some(creator.to_string()), +// ) +// .unwrap(); + +// println!( +// "collection_a: {:?}, collection_b: {:?}", +// collection_a, collection_b +// ); + +// Ok((p2p_trade, collection_a, collection_b)) +// } diff --git a/contracts/cw721-trade/tests/suite.rs b/contracts/cw721-trade/tests/suite.rs new file mode 100644 index 0000000..88900e7 --- /dev/null +++ b/contracts/cw721-trade/tests/suite.rs @@ -0,0 +1,117 @@ +use boot_core::*; +use cosmwasm_std::{Addr, Decimal, Empty, DepsMut, testing::{mock_info, mock_env}}; +use cw721_base::{InstantiateMsg as Cw721InstantiateMsg, Cw721Contract}; +use cw_multi_test::{App, ContractWrapper, Executor}; +use pegasus_boot::cw721_trade::Cw721Trade; +use sg_multi_test::mock_deps; +use std::str::FromStr; + +pub fn store_sg721(app: &mut App) -> u64 { + let contract = ContractWrapper::new_with_empty( + cw721_base::Cw721Contract + sg721::contract::execute, + sg721::contract::instantiate, + sg721::contract::query, + ); + Box::new(contract); + app.store_code(contract) +} +fn setup_contract(deps: DepsMut<'_>, mock: Mock) -> Cw721Contract<'static, Extension, Empty> { + let contract = Cw721Contract::default(); + let msg = Cw721InstantiateMsg { + name: "collection1".to_string(), + symbol: "C1".to_string(), + minter: String::from("owner"), + }; + contract.instantiate(mock_deps(), mock_env(), info, msg); + + let info = mock_info("owner", &[]); + let res = contract.instantiate(deps, mock_env(), info, msg).unwrap(); + assert_eq!(0, res.messages.len()); + contract +} + +pub struct Suite { + pub owner: Addr, + pub collection1: Addr, + pub collection2: Addr, + pub collection3: Addr, + pub pegasus: Cw721Trade, + mock: Mock, +} +#[derive(Debug)] +pub struct SuiteBuilder {} + +impl Default for SuiteBuilder { + fn default() -> Self { + Self::new() + } +} + +impl SuiteBuilder { + pub fn new() -> Self { + Self {} + } + + pub fn build(&self, mock_chain: &Mock) -> Suite { + let mut app = App::default(); + let owner = Addr::unchecked("owner"); + let cw721_id = store_sg721(&mut app); + let collection1 = app + .instantiate_contract( + cw721_id, + owner.clone(), + &Cw721InstantiateMsg { + name: "collection1".to_string(), + symbol: "collection1".to_string(), + minter: owner.to_string(), + }, + &vec![], + "collection1", + None, + ) + .unwrap(); + + let collection2 = app + .instantiate_contract( + cw721_id, + owner.clone(), + &Cw721InstantiateMsg { + name: "collection2".to_string(), + symbol: "collection2".to_string(), + minter: owner.to_string(), + }, + &vec![], + "collection2", + None, + ) + .unwrap(); + + let collection3 = app + .instantiate_contract( + cw721_id, + owner.clone(), + &Cw721InstantiateMsg { + name: "collection3".to_string(), + symbol: "collection3".to_string(), + minter: owner.to_string(), + }, + &vec![], + "collection3", + None, + ) + .unwrap(); + + let pegasus = Cw721Trade::new("pegasus", mock_chain); + + drop(app); + Suite { + owner, + collection1, + collection2, + collection3, + pegasus, + mock, + } + } +} diff --git a/contracts/cw721-trade/tests/test_utils/Pegasus.rs b/contracts/cw721-trade/tests/test_utils/Pegasus.rs new file mode 100644 index 0000000..e69de29 diff --git a/packages/pegasus-boot/Cargo.toml b/packages/pegasus-boot/Cargo.toml index cae8390..72eaa32 100644 --- a/packages/pegasus-boot/Cargo.toml +++ b/packages/pegasus-boot/Cargo.toml @@ -8,3 +8,6 @@ edition = "2021" [dependencies] boot-core = { workspace = true } pegasus = { path = "../pegasus" } +cw721 = { workspace = true } +cw721-base = { workspace = true } +sg721 = { workspace = true } diff --git a/packages/pegasus-boot/src/cw721_trade.rs b/packages/pegasus-boot/src/cw721_trade.rs index bee6555..aec9153 100644 --- a/packages/pegasus-boot/src/cw721_trade.rs +++ b/packages/pegasus-boot/src/cw721_trade.rs @@ -1,7 +1,32 @@ use boot_core::*; -use pegasus::cw721_trade::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; +use cw721_base::msg::ExecuteMsg as BaseCw721ExecuteMsg; +use cw721_base::{ + InstantiateMsg as BaseCw721InstantiateMsg, MintMsg, QueryMsg as BaseCw721QueryMsg, +}; +use pegasus::cw721_trade::{ + ExecuteMsg as TradeExecuteMsg, InstantiateMsg as TradeInstantiateMsg, + MigrateMsg as TradeMigrateMsg, QueryMsg as TradeQueryMsg, +}; -#[boot_contract(InstantiateMsg, ExecuteMsg, QueryMsg, MigrateMsg)] +// use sg721::{ExecuteMsg as Sg721ExecuteMsgGen, InstantiateMsg as Sg721InstantiateMsg}; + +// #[cfg_attr(feature = "boot", derive(boot_core::ExecuteFns))] +// #[cfg_attr(feature = "boot", impl_into(ExecuteMsg))] +// pub(crate) type Cw721ExecuteMsg = GCw721ExecuteMsg; + +// #[cfg_attr(feature = "boot", derive(boot_core::QueryFns))] +// #[cfg_attr(feature = "boot", impl_into(QueryMsg))] +// pub(crate) type Cw721QueryMsg = Cw721QueryMsg; + +// #[cfg_attr(feature = "boot", derive(boot_core::ExecuteFns))] +// #[cfg_attr(feature = "boot", impl_into(ExecuteMsg))] +// pub(crate) type Sg721ExecuteMsg = Sg721ExecuteMsgGen; + +// #[cfg_attr(feature = "boot", derive(boot_core::QueryFns))] +// #[cfg_attr(feature = "boot", impl_into(QueryMsg))] +// pub(crate) type Sg721QueryMsg = BaseCw721QueryMsg; + +#[boot_contract(TradeInstantiateMsg, TradeExecuteMsg, TradeQueryMsg, TradeMigrateMsg)] pub struct Cw721Trade; impl Cw721Trade @@ -16,3 +41,35 @@ where Self(Contract::new("cw721_trade", chain).with_address(Some(address))) } } + +// #[boot_contract(Cw721InstantiateMsg, Cw721ExecuteMsg, Cw721QueryMsg, Empty)] +// pub struct Cw721; + +// impl Cw721 +// where +// TxResponse: IndexResponse, +// { +// pub fn new(name: &str, chain: Chain) -> Self { +// Self(Contract::new(name, chain).with_wasm_path("cw721_base")) +// } + +// pub fn load(chain: Chain, address: &Addr) -> Self { +// Self(Contract::new("cw721", chain).with_address(Some(address))) +// } +// } + +// #[boot_contract(Sg721InstantiateMsg, Sg721ExecuteMsg, Sg721QueryMsg, Empty)] +// pub struct Sg721; + +// impl Sg721 +// where +// TxResponse: IndexResponse, +// { +// pub fn new(name: &str, chain: Chain) -> Self { +// Self(Contract::new(name, chain).with_wasm_path("sg721")) +// } + +// pub fn load(chain: Chain, address: &Addr) -> Self { +// Self(Contract::new("sg721", chain).with_address(Some(address))) +// } +// } diff --git a/packages/pegasus-boot/src/lib.rs b/packages/pegasus-boot/src/lib.rs index 3ec47e8..2bfd690 100644 --- a/packages/pegasus-boot/src/lib.rs +++ b/packages/pegasus-boot/src/lib.rs @@ -1,2 +1 @@ - pub mod cw721_trade;