From 6d79cc56a68a994226d797760fd2f9b661ecc21d Mon Sep 17 00:00:00 2001 From: anilcse Date: Fri, 8 Nov 2024 16:00:10 +0530 Subject: [PATCH 01/24] Add intro --- README.md | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 127 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b570116e..4e437f1f 100644 --- a/README.md +++ b/README.md @@ -1 +1,127 @@ -# dotc \ No newline at end of file +# cosmos-otc-platform ๐ŸŒŸ + +A decentralized Over-The-Counter (OTC) trading platform built with CosmWasm. This smart contract enables secure, transparent, and efficient OTC trading of tokens with customizable discount rates and bidding mechanisms. + +## Features ๐Ÿš€ + +- **Flexible Deal Creation**: Sellers can create OTC deals with: + - Custom token selection + - Configurable discount percentages + - Minimum price protection + - Minimum cap requirements + - Customizable bidding timeframes + +- **Advanced Bidding System**: + - Buyers can place bids with desired quantities + - Maximum price protection for buyers + - Real-time bid updates and withdrawals + - Automatic bid sorting by discount rates + +- **Secure Deal Settlement**: + - Automatic deal conclusion at specified time + - Fair distribution prioritizing lowest discount bids + - Automatic refunds for unsuccessful bids + - Platform fee management + +## Prerequisites ๐Ÿ“‹ + +- Rust 1.63.0+ +- [wasmd](https://github.com/CosmWasm/wasmd) 0.30.0+ +- [cargo-generate](https://github.com/cargo-generate/cargo-generate) + +## Installation ๐Ÿ› ๏ธ + +```bash +# Clone the repository +git clone https://github.com/yourusername/cosmos-otc-platform +cd cosmos-otc-platform + +# Compile the contract +cargo build + +# Run tests +cargo test + +# Generate Wasm binary +cargo wasm +``` + +## Usage ๐Ÿ“ + +### Creating an OTC Deal + +```rust +let msg = ExecuteMsg::CreateDeal { + sell_token: "token_address", + total_amount: Uint128::new(1000000), + min_price: Uint128::new(100), + discount_percentage: 10, + min_cap: Uint128::new(500000), + bid_start_time: 1234567890, + bid_end_time: 1234657890, + conclude_time: 1234747890, +}; +``` + +### Placing a Bid + +```rust +let msg = ExecuteMsg::PlaceBid { + deal_id: 1, + amount: Uint128::new(100000), + discount_percentage: 5, + max_price: Some(Uint128::new(110)), +}; +``` + +## Contract Architecture ๐Ÿ—๏ธ + +``` +src/ +โ”œโ”€โ”€ lib.rs # Entry point +โ”œโ”€โ”€ contract.rs # Core contract logic +โ”œโ”€โ”€ msg.rs # Message definitions +โ”œโ”€โ”€ state.rs # State management +โ”œโ”€โ”€ error.rs # Error handling +โ””โ”€โ”€ helpers.rs # Utility functions +``` + +## Testing ๐Ÿงช + +```bash +# Run all tests +cargo test + +# Run specific test +cargo test test_create_deal +``` + +## Security Considerations ๐Ÿ”’ + +- All monetary operations are atomic +- Time-based validations prevent premature or late actions +- Minimum price protection for sellers +- Maximum price protection for buyers +- Automatic refund mechanism +- Platform fee validation + +## Contributing ๐Ÿค + +1. Fork the repository +2. Create your feature branch (`git checkout -b feature/AmazingFeature`) +3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) +4. Push to the branch (`git push origin feature/AmazingFeature`) +5. Open a Pull Request + +## Contact ๐Ÿ“ง + +Anil - [@anilcse](https://twitter.com/anilcse_) + +Project Link: [https://github.com/vitwit/cw-otc-dex](https://github.com/vitwit/cw-otc-dex) + +## Acknowledgments ๐Ÿ™ + +- CosmWasm team for the amazing smart contract platform + +--- +Made with โค๏ธ for the Cosmos ecosystem \ No newline at end of file From aaa7d43ab18b17d9c2df90a52df17b5314ae10f7 Mon Sep 17 00:00:00 2001 From: anilcse Date: Fri, 8 Nov 2024 16:03:03 +0530 Subject: [PATCH 02/24] Add template --- Cargo.toml | 48 ++++++++++++ Developing.md | 104 ++++++++++++++++++++++++++ Importing.md | 62 ++++++++++++++++ NOTICE | 13 ++++ Publishing.md | 115 +++++++++++++++++++++++++++++ src/bin/schema.rs | 11 +++ src/contract.rs | 156 +++++++++++++++++++++++++++++++++++++++ src/error.rs | 13 ++++ src/helpers.rs | 47 ++++++++++++ src/integration_tests.rs | 78 ++++++++++++++++++++ src/lib.rs | 8 ++ src/msg.rs | 26 +++++++ src/state.rs | 13 ++++ 13 files changed, 694 insertions(+) create mode 100644 Cargo.toml create mode 100644 Developing.md create mode 100644 Importing.md create mode 100644 NOTICE create mode 100644 Publishing.md create mode 100644 src/bin/schema.rs create mode 100644 src/contract.rs create mode 100644 src/error.rs create mode 100644 src/helpers.rs create mode 100644 src/integration_tests.rs create mode 100644 src/lib.rs create mode 100644 src/msg.rs create mode 100644 src/state.rs diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..6624d8bc --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,48 @@ +[package] +name = "cw-otc-dex" +version = "0.1.0" +authors = ["anilcse "] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib", "rlib"] + +[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] +# 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=/target \ + --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ + cosmwasm/optimizer:0.15.0 +""" + +[dependencies] +cosmwasm-schema = "2.1.0" +cosmwasm-std = { version = "2.1.0", features = [ + "cosmwasm_1_4", + # Enable this if you only deploy to chains that have CosmWasm 2.0 or higher + # "cosmwasm_2_0", +] } +cw-storage-plus = "2.0.0" +cw2 = "2.0.0" +schemars = "0.8.16" +serde = { version = "1.0.197", default-features = false, features = ["derive"] } +thiserror = { version = "1.0.58" } + +[dev-dependencies] +cw-multi-test = "2.0.0" diff --git a/Developing.md b/Developing.md new file mode 100644 index 00000000..1b3245e3 --- /dev/null +++ b/Developing.md @@ -0,0 +1,104 @@ +# Developing + +If you have recently created a contract with this template, you probably could use some +help on how to build and test the contract, as well as prepare it for production. This +file attempts to provide a brief overview, assuming you have installed a recent +version of Rust already (eg. 1.58.1+). + +## Prerequisites + +Before starting, make sure you have [rustup](https://rustup.rs/) along with a +recent `rustc` and `cargo` version installed. Currently, we are testing on 1.58.1+. + +And you need to have the `wasm32-unknown-unknown` target installed as well. + +You can check that via: + +```sh +rustc --version +cargo --version +rustup target list --installed +# if wasm32 is not listed above, run this +rustup target add wasm32-unknown-unknown +``` + +## Compiling and running tests + +Now that you created your custom contract, make sure you can compile and run it before +making any changes. Go into the repository and do: + +```sh +# this will produce a wasm build in ./target/wasm32-unknown-unknown/release/YOUR_NAME_HERE.wasm +cargo wasm + +# this runs unit tests with helpful backtraces +RUST_BACKTRACE=1 cargo unit-test + +# auto-generate json schema +cargo schema +``` + +### Understanding the tests + +The main code is in `src/contract.rs` and the unit tests there run in pure rust, +which makes them very quick to execute and give nice output on failures, especially +if you do `RUST_BACKTRACE=1 cargo unit-test`. + +We consider testing critical for anything on a blockchain, and recommend to always keep +the tests up to date. + +## Generating JSON Schema + +While the Wasm calls (`instantiate`, `execute`, `query`) accept JSON, this is not enough +information to use it. We need to expose the schema for the expected messages to the +clients. You can generate this schema by calling `cargo schema`, which will output +4 files in `./schema`, corresponding to the 3 message types the contract accepts, +as well as the internal `State`. + +These files are in standard json-schema format, which should be usable by various +client side tools, either to auto-generate codecs, or just to validate incoming +json wrt. the defined schema. + +## Preparing the Wasm bytecode for production + +Before we upload it to a chain, we need to ensure the smallest output size possible, +as this will be included in the body of a transaction. We also want to have a +reproducible build process, so third parties can verify that the uploaded Wasm +code did indeed come from the claimed rust code. + +To solve both these issues, we have produced `rust-optimizer`, a docker image to +produce an extremely small build output in a consistent manner. The suggest way +to run it is this: + +```sh +docker run --rm -v "$(pwd)":/code \ + --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \ + --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ + cosmwasm/optimizer:0.15.0 +``` + +Or, If you're on an arm64 machine, you should use a docker image built with arm64. + +```sh +docker run --rm -v "$(pwd)":/code \ + --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \ + --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ + cosmwasm/optimizer-arm64:0.15.0 +``` + +We must mount the contract code to `/code`. You can use an absolute path instead +of `$(pwd)` if you don't want to `cd` to the directory first. The other two +volumes are nice for speedup. +Note the `/target` cache is unique for each contract being compiled to limit +interference, while the registry cache is global. + +This is rather slow compared to local compilations, especially the first compile +of a given contract. The use of the two volume caches is very useful to speed up +following compiles of the same contract. + +This produces an `artifacts` directory with a `PROJECT_NAME.wasm`, as well as +`checksums.txt`, containing the Sha256 hash of the wasm file. +The wasm file is compiled deterministically (anyone else running the same +docker on the same git commit should get the identical file with the same Sha256 hash). +It is also stripped and minimized for upload to a blockchain (we will also +gzip it in the uploading process to make it even smaller). diff --git a/Importing.md b/Importing.md new file mode 100644 index 00000000..2601dd8d --- /dev/null +++ b/Importing.md @@ -0,0 +1,62 @@ +# Importing + +In [Publishing](./Publishing.md), we discussed how you can publish your contract to the world. +This looks at the flip-side, how can you use someone else's contract (which is the same +question as how they will use your contract). Let's go through the various stages. + +## Verifying Artifacts + +Before using remote code, you most certainly want to verify it is honest. + +The simplest audit of the repo is to simply check that the artifacts in the repo +are correct. This involves recompiling the claimed source with the claimed builder +and validating that the locally compiled code (hash) matches the code hash that was +uploaded. This will verify that the source code is the correct preimage. Which allows +one to audit the original (Rust) source code, rather than looking at wasm bytecode. + +We have a script to do this automatic verification steps that can +easily be run by many individuals. Please check out +[`cosmwasm-verify`](https://github.com/CosmWasm/cosmwasm-verify/blob/master/README.md) +to see a simple shell script that does all these steps and easily allows you to verify +any uploaded contract. + +## Reviewing + +Once you have done the quick programmatic checks, it is good to give at least a quick +look through the code. A glance at `examples/schema.rs` to make sure it is outputting +all relevant structs from `contract.rs`, and also ensure `src/lib.rs` is just the +default wrapper (nothing funny going on there). After this point, we can dive into +the contract code itself. Check the flows for the execute methods, any invariants and +permission checks that should be there, and a reasonable data storage format. + +You can dig into the contract as far as you want, but it is important to make sure there +are no obvious backdoors at least. + +## Decentralized Verification + +It's not very practical to do a deep code review on every dependency you want to use, +which is a big reason for the popularity of code audits in the blockchain world. We trust +some experts review in lieu of doing the work ourselves. But wouldn't it be nice to do this +in a decentralized manner and peer-review each other's contracts? Bringing in deeper domain +knowledge and saving fees. + +Luckily, there is an amazing project called [crev](https://github.com/crev-dev/cargo-crev/blob/master/cargo-crev/README.md) +that provides `A cryptographically verifiable code review system for the cargo (Rust) package manager`. + +I highly recommend that CosmWasm contract developers get set up with this. At minimum, we +can all add a review on a package that programmatically checked out that the json schemas +and wasm bytecode do match the code, and publish our claim, so we don't all rely on some +central server to say it validated this. As we go on, we can add deeper reviews on standard +packages. + +If you want to use `cargo-crev`, please follow their +[getting started guide](https://github.com/crev-dev/cargo-crev/blob/master/cargo-crev/src/doc/getting_started.md) +and once you have made your own *proof repository* with at least one *trust proof*, +please make a PR to the [`cawesome-wasm`]() repo with a link to your repo and +some public name or pseudonym that people know you by. This allows people who trust you +to also reuse your proofs. + +There is a [standard list of proof repos](https://github.com/crev-dev/cargo-crev/wiki/List-of-Proof-Repositories) +with some strong rust developers in there. This may cover dependencies like `serde` and `snafu` +but will not hit any CosmWasm-related modules, so we look to bootstrap a very focused +review community. diff --git a/NOTICE b/NOTICE new file mode 100644 index 00000000..57c6d088 --- /dev/null +++ b/NOTICE @@ -0,0 +1,13 @@ +Copyright 2024 anilcse + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/Publishing.md b/Publishing.md new file mode 100644 index 00000000..c94f8675 --- /dev/null +++ b/Publishing.md @@ -0,0 +1,115 @@ +# Publishing Contracts + +This is an overview of how to publish the contract's source code in this repo. +We use Cargo's default registry [crates.io](https://crates.io/) for publishing contracts written in Rust. + +## Preparation + +Ensure the `Cargo.toml` file in the repo is properly configured. In particular, you want to +choose a name starting with `cw-`, which will help a lot finding CosmWasm contracts when +searching on crates.io. For the first publication, you will probably want version `0.1.0`. +If you have tested this on a public net already and/or had an audit on the code, +you can start with `1.0.0`, but that should imply some level of stability and confidence. +You will want entries like the following in `Cargo.toml`: + +```toml +name = "cw-escrow" +version = "0.1.0" +description = "Simple CosmWasm contract for an escrow with arbiter and timeout" +repository = "https://github.com/confio/cosmwasm-examples" +``` + +You will also want to add a valid [SPDX license statement](https://spdx.org/licenses/), +so others know the rules for using this crate. You can use any license you wish, +even a commercial license, but we recommend choosing one of the following, unless you have +specific requirements. + +* Permissive: [`Apache-2.0`](https://spdx.org/licenses/Apache-2.0.html#licenseText) or [`MIT`](https://spdx.org/licenses/MIT.html#licenseText) +* Copyleft: [`GPL-3.0-or-later`](https://spdx.org/licenses/GPL-3.0-or-later.html#licenseText) or [`AGPL-3.0-or-later`](https://spdx.org/licenses/AGPL-3.0-or-later.html#licenseText) +* Commercial license: `Commercial` (not sure if this works, I cannot find examples) + +It is also helpful to download the LICENSE text (linked to above) and store this +in a LICENSE file in your repo. Now, you have properly configured your crate for use +in a larger ecosystem. + +### Updating schema + +To allow easy use of the contract, we can publish the schema (`schema/*.json`) together +with the source code. + +```sh +cargo schema +``` + +Ensure you check in all the schema files, and make a git commit with the final state. +This commit will be published and should be tagged. Generally, you will want to +tag with the version (eg. `v0.1.0`), but in the `cosmwasm-examples` repo, we have +multiple contracts and label it like `escrow-0.1.0`. Don't forget a +`git push && git push --tags` + +### Note on build results + +Build results like Wasm bytecode or expected hash don't need to be updated since +they don't belong to the source publication. However, they are excluded from packaging +in `Cargo.toml` which allows you to commit them to your git repository if you like. + +```toml +exclude = ["artifacts"] +``` + +A single source code can be built with multiple different optimizers, so +we should not make any strict assumptions on the tooling that will be used. + +## Publishing + +Now that your package is properly configured and all artifacts are committed, it +is time to share it with the world. +Please refer to the [complete instructions for any questions](https://rurust.github.io/cargo-docs-ru/crates-io.html), +but I will try to give a quick overview of the happy path here. + +### Registry + +You will need an account on [crates.io](https://crates.io) to publish a rust crate. +If you don't have one already, just click on "Log in with GitHub" in the top-right +to quickly set up a free account. Once inside, click on your username (top-right), +then "Account Settings". On the bottom, there is a section called "API Access". +If you don't have this set up already, create a new token and use `cargo login` +to set it up. This will now authenticate you with the `cargo` cli tool and allow +you to publish. + +### Uploading + +Once this is set up, make sure you commit the current state you want to publish. +Then try `cargo publish --dry-run`. If that works well, review the files that +will be published via `cargo package --list`. If you are satisfied, you can now +officially publish it via `cargo publish`. + +Congratulations, your package is public to the world. + +### Sharing + +Once you have published your package, people can now find it by +[searching for "cw-" on crates.io](https://crates.io/search?q=cw). +But that isn't exactly the simplest way. To make things easier and help +keep the ecosystem together, we suggest making a PR to add your package +to the [`cawesome-wasm`](https://github.com/cosmwasm/cawesome-wasm) list. + +### Organizations + +Many times you are writing a contract not as a solo developer, but rather as +part of an organization. You will want to allow colleagues to upload new +versions of the contract to crates.io when you are on holiday. +[These instructions show how]() you can set up your crate to allow multiple maintainers. + +You can add another owner to the crate by specifying their github user. Note, you will +now both have complete control of the crate, and they can remove you: + +`cargo owner --add ethanfrey` + +You can also add an existing github team inside your organization: + +`cargo owner --add github:confio:developers` + +The team will allow anyone who is currently in the team to publish new versions of the crate. +And this is automatically updated when you make changes on github. However, it will not allow +anyone in the team to add or remove other owners. diff --git a/src/bin/schema.rs b/src/bin/schema.rs new file mode 100644 index 00000000..da9d3fd8 --- /dev/null +++ b/src/bin/schema.rs @@ -0,0 +1,11 @@ +use cosmwasm_schema::write_api; + +use cw_otc_dex::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; + +fn main() { + write_api! { + instantiate: InstantiateMsg, + execute: ExecuteMsg, + query: QueryMsg, + } +} diff --git a/src/contract.rs b/src/contract.rs new file mode 100644 index 00000000..03aef1b6 --- /dev/null +++ b/src/contract.rs @@ -0,0 +1,156 @@ +#[cfg(not(feature = "library"))] +use cosmwasm_std::entry_point; +use cosmwasm_std::{to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult}; +use cw2::set_contract_version; + +use crate::error::ContractError; +use crate::msg::{ExecuteMsg, GetCountResponse, InstantiateMsg, QueryMsg}; +use crate::state::{State, STATE}; + +// version info for migration info +const CONTRACT_NAME: &str = "crates.io:cw-otc-dex"; +const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn instantiate( + deps: DepsMut, + _env: Env, + info: MessageInfo, + msg: InstantiateMsg, +) -> Result { + let state = State { + count: msg.count, + owner: info.sender.clone(), + }; + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; + STATE.save(deps.storage, &state)?; + + Ok(Response::new() + .add_attribute("method", "instantiate") + .add_attribute("owner", info.sender) + .add_attribute("count", msg.count.to_string())) +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn execute( + deps: DepsMut, + _env: Env, + info: MessageInfo, + msg: ExecuteMsg, +) -> Result { + match msg { + ExecuteMsg::Increment {} => execute::increment(deps), + ExecuteMsg::Reset { count } => execute::reset(deps, info, count), + } +} + +pub mod execute { + use super::*; + + pub fn increment(deps: DepsMut) -> Result { + STATE.update(deps.storage, |mut state| -> Result<_, ContractError> { + state.count += 1; + Ok(state) + })?; + + Ok(Response::new().add_attribute("action", "increment")) + } + + pub fn reset(deps: DepsMut, info: MessageInfo, count: i32) -> Result { + STATE.update(deps.storage, |mut state| -> Result<_, ContractError> { + if info.sender != state.owner { + return Err(ContractError::Unauthorized {}); + } + state.count = count; + Ok(state) + })?; + Ok(Response::new().add_attribute("action", "reset")) + } +} + +#[cfg_attr(not(feature = "library"), entry_point)] +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + match msg { + QueryMsg::GetCount {} => to_json_binary(&query::count(deps)?), + } +} + +pub mod query { + use super::*; + + pub fn count(deps: Deps) -> StdResult { + let state = STATE.load(deps.storage)?; + Ok(GetCountResponse { count: state.count }) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; + use cosmwasm_std::{coins, from_json}; + + #[test] + fn proper_initialization() { + let mut deps = mock_dependencies(); + + let msg = InstantiateMsg { count: 17 }; + let info = mock_info("creator", &coins(1000, "earth")); + + // we can just call .unwrap() to assert this was a success + let res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); + assert_eq!(0, res.messages.len()); + + // it worked, let's query the state + let res = query(deps.as_ref(), mock_env(), QueryMsg::GetCount {}).unwrap(); + let value: GetCountResponse = from_json(&res).unwrap(); + assert_eq!(17, value.count); + } + + #[test] + fn increment() { + let mut deps = mock_dependencies(); + + let msg = InstantiateMsg { count: 17 }; + let info = mock_info("creator", &coins(2, "token")); + let _res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); + + // beneficiary can release it + let info = mock_info("anyone", &coins(2, "token")); + let msg = ExecuteMsg::Increment {}; + let _res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); + + // should increase counter by 1 + let res = query(deps.as_ref(), mock_env(), QueryMsg::GetCount {}).unwrap(); + let value: GetCountResponse = from_json(&res).unwrap(); + assert_eq!(18, value.count); + } + + #[test] + fn reset() { + let mut deps = mock_dependencies(); + + let msg = InstantiateMsg { count: 17 }; + let info = mock_info("creator", &coins(2, "token")); + let _res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); + + // beneficiary can release it + let unauth_info = mock_info("anyone", &coins(2, "token")); + let msg = ExecuteMsg::Reset { count: 5 }; + let res = execute(deps.as_mut(), mock_env(), unauth_info, msg); + match res { + Err(ContractError::Unauthorized {}) => {} + _ => panic!("Must return unauthorized error"), + } + + // only the original creator can reset the counter + let auth_info = mock_info("creator", &coins(2, "token")); + let msg = ExecuteMsg::Reset { count: 5 }; + let _res = execute(deps.as_mut(), mock_env(), auth_info, msg).unwrap(); + + // should now be 5 + let res = query(deps.as_ref(), mock_env(), QueryMsg::GetCount {}).unwrap(); + let value: GetCountResponse = from_json(&res).unwrap(); + assert_eq!(5, value.count); + } +} diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 00000000..4a69d8ff --- /dev/null +++ b/src/error.rs @@ -0,0 +1,13 @@ +use cosmwasm_std::StdError; +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum ContractError { + #[error("{0}")] + Std(#[from] StdError), + + #[error("Unauthorized")] + Unauthorized {}, + // Add any other custom errors you like here. + // Look at https://docs.rs/thiserror/1.0.21/thiserror/ for details. +} diff --git a/src/helpers.rs b/src/helpers.rs new file mode 100644 index 00000000..6d988cce --- /dev/null +++ b/src/helpers.rs @@ -0,0 +1,47 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +use cosmwasm_std::{ + to_json_binary, Addr, CosmosMsg, CustomQuery, Querier, QuerierWrapper, StdResult, WasmMsg, + WasmQuery, +}; + +use crate::msg::{ExecuteMsg, GetCountResponse, QueryMsg}; + +/// CwTemplateContract is a wrapper around Addr that provides a lot of helpers +/// for working with this. +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +pub struct CwTemplateContract(pub Addr); + +impl CwTemplateContract { + pub fn addr(&self) -> Addr { + self.0.clone() + } + + pub fn call>(&self, msg: T) -> StdResult { + let msg = to_json_binary(&msg.into())?; + Ok(WasmMsg::Execute { + contract_addr: self.addr().into(), + msg, + funds: vec![], + } + .into()) + } + + /// Get Count + pub fn count(&self, querier: &Q) -> StdResult + where + Q: Querier, + T: Into, + CQ: CustomQuery, + { + let msg = QueryMsg::GetCount {}; + let query = WasmQuery::Smart { + contract_addr: self.addr().into(), + msg: to_json_binary(&msg)?, + } + .into(); + let res: GetCountResponse = QuerierWrapper::::new(querier).query(&query)?; + Ok(res) + } +} diff --git a/src/integration_tests.rs b/src/integration_tests.rs new file mode 100644 index 00000000..324f2ecd --- /dev/null +++ b/src/integration_tests.rs @@ -0,0 +1,78 @@ +#[cfg(test)] +mod tests { + use crate::helpers::CwTemplateContract; + use crate::msg::InstantiateMsg; + use cosmwasm_std::testing::MockApi; + use cosmwasm_std::{Addr, Coin, Empty, Uint128}; + use cw_multi_test::{App, AppBuilder, Contract, ContractWrapper, Executor}; + + pub fn contract_template() -> Box> { + let contract = ContractWrapper::new( + crate::contract::execute, + crate::contract::instantiate, + crate::contract::query, + ); + Box::new(contract) + } + + const USER: &str = "USER"; + const ADMIN: &str = "ADMIN"; + const NATIVE_DENOM: &str = "denom"; + + fn mock_app() -> App { + AppBuilder::new().build(|router, _, storage| { + router + .bank + .init_balance( + storage, + &MockApi::default().addr_make(USER), + vec![Coin { + denom: NATIVE_DENOM.to_string(), + amount: Uint128::new(1), + }], + ) + .unwrap(); + }) + } + + fn proper_instantiate() -> (App, CwTemplateContract) { + let mut app = mock_app(); + let cw_template_id = app.store_code(contract_template()); + + let user = app.api().addr_make(USER); + assert_eq!( + app.wrap().query_balance(user, NATIVE_DENOM).unwrap().amount, + Uint128::new(1) + ); + + let msg = InstantiateMsg { count: 1i32 }; + let cw_template_contract_addr = app + .instantiate_contract( + cw_template_id, + Addr::unchecked(ADMIN), + &msg, + &[], + "test", + None, + ) + .unwrap(); + + let cw_template_contract = CwTemplateContract(cw_template_contract_addr); + + (app, cw_template_contract) + } + + mod count { + use super::*; + use crate::msg::ExecuteMsg; + + #[test] + fn count() { + let (mut app, cw_template_contract) = proper_instantiate(); + + let msg = ExecuteMsg::Increment {}; + let cosmos_msg = cw_template_contract.call(msg).unwrap(); + app.execute(Addr::unchecked(USER), cosmos_msg).unwrap(); + } + } +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 00000000..d6185c4e --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,8 @@ +pub mod contract; +mod error; +pub mod helpers; +pub mod integration_tests; +pub mod msg; +pub mod state; + +pub use crate::error::ContractError; diff --git a/src/msg.rs b/src/msg.rs new file mode 100644 index 00000000..0edfa328 --- /dev/null +++ b/src/msg.rs @@ -0,0 +1,26 @@ +use cosmwasm_schema::{cw_serde, QueryResponses}; + +#[cw_serde] +pub struct InstantiateMsg { + pub count: i32, +} + +#[cw_serde] +pub enum ExecuteMsg { + Increment {}, + Reset { count: i32 }, +} + +#[cw_serde] +#[derive(QueryResponses)] +pub enum QueryMsg { + // GetCount returns the current count as a json-encoded number + #[returns(GetCountResponse)] + GetCount {}, +} + +// We define a custom struct for each query response +#[cw_serde] +pub struct GetCountResponse { + pub count: i32, +} diff --git a/src/state.rs b/src/state.rs new file mode 100644 index 00000000..bad92026 --- /dev/null +++ b/src/state.rs @@ -0,0 +1,13 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +use cosmwasm_std::Addr; +use cw_storage_plus::Item; + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +pub struct State { + pub count: i32, + pub owner: Addr, +} + +pub const STATE: Item = Item::new("state"); From ed22457eff6f398e7cf323f9544639b733f492ac Mon Sep 17 00:00:00 2001 From: anilcse Date: Fri, 8 Nov 2024 16:07:49 +0530 Subject: [PATCH 03/24] Add definitions --- LICENSE | 202 +++++++++++++++++++++++++++++++++++++++ src/error.rs | 50 +++++++++- src/helpers.rs | 119 +++++++++++++++-------- src/integration_tests.rs | 78 --------------- src/lib.rs | 20 +++- src/msg.rs | 102 +++++++++++++++++--- src/state.rs | 65 +++++++++++-- 7 files changed, 492 insertions(+), 144 deletions(-) create mode 100644 LICENSE delete mode 100644 src/integration_tests.rs diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/src/error.rs b/src/error.rs index 4a69d8ff..429c7b81 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,13 +1,57 @@ + use cosmwasm_std::StdError; use thiserror::Error; +/// Custom error types for the OTC platform contract #[derive(Error, Debug)] pub enum ContractError { + /// Wraps std::error::Error #[error("{0}")] Std(#[from] StdError), + /// When someone tries to execute an action they're not authorized for #[error("Unauthorized")] Unauthorized {}, - // Add any other custom errors you like here. - // Look at https://docs.rs/thiserror/1.0.21/thiserror/ for details. -} + + /// When deal times are invalid (e.g., end time before start time) + #[error("Invalid time parameters: {reason}")] + InvalidTimeParameters { reason: String }, + + /// When someone tries to bid before the bidding period starts + #[error("Bidding has not started yet")] + BiddingNotStarted {}, + + /// When someone tries to bid after the bidding period ends + #[error("Bidding has ended")] + BiddingEnded {}, + + /// When someone tries to conclude a deal before its conclusion time + #[error("Deal cannot be concluded yet")] + ConclusionTimeNotReached {}, + + /// When someone tries to modify a deal that's already concluded + #[error("Deal already concluded")] + DealAlreadyConcluded {}, + + /// When the platform fee provided is less than required + #[error("Insufficient platform fee. Required: {required}, provided: {provided}")] + InsufficientPlatformFee { + required: u128, + provided: u128, + }, + + /// When the bid amount is invalid (e.g., zero) + #[error("Invalid bid amount: {reason}")] + InvalidBidAmount { reason: String }, + + /// When trying to update or withdraw a non-existent bid + #[error("Bid not found for deal {deal_id} from bidder {bidder}")] + BidNotFound { + deal_id: u64, + bidder: String, + }, + + /// When the deal has insufficient funds for transfer + #[error("Insufficient funds")] + InsufficientFunds {}, +} \ No newline at end of file diff --git a/src/helpers.rs b/src/helpers.rs index 6d988cce..b8dcf3b9 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,47 +1,90 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - use cosmwasm_std::{ - to_json_binary, Addr, CosmosMsg, CustomQuery, Querier, QuerierWrapper, StdResult, WasmMsg, - WasmQuery, + Addr, Coin, CosmosMsg, BankMsg, Uint128, WasmMsg, + to_binary, StdResult, Order, Storage, }; +use cw20::Cw20ExecuteMsg; -use crate::msg::{ExecuteMsg, GetCountResponse, QueryMsg}; +use crate::state::{BIDS, Bid}; +use crate::error::ContractError; -/// CwTemplateContract is a wrapper around Addr that provides a lot of helpers -/// for working with this. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct CwTemplateContract(pub Addr); +/// Creates a CosmosMsg for transferring CW20 tokens +pub fn create_token_transfer_msg( + token_addr: String, + recipient: String, + amount: Uint128, +) -> StdResult { + Ok(CosmosMsg::Wasm(WasmMsg::Execute { + contract_addr: token_addr, + msg: to_binary(&Cw20ExecuteMsg::Transfer { + recipient, + amount, + })?, + funds: vec![], + })) +} -impl CwTemplateContract { - pub fn addr(&self) -> Addr { - self.0.clone() - } +/// Creates a CosmosMsg for sending native tokens +pub fn create_payment_msg( + recipient: String, + amount: Uint128, + denom: &str, +) -> CosmosMsg { + CosmosMsg::Bank(BankMsg::Send { + to_address: recipient, + amount: vec![Coin { + denom: denom.to_string(), + amount, + }], + }) +} - pub fn call>(&self, msg: T) -> StdResult { - let msg = to_json_binary(&msg.into())?; - Ok(WasmMsg::Execute { - contract_addr: self.addr().into(), - msg, - funds: vec![], - } - .into()) - } +/// Retrieves all bids for a deal, sorted by discount percentage +pub fn get_sorted_bids( + storage: &dyn Storage, + deal_id: u64, +) -> StdResult> { + let mut bids: Vec<(String, Bid)> = BIDS + .prefix(deal_id) + .range(storage, None, None, Order::Ascending) + .map(|item| { + let (addr, bid) = item?; + Ok((addr.to_string(), bid)) + }) + .collect::>>()?; + + bids.sort_by(|a, b| a.1.discount_percentage.cmp(&b.1.discount_percentage)); + Ok(bids) +} - /// Get Count - pub fn count(&self, querier: &Q) -> StdResult - where - Q: Querier, - T: Into, - CQ: CustomQuery, - { - let msg = QueryMsg::GetCount {}; - let query = WasmQuery::Smart { - contract_addr: self.addr().into(), - msg: to_json_binary(&msg)?, - } - .into(); - let res: GetCountResponse = QuerierWrapper::::new(querier).query(&query)?; - Ok(res) +/// Validates deal time parameters +pub fn validate_deal_times( + bid_start_time: u64, + bid_end_time: u64, + conclude_time: u64, + current_time: u64, +) -> Result<(), ContractError> { + if bid_start_time >= bid_end_time { + return Err(ContractError::InvalidTimeParameters { + reason: "Bid start time must be before bid end time".to_string(), + }); + } + if bid_end_time >= conclude_time { + return Err(ContractError::InvalidTimeParameters { + reason: "Bid end time must be before conclude time".to_string(), + }); } + if bid_start_time < current_time { + return Err(ContractError::InvalidTimeParameters { + reason: "Bid start time must be in the future".to_string(), + }); + } + Ok(()) } + +/// Calculates the platform fee for a given amount +pub fn calculate_platform_fee( + amount: Uint128, + fee_percentage: u64, +) -> StdResult { + amount.multiply_ratio(fee_percentage, 10000u128) +} \ No newline at end of file diff --git a/src/integration_tests.rs b/src/integration_tests.rs deleted file mode 100644 index 324f2ecd..00000000 --- a/src/integration_tests.rs +++ /dev/null @@ -1,78 +0,0 @@ -#[cfg(test)] -mod tests { - use crate::helpers::CwTemplateContract; - use crate::msg::InstantiateMsg; - use cosmwasm_std::testing::MockApi; - use cosmwasm_std::{Addr, Coin, Empty, Uint128}; - use cw_multi_test::{App, AppBuilder, Contract, ContractWrapper, Executor}; - - pub fn contract_template() -> Box> { - let contract = ContractWrapper::new( - crate::contract::execute, - crate::contract::instantiate, - crate::contract::query, - ); - Box::new(contract) - } - - const USER: &str = "USER"; - const ADMIN: &str = "ADMIN"; - const NATIVE_DENOM: &str = "denom"; - - fn mock_app() -> App { - AppBuilder::new().build(|router, _, storage| { - router - .bank - .init_balance( - storage, - &MockApi::default().addr_make(USER), - vec![Coin { - denom: NATIVE_DENOM.to_string(), - amount: Uint128::new(1), - }], - ) - .unwrap(); - }) - } - - fn proper_instantiate() -> (App, CwTemplateContract) { - let mut app = mock_app(); - let cw_template_id = app.store_code(contract_template()); - - let user = app.api().addr_make(USER); - assert_eq!( - app.wrap().query_balance(user, NATIVE_DENOM).unwrap().amount, - Uint128::new(1) - ); - - let msg = InstantiateMsg { count: 1i32 }; - let cw_template_contract_addr = app - .instantiate_contract( - cw_template_id, - Addr::unchecked(ADMIN), - &msg, - &[], - "test", - None, - ) - .unwrap(); - - let cw_template_contract = CwTemplateContract(cw_template_contract_addr); - - (app, cw_template_contract) - } - - mod count { - use super::*; - use crate::msg::ExecuteMsg; - - #[test] - fn count() { - let (mut app, cw_template_contract) = proper_instantiate(); - - let msg = ExecuteMsg::Increment {}; - let cosmos_msg = cw_template_contract.call(msg).unwrap(); - app.execute(Addr::unchecked(USER), cosmos_msg).unwrap(); - } - } -} diff --git a/src/lib.rs b/src/lib.rs index d6185c4e..561bfb67 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,22 @@ +//! CosmWasm OTC Platform Smart Contract +//! +//! This contract implements a decentralized over-the-counter (OTC) trading platform +//! where sellers can create deals with customizable parameters and buyers can place +//! bids with their desired discount rates. +//! +//! ## Features +//! +//! * Create OTC deals with custom parameters +//! * Place, update, and withdraw bids +//! * Automatic deal conclusion +//! * Minimum price protection for sellers +//! * Maximum price protection for buyers +//! * Platform fee mechanism + pub mod contract; -mod error; +pub mod error; pub mod helpers; -pub mod integration_tests; pub mod msg; pub mod state; -pub use crate::error::ContractError; +pub use crate::error::ContractError; \ No newline at end of file diff --git a/src/msg.rs b/src/msg.rs index 0edfa328..fb57ba3a 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -1,26 +1,98 @@ -use cosmwasm_schema::{cw_serde, QueryResponses}; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use cosmwasm_std::Uint128; +use crate::state::{Config, Deal, Bid}; -#[cw_serde] +/// Message for contract instantiation +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct InstantiateMsg { - pub count: i32, + /// Platform fee percentage in basis points + pub platform_fee_percentage: u64, } -#[cw_serde] +/// Messages for executing contract functions +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[serde(rename_all = "snake_case")] pub enum ExecuteMsg { - Increment {}, - Reset { count: i32 }, + /// Creates a new OTC deal + CreateDeal { + /// Address of the token being sold + sell_token: String, + /// Total amount of tokens to sell + total_amount: Uint128, + /// Minimum price per token + min_price: Uint128, + /// Maximum discount percentage offered + discount_percentage: u64, + /// Minimum total value required for deal conclusion + min_cap: Uint128, + /// Unix timestamp for bid start + bid_start_time: u64, + /// Unix timestamp for bid end + bid_end_time: u64, + /// Unix timestamp for deal conclusion + conclude_time: u64, + }, + /// Places a new bid on an existing deal + PlaceBid { + /// ID of the deal to bid on + deal_id: u64, + /// Amount of tokens to buy + amount: Uint128, + /// Requested discount percentage + discount_percentage: u64, + /// Optional maximum price willing to pay + max_price: Option, + }, + /// Updates an existing bid + UpdateBid { + /// ID of the deal + deal_id: u64, + /// New amount of tokens to buy + new_amount: Uint128, + /// New requested discount percentage + new_discount_percentage: u64, + /// New maximum price willing to pay + new_max_price: Option, + }, + /// Withdraws an existing bid + WithdrawBid { + /// ID of the deal + deal_id: u64, + }, + /// Concludes a deal after its conclusion time + ConcludeDeal { + /// ID of the deal to conclude + deal_id: u64, + }, } -#[cw_serde] -#[derive(QueryResponses)] +/// Messages for querying contract state +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[serde(rename_all = "snake_case")] pub enum QueryMsg { - // GetCount returns the current count as a json-encoded number - #[returns(GetCountResponse)] - GetCount {}, + /// Get details of a specific deal + GetDeal { deal_id: u64 }, + /// Get all bids for a specific deal + GetBids { deal_id: u64 }, + /// Get contract configuration + GetConfig {}, } -// We define a custom struct for each query response -#[cw_serde] -pub struct GetCountResponse { - pub count: i32, +/// Response for GetDeal query +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct DealResponse { + pub deal: Deal, } + +/// Response for GetBids query +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct BidsResponse { + pub bids: Vec<(String, Bid)>, +} + +/// Response for GetConfig query +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct ConfigResponse { + pub config: Config, +} \ No newline at end of file diff --git a/src/state.rs b/src/state.rs index bad92026..b771b5be 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,13 +1,64 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use cosmwasm_std::{Addr, Uint128}; +use cw_storage_plus::{Item, Map}; -use cosmwasm_std::Addr; -use cw_storage_plus::Item; +/// Configuration for the OTC platform +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct Config { + /// Platform fee percentage in basis points (1/100 of a percent) + /// e.g., 100 = 1%, 50 = 0.5% + pub platform_fee_percentage: u64, +} + +/// Represents an OTC deal created by a seller +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct Deal { + /// Address of the seller who created the deal + pub seller: String, + /// Address of the token being sold + pub sell_token: String, + /// Total amount of tokens being sold + pub total_amount: Uint128, + /// Minimum price per token that the seller will accept + pub min_price: Uint128, + /// Seller's maximum discount percentage they're willing to offer + pub discount_percentage: u64, + /// Minimum total value of bids required for the deal to conclude + pub min_cap: Uint128, + /// Unix timestamp when bidding starts + pub bid_start_time: u64, + /// Unix timestamp when bidding ends + pub bid_end_time: u64, + /// Unix timestamp when the deal can be concluded + pub conclude_time: u64, + /// Whether the deal has been concluded + pub is_concluded: bool, + /// Total amount of all active bids + pub total_bids_amount: Uint128, +} -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct State { - pub count: i32, - pub owner: Addr, +/// Represents a bid placed by a buyer +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct Bid { + /// Address of the bidder + pub bidder: String, + /// Amount of tokens the bidder wants to buy + pub amount: Uint128, + /// Discount percentage requested by the bidder + pub discount_percentage: u64, + /// Optional maximum price the bidder is willing to pay + pub max_price: Option, } -pub const STATE: Item = Item::new("state"); +/// Stores the contract configuration +pub const CONFIG: Item = Item::new("config"); + +/// Counter for generating unique deal IDs +pub const DEAL_COUNTER: Item = Item::new("deal_counter"); + +/// Maps deal IDs to Deal structs +pub const DEALS: Map = Map::new("deals"); + +/// Maps (deal_id, bidder_address) to Bid structs +pub const BIDS: Map<(u64, &Addr), Bid> = Map::new("bids"); From 84f8c2fad3d3d704ae57376b490c022c5f0b2302 Mon Sep 17 00:00:00 2001 From: anilcse Date: Fri, 8 Nov 2024 16:50:06 +0530 Subject: [PATCH 04/24] Fix schema gen --- .gitignore | 1 + Cargo.lock | 2869 ++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 8 +- examples/schema.rs | 23 + src/contract.rs | 574 +++++++-- 5 files changed, 3377 insertions(+), 98 deletions(-) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 examples/schema.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..9f970225 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target/ \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 00000000..bfe78dfd --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2869 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli 0.31.1", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + +[[package]] +name = "anyhow" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" + +[[package]] +name = "ark-bls12-381" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools 0.10.5", + "num-traits", + "rayon", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest 0.10.7", + "itertools 0.10.5", + "num-bigint", + "num-traits", + "paste", + "rayon", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest 0.10.7", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", + "rayon", +] + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets", +] + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + +[[package]] +name = "bech32" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bnum" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56953345e39537a3e18bdaeba4cb0c58a78c1f61f361dc0fa7c5c7340ae87c5f" + +[[package]] +name = "bnum" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e31ea183f6ee62ac8b8a8cf7feddd766317adfb13ff469de57ce033efd6a790" + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "bytecheck" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" + +[[package]] +name = "cc" +version = "1.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baee610e9452a8f6f0a1b6194ec09ff9e2d85dea54432acdae41aa0761c95d70" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clru" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbd0f76e066e64fdc5631e3bb46381254deab9ef1158292f27c8c57e3bf3fe59" + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "corosensei" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80128832c58ea9cbd041d2a759ec449224487b2c1e400453d99d244eead87a8e" +dependencies = [ + "autocfg", + "cfg-if", + "libc", + "scopeguard", + "windows-sys 0.33.0", +] + +[[package]] +name = "cosmwasm-core" +version = "2.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6ceb8624260d0d3a67c4e1a1d43fc7e9406720afbcb124521501dd138f90aa" + +[[package]] +name = "cosmwasm-crypto" +version = "1.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58535cbcd599b3c193e3967c8292fe1dbbb5de7c2a2d87380661091dd4744044" +dependencies = [ + "digest 0.10.7", + "ed25519-zebra 3.1.0", + "k256", + "rand_core 0.6.4", + "thiserror 1.0.68", +] + +[[package]] +name = "cosmwasm-crypto" +version = "2.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4125381e5fd7fefe9f614640049648088015eca2b60d861465329a5d87dfa538" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-serialize", + "cosmwasm-core", + "digest 0.10.7", + "ecdsa", + "ed25519-zebra 4.0.3", + "k256", + "num-traits", + "p256", + "rand_core 0.6.4", + "rayon", + "sha2 0.10.8", + "thiserror 1.0.68", +] + +[[package]] +name = "cosmwasm-derive" +version = "1.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8e07de16c800ac82fd188d055ecdb923ead0cf33960d3350089260bb982c09f" +dependencies = [ + "syn 1.0.109", +] + +[[package]] +name = "cosmwasm-derive" +version = "2.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5658b1dc64e10b56ae7a449f678f96932a96f6cfad1769d608d1d1d656480a" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "cosmwasm-schema" +version = "1.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d388adfa9cb449557a92e9318121ac1a481fc4f599213b03a5b62699b403b4" +dependencies = [ + "cosmwasm-schema-derive 1.5.8", + "schemars", + "serde", + "serde_json", + "thiserror 1.0.68", +] + +[[package]] +name = "cosmwasm-schema" +version = "2.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f86b4d949b6041519c58993a73f4bbfba8083ba14f7001eae704865a09065845" +dependencies = [ + "cosmwasm-schema-derive 2.1.4", + "schemars", + "serde", + "serde_json", + "thiserror 1.0.68", +] + +[[package]] +name = "cosmwasm-schema-derive" +version = "1.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2411b389e56e6484f81ba955b758d02522d620c98fc960c4bd2251d48b7aa19f" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "cosmwasm-schema-derive" +version = "2.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ef1b5835a65fcca3ab8b9a02b4f4dacc78e233a5c2f20b270efb9db0666d12" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "cosmwasm-std" +version = "1.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c21fde95ccd20044a23c0ac6fd8c941f3e8c158169dc94b5aa6491a2d9551a8d" +dependencies = [ + "base64 0.21.7", + "bech32 0.9.1", + "bnum 0.10.0", + "cosmwasm-crypto 1.5.8", + "cosmwasm-derive 1.5.8", + "derivative", + "forward_ref", + "hex", + "schemars", + "serde", + "serde-json-wasm 0.5.2", + "sha2 0.10.8", + "static_assertions", + "thiserror 1.0.68", +] + +[[package]] +name = "cosmwasm-std" +version = "2.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70eb7ab0c1e99dd6207496963ba2a457c4128ac9ad9c72a83f8d9808542b849b" +dependencies = [ + "base64 0.22.1", + "bech32 0.11.0", + "bnum 0.11.0", + "cosmwasm-core", + "cosmwasm-crypto 2.1.4", + "cosmwasm-derive 2.1.4", + "derive_more", + "hex", + "rand_core 0.6.4", + "schemars", + "serde", + "serde-json-wasm 1.0.1", + "sha2 0.10.8", + "static_assertions", + "thiserror 1.0.68", +] + +[[package]] +name = "cosmwasm-vm" +version = "1.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f0759572dd51046c18c60727c58adf75dc91adb35325a2ef79eff572f190c14" +dependencies = [ + "bitflags 1.3.2", + "bytecheck", + "bytes", + "clru", + "cosmwasm-crypto 1.5.8", + "cosmwasm-std 1.5.8", + "crc32fast", + "derivative", + "enumset", + "hex", + "schemars", + "serde", + "serde_json", + "sha2 0.10.8", + "thiserror 1.0.68", + "wasmer", + "wasmer-middlewares", + "wasmer-types", +] + +[[package]] +name = "cpufeatures" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +dependencies = [ + "libc", +] + +[[package]] +name = "cranelift-bforest" +version = "0.91.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2ab4512dfd3a6f4be184403a195f76e81a8a9f9e6c898e19d2dc3ce20e0115" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.91.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98b022ed2a5913a38839dfbafe6cf135342661293b08049843362df4301261dc" +dependencies = [ + "arrayvec", + "bumpalo", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-egraph", + "cranelift-entity", + "cranelift-isle", + "gimli 0.26.2", + "log", + "regalloc2", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.91.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "639307b45434ad112a98f8300c0f0ab085cbefcd767efcdef9ef19d4c0756e74" +dependencies = [ + "cranelift-codegen-shared", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.91.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "278e52e29c53fcf32431ef08406c295699a70306d05a0715c5b1bf50e33a9ab7" + +[[package]] +name = "cranelift-egraph" +version = "0.91.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624b54323b06e675293939311943ba82d323bb340468ce1889be5da7932c8d73" +dependencies = [ + "cranelift-entity", + "fxhash", + "hashbrown 0.12.3", + "indexmap", + "log", + "smallvec", +] + +[[package]] +name = "cranelift-entity" +version = "0.91.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a59bcbca89c3f1b70b93ab3cbba5e5e0cbf3e63dadb23c7525cb142e21a9d4c" + +[[package]] +name = "cranelift-frontend" +version = "0.91.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d70abacb8cfef3dc8ff7e8836e9c1d70f7967dfdac824a4cd5e30223415aca6" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-isle" +version = "0.91.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "393bc73c451830ff8dbb3a07f61843d6cb41a084f9996319917c0b291ed785bb" + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "cw-multi-test" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1149fe104344cc4f4ca0fc784b7411042fd1626813fe85fd412b05252a0ae9d8" +dependencies = [ + "anyhow", + "bech32 0.11.0", + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", + "cw-storage-plus", + "cw-utils", + "itertools 0.13.0", + "prost", + "schemars", + "serde", + "sha2 0.10.8", + "thiserror 2.0.0", +] + +[[package]] +name = "cw-otc-dex" +version = "0.1.0" +dependencies = [ + "cosmwasm-schema 1.5.8", + "cosmwasm-std 2.1.4", + "cosmwasm-vm", + "cw-multi-test", + "cw-storage-plus", + "cw2", + "schemars", + "serde", + "thiserror 1.0.68", +] + +[[package]] +name = "cw-storage-plus" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f13360e9007f51998d42b1bc6b7fa0141f74feae61ed5fd1e5b0a89eec7b5de1" +dependencies = [ + "cosmwasm-std 2.1.4", + "schemars", + "serde", +] + +[[package]] +name = "cw-utils" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07dfee7f12f802431a856984a32bce1cb7da1e6c006b5409e3981035ce562dec" +dependencies = [ + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", + "schemars", + "serde", + "thiserror 1.0.68", +] + +[[package]] +name = "cw2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b04852cd38f044c0751259d5f78255d07590d136b8a86d4e09efdd7666bd6d27" +dependencies = [ + "cosmwasm-schema 2.1.4", + "cosmwasm-std 2.1.4", + "cw-storage-plus", + "schemars", + "semver", + "serde", + "thiserror 1.0.68", +] + +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "unicode-xid", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + +[[package]] +name = "dynasm" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "add9a102807b524ec050363f09e06f1504214b0e1c7797f64261c891022dce8b" +dependencies = [ + "bitflags 1.3.2", + "byteorder", + "lazy_static", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "dynasmrt" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64fba5a42bd76a17cad4bfa00de168ee1cbfa06a5e8ce992ae880218c05641a9" +dependencies = [ + "byteorder", + "dynasm", + "memmap2 0.5.10", +] + +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest 0.10.7", + "elliptic-curve", + "rfc6979", + "signature", + "spki", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-zebra" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +dependencies = [ + "curve25519-dalek 3.2.0", + "hashbrown 0.12.3", + "hex", + "rand_core 0.6.4", + "serde", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "ed25519-zebra" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" +dependencies = [ + "curve25519-dalek 4.1.3", + "ed25519", + "hashbrown 0.14.5", + "hex", + "rand_core 0.6.4", + "sha2 0.10.8", + "zeroize", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest 0.10.7", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "enum-iterator" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eeac5c5edb79e4e39fe8439ef35207780a11f69c52cbe424ce3dfad4cb78de6" +dependencies = [ + "enum-iterator-derive", +] + +[[package]] +name = "enum-iterator-derive" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c134c37760b27a871ba422106eedbb8247da973a09e82558bf26d619c882b159" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "enumset" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07a4b049558765cef5f0c1a273c3fc57084d768b44d2f98127aef4cceb17293" +dependencies = [ + "enumset_derive", +] + +[[package]] +name = "enumset_derive" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59c3b24c345d8c314966bdc1832f6c2635bfcce8e7cf363bd115987bba2ee242" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "forward_ref" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", + "zeroize", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.8", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.11", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash 0.8.11", + "allocator-api2", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2 0.10.8", + "signature", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "libc" +version = "0.2.162" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" + +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "memmap2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +dependencies = [ + "libc", +] + +[[package]] +name = "memmap2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d28bba84adfe6646737845bc5ebbfa2c08424eb1c37e94a1fd2a82adb56a872" +dependencies = [ + "libc", +] + +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + +[[package]] +name = "more-asserts" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.36.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2 0.10.8", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" +dependencies = [ + "anyhow", + "itertools 0.10.5", + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_chacha", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "redox_syscall" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +dependencies = [ + "bitflags 2.6.0", +] + +[[package]] +name = "regalloc2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300d4fbfb40c1c66a78ba3ddd41c1110247cf52f97b87d0f2fc9209bd49b030c" +dependencies = [ + "fxhash", + "log", + "slice-group-by", + "smallvec", +] + +[[package]] +name = "region" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6b6ebd13bc009aef9cd476c1310d49ac354d36e240cf1bd753290f3dc7199a7" +dependencies = [ + "bitflags 1.3.2", + "libc", + "mach2", + "windows-sys 0.52.0", +] + +[[package]] +name = "rend" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + +[[package]] +name = "rkyv" +version = "0.7.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9008cd6385b9e161d8229e1f6549dd23c3d022f132a2ea37ac3a10ac4935779b" +dependencies = [ + "bitvec", + "bytecheck", + "bytes", + "hashbrown 0.12.3", + "indexmap", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "503d1d27590a2b0a3a4ca4c94755aa2875657196ecbf401a42eff41d7de532c0" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.87", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "self_cell" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a" + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.214" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-json-wasm" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9213a07d53faa0b8dd81e767a54a8188a242fdb9be99ab75ec576a774bfdd7" +dependencies = [ + "serde", +] + +[[package]] +name = "serde-json-wasm" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05da0d153dd4595bdffd5099dc0e9ce425b205ee648eb93437ff7302af8c9a5" +dependencies = [ + "serde", +] + +[[package]] +name = "serde-wasm-bindgen" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b4c031cd0d9014307d82b8abf653c0290fbdaeb4c02d00c63cf52f728628bf" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + +[[package]] +name = "serde_derive" +version = "1.0.214" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "serde_json" +version = "1.0.132" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "shared-buffer" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6c99835bad52957e7aa241d3975ed17c1e5f8c92026377d117a606f36b84b16" +dependencies = [ + "bytes", + "memmap2 0.6.2", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "slice-group-by" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + +[[package]] +name = "thiserror" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" +dependencies = [ + "thiserror-impl 1.0.68", +] + +[[package]] +name = "thiserror" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15291287e9bff1bc6f9ff3409ed9af665bec7a5fc8ac079ea96be07bca0e2668" +dependencies = [ + "thiserror-impl 2.0.0", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22efd00f33f93fa62848a7cab956c3d38c8d43095efda1decfc2b3a5dc0b8972" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "url" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.87", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-downcast" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dac026d43bcca6e7ce1c0956ba68f59edf6403e8e930a5d891be72c31a44340" +dependencies = [ + "js-sys", + "once_cell", + "wasm-bindgen", + "wasm-bindgen-downcast-macros", +] + +[[package]] +name = "wasm-bindgen-downcast-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5020cfa87c7cecefef118055d44e3c1fc122c7ec25701d528ee458a0b45f38f" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" + +[[package]] +name = "wasmer" +version = "4.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e626f958755a90a6552b9528f59b58a62ae288e6c17fcf40e99495bc33c60f0" +dependencies = [ + "bytes", + "cfg-if", + "derivative", + "indexmap", + "js-sys", + "more-asserts", + "rustc-demangle", + "serde", + "serde-wasm-bindgen", + "shared-buffer", + "target-lexicon", + "thiserror 1.0.68", + "wasm-bindgen", + "wasm-bindgen-downcast", + "wasmer-compiler", + "wasmer-compiler-cranelift", + "wasmer-compiler-singlepass", + "wasmer-derive", + "wasmer-types", + "wasmer-vm", + "winapi", +] + +[[package]] +name = "wasmer-compiler" +version = "4.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "848e1922694cf97f4df680a0534c9d72c836378b5eb2313c1708fe1a75b40044" +dependencies = [ + "backtrace", + "bytes", + "cfg-if", + "enum-iterator", + "enumset", + "lazy_static", + "leb128", + "memmap2 0.5.10", + "more-asserts", + "region", + "rkyv", + "self_cell", + "shared-buffer", + "smallvec", + "thiserror 1.0.68", + "wasmer-types", + "wasmer-vm", + "wasmparser", + "winapi", +] + +[[package]] +name = "wasmer-compiler-cranelift" +version = "4.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d96bce6fad15a954edcfc2749b59e47ea7de524b6ef3df392035636491a40b4" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "gimli 0.26.2", + "more-asserts", + "rayon", + "smallvec", + "target-lexicon", + "tracing", + "wasmer-compiler", + "wasmer-types", +] + +[[package]] +name = "wasmer-compiler-singlepass" +version = "4.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebaa865b40ffb3351b03dab9fe9930a5248c25daebd55b464b79b862d9b55ccd" +dependencies = [ + "byteorder", + "dynasm", + "dynasmrt", + "enumset", + "gimli 0.26.2", + "lazy_static", + "more-asserts", + "rayon", + "smallvec", + "wasmer-compiler", + "wasmer-types", +] + +[[package]] +name = "wasmer-derive" +version = "4.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f08f80d166a9279671b7af7a09409c28ede2e0b4e3acabbf0e3cb22c8038ba7" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "wasmer-middlewares" +version = "4.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeb4b87c0ea9f8636c81a8ab8f52bad01c8623c9fcbb3db5f367d5f157fada30" +dependencies = [ + "wasmer", + "wasmer-types", + "wasmer-vm", +] + +[[package]] +name = "wasmer-types" +version = "4.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae2c892882f0b416783fb4310e5697f5c30587f6f9555f9d4f2be85ab39d5d3d" +dependencies = [ + "bytecheck", + "enum-iterator", + "enumset", + "indexmap", + "more-asserts", + "rkyv", + "target-lexicon", + "thiserror 1.0.68", +] + +[[package]] +name = "wasmer-vm" +version = "4.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c0a9a57b627fb39e5a491058d4365f099bc9b140031c000fded24a3306d9480" +dependencies = [ + "backtrace", + "cc", + "cfg-if", + "corosensei", + "crossbeam-queue", + "dashmap", + "derivative", + "enum-iterator", + "fnv", + "indexmap", + "lazy_static", + "libc", + "mach", + "memoffset", + "more-asserts", + "region", + "scopeguard", + "thiserror 1.0.68", + "wasmer-types", + "winapi", +] + +[[package]] +name = "wasmparser" +version = "0.95.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ea896273ea99b15132414be1da01ab0d8836415083298ecaffbe308eaac87a" +dependencies = [ + "indexmap", + "url", +] + +[[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.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43dbb096663629518eb1dfa72d80243ca5a6aca764cae62a2df70af760a9be75" +dependencies = [ + "windows_aarch64_msvc 0.33.0", + "windows_i686_gnu 0.33.0", + "windows_i686_msvc 0.33.0", + "windows_x86_64_gnu 0.33.0", + "windows_x86_64_msvc 0.33.0", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] diff --git a/Cargo.toml b/Cargo.toml index 6624d8bc..39cc2306 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,10 @@ edition = "2021" [lib] crate-type = ["cdylib", "rlib"] +[[example]] +name = "schema" +path = "examples/schema.rs" + [profile.release] opt-level = 3 debug = false @@ -21,6 +25,7 @@ incremental = false overflow-checks = true [features] +default = [] # use library feature to disable all instantiate/execute/query exports library = [] @@ -32,7 +37,6 @@ optimize = """docker run --rm -v "$(pwd)":/code \ """ [dependencies] -cosmwasm-schema = "2.1.0" cosmwasm-std = { version = "2.1.0", features = [ "cosmwasm_1_4", # Enable this if you only deploy to chains that have CosmWasm 2.0 or higher @@ -45,4 +49,6 @@ serde = { version = "1.0.197", default-features = false, features = ["derive"] } thiserror = { version = "1.0.58" } [dev-dependencies] +cosmwasm-vm = "1.1.0" cw-multi-test = "2.0.0" +cosmwasm-schema = "1.0.0" diff --git a/examples/schema.rs b/examples/schema.rs new file mode 100644 index 00000000..5b466902 --- /dev/null +++ b/examples/schema.rs @@ -0,0 +1,23 @@ +// examples/schema.rs + +use std::env::current_dir; +use std::fs::create_dir_all; + +use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; + +use crate_name::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use crate_name::state::{Bid, Config, OtcDeal}; + +fn main() { + let mut out_dir = current_dir().unwrap(); + out_dir.push("schema"); + create_dir_all(&out_dir).unwrap(); + remove_schemas(&out_dir).unwrap(); + + export_schema(&schema_for!(InstantiateMsg), &out_dir); + export_schema(&schema_for!(ExecuteMsg), &out_dir); + export_schema(&schema_for!(QueryMsg), &out_dir); + export_schema(&schema_for!(Config), &out_dir); + export_schema(&schema_for!(OtcDeal), &out_dir); + export_schema(&schema_for!(Bid), &out_dir); +} diff --git a/src/contract.rs b/src/contract.rs index 03aef1b6..cacce61c 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -1,16 +1,25 @@ -#[cfg(not(feature = "library"))] -use cosmwasm_std::entry_point; -use cosmwasm_std::{to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult}; +use cosmwasm_std::{ + to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, + StdResult, Uint128, Order, entry_point, CosmosMsg, Storage, +}; use cw2::set_contract_version; use crate::error::ContractError; -use crate::msg::{ExecuteMsg, GetCountResponse, InstantiateMsg, QueryMsg}; -use crate::state::{State, STATE}; +use crate::msg::{ + ExecuteMsg, InstantiateMsg, QueryMsg, ConfigResponse, + DealResponse, BidsResponse, +}; +use crate::state::{Config, Deal, Bid, CONFIG, DEAL_COUNTER, DEALS, BIDS}; +use crate::helpers::{ + create_token_transfer_msg, create_payment_msg, get_sorted_bids, + validate_deal_times, calculate_platform_fee, +}; -// version info for migration info -const CONTRACT_NAME: &str = "crates.io:cw-otc-dex"; +/// Contract name and version info for migration +const CONTRACT_NAME: &str = "crates.io:cosmos-otc-platform"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); +/// Initializes the contract with the specified configuration #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, @@ -18,139 +27,510 @@ pub fn instantiate( info: MessageInfo, msg: InstantiateMsg, ) -> Result { - let state = State { - count: msg.count, - owner: info.sender.clone(), - }; + // Validate platform fee percentage (must be between 0 and 10000) + if msg.platform_fee_percentage > 10000 { + return Err(ContractError::InvalidTimeParameters { + reason: "Platform fee percentage must not exceed 100%".to_string(), + }); + } + set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - STATE.save(deps.storage, &state)?; + + let config = Config { + platform_fee_percentage: msg.platform_fee_percentage, + }; + + CONFIG.save(deps.storage, &config)?; + DEAL_COUNTER.save(deps.storage, &0u64)?; Ok(Response::new() .add_attribute("method", "instantiate") - .add_attribute("owner", info.sender) - .add_attribute("count", msg.count.to_string())) + .add_attribute("owner", info.sender)) } +/// Handles all execute messages #[cfg_attr(not(feature = "library"), entry_point)] pub fn execute( deps: DepsMut, - _env: Env, + env: Env, info: MessageInfo, msg: ExecuteMsg, ) -> Result { match msg { - ExecuteMsg::Increment {} => execute::increment(deps), - ExecuteMsg::Reset { count } => execute::reset(deps, info, count), + ExecuteMsg::CreateDeal { + sell_token, + total_amount, + min_price, + discount_percentage, + min_cap, + bid_start_time, + bid_end_time, + conclude_time, + } => execute_create_deal( + deps, + env, + info, + sell_token, + total_amount, + min_price, + discount_percentage, + min_cap, + bid_start_time, + bid_end_time, + conclude_time, + ), + ExecuteMsg::PlaceBid { + deal_id, + amount, + discount_percentage, + max_price, + } => execute_place_bid(deps, env, info, deal_id, amount, discount_percentage, max_price), + ExecuteMsg::UpdateBid { + deal_id, + new_amount, + new_discount_percentage, + new_max_price, + } => execute_update_bid(deps, env, info, deal_id, new_amount, new_discount_percentage, new_max_price), + ExecuteMsg::WithdrawBid { deal_id } => execute_withdraw_bid(deps, env, info, deal_id), + ExecuteMsg::ConcludeDeal { deal_id } => execute_conclude_deal(deps, env, info, deal_id), } } -pub mod execute { - use super::*; - - pub fn increment(deps: DepsMut) -> Result { - STATE.update(deps.storage, |mut state| -> Result<_, ContractError> { - state.count += 1; - Ok(state) - })?; +/// Creates a new OTC deal +pub fn execute_create_deal( + deps: DepsMut, + env: Env, + info: MessageInfo, + sell_token: String, + total_amount: Uint128, + min_price: Uint128, + discount_percentage: u64, + min_cap: Uint128, + bid_start_time: u64, + bid_end_time: u64, + conclude_time: u64, +) -> Result { + // Validate time parameters + validate_deal_times( + bid_start_time, + bid_end_time, + conclude_time, + env.block.time.seconds(), + )?; - Ok(Response::new().add_attribute("action", "increment")) + // Validate discount percentage + if discount_percentage > 10000 { + return Err(ContractError::InvalidTimeParameters { + reason: "Discount percentage must not exceed 100%".to_string(), + }); } - pub fn reset(deps: DepsMut, info: MessageInfo, count: i32) -> Result { - STATE.update(deps.storage, |mut state| -> Result<_, ContractError> { - if info.sender != state.owner { - return Err(ContractError::Unauthorized {}); - } - state.count = count; - Ok(state) - })?; - Ok(Response::new().add_attribute("action", "reset")) + // Calculate and validate platform fee + let config = CONFIG.load(deps.storage)?; + let platform_fee = calculate_platform_fee(total_amount, config.platform_fee_percentage)?; + + // Ensure seller has sent enough platform fee + let provided_fee = info + .funds + .iter() + .find(|c| c.denom == "uusd") // Replace with your desired denomination + .map(|c| c.amount) + .unwrap_or_default(); + + if provided_fee < platform_fee { + return Err(ContractError::InsufficientPlatformFee { + required: platform_fee.u128(), + provided: provided_fee.u128(), + }); } + + // Create and save new deal + let deal_id = DEAL_COUNTER.load(deps.storage)? + 1; + DEAL_COUNTER.save(deps.storage, &deal_id)?; + + let deal = Deal { + seller: info.sender.to_string(), + sell_token, + total_amount, + min_price, + discount_percentage, + min_cap, + bid_start_time, + bid_end_time, + conclude_time, + is_concluded: false, + total_bids_amount: Uint128::zero(), + }; + + DEALS.save(deps.storage, deal_id, &deal)?; + + Ok(Response::new() + .add_attribute("method", "create_deal") + .add_attribute("deal_id", deal_id.to_string()) + .add_attribute("seller", info.sender)) } -#[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { - match msg { - QueryMsg::GetCount {} => to_json_binary(&query::count(deps)?), +/// Places a new bid on an existing deal +pub fn execute_place_bid( + deps: DepsMut, + env: Env, + info: MessageInfo, + deal_id: u64, + amount: Uint128, + discount_percentage: u64, + max_price: Option, +) -> Result { + let deal = DEALS.load(deps.storage, deal_id)?; + + // Validate bid timing + let current_time = env.block.time.seconds(); + if current_time < deal.bid_start_time { + return Err(ContractError::BiddingNotStarted {}); } + if current_time >= deal.bid_end_time { + return Err(ContractError::BiddingEnded {}); + } + + // Validate bid amount + if amount.is_zero() { + return Err(ContractError::InvalidBidAmount { + reason: "Bid amount must be greater than zero".to_string(), + }); + } + + // Validate discount percentage + if discount_percentage > 10000 { + return Err(ContractError::InvalidBidAmount { + reason: "Discount percentage must not exceed 100%".to_string(), + }); + } + + let bid = Bid { + bidder: info.sender.to_string(), + amount, + discount_percentage, + max_price, + }; + + BIDS.save(deps.storage, (deal_id, &info.sender), &bid)?; + + // Update total bids amount + let new_total = deal.total_bids_amount + amount; + DEALS.update(deps.storage, deal_id, |deal_opt| -> StdResult<_> { + let mut deal = deal_opt.unwrap(); + deal.total_bids_amount = new_total; + Ok(deal) + })?; + + Ok(Response::new() + .add_attribute("method", "place_bid") + .add_attribute("deal_id", deal_id.to_string()) + .add_attribute("bidder", info.sender) + .add_attribute("amount", amount)) } -pub mod query { - use super::*; +/// Updates an existing bid +pub fn execute_update_bid( + deps: DepsMut, + env: Env, + info: MessageInfo, + deal_id: u64, + new_amount: Uint128, + new_discount_percentage: u64, + new_max_price: Option, +) -> Result { + let deal = DEALS.load(deps.storage, deal_id)?; + + // Validate timing + if env.block.time.seconds() >= deal.bid_end_time { + return Err(ContractError::BiddingEnded {}); + } + + // Load existing bid + let old_bid = BIDS.load(deps.storage, (deal_id, &info.sender))?; + + // Update total bids amount + let amount_diff = new_amount.checked_sub(old_bid.amount)?; + DEALS.update(deps.storage, deal_id, |deal_opt| -> StdResult<_> { + let mut deal = deal_opt.unwrap(); + deal.total_bids_amount = deal.total_bids_amount.checked_add(amount_diff)?; + Ok(deal) + })?; + + // Save updated bid + let new_bid = Bid { + bidder: info.sender.to_string(), + amount: new_amount, + discount_percentage: new_discount_percentage, + max_price: new_max_price, + }; + BIDS.save(deps.storage, (deal_id, &info.sender), &new_bid)?; - pub fn count(deps: Deps) -> StdResult { - let state = STATE.load(deps.storage)?; - Ok(GetCountResponse { count: state.count }) + Ok(Response::new() + .add_attribute("method", "update_bid") + .add_attribute("deal_id", deal_id.to_string()) + .add_attribute("bidder", info.sender)) +} + +/// Withdraws an existing bid +pub fn execute_withdraw_bid( + deps: DepsMut, + env: Env, + info: MessageInfo, + deal_id: u64, +) -> Result { + let deal = DEALS.load(deps.storage, deal_id)?; + + // Validate timing + if env.block.time.seconds() >= deal.bid_end_time { + return Err(ContractError::BiddingEnded {}); } + + // Load and remove bid + let bid = BIDS.load(deps.storage, (deal_id, &info.sender))?; + BIDS.remove(deps.storage, (deal_id, &info.sender)); + + // Update total bids amount + DEALS.update(deps.storage, deal_id, |deal_opt| -> StdResult<_> { + let mut deal = deal_opt.unwrap(); + deal.total_bids_amount = deal.total_bids_amount.checked_sub(bid.amount)?; + Ok(deal) + })?; + + Ok(Response::new() + .add_attribute("method", "withdraw_bid") + .add_attribute("deal_id", deal_id.to_string()) + .add_attribute("bidder", info.sender)) } -#[cfg(test)] -mod tests { - use super::*; - use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; - use cosmwasm_std::{coins, from_json}; +/// Concludes an OTC deal by processing all bids and distributing tokens +/// +/// # Deal Conclusion Process +/// 1. Validates deal timing and status +/// 2. Checks if minimum cap is met +/// 3. If min cap not met: refunds all bidders +/// 4. If min cap met: +/// - Sorts bids by discount (lowest first) +/// - Processes bids until all tokens are allocated +/// - Transfers tokens to successful bidders +/// - Transfers payments to seller +/// - Refunds unsuccessful bidders +/// +/// # Arguments +/// * `deps` - Mutable dependencies for storage access +/// * `env` - Environment variables, primarily used for time validation +/// * `_info` - Message information (unused but kept for consistency) +/// * `deal_id` - Identifier of the deal to conclude +/// +/// # Returns +/// * `Response` - Success response with transfer messages and events +/// * `ContractError` - Various error conditions that might occur +pub fn execute_conclude_deal( + deps: DepsMut, + env: Env, + _info: MessageInfo, + deal_id: u64, +) -> Result { + // Load deal data + let mut deal = DEALS.load(deps.storage, deal_id)?; + + // Validation: Check timing and conclusion status + if env.block.time.seconds() < deal.conclude_time { + return Err(ContractError::ConclusionTimeNotReached {}); + } + if deal.is_concluded { + return Err(ContractError::DealAlreadyConcluded {}); + } - #[test] - fn proper_initialization() { - let mut deps = mock_dependencies(); + // Case 1: Minimum cap not met - refund all bidders + if deal.total_bids_amount < deal.min_cap { + let refund_messages = process_failed_deal(deps.storage, deal_id)?; + + // Mark deal as concluded + deal.is_concluded = true; + DEALS.save(deps.storage, deal_id, &deal)?; + + return Ok(Response::new() + .add_messages(refund_messages) + .add_attribute("method", "conclude_deal_refund") + .add_attribute("deal_id", deal_id.to_string()) + .add_attribute("reason", "min_cap_not_met") + .add_attribute("total_refunded", deal.total_bids_amount)); + } + + // Case 2: Process successful deal + let (messages, stats) = process_successful_deal( + deps.storage, + &deal, + deal_id, + )?; - let msg = InstantiateMsg { count: 17 }; - let info = mock_info("creator", &coins(1000, "earth")); + // Mark deal as concluded + deal.is_concluded = true; + DEALS.save(deps.storage, deal_id, &deal)?; + + Ok(Response::new() + .add_messages(messages) + .add_attribute("method", "conclude_deal") + .add_attribute("deal_id", deal_id.to_string()) + .add_attribute("tokens_sold", stats.tokens_sold) + .add_attribute("total_payment", stats.total_payment) + .add_attribute("successful_bids", stats.successful_bids.to_string()) + .add_attribute("refunded_bids", stats.refunded_bids.to_string())) +} + +/// Helper struct to track deal conclusion statistics +struct DealStats { + tokens_sold: Uint128, + total_payment: Uint128, + successful_bids: u32, + refunded_bids: u32, +} - // we can just call .unwrap() to assert this was a success - let res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); - assert_eq!(0, res.messages.len()); +/// Processes a failed deal by refunding all bidders +fn process_failed_deal( + storage: &dyn Storage, + deal_id: u64, +) -> Result, ContractError> { + let mut messages: Vec = vec![]; + let bids = get_sorted_bids(storage, deal_id)?; - // it worked, let's query the state - let res = query(deps.as_ref(), mock_env(), QueryMsg::GetCount {}).unwrap(); - let value: GetCountResponse = from_json(&res).unwrap(); - assert_eq!(17, value.count); + for (bidder, bid) in bids { + messages.push(create_payment_msg( + bidder, + bid.amount, + "uusd", // Replace with actual denom + )); } - #[test] - fn increment() { - let mut deps = mock_dependencies(); + Ok(messages) +} + +/// Processes a successful deal by allocating tokens and handling payments +fn process_successful_deal( + storage: &dyn Storage, + deal: &Deal, + deal_id: u64, +) -> Result<(Vec, DealStats), ContractError> { + let mut messages: Vec = vec![]; + let mut stats = DealStats { + tokens_sold: Uint128::zero(), + total_payment: Uint128::zero(), + successful_bids: 0, + refunded_bids: 0, + }; + + let mut remaining_tokens = deal.total_amount; + let bids = get_sorted_bids(storage, deal_id)?; + + // Process bids from lowest to highest discount + for (bidder, bid) in bids { + if remaining_tokens.is_zero() { + // Refund remaining bids + messages.push(create_payment_msg( + bidder, + bid.amount, + "uusd", + )); + stats.refunded_bids += 1; + continue; + } + + // Calculate token allocation + let tokens_to_receive = std::cmp::min(bid.amount, remaining_tokens); + + // Calculate final price with discount + let base_price = tokens_to_receive.multiply_ratio(deal.min_price, Uint128::new(1u128)); + let discount = base_price.multiply_ratio(bid.discount_percentage, 100u128); + let final_price = base_price.checked_sub(discount)?; + + // Check if price meets buyer's max price constraint + if let Some(max_price) = bid.max_price { + if final_price > max_price { + messages.push(create_payment_msg( + bidder, + bid.amount, + "uusd", + )); + stats.refunded_bids += 1; + continue; + } + } - let msg = InstantiateMsg { count: 17 }; - let info = mock_info("creator", &coins(2, "token")); - let _res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); + // Process successful bid + + // 1. Transfer tokens to buyer + messages.push(create_token_transfer_msg( + deal.sell_token.clone(), + bidder.clone(), + tokens_to_receive, + )?); - // beneficiary can release it - let info = mock_info("anyone", &coins(2, "token")); - let msg = ExecuteMsg::Increment {}; - let _res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); + // 2. Transfer payment to seller + messages.push(create_payment_msg( + deal.seller.clone(), + final_price, + "uusd", + )); - // should increase counter by 1 - let res = query(deps.as_ref(), mock_env(), QueryMsg::GetCount {}).unwrap(); - let value: GetCountResponse = from_json(&res).unwrap(); - assert_eq!(18, value.count); + // Update running totals + remaining_tokens = remaining_tokens.checked_sub(tokens_to_receive)?; + stats.tokens_sold += tokens_to_receive; + stats.total_payment += final_price; + stats.successful_bids += 1; } + // Validate all tokens are accounted for + if stats.tokens_sold + remaining_tokens != deal.total_amount { + return Err(ContractError::InvalidBidAmount { + reason: "Token allocation mismatch".to_string() + }); + } + + Ok((messages, stats)) +} + +#[cfg(test)] +mod tests { + use super::*; + use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; + #[test] - fn reset() { + fn test_conclude_deal_min_cap_not_met() { let mut deps = mock_dependencies(); + let env = mock_env(); + let info = mock_info("anyone", &[]); - let msg = InstantiateMsg { count: 17 }; - let info = mock_info("creator", &coins(2, "token")); - let _res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); - - // beneficiary can release it - let unauth_info = mock_info("anyone", &coins(2, "token")); - let msg = ExecuteMsg::Reset { count: 5 }; - let res = execute(deps.as_mut(), mock_env(), unauth_info, msg); - match res { - Err(ContractError::Unauthorized {}) => {} - _ => panic!("Must return unauthorized error"), - } + // Setup test deal + let deal = Deal { + seller: "seller".to_string(), + sell_token: "token".to_string(), + total_amount: Uint128::new(1000), + min_price: Uint128::new(10), + discount_percentage: 10, + min_cap: Uint128::new(5000), + bid_start_time: env.block.time.seconds() - 1000, + bid_end_time: env.block.time.seconds() - 500, + conclude_time: env.block.time.seconds() - 100, + is_concluded: false, + total_bids_amount: Uint128::new(1000), // Less than min_cap + }; + DEALS.save(deps.as_mut().storage, 1, &deal).unwrap(); - // only the original creator can reset the counter - let auth_info = mock_info("creator", &coins(2, "token")); - let msg = ExecuteMsg::Reset { count: 5 }; - let _res = execute(deps.as_mut(), mock_env(), auth_info, msg).unwrap(); + // Add test bid + let bid = Bid { + bidder: "bidder".to_string(), + amount: Uint128::new(1000), + discount_percentage: 5, + max_price: None, + }; + BIDS.save(deps.as_mut().storage, (1, &Addr::unchecked("bidder")), &bid).unwrap(); - // should now be 5 - let res = query(deps.as_ref(), mock_env(), QueryMsg::GetCount {}).unwrap(); - let value: GetCountResponse = from_json(&res).unwrap(); - assert_eq!(5, value.count); + // Execute conclude + let result = execute_conclude_deal(deps.as_mut(), env, info, 1).unwrap(); + + // Verify refund + assert!(result.messages.len() == 1); // One refund message + assert!(result.attributes.contains(&attr("reason", "min_cap_not_met"))); } -} +} \ No newline at end of file From 6840e0f54d44352690b91475da263c16b2f0d9f3 Mon Sep 17 00:00:00 2001 From: anilcse Date: Fri, 8 Nov 2024 17:01:18 +0530 Subject: [PATCH 05/24] Fix build --- Cargo.lock | 2596 ++++++----------------------------------------- Cargo.toml | 27 +- src/contract.rs | 7 +- src/error.rs | 19 +- src/helpers.rs | 4 +- src/msg.rs | 6 +- 6 files changed, 312 insertions(+), 2347 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bfe78dfd..6077a651 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,21 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "addr2line" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" -dependencies = [ - "gimli 0.31.1", -] - -[[package]] -name = "adler2" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" - [[package]] name = "ahash" version = "0.7.8" @@ -28,178 +13,12 @@ dependencies = [ "version_check", ] -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "allocator-api2" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" - [[package]] name = "anyhow" version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" -[[package]] -name = "ark-bls12-381" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" -dependencies = [ - "ark-ec", - "ark-ff", - "ark-serialize", - "ark-std", -] - -[[package]] -name = "ark-ec" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" -dependencies = [ - "ark-ff", - "ark-poly", - "ark-serialize", - "ark-std", - "derivative", - "hashbrown 0.13.2", - "itertools 0.10.5", - "num-traits", - "rayon", - "zeroize", -] - -[[package]] -name = "ark-ff" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" -dependencies = [ - "ark-ff-asm", - "ark-ff-macros", - "ark-serialize", - "ark-std", - "derivative", - "digest 0.10.7", - "itertools 0.10.5", - "num-bigint", - "num-traits", - "paste", - "rayon", - "rustc_version", - "zeroize", -] - -[[package]] -name = "ark-ff-asm" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" -dependencies = [ - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-ff-macros" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" -dependencies = [ - "num-bigint", - "num-traits", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-poly" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" -dependencies = [ - "ark-ff", - "ark-serialize", - "ark-std", - "derivative", - "hashbrown 0.13.2", -] - -[[package]] -name = "ark-serialize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" -dependencies = [ - "ark-serialize-derive", - "ark-std", - "digest 0.10.7", - "num-bigint", -] - -[[package]] -name = "ark-serialize-derive" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-std" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" -dependencies = [ - "num-traits", - "rand", - "rayon", -] - -[[package]] -name = "arrayvec" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" - -[[package]] -name = "autocfg" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" - -[[package]] -name = "backtrace" -version = "0.3.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" -dependencies = [ - "addr2line", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", - "windows-targets", -] - [[package]] name = "base16ct" version = "0.2.0" @@ -212,12 +31,6 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" -[[package]] -name = "base64" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" - [[package]] name = "base64ct" version = "1.6.0" @@ -230,36 +43,6 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" -[[package]] -name = "bech32" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.9.0" @@ -284,40 +67,6 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56953345e39537a3e18bdaeba4cb0c58a78c1f61f361dc0fa7c5c7340ae87c5f" -[[package]] -name = "bnum" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e31ea183f6ee62ac8b8a8cf7feddd766317adfb13ff469de57ce033efd6a790" - -[[package]] -name = "bumpalo" -version = "3.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" - -[[package]] -name = "bytecheck" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" -dependencies = [ - "bytecheck_derive", - "ptr_meta", - "simdutf8", -] - -[[package]] -name = "bytecheck_derive" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "byteorder" version = "1.5.0" @@ -330,52 +79,18 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" -[[package]] -name = "cc" -version = "1.1.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baee610e9452a8f6f0a1b6194ec09ff9e2d85dea54432acdae41aa0761c95d70" -dependencies = [ - "shlex", -] - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "clru" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbd0f76e066e64fdc5631e3bb46381254deab9ef1158292f27c8c57e3bf3fe59" - [[package]] name = "const-oid" version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "corosensei" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80128832c58ea9cbd041d2a759ec449224487b2c1e400453d99d244eead87a8e" -dependencies = [ - "autocfg", - "cfg-if", - "libc", - "scopeguard", - "windows-sys 0.33.0", -] - -[[package]] -name = "cosmwasm-core" -version = "2.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6ceb8624260d0d3a67c4e1a1d43fc7e9406720afbcb124521501dd138f90aa" - [[package]] name = "cosmwasm-crypto" version = "1.5.8" @@ -383,33 +98,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58535cbcd599b3c193e3967c8292fe1dbbb5de7c2a2d87380661091dd4744044" dependencies = [ "digest 0.10.7", - "ed25519-zebra 3.1.0", - "k256", - "rand_core 0.6.4", - "thiserror 1.0.68", -] - -[[package]] -name = "cosmwasm-crypto" -version = "2.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4125381e5fd7fefe9f614640049648088015eca2b60d861465329a5d87dfa538" -dependencies = [ - "ark-bls12-381", - "ark-ec", - "ark-ff", - "ark-serialize", - "cosmwasm-core", - "digest 0.10.7", - "ecdsa", - "ed25519-zebra 4.0.3", + "ed25519-zebra", "k256", - "num-traits", - "p256", "rand_core 0.6.4", - "rayon", - "sha2 0.10.8", - "thiserror 1.0.68", + "thiserror", ] [[package]] @@ -421,41 +113,17 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "cosmwasm-derive" -version = "2.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5658b1dc64e10b56ae7a449f678f96932a96f6cfad1769d608d1d1d656480a" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - [[package]] name = "cosmwasm-schema" version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93d388adfa9cb449557a92e9318121ac1a481fc4f599213b03a5b62699b403b4" dependencies = [ - "cosmwasm-schema-derive 1.5.8", - "schemars", - "serde", - "serde_json", - "thiserror 1.0.68", -] - -[[package]] -name = "cosmwasm-schema" -version = "2.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86b4d949b6041519c58993a73f4bbfba8083ba14f7001eae704865a09065845" -dependencies = [ - "cosmwasm-schema-derive 2.1.4", + "cosmwasm-schema-derive", "schemars", "serde", "serde_json", - "thiserror 1.0.68", + "thiserror", ] [[package]] @@ -469,86 +137,36 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "cosmwasm-schema-derive" -version = "2.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ef1b5835a65fcca3ab8b9a02b4f4dacc78e233a5c2f20b270efb9db0666d12" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - [[package]] name = "cosmwasm-std" version = "1.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c21fde95ccd20044a23c0ac6fd8c941f3e8c158169dc94b5aa6491a2d9551a8d" dependencies = [ - "base64 0.21.7", - "bech32 0.9.1", - "bnum 0.10.0", - "cosmwasm-crypto 1.5.8", - "cosmwasm-derive 1.5.8", + "base64", + "bech32", + "bnum", + "cosmwasm-crypto", + "cosmwasm-derive", "derivative", "forward_ref", "hex", "schemars", "serde", - "serde-json-wasm 0.5.2", + "serde-json-wasm", "sha2 0.10.8", "static_assertions", - "thiserror 1.0.68", + "thiserror", ] [[package]] -name = "cosmwasm-std" -version = "2.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70eb7ab0c1e99dd6207496963ba2a457c4128ac9ad9c72a83f8d9808542b849b" -dependencies = [ - "base64 0.22.1", - "bech32 0.11.0", - "bnum 0.11.0", - "cosmwasm-core", - "cosmwasm-crypto 2.1.4", - "cosmwasm-derive 2.1.4", - "derive_more", - "hex", - "rand_core 0.6.4", - "schemars", - "serde", - "serde-json-wasm 1.0.1", - "sha2 0.10.8", - "static_assertions", - "thiserror 1.0.68", -] - -[[package]] -name = "cosmwasm-vm" -version = "1.5.8" +name = "cosmwasm-storage" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f0759572dd51046c18c60727c58adf75dc91adb35325a2ef79eff572f190c14" +checksum = "66de2ab9db04757bcedef2b5984fbe536903ada4a8a9766717a4a71197ef34f6" dependencies = [ - "bitflags 1.3.2", - "bytecheck", - "bytes", - "clru", - "cosmwasm-crypto 1.5.8", - "cosmwasm-std 1.5.8", - "crc32fast", - "derivative", - "enumset", - "hex", - "schemars", + "cosmwasm-std", "serde", - "serde_json", - "sha2 0.10.8", - "thiserror 1.0.68", - "wasmer", - "wasmer-middlewares", - "wasmer-types", ] [[package]] @@ -561,312 +179,128 @@ dependencies = [ ] [[package]] -name = "cranelift-bforest" -version = "0.91.1" +name = "crypto-bigint" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2ab4512dfd3a6f4be184403a195f76e81a8a9f9e6c898e19d2dc3ce20e0115" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ - "cranelift-entity", + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", ] [[package]] -name = "cranelift-codegen" -version = "0.91.1" +name = "crypto-common" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98b022ed2a5913a38839dfbafe6cf135342661293b08049843362df4301261dc" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "arrayvec", - "bumpalo", - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-egraph", - "cranelift-entity", - "cranelift-isle", - "gimli 0.26.2", - "log", - "regalloc2", - "smallvec", - "target-lexicon", + "generic-array", + "typenum", ] [[package]] -name = "cranelift-codegen-meta" -version = "0.91.1" +name = "curve25519-dalek" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "639307b45434ad112a98f8300c0f0ab085cbefcd767efcdef9ef19d4c0756e74" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" dependencies = [ - "cranelift-codegen-shared", + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", ] [[package]] -name = "cranelift-codegen-shared" -version = "0.91.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278e52e29c53fcf32431ef08406c295699a70306d05a0715c5b1bf50e33a9ab7" - -[[package]] -name = "cranelift-egraph" -version = "0.91.1" +name = "cw-multi-test" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624b54323b06e675293939311943ba82d323bb340468ce1889be5da7932c8d73" +checksum = "cc392a5cb7e778e3f90adbf7faa43c4db7f35b6623224b08886d796718edb875" dependencies = [ - "cranelift-entity", - "fxhash", - "hashbrown 0.12.3", - "indexmap", - "log", - "smallvec", + "anyhow", + "bech32", + "cosmwasm-std", + "cw-storage-plus", + "cw-utils", + "derivative", + "itertools 0.12.1", + "prost", + "schemars", + "serde", + "sha2 0.10.8", + "thiserror", ] [[package]] -name = "cranelift-entity" -version = "0.91.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a59bcbca89c3f1b70b93ab3cbba5e5e0cbf3e63dadb23c7525cb142e21a9d4c" - -[[package]] -name = "cranelift-frontend" -version = "0.91.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d70abacb8cfef3dc8ff7e8836e9c1d70f7967dfdac824a4cd5e30223415aca6" +name = "cw-otc-dex" +version = "0.1.0" dependencies = [ - "cranelift-codegen", - "log", - "smallvec", - "target-lexicon", + "cosmwasm-schema", + "cosmwasm-std", + "cosmwasm-storage", + "cw-multi-test", + "cw-storage-plus", + "cw2", + "cw20", + "schemars", + "serde", + "thiserror", ] [[package]] -name = "cranelift-isle" -version = "0.91.1" +name = "cw-storage-plus" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "393bc73c451830ff8dbb3a07f61843d6cb41a084f9996319917c0b291ed785bb" - -[[package]] -name = "crc32fast" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-queue" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" - -[[package]] -name = "crypto-bigint" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" -dependencies = [ - "generic-array", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "curve25519-dalek" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek" -version = "4.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" -dependencies = [ - "cfg-if", - "cpufeatures", - "curve25519-dalek-derive", - "digest 0.10.7", - "fiat-crypto", - "rustc_version", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "cw-multi-test" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1149fe104344cc4f4ca0fc784b7411042fd1626813fe85fd412b05252a0ae9d8" -dependencies = [ - "anyhow", - "bech32 0.11.0", - "cosmwasm-schema 2.1.4", - "cosmwasm-std 2.1.4", - "cw-storage-plus", - "cw-utils", - "itertools 0.13.0", - "prost", - "schemars", - "serde", - "sha2 0.10.8", - "thiserror 2.0.0", -] - -[[package]] -name = "cw-otc-dex" -version = "0.1.0" +checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" dependencies = [ - "cosmwasm-schema 1.5.8", - "cosmwasm-std 2.1.4", - "cosmwasm-vm", - "cw-multi-test", - "cw-storage-plus", - "cw2", - "schemars", - "serde", - "thiserror 1.0.68", -] - -[[package]] -name = "cw-storage-plus" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f13360e9007f51998d42b1bc6b7fa0141f74feae61ed5fd1e5b0a89eec7b5de1" -dependencies = [ - "cosmwasm-std 2.1.4", + "cosmwasm-std", "schemars", "serde", ] [[package]] name = "cw-utils" -version = "2.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07dfee7f12f802431a856984a32bce1cb7da1e6c006b5409e3981035ce562dec" +checksum = "1c4a657e5caacc3a0d00ee96ca8618745d050b8f757c709babafb81208d4239c" dependencies = [ - "cosmwasm-schema 2.1.4", - "cosmwasm-std 2.1.4", + "cosmwasm-schema", + "cosmwasm-std", + "cw2", "schemars", + "semver", "serde", - "thiserror 1.0.68", + "thiserror", ] [[package]] name = "cw2" -version = "2.0.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b04852cd38f044c0751259d5f78255d07590d136b8a86d4e09efdd7666bd6d27" +checksum = "c6c120b24fbbf5c3bedebb97f2cc85fbfa1c3287e09223428e7e597b5293c1fa" dependencies = [ - "cosmwasm-schema 2.1.4", - "cosmwasm-std 2.1.4", + "cosmwasm-schema", + "cosmwasm-std", "cw-storage-plus", "schemars", "semver", "serde", - "thiserror 1.0.68", -] - -[[package]] -name = "darling" -version = "0.20.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.20.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "darling_macro" -version = "0.20.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" -dependencies = [ - "darling_core", - "quote", - "syn 2.0.87", + "thiserror", ] [[package]] -name = "dashmap" -version = "5.5.3" +name = "cw20" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +checksum = "526e39bb20534e25a1cd0386727f0038f4da294e5e535729ba3ef54055246abd" dependencies = [ - "cfg-if", - "hashbrown 0.14.5", - "lock_api", - "once_cell", - "parking_lot_core", + "cosmwasm-schema", + "cosmwasm-std", + "cw-utils", + "schemars", + "serde", ] [[package]] @@ -890,27 +324,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "derive_more" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" -dependencies = [ - "derive_more-impl", -] - -[[package]] -name = "derive_more-impl" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", - "unicode-xid", -] - [[package]] name = "digest" version = "0.9.0" @@ -932,49 +345,12 @@ dependencies = [ "subtle", ] -[[package]] -name = "displaydoc" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - [[package]] name = "dyn-clone" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" -[[package]] -name = "dynasm" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add9a102807b524ec050363f09e06f1504214b0e1c7797f64261c891022dce8b" -dependencies = [ - "bitflags 1.3.2", - "byteorder", - "lazy_static", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "dynasmrt" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64fba5a42bd76a17cad4bfa00de168ee1cbfa06a5e8ce992ae880218c05641a9" -dependencies = [ - "byteorder", - "dynasm", - "memmap2 0.5.10", -] - [[package]] name = "ecdsa" version = "0.16.9" @@ -989,23 +365,14 @@ dependencies = [ "spki", ] -[[package]] -name = "ed25519" -version = "2.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" -dependencies = [ - "signature", -] - [[package]] name = "ed25519-zebra" version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" dependencies = [ - "curve25519-dalek 3.2.0", - "hashbrown 0.12.3", + "curve25519-dalek", + "hashbrown", "hex", "rand_core 0.6.4", "serde", @@ -1013,21 +380,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "ed25519-zebra" -version = "4.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" -dependencies = [ - "curve25519-dalek 4.1.3", - "ed25519", - "hashbrown 0.14.5", - "hex", - "rand_core 0.6.4", - "sha2 0.10.8", - "zeroize", -] - [[package]] name = "either" version = "1.13.0" @@ -1053,53 +405,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "enum-iterator" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eeac5c5edb79e4e39fe8439ef35207780a11f69c52cbe424ce3dfad4cb78de6" -dependencies = [ - "enum-iterator-derive", -] - -[[package]] -name = "enum-iterator-derive" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c134c37760b27a871ba422106eedbb8247da973a09e82558bf26d619c882b159" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "enumset" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a4b049558765cef5f0c1a273c3fc57084d768b44d2f98127aef4cceb17293" -dependencies = [ - "enumset_derive", -] - -[[package]] -name = "enumset_derive" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59c3b24c345d8c314966bdc1832f6c2635bfcce8e7cf363bd115987bba2ee242" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - [[package]] name = "ff" version = "0.13.0" @@ -1110,48 +415,12 @@ dependencies = [ "subtle", ] -[[package]] -name = "fiat-crypto" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "form_urlencoded" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" -dependencies = [ - "percent-encoding", -] - [[package]] name = "forward_ref" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -1174,23 +443,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" -dependencies = [ - "fallible-iterator", - "indexmap", - "stable_deref_trait", -] - -[[package]] -name = "gimli" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" - [[package]] name = "group" version = "0.13.0" @@ -1208,33 +460,14 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.8", + "ahash", ] [[package]] -name = "hashbrown" -version = "0.13.2" +name = "hex" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash 0.8.11", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash 0.8.11", - "allocator-api2", -] - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" @@ -1246,1099 +479,354 @@ dependencies = [ ] [[package]] -name = "icu_collections" -version = "1.5.0" +name = "itertools" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ - "displaydoc", - "yoke", - "zerofrom", - "zerovec", + "either", ] [[package]] -name = "icu_locid" -version = "1.5.0" +name = "itertools" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", + "either", ] [[package]] -name = "icu_locid_transform" -version = "1.5.0" +name = "itoa" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_locid_transform_data", - "icu_provider", - "tinystr", - "zerovec", -] +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] -name = "icu_locid_transform_data" -version = "1.5.0" +name = "k256" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2 0.10.8", + "signature", +] [[package]] -name = "icu_normalizer" -version = "1.5.0" +name = "libc" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_normalizer_data", - "icu_properties", - "icu_provider", - "smallvec", - "utf16_iter", - "utf8_iter", - "write16", - "zerovec", -] +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] -name = "icu_normalizer_data" -version = "1.5.0" +name = "memchr" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] -name = "icu_properties" -version = "1.5.1" +name = "once_cell" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_locid_transform", - "icu_properties_data", - "icu_provider", - "tinystr", - "zerovec", -] +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] -name = "icu_properties_data" -version = "1.5.0" +name = "opaque-debug" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] -name = "icu_provider" -version = "1.5.0" +name = "pkcs8" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "displaydoc", - "icu_locid", - "icu_provider_macros", - "stable_deref_trait", - "tinystr", - "writeable", - "yoke", - "zerofrom", - "zerovec", + "der", + "spki", ] [[package]] -name = "icu_provider_macros" -version = "1.5.0" +name = "proc-macro2" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", + "unicode-ident", ] [[package]] -name = "ident_case" -version = "1.0.1" +name = "prost" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +dependencies = [ + "bytes", + "prost-derive", +] [[package]] -name = "idna" -version = "1.0.3" +name = "prost-derive" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ - "idna_adapter", - "smallvec", - "utf8_iter", + "anyhow", + "itertools 0.10.5", + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] -name = "idna_adapter" -version = "1.2.0" +name = "quote" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ - "icu_normalizer", - "icu_properties", + "proc-macro2", ] [[package]] -name = "indexmap" -version = "1.9.3" +name = "rand_core" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" [[package]] -name = "itertools" -version = "0.10.5" +name = "rand_core" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "either", + "getrandom", ] [[package]] -name = "itertools" -version = "0.13.0" +name = "rfc6979" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ - "either", + "hmac", + "subtle", ] [[package]] -name = "itoa" -version = "1.0.11" +name = "ryu" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] -name = "js-sys" -version = "0.3.72" +name = "schemars" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" dependencies = [ - "wasm-bindgen", + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", ] [[package]] -name = "k256" -version = "0.13.4" +name = "schemars_derive" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "once_cell", - "sha2 0.10.8", - "signature", + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.87", ] [[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - -[[package]] -name = "leb128" -version = "0.2.5" +name = "sec1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] [[package]] -name = "libc" -version = "0.2.162" +name = "semver" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] -name = "litemap" -version = "0.7.3" +name = "serde" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" +checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +dependencies = [ + "serde_derive", +] [[package]] -name = "lock_api" -version = "0.4.12" +name = "serde-json-wasm" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +checksum = "9e9213a07d53faa0b8dd81e767a54a8188a242fdb9be99ab75ec576a774bfdd7" dependencies = [ - "autocfg", - "scopeguard", + "serde", ] [[package]] -name = "log" -version = "0.4.22" +name = "serde_derive" +version = "1.0.214" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] [[package]] -name = "mach" -version = "0.3.2" +name = "serde_derive_internals" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ - "libc", + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] -name = "mach2" -version = "0.4.2" +name = "serde_json" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ - "libc", + "itoa", + "memchr", + "ryu", + "serde", ] [[package]] -name = "memchr" -version = "2.7.4" +name = "sha2" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] [[package]] -name = "memmap2" -version = "0.5.10" +name = "sha2" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ - "libc", + "cfg-if", + "cpufeatures", + "digest 0.10.7", ] [[package]] -name = "memmap2" -version = "0.6.2" +name = "signature" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d28bba84adfe6646737845bc5ebbfa2c08424eb1c37e94a1fd2a82adb56a872" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "libc", + "digest 0.10.7", + "rand_core 0.6.4", ] [[package]] -name = "memoffset" -version = "0.8.0" +name = "spki" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ - "autocfg", + "base64ct", + "der", ] [[package]] -name = "miniz_oxide" -version = "0.8.0" +name = "static_assertions" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" -dependencies = [ - "adler2", -] +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] -name = "more-asserts" -version = "0.2.2" +name = "subtle" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] -name = "num-bigint" -version = "0.4.6" +name = "syn" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "num-integer", - "num-traits", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "num-integer" -version = "0.1.46" +name = "syn" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ - "num-traits", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "num-traits" -version = "0.2.19" +name = "thiserror" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" dependencies = [ - "autocfg", + "thiserror-impl", ] [[package]] -name = "object" -version = "0.36.5" +name = "thiserror-impl" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" dependencies = [ - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" - -[[package]] -name = "opaque-debug" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" - -[[package]] -name = "p256" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" -dependencies = [ - "ecdsa", - "elliptic-curve", - "primeorder", - "sha2 0.10.8", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - -[[package]] -name = "paste" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" - -[[package]] -name = "percent-encoding" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" - -[[package]] -name = "pin-project-lite" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" -dependencies = [ - "zerocopy", -] - -[[package]] -name = "primeorder" -version = "0.13.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" -dependencies = [ - "elliptic-curve", -] - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro2" -version = "1.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "prost" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-derive" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" -dependencies = [ - "anyhow", - "itertools 0.10.5", - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "quote" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "rand_chacha", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rayon" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" -dependencies = [ - "crossbeam-deque", - "crossbeam-utils", -] - -[[package]] -name = "redox_syscall" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" -dependencies = [ - "bitflags 2.6.0", -] - -[[package]] -name = "regalloc2" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300d4fbfb40c1c66a78ba3ddd41c1110247cf52f97b87d0f2fc9209bd49b030c" -dependencies = [ - "fxhash", - "log", - "slice-group-by", - "smallvec", -] - -[[package]] -name = "region" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6b6ebd13bc009aef9cd476c1310d49ac354d36e240cf1bd753290f3dc7199a7" -dependencies = [ - "bitflags 1.3.2", - "libc", - "mach2", - "windows-sys 0.52.0", -] - -[[package]] -name = "rend" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" -dependencies = [ - "bytecheck", -] - -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - -[[package]] -name = "rkyv" -version = "0.7.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9008cd6385b9e161d8229e1f6549dd23c3d022f132a2ea37ac3a10ac4935779b" -dependencies = [ - "bitvec", - "bytecheck", - "bytes", - "hashbrown 0.12.3", - "indexmap", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", - "tinyvec", - "uuid", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "503d1d27590a2b0a3a4ca4c94755aa2875657196ecbf401a42eff41d7de532c0" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" - -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "ryu" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" - -[[package]] -name = "schemars" -version = "0.8.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" -dependencies = [ - "dyn-clone", - "schemars_derive", - "serde", - "serde_json", -] - -[[package]] -name = "schemars_derive" -version = "0.8.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" -dependencies = [ - "proc-macro2", - "quote", - "serde_derive_internals", - "syn 2.0.87", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - -[[package]] -name = "self_cell" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a" - -[[package]] -name = "semver" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" - -[[package]] -name = "serde" -version = "1.0.214" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde-json-wasm" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e9213a07d53faa0b8dd81e767a54a8188a242fdb9be99ab75ec576a774bfdd7" -dependencies = [ - "serde", -] - -[[package]] -name = "serde-json-wasm" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f05da0d153dd4595bdffd5099dc0e9ce425b205ee648eb93437ff7302af8c9a5" -dependencies = [ - "serde", -] - -[[package]] -name = "serde-wasm-bindgen" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b4c031cd0d9014307d82b8abf653c0290fbdaeb4c02d00c63cf52f728628bf" -dependencies = [ - "js-sys", - "serde", - "wasm-bindgen", -] - -[[package]] -name = "serde_derive" -version = "1.0.214" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "serde_derive_internals" -version = "0.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "serde_json" -version = "1.0.132" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" -dependencies = [ - "itoa", - "memchr", - "ryu", - "serde", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "sha2" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", -] - -[[package]] -name = "shared-buffer" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6c99835bad52957e7aa241d3975ed17c1e5f8c92026377d117a606f36b84b16" -dependencies = [ - "bytes", - "memmap2 0.6.2", -] - -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] - -[[package]] -name = "simdutf8" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" - -[[package]] -name = "slice-group-by" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" - -[[package]] -name = "smallvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "synstructure" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "target-lexicon" -version = "0.12.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" - -[[package]] -name = "thiserror" -version = "1.0.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" -dependencies = [ - "thiserror-impl 1.0.68", -] - -[[package]] -name = "thiserror" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15291287e9bff1bc6f9ff3409ed9af665bec7a5fc8ac079ea96be07bca0e2668" -dependencies = [ - "thiserror-impl 2.0.0", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "thiserror-impl" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22efd00f33f93fa62848a7cab956c3d38c8d43095efda1decfc2b3a5dc0b8972" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "tinystr" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" -dependencies = [ - "displaydoc", - "zerovec", -] - -[[package]] -name = "tinyvec" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "unicode-ident" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" - -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - -[[package]] -name = "url" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - -[[package]] -name = "utf16_iter" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" - -[[package]] -name = "utf8_iter" -version = "1.0.4" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] -name = "uuid" -version = "1.11.0" +name = "unicode-ident" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "version_check" @@ -2352,518 +840,8 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasm-bindgen" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" -dependencies = [ - "cfg-if", - "once_cell", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.87", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-downcast" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dac026d43bcca6e7ce1c0956ba68f59edf6403e8e930a5d891be72c31a44340" -dependencies = [ - "js-sys", - "once_cell", - "wasm-bindgen", - "wasm-bindgen-downcast-macros", -] - -[[package]] -name = "wasm-bindgen-downcast-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5020cfa87c7cecefef118055d44e3c1fc122c7ec25701d528ee458a0b45f38f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" - -[[package]] -name = "wasmer" -version = "4.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e626f958755a90a6552b9528f59b58a62ae288e6c17fcf40e99495bc33c60f0" -dependencies = [ - "bytes", - "cfg-if", - "derivative", - "indexmap", - "js-sys", - "more-asserts", - "rustc-demangle", - "serde", - "serde-wasm-bindgen", - "shared-buffer", - "target-lexicon", - "thiserror 1.0.68", - "wasm-bindgen", - "wasm-bindgen-downcast", - "wasmer-compiler", - "wasmer-compiler-cranelift", - "wasmer-compiler-singlepass", - "wasmer-derive", - "wasmer-types", - "wasmer-vm", - "winapi", -] - -[[package]] -name = "wasmer-compiler" -version = "4.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "848e1922694cf97f4df680a0534c9d72c836378b5eb2313c1708fe1a75b40044" -dependencies = [ - "backtrace", - "bytes", - "cfg-if", - "enum-iterator", - "enumset", - "lazy_static", - "leb128", - "memmap2 0.5.10", - "more-asserts", - "region", - "rkyv", - "self_cell", - "shared-buffer", - "smallvec", - "thiserror 1.0.68", - "wasmer-types", - "wasmer-vm", - "wasmparser", - "winapi", -] - -[[package]] -name = "wasmer-compiler-cranelift" -version = "4.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d96bce6fad15a954edcfc2749b59e47ea7de524b6ef3df392035636491a40b4" -dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "gimli 0.26.2", - "more-asserts", - "rayon", - "smallvec", - "target-lexicon", - "tracing", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-compiler-singlepass" -version = "4.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebaa865b40ffb3351b03dab9fe9930a5248c25daebd55b464b79b862d9b55ccd" -dependencies = [ - "byteorder", - "dynasm", - "dynasmrt", - "enumset", - "gimli 0.26.2", - "lazy_static", - "more-asserts", - "rayon", - "smallvec", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-derive" -version = "4.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f08f80d166a9279671b7af7a09409c28ede2e0b4e3acabbf0e3cb22c8038ba7" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "wasmer-middlewares" -version = "4.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeb4b87c0ea9f8636c81a8ab8f52bad01c8623c9fcbb3db5f367d5f157fada30" -dependencies = [ - "wasmer", - "wasmer-types", - "wasmer-vm", -] - -[[package]] -name = "wasmer-types" -version = "4.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae2c892882f0b416783fb4310e5697f5c30587f6f9555f9d4f2be85ab39d5d3d" -dependencies = [ - "bytecheck", - "enum-iterator", - "enumset", - "indexmap", - "more-asserts", - "rkyv", - "target-lexicon", - "thiserror 1.0.68", -] - -[[package]] -name = "wasmer-vm" -version = "4.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c0a9a57b627fb39e5a491058d4365f099bc9b140031c000fded24a3306d9480" -dependencies = [ - "backtrace", - "cc", - "cfg-if", - "corosensei", - "crossbeam-queue", - "dashmap", - "derivative", - "enum-iterator", - "fnv", - "indexmap", - "lazy_static", - "libc", - "mach", - "memoffset", - "more-asserts", - "region", - "scopeguard", - "thiserror 1.0.68", - "wasmer-types", - "winapi", -] - -[[package]] -name = "wasmparser" -version = "0.95.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ea896273ea99b15132414be1da01ab0d8836415083298ecaffbe308eaac87a" -dependencies = [ - "indexmap", - "url", -] - -[[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.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43dbb096663629518eb1dfa72d80243ca5a6aca764cae62a2df70af760a9be75" -dependencies = [ - "windows_aarch64_msvc 0.33.0", - "windows_i686_gnu 0.33.0", - "windows_i686_msvc 0.33.0", - "windows_x86_64_gnu 0.33.0", - "windows_x86_64_msvc 0.33.0", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.52.6", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "write16" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" - -[[package]] -name = "writeable" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "yoke" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" -dependencies = [ - "serde", - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", - "synstructure", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "byteorder", - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "zerofrom" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", - "synstructure", -] - [[package]] name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - -[[package]] -name = "zerovec" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" -dependencies = [ - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] diff --git a/Cargo.toml b/Cargo.toml index 39cc2306..e83f0e1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,10 +9,6 @@ edition = "2021" [lib] crate-type = ["cdylib", "rlib"] -[[example]] -name = "schema" -path = "examples/schema.rs" - [profile.release] opt-level = 3 debug = false @@ -37,18 +33,15 @@ optimize = """docker run --rm -v "$(pwd)":/code \ """ [dependencies] -cosmwasm-std = { version = "2.1.0", features = [ - "cosmwasm_1_4", - # Enable this if you only deploy to chains that have CosmWasm 2.0 or higher - # "cosmwasm_2_0", -] } -cw-storage-plus = "2.0.0" -cw2 = "2.0.0" -schemars = "0.8.16" -serde = { version = "1.0.197", default-features = false, features = ["derive"] } -thiserror = { version = "1.0.58" } +cosmwasm-std = "1.5.0" +cosmwasm-schema = "1.5.0" +cosmwasm-storage = "1.5.0" +cw-storage-plus = "1.1.0" +cw2 = "1.1.1" +cw20 = "1.1.1" +schemars = "0.8.15" +serde = { version = "1.0.188", default-features = false, features = ["derive"] } +thiserror = "1.0.49" [dev-dependencies] -cosmwasm-vm = "1.1.0" -cw-multi-test = "2.0.0" -cosmwasm-schema = "1.0.0" +cw-multi-test = "0.20.0" diff --git a/src/contract.rs b/src/contract.rs index cacce61c..a7930f39 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -1,13 +1,12 @@ use cosmwasm_std::{ - to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, - StdResult, Uint128, Order, entry_point, CosmosMsg, Storage, + DepsMut, Env, MessageInfo, Response, + StdResult, Uint128, entry_point, CosmosMsg, Storage, }; use cw2::set_contract_version; use crate::error::ContractError; use crate::msg::{ - ExecuteMsg, InstantiateMsg, QueryMsg, ConfigResponse, - DealResponse, BidsResponse, + ExecuteMsg, InstantiateMsg, }; use crate::state::{Config, Deal, Bid, CONFIG, DEAL_COUNTER, DEALS, BIDS}; use crate::helpers::{ diff --git a/src/error.rs b/src/error.rs index 429c7b81..98fdd9fa 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,57 +1,48 @@ - -use cosmwasm_std::StdError; +// error.rs +use cosmwasm_std::{StdError, OverflowError}; use thiserror::Error; -/// Custom error types for the OTC platform contract #[derive(Error, Debug)] pub enum ContractError { - /// Wraps std::error::Error #[error("{0}")] Std(#[from] StdError), - /// When someone tries to execute an action they're not authorized for + #[error("{0}")] + Overflow(#[from] OverflowError), + #[error("Unauthorized")] Unauthorized {}, - /// When deal times are invalid (e.g., end time before start time) #[error("Invalid time parameters: {reason}")] InvalidTimeParameters { reason: String }, - /// When someone tries to bid before the bidding period starts #[error("Bidding has not started yet")] BiddingNotStarted {}, - /// When someone tries to bid after the bidding period ends #[error("Bidding has ended")] BiddingEnded {}, - /// When someone tries to conclude a deal before its conclusion time #[error("Deal cannot be concluded yet")] ConclusionTimeNotReached {}, - /// When someone tries to modify a deal that's already concluded #[error("Deal already concluded")] DealAlreadyConcluded {}, - /// When the platform fee provided is less than required #[error("Insufficient platform fee. Required: {required}, provided: {provided}")] InsufficientPlatformFee { required: u128, provided: u128, }, - /// When the bid amount is invalid (e.g., zero) #[error("Invalid bid amount: {reason}")] InvalidBidAmount { reason: String }, - /// When trying to update or withdraw a non-existent bid #[error("Bid not found for deal {deal_id} from bidder {bidder}")] BidNotFound { deal_id: u64, bidder: String, }, - /// When the deal has insufficient funds for transfer #[error("Insufficient funds")] InsufficientFunds {}, } \ No newline at end of file diff --git a/src/helpers.rs b/src/helpers.rs index b8dcf3b9..59f77d03 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,5 +1,5 @@ use cosmwasm_std::{ - Addr, Coin, CosmosMsg, BankMsg, Uint128, WasmMsg, + Coin, CosmosMsg, BankMsg, Uint128, WasmMsg, to_binary, StdResult, Order, Storage, }; use cw20::Cw20ExecuteMsg; @@ -86,5 +86,5 @@ pub fn calculate_platform_fee( amount: Uint128, fee_percentage: u64, ) -> StdResult { - amount.multiply_ratio(fee_percentage, 10000u128) + Ok(amount.multiply_ratio(fee_percentage, 10000u128)) } \ No newline at end of file diff --git a/src/msg.rs b/src/msg.rs index fb57ba3a..14e35e9f 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -1,6 +1,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_std::Uint128; +use cosmwasm_schema::{cw_serde, QueryResponses}; use crate::state::{Config, Deal, Bid}; /// Message for contract instantiation @@ -68,14 +69,17 @@ pub enum ExecuteMsg { } /// Messages for querying contract state -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema, QueryResponses)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { /// Get details of a specific deal + #[returns(DealResponse)] GetDeal { deal_id: u64 }, /// Get all bids for a specific deal + #[returns(BidsResponse)] GetBids { deal_id: u64 }, /// Get contract configuration + #[returns(ConfigResponse)] GetConfig {}, } From f2f8821546922cd0feff1b29bc99e1b1402ed4d3 Mon Sep 17 00:00:00 2001 From: anilcse Date: Fri, 8 Nov 2024 17:03:54 +0530 Subject: [PATCH 06/24] Fix cargo schema --- examples/schema.rs | 6 +++--- src/contract.rs | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/schema.rs b/examples/schema.rs index 5b466902..0be3c1ca 100644 --- a/examples/schema.rs +++ b/examples/schema.rs @@ -5,8 +5,8 @@ use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use crate_name::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate_name::state::{Bid, Config, OtcDeal}; +use cw_otc_dex::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use cw_otc_dex::state::{Bid, Config, Deal}; fn main() { let mut out_dir = current_dir().unwrap(); @@ -18,6 +18,6 @@ fn main() { export_schema(&schema_for!(ExecuteMsg), &out_dir); export_schema(&schema_for!(QueryMsg), &out_dir); export_schema(&schema_for!(Config), &out_dir); - export_schema(&schema_for!(OtcDeal), &out_dir); + export_schema(&schema_for!(Deal), &out_dir); export_schema(&schema_for!(Bid), &out_dir); } diff --git a/src/contract.rs b/src/contract.rs index a7930f39..c0a88786 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -3,7 +3,8 @@ use cosmwasm_std::{ StdResult, Uint128, entry_point, CosmosMsg, Storage, }; use cw2::set_contract_version; - +use cosmwasm_std::Addr; +use cosmwasm_std::attr; use crate::error::ContractError; use crate::msg::{ ExecuteMsg, InstantiateMsg, From 71bad8418384399a431083208edc7ab1fed0979d Mon Sep 17 00:00:00 2001 From: anilcse Date: Fri, 8 Nov 2024 21:09:45 +0530 Subject: [PATCH 07/24] Add tests --- tests/common.rs | 262 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 262 insertions(+) create mode 100644 tests/common.rs diff --git a/tests/common.rs b/tests/common.rs new file mode 100644 index 00000000..55f9da69 --- /dev/null +++ b/tests/common.rs @@ -0,0 +1,262 @@ +#[cfg(test)] +mod tests { + use super::*; + use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; + use cosmwasm_std::{Env, Timestamp, coins, Addr, Uint128, DepsMut}; + + use cw_otc_dex::msg::{ExecuteMsg, InstantiateMsg}; + use cw_otc_dex::state::{BIDS, CONFIG, DEAL_COUNTER, DEALS, Bid, Config, Deal}; + use cw_otc_dex::error::ContractError; + use cw_otc_dex::contract::{execute, instantiate}; + + const PLATFORM_FEE_PERCENTAGE: u64 = 100; // 1% + const MOCK_SELL_TOKEN: &str = "token"; + const MOCK_PAYMENT_DENOM: &str = "uusd"; + + // Helper function to create mock environment with specified time + fn mock_env_at_time(timestamp: u64) -> Env { + let mut env = mock_env(); + env.block.time = Timestamp::from_seconds(timestamp); + env + } + + // Helper function to create a standard test deal message with future timestamps + fn create_test_deal_msg(start_time: u64) -> ExecuteMsg { + ExecuteMsg::CreateDeal { + sell_token: MOCK_SELL_TOKEN.to_string(), + total_amount: Uint128::new(1000000u128), + min_price: Uint128::new(1u128), + discount_percentage: 1000, // 10% + min_cap: Uint128::new(500000u128), + bid_start_time: start_time + 1000, // Ensure future start + bid_end_time: start_time + 2000, // End time after start + conclude_time: start_time + 3000, // Conclude time after end + } + } + + fn setup_contract(deps: DepsMut) { + let msg = InstantiateMsg { + platform_fee_percentage: PLATFORM_FEE_PERCENTAGE, + }; + let info = mock_info("creator", &[]); + let res = instantiate(deps, mock_env(), info, msg).unwrap(); + assert_eq!(0, res.messages.len()); + } + + #[test] + fn proper_initialization() { + let mut deps = mock_dependencies(); + let msg = InstantiateMsg { + platform_fee_percentage: PLATFORM_FEE_PERCENTAGE, + }; + let info = mock_info("creator", &[]); + let res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); + assert_eq!(0, res.messages.len()); + } + + #[test] + fn test_create_deal() { + let mut deps = mock_dependencies(); + setup_contract(deps.as_mut()); + + let current_time = 1000u64; + let env = mock_env_at_time(current_time); + let total_amount = Uint128::new(1000000u128); + let platform_fee = total_amount.multiply_ratio(PLATFORM_FEE_PERCENTAGE as u128, 10000u128); + let msg = create_test_deal_msg(current_time); + + // Test with insufficient platform fee + let info = mock_info("seller", &coins(platform_fee.u128() - 1, MOCK_PAYMENT_DENOM)); + let err = execute(deps.as_mut(), env.clone(), info, msg.clone()).unwrap_err(); + assert!(matches!(err, ContractError::InsufficientPlatformFee { .. })); + + // Test successful deal creation + let info = mock_info("seller", &coins(platform_fee.u128(), MOCK_PAYMENT_DENOM)); + let res = execute(deps.as_mut(), env.clone(), info, msg).unwrap(); + assert_eq!(res.attributes.len(), 3); + + let deal = DEALS.load(deps.as_ref().storage, 1).unwrap(); + assert_eq!(deal.seller, "seller"); + assert_eq!(deal.total_amount, total_amount); + assert_eq!(deal.is_concluded, false); + } + + #[test] + fn test_place_bid() { + let mut deps = mock_dependencies(); + setup_contract(deps.as_mut()); + + let start_time = 1000u64; + let env = mock_env_at_time(start_time); + + // Create deal + let total_amount = Uint128::new(1000000u128); + let platform_fee = total_amount.multiply_ratio(PLATFORM_FEE_PERCENTAGE as u128, 10000u128); + let create_msg = create_test_deal_msg(start_time); + + let info = mock_info("seller", &coins(platform_fee.u128(), MOCK_PAYMENT_DENOM)); + execute(deps.as_mut(), env.clone(), info, create_msg).unwrap(); + + // Move to bidding period + let mut bid_env = mock_env_at_time(start_time + 1500); // During bidding period + + let bid_msg = ExecuteMsg::PlaceBid { + deal_id: 1, + amount: Uint128::new(100000u128), + discount_percentage: 500, + max_price: Some(Uint128::new(95000u128)), + }; + + let info = mock_info("bidder1", &[]); + let res = execute(deps.as_mut(), bid_env.clone(), info, bid_msg).unwrap(); + assert_eq!(res.attributes.len(), 4); + + let bid = BIDS.load(deps.as_ref().storage, (1, &Addr::unchecked("bidder1"))).unwrap(); + assert_eq!(bid.amount, Uint128::new(100000u128)); + assert_eq!(bid.discount_percentage, 500); + } + + #[test] + fn test_update_bid() { + let mut deps = mock_dependencies(); + setup_contract(deps.as_mut()); + + let start_time = 1000u64; + let env = mock_env_at_time(start_time); + + // Create deal + let total_amount = Uint128::new(1000000u128); + let platform_fee = total_amount.multiply_ratio(PLATFORM_FEE_PERCENTAGE as u128, 10000u128); + let create_msg = create_test_deal_msg(start_time); + + let info = mock_info("seller", &coins(platform_fee.u128(), MOCK_PAYMENT_DENOM)); + execute(deps.as_mut(), env.clone(), info, create_msg).unwrap(); + + // Move to bidding period + let mut bid_env = mock_env_at_time(start_time + 1500); + + // Place initial bid + let bid_msg = ExecuteMsg::PlaceBid { + deal_id: 1, + amount: Uint128::new(100000u128), + discount_percentage: 500, + max_price: Some(Uint128::new(95000u128)), + }; + let info = mock_info("bidder1", &[]); + execute(deps.as_mut(), bid_env.clone(), info.clone(), bid_msg).unwrap(); + + // Test bid update + let update_msg = ExecuteMsg::UpdateBid { + deal_id: 1, + new_amount: Uint128::new(150000u128), + new_discount_percentage: 600, + new_max_price: Some(Uint128::new(140000u128)), + }; + + let res = execute(deps.as_mut(), bid_env.clone(), info, update_msg).unwrap(); + assert_eq!(res.attributes.len(), 3); + + let bid = BIDS.load(deps.as_ref().storage, (1, &Addr::unchecked("bidder1"))).unwrap(); + assert_eq!(bid.amount, Uint128::new(150000u128)); + assert_eq!(bid.discount_percentage, 600); + } + + fn test_conclude_deal() { + let mut deps = mock_dependencies(); + setup_contract(deps.as_mut()); + + let start_time = 1000u64; + let env = mock_env_at_time(start_time); + + // Create test deal + let total_amount = Uint128::new(1000000u128); + let platform_fee = total_amount.multiply_ratio(PLATFORM_FEE_PERCENTAGE as u128, 10000u128); + let create_msg = create_test_deal_msg(start_time); + + let info = mock_info("seller", &coins(platform_fee.u128(), MOCK_PAYMENT_DENOM)); + execute(deps.as_mut(), env.clone(), info, create_msg).unwrap(); + + // Move to bidding period + let bid_env = mock_env_at_time(start_time + 1500); + + // Add some bids (but below min_cap) + let bid_msg = ExecuteMsg::PlaceBid { + deal_id: 1, + amount: Uint128::new(400000u128), + discount_percentage: 500, + max_price: None, + }; + let info = mock_info("bidder1", &[]); + execute(deps.as_mut(), bid_env.clone(), info, bid_msg).unwrap(); + + // Move to conclusion time + let conclude_env = mock_env_at_time(start_time + 3500); + + // Test failed deal (below min cap) + let conclude_msg = ExecuteMsg::ConcludeDeal { deal_id: 1 }; + let info = mock_info("anyone", &[]); + let res = execute(deps.as_mut(), conclude_env.clone(), info.clone(), conclude_msg.clone()).unwrap(); + + assert!(res.messages.len() > 0); + assert!(res.attributes.iter().any(|attr| attr.value == "min_cap_not_met")); + + // Reset for successful conclusion test + let mut deps = mock_dependencies(); + setup_contract(deps.as_mut()); + + // Create new deal + let env = mock_env_at_time(start_time); + // Create a new message instead of reusing the moved one + let new_create_msg = create_test_deal_msg(start_time); + let info = mock_info("seller", &coins(platform_fee.u128(), MOCK_PAYMENT_DENOM)); + execute(deps.as_mut(), env.clone(), info, new_create_msg).unwrap(); + + // Move to bidding period and place bid meeting min_cap + let bid_env = mock_env_at_time(start_time + 1500); + let bid_msg = ExecuteMsg::PlaceBid { + deal_id: 1, + amount: Uint128::new(600000u128), + discount_percentage: 500, + max_price: None, + }; + let info = mock_info("bidder1", &[]); + execute(deps.as_mut(), bid_env.clone(), info, bid_msg).unwrap(); + + // Test successful conclusion + let info = mock_info("anyone", &[]); + let res = execute(deps.as_mut(), conclude_env.clone(), info, conclude_msg).unwrap(); + + assert!(res.messages.len() > 0); + assert!(res.attributes.iter().any(|attr| attr.key == "tokens_sold")); + assert!(res.attributes.iter().any(|attr| attr.key == "total_payment")); + } + + #[test] + fn test_validation_errors() { + let mut deps = mock_dependencies(); + setup_contract(deps.as_mut()); + + let current_time = 1000u64; + let env = mock_env_at_time(current_time); + + let msg = ExecuteMsg::CreateDeal { + sell_token: MOCK_SELL_TOKEN.to_string(), + total_amount: Uint128::new(1000000u128), + min_price: Uint128::new(1u128), + discount_percentage: 11000, // Invalid: > 100% + min_cap: Uint128::new(500000u128), + bid_start_time: current_time + 1000, + bid_end_time: current_time + 2000, + conclude_time: current_time + 3000, + }; + + let info = mock_info("seller", &coins(10000, MOCK_PAYMENT_DENOM)); + let err = execute(deps.as_mut(), env.clone(), info, msg).unwrap_err(); + match err { + ContractError::InvalidTimeParameters { reason } => { + assert!(reason.contains("Discount percentage")); + } + _ => panic!("Expected InvalidTimeParameters error for invalid discount percentage"), + } + } +} \ No newline at end of file From 59345bbd89f258727e6dca7d7723c77ec172023a Mon Sep 17 00:00:00 2001 From: anilcse Date: Fri, 8 Nov 2024 21:33:32 +0530 Subject: [PATCH 08/24] Add more tests --- src/contract.rs | 45 -------------------- tests/common.rs | 104 ++++++++++++++++++++++++++++++++++++++++++++++- tests/queries.rs | 0 3 files changed, 102 insertions(+), 47 deletions(-) create mode 100644 tests/queries.rs diff --git a/src/contract.rs b/src/contract.rs index c0a88786..34593ba3 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -489,48 +489,3 @@ fn process_successful_deal( Ok((messages, stats)) } - -#[cfg(test)] -mod tests { - use super::*; - use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; - - #[test] - fn test_conclude_deal_min_cap_not_met() { - let mut deps = mock_dependencies(); - let env = mock_env(); - let info = mock_info("anyone", &[]); - - // Setup test deal - let deal = Deal { - seller: "seller".to_string(), - sell_token: "token".to_string(), - total_amount: Uint128::new(1000), - min_price: Uint128::new(10), - discount_percentage: 10, - min_cap: Uint128::new(5000), - bid_start_time: env.block.time.seconds() - 1000, - bid_end_time: env.block.time.seconds() - 500, - conclude_time: env.block.time.seconds() - 100, - is_concluded: false, - total_bids_amount: Uint128::new(1000), // Less than min_cap - }; - DEALS.save(deps.as_mut().storage, 1, &deal).unwrap(); - - // Add test bid - let bid = Bid { - bidder: "bidder".to_string(), - amount: Uint128::new(1000), - discount_percentage: 5, - max_price: None, - }; - BIDS.save(deps.as_mut().storage, (1, &Addr::unchecked("bidder")), &bid).unwrap(); - - // Execute conclude - let result = execute_conclude_deal(deps.as_mut(), env, info, 1).unwrap(); - - // Verify refund - assert!(result.messages.len() == 1); // One refund message - assert!(result.attributes.contains(&attr("reason", "min_cap_not_met"))); - } -} \ No newline at end of file diff --git a/tests/common.rs b/tests/common.rs index 55f9da69..de678713 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -2,12 +2,12 @@ mod tests { use super::*; use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; - use cosmwasm_std::{Env, Timestamp, coins, Addr, Uint128, DepsMut}; + use cosmwasm_std::{Env, Timestamp, coins, Addr, Uint128, DepsMut, BankMsg, CosmosMsg, SubMsg}; use cw_otc_dex::msg::{ExecuteMsg, InstantiateMsg}; use cw_otc_dex::state::{BIDS, CONFIG, DEAL_COUNTER, DEALS, Bid, Config, Deal}; use cw_otc_dex::error::ContractError; - use cw_otc_dex::contract::{execute, instantiate}; + use cw_otc_dex::contract::{execute, instantiate, execute_conclude_deal}; const PLATFORM_FEE_PERCENTAGE: u64 = 100; // 1% const MOCK_SELL_TOKEN: &str = "token"; @@ -231,6 +231,106 @@ mod tests { assert!(res.attributes.iter().any(|attr| attr.key == "total_payment")); } + #[test] + fn test_conclude_deal_min_cap_not_met() { + let mut deps = mock_dependencies(); + setup_contract(deps.as_mut()); + + // Setup: Create a deal + let start_time = 1000u64; + let env = mock_env_at_time(start_time); + + let total_amount = Uint128::new(1000000u128); + let min_cap = Uint128::new(500000u128); + let platform_fee = total_amount.multiply_ratio(PLATFORM_FEE_PERCENTAGE as u128, 10000u128); + let create_msg = create_test_deal_msg(start_time); + + let info = mock_info("seller", &coins(platform_fee.u128(), MOCK_PAYMENT_DENOM)); + execute(deps.as_mut(), env.clone(), info, create_msg).unwrap(); + + // Add multiple bids that sum up to less than min_cap + let bid_env = mock_env_at_time(start_time + 1500); // During bidding period + + // First bid + let bid_msg1 = ExecuteMsg::PlaceBid { + deal_id: 1, + amount: Uint128::new(200000u128), + discount_percentage: 500, + max_price: None, + }; + let info = mock_info("bidder1", &[]); + execute(deps.as_mut(), bid_env.clone(), info, bid_msg1).unwrap(); + + // Second bid + let bid_msg2 = ExecuteMsg::PlaceBid { + deal_id: 1, + amount: Uint128::new(150000u128), + discount_percentage: 600, + max_price: None, + }; + let info = mock_info("bidder2", &[]); + execute(deps.as_mut(), bid_env.clone(), info, bid_msg2).unwrap(); + + // Verify total bids amount is less than min_cap + let deal = DEALS.load(deps.as_ref().storage, 1).unwrap(); + assert!(deal.total_bids_amount < min_cap); + assert_eq!(deal.total_bids_amount, Uint128::new(350000u128)); + + // Move to conclusion time and conclude the deal + let conclude_time = start_time + 3500; + let conclude_msg = ExecuteMsg::ConcludeDeal { deal_id: 1 }; + let info = mock_info("anyone", &[]); + let res = execute( + deps.as_mut(), + mock_env_at_time(conclude_time), + info, + conclude_msg + ).unwrap(); + + // Verify response + assert!(res.messages.len() == 2); // Should have refund messages for both bidders + + // Check refund messages + let expected_refunds = vec![ + SubMsg::new(CosmosMsg::Bank(BankMsg::Send { + to_address: "bidder1".to_string(), + amount: coins(200000u128, MOCK_PAYMENT_DENOM), + })), + SubMsg::new(CosmosMsg::Bank(BankMsg::Send { + to_address: "bidder2".to_string(), + amount: coins(150000u128, MOCK_PAYMENT_DENOM), + })), + ]; + + for expected_msg in expected_refunds { + assert!(res.messages.contains(&expected_msg)); + } + + // Verify attributes + assert!(res.attributes.iter().any(|attr| attr.key == "method" && attr.value == "conclude_deal_refund")); + assert!(res.attributes.iter().any(|attr| attr.key == "reason" && attr.value == "min_cap_not_met")); + assert!(res.attributes.iter().any(|attr| attr.key == "total_refunded" && attr.value == "350000")); + + // Verify deal is marked as concluded + let deal = DEALS.load(deps.as_ref().storage, 1).unwrap(); + assert!(deal.is_concluded); + + // Try to conclude again - should fail + let conclude_msg = ExecuteMsg::ConcludeDeal { deal_id: 1 }; + let info = mock_info("anyone", &[]); + let err = execute( + deps.as_mut(), + mock_env_at_time(conclude_time), + info, + conclude_msg + ).unwrap_err(); + assert!(matches!(err, ContractError::DealAlreadyConcluded {})); + + // Verify bids were not removed (optional, depending on your contract's behavior) + assert!(BIDS.may_load(deps.as_ref().storage, (1, &Addr::unchecked("bidder1"))).unwrap().is_some()); + assert!(BIDS.may_load(deps.as_ref().storage, (1, &Addr::unchecked("bidder2"))).unwrap().is_some()); + } + #[test] fn test_validation_errors() { let mut deps = mock_dependencies(); diff --git a/tests/queries.rs b/tests/queries.rs new file mode 100644 index 00000000..e69de29b From ffb2abbd40a4103783aaae2a8da751f946726e38 Mon Sep 17 00:00:00 2001 From: anilcse Date: Sat, 9 Nov 2024 20:58:27 +0530 Subject: [PATCH 09/24] Add CI jobs --- .circleci/config.yml | 0 .github/workflows/Basic.yml | 75 +++++++++++++++++++++++++++++++++++ .github/workflows/Release.yml | 35 ++++++++++++++++ .github/workflows/test.yml | 23 +++++++++++ 4 files changed, 133 insertions(+) create mode 100644 .circleci/config.yml create mode 100644 .github/workflows/Basic.yml create mode 100644 .github/workflows/Release.yml create mode 100644 .github/workflows/test.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..e69de29b diff --git a/.github/workflows/Basic.yml b/.github/workflows/Basic.yml new file mode 100644 index 00000000..20636df1 --- /dev/null +++ b/.github/workflows/Basic.yml @@ -0,0 +1,75 @@ +# Based on https://github.com/actions-rs/example/blob/master/.github/workflows/quickstart.yml + +on: [push, pull_request] + +name: Basic + +jobs: + + test: + name: Test Suite + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: 1.81.0 + target: wasm32-unknown-unknown + override: true + + - name: Run unit tests + uses: actions-rs/cargo@v1 + with: + command: unit-test + args: --locked + env: + RUST_BACKTRACE: 1 + + - name: Compile WASM contract + uses: actions-rs/cargo@v1 + with: + command: wasm + args: --locked + env: + RUSTFLAGS: "-C link-arg=-s" + + lints: + name: Lints + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: 1.81.0 + override: true + components: rustfmt, clippy + + - name: Run cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + # - name: Run cargo clippy + # uses: actions-rs/cargo@v1 + # with: + # command: clippy + # args: -- -D warnings + + - name: Generate Schema + uses: actions-rs/cargo@v1 + with: + command: schema + args: --locked + + - name: Schema Changes + # fails if any changes not committed + run: git diff --exit-code schema \ No newline at end of file diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml new file mode 100644 index 00000000..af2f8d3f --- /dev/null +++ b/.github/workflows/Release.yml @@ -0,0 +1,35 @@ +name: release wasm + +on: + release: + types: [created] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + - name: Install cargo-run-script + uses: actions-rs/cargo@v1 + with: + command: install + args: cargo-run-script + - name: Run cargo optimize + uses: actions-rs/cargo@v1 + with: + command: run-script + args: optimize + - name: Get release ID + id: get_release + uses: bruceadams/get-release@v1.2.3 + env: + GITHUB_TOKEN: ${{ github.token }} + - name: Upload optimized wasm + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./artifacts/*.wasm + tag: ${{ github.ref }} + overwrite: true + file_glob: true \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..bc2652d9 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,23 @@ +name: Contract CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: wasm32-unknown-unknown + override: true + - name: Run tests + run: cargo test --verbose + - name: Build WASM + run: cargo build --release --target wasm32-unknown-unknown \ No newline at end of file From 6aa1fbdb818ba7d6b48f72c12e55fc62803b5937 Mon Sep 17 00:00:00 2001 From: anilcse Date: Sat, 9 Nov 2024 21:34:46 +0530 Subject: [PATCH 10/24] more queries --- src/contract.rs | 275 +++++++++++++++++++++++++++++++++++++++++++++++- src/error.rs | 41 +++----- src/msg.rs | 87 ++++++++++++++- src/state.rs | 84 +++++++++------ tests/deals.rs | 0 tests/mod.rs | 0 6 files changed, 425 insertions(+), 62 deletions(-) create mode 100644 tests/deals.rs create mode 100644 tests/mod.rs diff --git a/src/contract.rs b/src/contract.rs index 34593ba3..b65f2ce4 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -1,10 +1,10 @@ use cosmwasm_std::{ - DepsMut, Env, MessageInfo, Response, + DepsMut, Env, MessageInfo, Response, Deps, Order, to_binary, Binary, StdResult, Uint128, entry_point, CosmosMsg, Storage, }; +use cosmwasm_std::StdError; use cw2::set_contract_version; use cosmwasm_std::Addr; -use cosmwasm_std::attr; use crate::error::ContractError; use crate::msg::{ ExecuteMsg, InstantiateMsg, @@ -15,6 +15,9 @@ use crate::helpers::{ validate_deal_times, calculate_platform_fee, }; +use crate::msg::{QueryMsg, DealResponse, DealsResponse, BidResponse, DealStatsResponse}; +use cw_storage_plus::Bound; + /// Contract name and version info for migration const CONTRACT_NAME: &str = "crates.io:cosmos-otc-platform"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -489,3 +492,271 @@ fn process_successful_deal( Ok((messages, stats)) } + +const DEFAULT_LIMIT: u32 = 10; +const MAX_LIMIT: u32 = 30; + +pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { + let response = match msg { + QueryMsg::GetDeal { deal_id } => to_binary(&query_deal(deps, deal_id)?), + QueryMsg::ListDeals { start_after, limit } => to_binary(&list_deals(deps, start_after, limit)?), + QueryMsg::GetBid { deal_id, bidder } => to_binary(&query_bid(deps, deal_id, bidder)?), + QueryMsg::ListBidsForDeal { deal_id, start_after, limit } => { + to_binary(&list_bids_for_deal(deps, deal_id, start_after, limit)?) + }, + QueryMsg::ListDealsBySeller { seller, start_after, limit } => { + to_binary(&list_deals_by_seller(deps, seller, start_after, limit)?) + }, + QueryMsg::ListBidsByBidder { bidder, start_after, limit } => { + to_binary(&list_bids_by_bidder(deps, bidder, start_after, limit)?) + }, + QueryMsg::ListActiveDeals { start_after, limit } => { + to_binary(&list_active_deals(deps, env, start_after, limit)?) + }, + QueryMsg::ListDealsByStatus { is_concluded, start_after, limit } => { + to_binary(&list_deals_by_status(deps, is_concluded, start_after, limit)?) + }, + QueryMsg::GetConfig {} => to_binary(&query_config(deps)?), + QueryMsg::GetDealStats { deal_id } => to_binary(&query_deal_stats(deps, env, deal_id)?), + }; + Ok(response?) +} + +// Update return types of query functions to use StdResult instead of Result<_, ContractError> +pub fn query_deal(deps: Deps, deal_id: u64) -> StdResult { + let deal = DEALS.load(deps.storage, deal_id) + .map_err(|_| StdError::generic_err("Deal not found"))?; + Ok(DealResponse { deal }) +} + +pub fn query_bid( + deps: Deps, + deal_id: u64, + bidder: String, +) -> StdResult { + let addr = deps.api.addr_validate(&bidder)?; + let bid = BIDS + .load(deps.storage, (deal_id, &addr)) + .map_err(|_| StdError::generic_err("Bid not found"))?; + Ok(BidResponse { bid }) +} + +pub fn list_bids_for_deal( + deps: Deps, + deal_id: u64, + start_after: Option, + limit: Option, +) -> StdResult> { + // Check if deal exists + DEALS.load(deps.storage, deal_id) + .map_err(|_| StdError::generic_err("Deal not found"))?; + + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + + // Convert start_after to validated address + let start_addr = match start_after { + Some(addr_str) => Some(deps.api.addr_validate(&addr_str)?), + None => None, + }; + + let start_bound = start_addr.as_ref().map(|addr| { + let bound_key = (deal_id, addr); + Bound::exclusive(bound_key) + }); + + // Query bids + let bids = BIDS + .range( + deps.storage, + start_bound, + Some(Bound::inclusive((deal_id + 1, &Addr::unchecked("")))), + Order::Ascending, + ) + .filter(|r| matches!(r, Ok((key, _)) if key.0 == deal_id)) + .take(limit) + .map(|item| item.map(|(_, bid)| BidResponse { bid })) + .collect::>>()?; + + Ok(bids) +} + +pub fn list_deals( + deps: Deps, + start_after: Option, + limit: Option, +) -> StdResult { + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + let start = start_after.map(Bound::exclusive); + + let deals: StdResult> = DEALS + .range(deps.storage, start, None, Order::Ascending) + .take(limit) + .map(|item| item.map(|(_, deal)| deal)) + .collect(); + + Ok(DealsResponse { deals: deals? }) +} + +pub fn list_deals_by_seller( + deps: Deps, + seller: String, + start_after: Option, + limit: Option, +) -> StdResult { + let seller_addr = deps.api.addr_validate(&seller)?; + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + let start = start_after.map(Bound::exclusive); + + let deals: StdResult> = DEALS + .range(deps.storage, start, None, Order::Ascending) + .filter(|r| match r { + Ok((_, deal)) => deal.seller == seller_addr, + Err(_) => true, // Keep errors to handle them in collect + }) + .take(limit) + .map(|item| item.map(|(_, deal)| deal)) + .collect(); + + Ok(DealsResponse { deals: deals? }) +} + +pub fn list_bids_by_bidder( + deps: Deps, + bidder: String, + start_after: Option<(u64, String)>, + limit: Option, +) -> StdResult> { + let bidder_addr = deps.api.addr_validate(&bidder)?; + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + + // Convert start_after into a proper bound + let start = start_after + .map(|(deal_id, _)| deal_id) + .map(|id| (id, &bidder_addr)); + + let mut bids = vec![]; + + let bid_range = BIDS.range( + deps.storage, + start.map(Bound::exclusive), + None, + Order::Ascending, + ); + + for result in bid_range { + let ((deal_id, addr), bid) = result?; + if addr == bidder_addr { + bids.push((deal_id, BidResponse { bid })); + if bids.len() >= limit { + break; + } + } + } + + Ok(bids) +} + +pub fn list_active_deals( + deps: Deps, + env: Env, + start_after: Option, + limit: Option, +) -> StdResult { + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + let start = start_after.map(Bound::exclusive); + let current_time = env.block.time.seconds(); + + let deals: StdResult> = DEALS + .range(deps.storage, start, None, Order::Ascending) + .filter(|r| match r { + Ok((_, deal)) => { + !deal.is_concluded && + deal.bid_start_time <= current_time && + deal.bid_end_time > current_time + } + Err(_) => true, // Keep errors to handle them in collect + }) + .take(limit) + .map(|item| item.map(|(_, deal)| deal)) + .collect(); + + Ok(DealsResponse { deals: deals? }) +} + +pub fn list_deals_by_status( + deps: Deps, + is_concluded: bool, + start_after: Option, + limit: Option, +) -> StdResult { + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + let start = start_after.map(Bound::exclusive); + + let deals: StdResult> = DEALS + .range(deps.storage, start, None, Order::Ascending) + .filter(|r| match r { + Ok((_, deal)) => deal.is_concluded == is_concluded, + Err(_) => true, // Keep errors to handle them in collect + }) + .take(limit) + .map(|item| item.map(|(_, deal)| deal)) + .collect(); + + Ok(DealsResponse { deals: deals? }) +} + +pub fn query_config(deps: Deps) -> StdResult { + CONFIG.load(deps.storage) +} + +pub fn query_deal_stats( + deps: Deps, + env: Env, + deal_id: u64, +) -> StdResult { + let deal = DEALS.load(deps.storage, deal_id) + .map_err(|_| StdError::generic_err("Deal not found"))?; + let current_time = env.block.time.seconds(); + + let mut total_bids_count = 0u32; + let mut total_discount = 0u64; + let mut highest_bid_amount = Uint128::zero(); + let mut lowest_bid_amount = None; + let mut total_bid_amount = Uint128::zero(); + let mut bidders = std::collections::HashSet::new(); + + // Process all bids for the deal + for result in BIDS.prefix(deal_id).range(deps.storage, None, None, Order::Ascending) { + let (_, bid) = result?; + total_bids_count += 1; + total_discount += bid.discount_percentage; + highest_bid_amount = std::cmp::max(highest_bid_amount, bid.amount); + lowest_bid_amount = Some(lowest_bid_amount.map_or(bid.amount, |current| std::cmp::min(current, bid.amount))); + total_bid_amount += bid.amount; + bidders.insert(bid.bidder); + } + + // Calculate time remaining if deal is active + let time_remaining = if !deal.is_concluded && current_time < deal.conclude_time { + Some(deal.conclude_time.saturating_sub(current_time)) + } else { + None + }; + + let average_discount = if total_bids_count > 0 { + total_discount / total_bids_count as u64 + } else { + 0 + }; + + Ok(DealStatsResponse { + total_bids_count, + unique_bidders_count: bidders.len() as u32, + average_discount, + highest_bid_amount, + lowest_bid_amount: lowest_bid_amount.unwrap_or_else(Uint128::zero), + total_bid_amount, + min_cap_reached: total_bid_amount >= deal.min_cap, + time_remaining, + }) +} \ No newline at end of file diff --git a/src/error.rs b/src/error.rs index 98fdd9fa..6818c821 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,8 +1,7 @@ -// error.rs use cosmwasm_std::{StdError, OverflowError}; use thiserror::Error; -#[derive(Error, Debug)] +#[derive(Error, Debug, PartialEq)] pub enum ContractError { #[error("{0}")] Std(#[from] StdError), @@ -13,36 +12,30 @@ pub enum ContractError { #[error("Unauthorized")] Unauthorized {}, - #[error("Invalid time parameters: {reason}")] - InvalidTimeParameters { reason: String }, + #[error("Deal not found")] + DealNotFound {}, - #[error("Bidding has not started yet")] - BiddingNotStarted {}, - - #[error("Bidding has ended")] - BiddingEnded {}, - - #[error("Deal cannot be concluded yet")] - ConclusionTimeNotReached {}, + #[error("Bid not found")] + BidNotFound {}, #[error("Deal already concluded")] DealAlreadyConcluded {}, - #[error("Insufficient platform fee. Required: {required}, provided: {provided}")] - InsufficientPlatformFee { - required: u128, - provided: u128, - }, + #[error("Invalid time parameters: {reason}")] + InvalidTimeParameters { reason: String }, #[error("Invalid bid amount: {reason}")] InvalidBidAmount { reason: String }, - #[error("Bid not found for deal {deal_id} from bidder {bidder}")] - BidNotFound { - deal_id: u64, - bidder: String, - }, + #[error("Insufficient platform fee. Required: {required}, provided: {provided}")] + InsufficientPlatformFee { required: u128, provided: u128 }, + + #[error("Bidding has not started")] + BiddingNotStarted {}, - #[error("Insufficient funds")] - InsufficientFunds {}, + #[error("Bidding has ended")] + BiddingEnded {}, + + #[error("Conclusion time not reached")] + ConclusionTimeNotReached {}, } \ No newline at end of file diff --git a/src/msg.rs b/src/msg.rs index 14e35e9f..f6ba3bfa 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -72,15 +72,72 @@ pub enum ExecuteMsg { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema, QueryResponses)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { - /// Get details of a specific deal + /// Get a specific deal by ID #[returns(DealResponse)] GetDeal { deal_id: u64 }, - /// Get all bids for a specific deal + + /// List all deals with optional pagination + #[returns(DealsResponse)] + ListDeals { + start_after: Option, + limit: Option, + }, + + /// Get a specific bid for a deal + #[returns(BidResponse)] + GetBid { + deal_id: u64, + bidder: String, + }, + + /// List all bids for a specific deal #[returns(BidsResponse)] - GetBids { deal_id: u64 }, + ListBidsForDeal { + deal_id: u64, + start_after: Option, + limit: Option, + }, + + /// Get all deals by seller + #[returns(DealsResponse)] + ListDealsBySeller { + seller: String, + start_after: Option, + limit: Option, + }, + + /// Get all bids by bidder across all deals + #[returns(BidsResponse)] + ListBidsByBidder { + bidder: String, + start_after: Option<(u64, String)>, // (deal_id, bidder) + limit: Option, + }, + + /// Get active deals (not concluded and in bidding period) + #[returns(DealsResponse)] + ListActiveDeals { + start_after: Option, + limit: Option, + }, + + /// Get deals by status + #[returns(DealsResponse)] + ListDealsByStatus { + is_concluded: bool, + start_after: Option, + limit: Option, + }, + /// Get contract configuration #[returns(ConfigResponse)] GetConfig {}, + + /// Get deal statistics + #[returns(DealStatsResponse)] + GetDealStats { + deal_id: u64, + }, } /// Response for GetDeal query @@ -89,6 +146,12 @@ pub struct DealResponse { pub deal: Deal, } +/// Response for GetBid query +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct BidResponse { + pub bid: Bid, +} + /// Response for GetBids query #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct BidsResponse { @@ -99,4 +162,22 @@ pub struct BidsResponse { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct ConfigResponse { pub config: Config, +} + +/// Response for ListDeals query +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +pub struct DealsResponse { + pub deals: Vec, +} + +#[cw_serde] +pub struct DealStatsResponse { + pub total_bids_count: u32, + pub unique_bidders_count: u32, + pub average_discount: u64, + pub highest_bid_amount: Uint128, + pub lowest_bid_amount: Uint128, + pub total_bid_amount: Uint128, + pub min_cap_reached: bool, + pub time_remaining: Option, // None if concluded or expired } \ No newline at end of file diff --git a/src/state.rs b/src/state.rs index b771b5be..a4c2515f 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1,64 +1,82 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; +use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Uint128}; use cw_storage_plus::{Item, Map}; -/// Configuration for the OTC platform -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct Config { - /// Platform fee percentage in basis points (1/100 of a percent) - /// e.g., 100 = 1%, 50 = 0.5% - pub platform_fee_percentage: u64, + pub platform_fee_percentage: u64, // In basis points (100 = 1%) } -/// Represents an OTC deal created by a seller -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct Deal { - /// Address of the seller who created the deal pub seller: String, - /// Address of the token being sold pub sell_token: String, - /// Total amount of tokens being sold pub total_amount: Uint128, - /// Minimum price per token that the seller will accept pub min_price: Uint128, - /// Seller's maximum discount percentage they're willing to offer - pub discount_percentage: u64, - /// Minimum total value of bids required for the deal to conclude + pub discount_percentage: u64, // In basis points (100 = 1%) pub min_cap: Uint128, - /// Unix timestamp when bidding starts pub bid_start_time: u64, - /// Unix timestamp when bidding ends pub bid_end_time: u64, - /// Unix timestamp when the deal can be concluded pub conclude_time: u64, - /// Whether the deal has been concluded pub is_concluded: bool, - /// Total amount of all active bids pub total_bids_amount: Uint128, } -/// Represents a bid placed by a buyer -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] +#[cw_serde] pub struct Bid { - /// Address of the bidder pub bidder: String, - /// Amount of tokens the bidder wants to buy pub amount: Uint128, - /// Discount percentage requested by the bidder pub discount_percentage: u64, - /// Optional maximum price the bidder is willing to pay pub max_price: Option, } -/// Stores the contract configuration +// Contract state storage pub const CONFIG: Item = Item::new("config"); - -/// Counter for generating unique deal IDs pub const DEAL_COUNTER: Item = Item::new("deal_counter"); -/// Maps deal IDs to Deal structs +// Maps for storing deals and bids pub const DEALS: Map = Map::new("deals"); - -/// Maps (deal_id, bidder_address) to Bid structs pub const BIDS: Map<(u64, &Addr), Bid> = Map::new("bids"); + +// Optional indexes for more efficient queries +pub const SELLER_DEALS: Map<(&Addr, u64), u64> = Map::new("seller_deals"); +pub const BIDDER_DEALS: Map<(&Addr, u64), u64> = Map::new("bidder_deals"); +pub const ACTIVE_DEALS: Map = Map::new("active_deals"); + +// Helper functions for state management +impl Deal { + pub fn is_active(&self, current_time: u64) -> bool { + !self.is_concluded && + self.bid_start_time <= current_time && + self.bid_end_time > current_time + } + + pub fn validate_times(&self, current_time: u64) -> bool { + self.bid_start_time > current_time && + self.bid_end_time > self.bid_start_time && + self.conclude_time > self.bid_end_time + } + + pub fn can_conclude(&self, current_time: u64) -> bool { + !self.is_concluded && current_time >= self.conclude_time + } + + pub fn can_bid(&self, current_time: u64) -> bool { + !self.is_concluded && + current_time >= self.bid_start_time && + current_time < self.bid_end_time + } +} + +impl Bid { + pub fn validate_bid(&self, deal: &Deal) -> bool { + self.amount > Uint128::zero() && + self.discount_percentage <= 10000 // Max 100% + } + + pub fn calculate_final_price(&self, deal: &Deal) -> Uint128 { + let base_price = self.amount.multiply_ratio(deal.min_price, Uint128::new(1u128)); + let discount = base_price.multiply_ratio(self.discount_percentage, 100u128); + base_price.saturating_sub(discount) + } +} \ No newline at end of file diff --git a/tests/deals.rs b/tests/deals.rs new file mode 100644 index 00000000..e69de29b diff --git a/tests/mod.rs b/tests/mod.rs new file mode 100644 index 00000000..e69de29b From 0d11070b95b4cf2702892754b726dd883fe338d3 Mon Sep 17 00:00:00 2001 From: anilcse Date: Sat, 9 Nov 2024 21:35:10 +0530 Subject: [PATCH 11/24] cargo fmt --- src/contract.rs | 193 +++++++++++++++++++++++++---------------------- src/error.rs | 4 +- src/helpers.rs | 30 ++------ src/lib.rs | 8 +- src/msg.rs | 19 ++--- src/state.rs | 31 ++++---- tests/common.rs | 136 +++++++++++++++++++++------------ tests/deals.rs | 1 + tests/mod.rs | 1 + tests/queries.rs | 1 + 10 files changed, 228 insertions(+), 196 deletions(-) diff --git a/src/contract.rs b/src/contract.rs index b65f2ce4..6b9fd0d9 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -1,21 +1,19 @@ -use cosmwasm_std::{ - DepsMut, Env, MessageInfo, Response, Deps, Order, to_binary, Binary, - StdResult, Uint128, entry_point, CosmosMsg, Storage, -}; -use cosmwasm_std::StdError; -use cw2::set_contract_version; -use cosmwasm_std::Addr; use crate::error::ContractError; -use crate::msg::{ - ExecuteMsg, InstantiateMsg, -}; -use crate::state::{Config, Deal, Bid, CONFIG, DEAL_COUNTER, DEALS, BIDS}; use crate::helpers::{ - create_token_transfer_msg, create_payment_msg, get_sorted_bids, - validate_deal_times, calculate_platform_fee, + calculate_platform_fee, create_payment_msg, create_token_transfer_msg, get_sorted_bids, + validate_deal_times, }; +use crate::msg::{ExecuteMsg, InstantiateMsg}; +use crate::state::{Bid, Config, Deal, BIDS, CONFIG, DEALS, DEAL_COUNTER}; +use cosmwasm_std::Addr; +use cosmwasm_std::StdError; +use cosmwasm_std::{ + entry_point, to_binary, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Order, Response, + StdResult, Storage, Uint128, +}; +use cw2::set_contract_version; -use crate::msg::{QueryMsg, DealResponse, DealsResponse, BidResponse, DealStatsResponse}; +use crate::msg::{BidResponse, DealResponse, DealStatsResponse, DealsResponse, QueryMsg}; use cw_storage_plus::Bound; /// Contract name and version info for migration @@ -42,7 +40,7 @@ pub fn instantiate( let config = Config { platform_fee_percentage: msg.platform_fee_percentage, }; - + CONFIG.save(deps.storage, &config)?; DEAL_COUNTER.save(deps.storage, &0u64)?; @@ -87,13 +85,29 @@ pub fn execute( amount, discount_percentage, max_price, - } => execute_place_bid(deps, env, info, deal_id, amount, discount_percentage, max_price), + } => execute_place_bid( + deps, + env, + info, + deal_id, + amount, + discount_percentage, + max_price, + ), ExecuteMsg::UpdateBid { deal_id, new_amount, new_discount_percentage, new_max_price, - } => execute_update_bid(deps, env, info, deal_id, new_amount, new_discount_percentage, new_max_price), + } => execute_update_bid( + deps, + env, + info, + deal_id, + new_amount, + new_discount_percentage, + new_max_price, + ), ExecuteMsg::WithdrawBid { deal_id } => execute_withdraw_bid(deps, env, info, deal_id), ExecuteMsg::ConcludeDeal { deal_id } => execute_conclude_deal(deps, env, info, deal_id), } @@ -131,7 +145,7 @@ pub fn execute_create_deal( // Calculate and validate platform fee let config = CONFIG.load(deps.storage)?; let platform_fee = calculate_platform_fee(total_amount, config.platform_fee_percentage)?; - + // Ensure seller has sent enough platform fee let provided_fee = info .funds @@ -184,7 +198,7 @@ pub fn execute_place_bid( max_price: Option, ) -> Result { let deal = DEALS.load(deps.storage, deal_id)?; - + // Validate bid timing let current_time = env.block.time.seconds(); if current_time < deal.bid_start_time { @@ -216,7 +230,7 @@ pub fn execute_place_bid( }; BIDS.save(deps.storage, (deal_id, &info.sender), &bid)?; - + // Update total bids amount let new_total = deal.total_bids_amount + amount; DEALS.update(deps.storage, deal_id, |deal_opt| -> StdResult<_> { @@ -243,7 +257,7 @@ pub fn execute_update_bid( new_max_price: Option, ) -> Result { let deal = DEALS.load(deps.storage, deal_id)?; - + // Validate timing if env.block.time.seconds() >= deal.bid_end_time { return Err(ContractError::BiddingEnded {}); @@ -251,7 +265,7 @@ pub fn execute_update_bid( // Load existing bid let old_bid = BIDS.load(deps.storage, (deal_id, &info.sender))?; - + // Update total bids amount let amount_diff = new_amount.checked_sub(old_bid.amount)?; DEALS.update(deps.storage, deal_id, |deal_opt| -> StdResult<_> { @@ -283,7 +297,7 @@ pub fn execute_withdraw_bid( deal_id: u64, ) -> Result { let deal = DEALS.load(deps.storage, deal_id)?; - + // Validate timing if env.block.time.seconds() >= deal.bid_end_time { return Err(ContractError::BiddingEnded {}); @@ -307,7 +321,7 @@ pub fn execute_withdraw_bid( } /// Concludes an OTC deal by processing all bids and distributing tokens -/// +/// /// # Deal Conclusion Process /// 1. Validates deal timing and status /// 2. Checks if minimum cap is met @@ -318,13 +332,13 @@ pub fn execute_withdraw_bid( /// - Transfers tokens to successful bidders /// - Transfers payments to seller /// - Refunds unsuccessful bidders -/// +/// /// # Arguments /// * `deps` - Mutable dependencies for storage access /// * `env` - Environment variables, primarily used for time validation /// * `_info` - Message information (unused but kept for consistency) /// * `deal_id` - Identifier of the deal to conclude -/// +/// /// # Returns /// * `Response` - Success response with transfer messages and events /// * `ContractError` - Various error conditions that might occur @@ -336,7 +350,7 @@ pub fn execute_conclude_deal( ) -> Result { // Load deal data let mut deal = DEALS.load(deps.storage, deal_id)?; - + // Validation: Check timing and conclusion status if env.block.time.seconds() < deal.conclude_time { return Err(ContractError::ConclusionTimeNotReached {}); @@ -348,7 +362,7 @@ pub fn execute_conclude_deal( // Case 1: Minimum cap not met - refund all bidders if deal.total_bids_amount < deal.min_cap { let refund_messages = process_failed_deal(deps.storage, deal_id)?; - + // Mark deal as concluded deal.is_concluded = true; DEALS.save(deps.storage, deal_id, &deal)?; @@ -362,11 +376,7 @@ pub fn execute_conclude_deal( } // Case 2: Process successful deal - let (messages, stats) = process_successful_deal( - deps.storage, - &deal, - deal_id, - )?; + let (messages, stats) = process_successful_deal(deps.storage, &deal, deal_id)?; // Mark deal as concluded deal.is_concluded = true; @@ -400,9 +410,7 @@ fn process_failed_deal( for (bidder, bid) in bids { messages.push(create_payment_msg( - bidder, - bid.amount, - "uusd", // Replace with actual denom + bidder, bid.amount, "uusd", // Replace with actual denom )); } @@ -430,18 +438,14 @@ fn process_successful_deal( for (bidder, bid) in bids { if remaining_tokens.is_zero() { // Refund remaining bids - messages.push(create_payment_msg( - bidder, - bid.amount, - "uusd", - )); + messages.push(create_payment_msg(bidder, bid.amount, "uusd")); stats.refunded_bids += 1; continue; } // Calculate token allocation let tokens_to_receive = std::cmp::min(bid.amount, remaining_tokens); - + // Calculate final price with discount let base_price = tokens_to_receive.multiply_ratio(deal.min_price, Uint128::new(1u128)); let discount = base_price.multiply_ratio(bid.discount_percentage, 100u128); @@ -450,18 +454,14 @@ fn process_successful_deal( // Check if price meets buyer's max price constraint if let Some(max_price) = bid.max_price { if final_price > max_price { - messages.push(create_payment_msg( - bidder, - bid.amount, - "uusd", - )); + messages.push(create_payment_msg(bidder, bid.amount, "uusd")); stats.refunded_bids += 1; continue; } } // Process successful bid - + // 1. Transfer tokens to buyer messages.push(create_token_transfer_msg( deal.sell_token.clone(), @@ -470,11 +470,7 @@ fn process_successful_deal( )?); // 2. Transfer payment to seller - messages.push(create_payment_msg( - deal.seller.clone(), - final_price, - "uusd", - )); + messages.push(create_payment_msg(deal.seller.clone(), final_price, "uusd")); // Update running totals remaining_tokens = remaining_tokens.checked_sub(tokens_to_receive)?; @@ -485,8 +481,8 @@ fn process_successful_deal( // Validate all tokens are accounted for if stats.tokens_sold + remaining_tokens != deal.total_amount { - return Err(ContractError::InvalidBidAmount { - reason: "Token allocation mismatch".to_string() + return Err(ContractError::InvalidBidAmount { + reason: "Token allocation mismatch".to_string(), }); } @@ -499,23 +495,38 @@ const MAX_LIMIT: u32 = 30; pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { let response = match msg { QueryMsg::GetDeal { deal_id } => to_binary(&query_deal(deps, deal_id)?), - QueryMsg::ListDeals { start_after, limit } => to_binary(&list_deals(deps, start_after, limit)?), + QueryMsg::ListDeals { start_after, limit } => { + to_binary(&list_deals(deps, start_after, limit)?) + } QueryMsg::GetBid { deal_id, bidder } => to_binary(&query_bid(deps, deal_id, bidder)?), - QueryMsg::ListBidsForDeal { deal_id, start_after, limit } => { - to_binary(&list_bids_for_deal(deps, deal_id, start_after, limit)?) - }, - QueryMsg::ListDealsBySeller { seller, start_after, limit } => { - to_binary(&list_deals_by_seller(deps, seller, start_after, limit)?) - }, - QueryMsg::ListBidsByBidder { bidder, start_after, limit } => { - to_binary(&list_bids_by_bidder(deps, bidder, start_after, limit)?) - }, + QueryMsg::ListBidsForDeal { + deal_id, + start_after, + limit, + } => to_binary(&list_bids_for_deal(deps, deal_id, start_after, limit)?), + QueryMsg::ListDealsBySeller { + seller, + start_after, + limit, + } => to_binary(&list_deals_by_seller(deps, seller, start_after, limit)?), + QueryMsg::ListBidsByBidder { + bidder, + start_after, + limit, + } => to_binary(&list_bids_by_bidder(deps, bidder, start_after, limit)?), QueryMsg::ListActiveDeals { start_after, limit } => { to_binary(&list_active_deals(deps, env, start_after, limit)?) - }, - QueryMsg::ListDealsByStatus { is_concluded, start_after, limit } => { - to_binary(&list_deals_by_status(deps, is_concluded, start_after, limit)?) - }, + } + QueryMsg::ListDealsByStatus { + is_concluded, + start_after, + limit, + } => to_binary(&list_deals_by_status( + deps, + is_concluded, + start_after, + limit, + )?), QueryMsg::GetConfig {} => to_binary(&query_config(deps)?), QueryMsg::GetDealStats { deal_id } => to_binary(&query_deal_stats(deps, env, deal_id)?), }; @@ -524,16 +535,13 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { // Update return types of query functions to use StdResult instead of Result<_, ContractError> pub fn query_deal(deps: Deps, deal_id: u64) -> StdResult { - let deal = DEALS.load(deps.storage, deal_id) + let deal = DEALS + .load(deps.storage, deal_id) .map_err(|_| StdError::generic_err("Deal not found"))?; Ok(DealResponse { deal }) } -pub fn query_bid( - deps: Deps, - deal_id: u64, - bidder: String, -) -> StdResult { +pub fn query_bid(deps: Deps, deal_id: u64, bidder: String) -> StdResult { let addr = deps.api.addr_validate(&bidder)?; let bid = BIDS .load(deps.storage, (deal_id, &addr)) @@ -548,11 +556,12 @@ pub fn list_bids_for_deal( limit: Option, ) -> StdResult> { // Check if deal exists - DEALS.load(deps.storage, deal_id) + DEALS + .load(deps.storage, deal_id) .map_err(|_| StdError::generic_err("Deal not found"))?; let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - + // Convert start_after to validated address let start_addr = match start_after { Some(addr_str) => Some(deps.api.addr_validate(&addr_str)?), @@ -628,14 +637,14 @@ pub fn list_bids_by_bidder( ) -> StdResult> { let bidder_addr = deps.api.addr_validate(&bidder)?; let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; - + // Convert start_after into a proper bound let start = start_after .map(|(deal_id, _)| deal_id) .map(|id| (id, &bidder_addr)); let mut bids = vec![]; - + let bid_range = BIDS.range( deps.storage, start.map(Bound::exclusive), @@ -670,9 +679,9 @@ pub fn list_active_deals( .range(deps.storage, start, None, Order::Ascending) .filter(|r| match r { Ok((_, deal)) => { - !deal.is_concluded && - deal.bid_start_time <= current_time && - deal.bid_end_time > current_time + !deal.is_concluded + && deal.bid_start_time <= current_time + && deal.bid_end_time > current_time } Err(_) => true, // Keep errors to handle them in collect }) @@ -709,12 +718,9 @@ pub fn query_config(deps: Deps) -> StdResult { CONFIG.load(deps.storage) } -pub fn query_deal_stats( - deps: Deps, - env: Env, - deal_id: u64, -) -> StdResult { - let deal = DEALS.load(deps.storage, deal_id) +pub fn query_deal_stats(deps: Deps, env: Env, deal_id: u64) -> StdResult { + let deal = DEALS + .load(deps.storage, deal_id) .map_err(|_| StdError::generic_err("Deal not found"))?; let current_time = env.block.time.seconds(); @@ -726,12 +732,17 @@ pub fn query_deal_stats( let mut bidders = std::collections::HashSet::new(); // Process all bids for the deal - for result in BIDS.prefix(deal_id).range(deps.storage, None, None, Order::Ascending) { + for result in BIDS + .prefix(deal_id) + .range(deps.storage, None, None, Order::Ascending) + { let (_, bid) = result?; total_bids_count += 1; total_discount += bid.discount_percentage; highest_bid_amount = std::cmp::max(highest_bid_amount, bid.amount); - lowest_bid_amount = Some(lowest_bid_amount.map_or(bid.amount, |current| std::cmp::min(current, bid.amount))); + lowest_bid_amount = Some( + lowest_bid_amount.map_or(bid.amount, |current| std::cmp::min(current, bid.amount)), + ); total_bid_amount += bid.amount; bidders.insert(bid.bidder); } @@ -759,4 +770,4 @@ pub fn query_deal_stats( min_cap_reached: total_bid_amount >= deal.min_cap, time_remaining, }) -} \ No newline at end of file +} diff --git a/src/error.rs b/src/error.rs index 6818c821..005181df 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{StdError, OverflowError}; +use cosmwasm_std::{OverflowError, StdError}; use thiserror::Error; #[derive(Error, Debug, PartialEq)] @@ -38,4 +38,4 @@ pub enum ContractError { #[error("Conclusion time not reached")] ConclusionTimeNotReached {}, -} \ No newline at end of file +} diff --git a/src/helpers.rs b/src/helpers.rs index 59f77d03..af646680 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,11 +1,10 @@ use cosmwasm_std::{ - Coin, CosmosMsg, BankMsg, Uint128, WasmMsg, - to_binary, StdResult, Order, Storage, + to_binary, BankMsg, Coin, CosmosMsg, Order, StdResult, Storage, Uint128, WasmMsg, }; use cw20::Cw20ExecuteMsg; -use crate::state::{BIDS, Bid}; use crate::error::ContractError; +use crate::state::{Bid, BIDS}; /// Creates a CosmosMsg for transferring CW20 tokens pub fn create_token_transfer_msg( @@ -15,20 +14,13 @@ pub fn create_token_transfer_msg( ) -> StdResult { Ok(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: token_addr, - msg: to_binary(&Cw20ExecuteMsg::Transfer { - recipient, - amount, - })?, + msg: to_binary(&Cw20ExecuteMsg::Transfer { recipient, amount })?, funds: vec![], })) } /// Creates a CosmosMsg for sending native tokens -pub fn create_payment_msg( - recipient: String, - amount: Uint128, - denom: &str, -) -> CosmosMsg { +pub fn create_payment_msg(recipient: String, amount: Uint128, denom: &str) -> CosmosMsg { CosmosMsg::Bank(BankMsg::Send { to_address: recipient, amount: vec![Coin { @@ -39,10 +31,7 @@ pub fn create_payment_msg( } /// Retrieves all bids for a deal, sorted by discount percentage -pub fn get_sorted_bids( - storage: &dyn Storage, - deal_id: u64, -) -> StdResult> { +pub fn get_sorted_bids(storage: &dyn Storage, deal_id: u64) -> StdResult> { let mut bids: Vec<(String, Bid)> = BIDS .prefix(deal_id) .range(storage, None, None, Order::Ascending) @@ -51,7 +40,7 @@ pub fn get_sorted_bids( Ok((addr.to_string(), bid)) }) .collect::>>()?; - + bids.sort_by(|a, b| a.1.discount_percentage.cmp(&b.1.discount_percentage)); Ok(bids) } @@ -82,9 +71,6 @@ pub fn validate_deal_times( } /// Calculates the platform fee for a given amount -pub fn calculate_platform_fee( - amount: Uint128, - fee_percentage: u64, -) -> StdResult { +pub fn calculate_platform_fee(amount: Uint128, fee_percentage: u64) -> StdResult { Ok(amount.multiply_ratio(fee_percentage, 10000u128)) -} \ No newline at end of file +} diff --git a/src/lib.rs b/src/lib.rs index 561bfb67..145edcfa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,11 +1,11 @@ //! CosmWasm OTC Platform Smart Contract -//! +//! //! This contract implements a decentralized over-the-counter (OTC) trading platform //! where sellers can create deals with customizable parameters and buyers can place //! bids with their desired discount rates. -//! +//! //! ## Features -//! +//! //! * Create OTC deals with custom parameters //! * Place, update, and withdraw bids //! * Automatic deal conclusion @@ -19,4 +19,4 @@ pub mod helpers; pub mod msg; pub mod state; -pub use crate::error::ContractError; \ No newline at end of file +pub use crate::error::ContractError; diff --git a/src/msg.rs b/src/msg.rs index f6ba3bfa..2a8f70ef 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -1,8 +1,8 @@ +use crate::state::{Bid, Config, Deal}; +use cosmwasm_schema::{cw_serde, QueryResponses}; +use cosmwasm_std::Uint128; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cosmwasm_std::Uint128; -use cosmwasm_schema::{cw_serde, QueryResponses}; -use crate::state::{Config, Deal, Bid}; /// Message for contract instantiation #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] @@ -85,10 +85,7 @@ pub enum QueryMsg { /// Get a specific bid for a deal #[returns(BidResponse)] - GetBid { - deal_id: u64, - bidder: String, - }, + GetBid { deal_id: u64, bidder: String }, /// List all bids for a specific deal #[returns(BidsResponse)] @@ -135,9 +132,7 @@ pub enum QueryMsg { /// Get deal statistics #[returns(DealStatsResponse)] - GetDealStats { - deal_id: u64, - }, + GetDealStats { deal_id: u64 }, } /// Response for GetDeal query @@ -179,5 +174,5 @@ pub struct DealStatsResponse { pub lowest_bid_amount: Uint128, pub total_bid_amount: Uint128, pub min_cap_reached: bool, - pub time_remaining: Option, // None if concluded or expired -} \ No newline at end of file + pub time_remaining: Option, // None if concluded or expired +} diff --git a/src/state.rs b/src/state.rs index a4c2515f..1e293569 100644 --- a/src/state.rs +++ b/src/state.rs @@ -4,7 +4,7 @@ use cw_storage_plus::{Item, Map}; #[cw_serde] pub struct Config { - pub platform_fee_percentage: u64, // In basis points (100 = 1%) + pub platform_fee_percentage: u64, // In basis points (100 = 1%) } #[cw_serde] @@ -13,7 +13,7 @@ pub struct Deal { pub sell_token: String, pub total_amount: Uint128, pub min_price: Uint128, - pub discount_percentage: u64, // In basis points (100 = 1%) + pub discount_percentage: u64, // In basis points (100 = 1%) pub min_cap: Uint128, pub bid_start_time: u64, pub bid_end_time: u64, @@ -46,15 +46,15 @@ pub const ACTIVE_DEALS: Map = Map::new("active_deals"); // Helper functions for state management impl Deal { pub fn is_active(&self, current_time: u64) -> bool { - !self.is_concluded && - self.bid_start_time <= current_time && - self.bid_end_time > current_time + !self.is_concluded + && self.bid_start_time <= current_time + && self.bid_end_time > current_time } pub fn validate_times(&self, current_time: u64) -> bool { - self.bid_start_time > current_time && - self.bid_end_time > self.bid_start_time && - self.conclude_time > self.bid_end_time + self.bid_start_time > current_time + && self.bid_end_time > self.bid_start_time + && self.conclude_time > self.bid_end_time } pub fn can_conclude(&self, current_time: u64) -> bool { @@ -62,21 +62,22 @@ impl Deal { } pub fn can_bid(&self, current_time: u64) -> bool { - !self.is_concluded && - current_time >= self.bid_start_time && - current_time < self.bid_end_time + !self.is_concluded + && current_time >= self.bid_start_time + && current_time < self.bid_end_time } } impl Bid { pub fn validate_bid(&self, deal: &Deal) -> bool { - self.amount > Uint128::zero() && - self.discount_percentage <= 10000 // Max 100% + self.amount > Uint128::zero() && self.discount_percentage <= 10000 // Max 100% } pub fn calculate_final_price(&self, deal: &Deal) -> Uint128 { - let base_price = self.amount.multiply_ratio(deal.min_price, Uint128::new(1u128)); + let base_price = self + .amount + .multiply_ratio(deal.min_price, Uint128::new(1u128)); let discount = base_price.multiply_ratio(self.discount_percentage, 100u128); base_price.saturating_sub(discount) } -} \ No newline at end of file +} diff --git a/tests/common.rs b/tests/common.rs index de678713..5ebda623 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -2,13 +2,13 @@ mod tests { use super::*; use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; - use cosmwasm_std::{Env, Timestamp, coins, Addr, Uint128, DepsMut, BankMsg, CosmosMsg, SubMsg}; + use cosmwasm_std::{coins, Addr, BankMsg, CosmosMsg, DepsMut, Env, SubMsg, Timestamp, Uint128}; - use cw_otc_dex::msg::{ExecuteMsg, InstantiateMsg}; - use cw_otc_dex::state::{BIDS, CONFIG, DEAL_COUNTER, DEALS, Bid, Config, Deal}; + use cw_otc_dex::contract::{execute, execute_conclude_deal, instantiate}; use cw_otc_dex::error::ContractError; - use cw_otc_dex::contract::{execute, instantiate, execute_conclude_deal}; - + use cw_otc_dex::msg::{ExecuteMsg, InstantiateMsg}; + use cw_otc_dex::state::{Bid, Config, Deal, BIDS, CONFIG, DEALS, DEAL_COUNTER}; + const PLATFORM_FEE_PERCENTAGE: u64 = 100; // 1% const MOCK_SELL_TOKEN: &str = "token"; const MOCK_PAYMENT_DENOM: &str = "uusd"; @@ -28,9 +28,9 @@ mod tests { min_price: Uint128::new(1u128), discount_percentage: 1000, // 10% min_cap: Uint128::new(500000u128), - bid_start_time: start_time + 1000, // Ensure future start - bid_end_time: start_time + 2000, // End time after start - conclude_time: start_time + 3000, // Conclude time after end + bid_start_time: start_time + 1000, // Ensure future start + bid_end_time: start_time + 2000, // End time after start + conclude_time: start_time + 3000, // Conclude time after end } } @@ -58,7 +58,7 @@ mod tests { fn test_create_deal() { let mut deps = mock_dependencies(); setup_contract(deps.as_mut()); - + let current_time = 1000u64; let env = mock_env_at_time(current_time); let total_amount = Uint128::new(1000000u128); @@ -66,7 +66,10 @@ mod tests { let msg = create_test_deal_msg(current_time); // Test with insufficient platform fee - let info = mock_info("seller", &coins(platform_fee.u128() - 1, MOCK_PAYMENT_DENOM)); + let info = mock_info( + "seller", + &coins(platform_fee.u128() - 1, MOCK_PAYMENT_DENOM), + ); let err = execute(deps.as_mut(), env.clone(), info, msg.clone()).unwrap_err(); assert!(matches!(err, ContractError::InsufficientPlatformFee { .. })); @@ -74,7 +77,7 @@ mod tests { let info = mock_info("seller", &coins(platform_fee.u128(), MOCK_PAYMENT_DENOM)); let res = execute(deps.as_mut(), env.clone(), info, msg).unwrap(); assert_eq!(res.attributes.len(), 3); - + let deal = DEALS.load(deps.as_ref().storage, 1).unwrap(); assert_eq!(deal.seller, "seller"); assert_eq!(deal.total_amount, total_amount); @@ -85,15 +88,15 @@ mod tests { fn test_place_bid() { let mut deps = mock_dependencies(); setup_contract(deps.as_mut()); - + let start_time = 1000u64; let env = mock_env_at_time(start_time); - + // Create deal let total_amount = Uint128::new(1000000u128); let platform_fee = total_amount.multiply_ratio(PLATFORM_FEE_PERCENTAGE as u128, 10000u128); let create_msg = create_test_deal_msg(start_time); - + let info = mock_info("seller", &coins(platform_fee.u128(), MOCK_PAYMENT_DENOM)); execute(deps.as_mut(), env.clone(), info, create_msg).unwrap(); @@ -111,7 +114,9 @@ mod tests { let res = execute(deps.as_mut(), bid_env.clone(), info, bid_msg).unwrap(); assert_eq!(res.attributes.len(), 4); - let bid = BIDS.load(deps.as_ref().storage, (1, &Addr::unchecked("bidder1"))).unwrap(); + let bid = BIDS + .load(deps.as_ref().storage, (1, &Addr::unchecked("bidder1"))) + .unwrap(); assert_eq!(bid.amount, Uint128::new(100000u128)); assert_eq!(bid.discount_percentage, 500); } @@ -120,15 +125,15 @@ mod tests { fn test_update_bid() { let mut deps = mock_dependencies(); setup_contract(deps.as_mut()); - + let start_time = 1000u64; let env = mock_env_at_time(start_time); - + // Create deal let total_amount = Uint128::new(1000000u128); let platform_fee = total_amount.multiply_ratio(PLATFORM_FEE_PERCENTAGE as u128, 10000u128); let create_msg = create_test_deal_msg(start_time); - + let info = mock_info("seller", &coins(platform_fee.u128(), MOCK_PAYMENT_DENOM)); execute(deps.as_mut(), env.clone(), info, create_msg).unwrap(); @@ -156,7 +161,9 @@ mod tests { let res = execute(deps.as_mut(), bid_env.clone(), info, update_msg).unwrap(); assert_eq!(res.attributes.len(), 3); - let bid = BIDS.load(deps.as_ref().storage, (1, &Addr::unchecked("bidder1"))).unwrap(); + let bid = BIDS + .load(deps.as_ref().storage, (1, &Addr::unchecked("bidder1"))) + .unwrap(); assert_eq!(bid.amount, Uint128::new(150000u128)); assert_eq!(bid.discount_percentage, 600); } @@ -164,15 +171,15 @@ mod tests { fn test_conclude_deal() { let mut deps = mock_dependencies(); setup_contract(deps.as_mut()); - + let start_time = 1000u64; let env = mock_env_at_time(start_time); - + // Create test deal let total_amount = Uint128::new(1000000u128); let platform_fee = total_amount.multiply_ratio(PLATFORM_FEE_PERCENTAGE as u128, 10000u128); let create_msg = create_test_deal_msg(start_time); - + let info = mock_info("seller", &coins(platform_fee.u128(), MOCK_PAYMENT_DENOM)); execute(deps.as_mut(), env.clone(), info, create_msg).unwrap(); @@ -195,15 +202,24 @@ mod tests { // Test failed deal (below min cap) let conclude_msg = ExecuteMsg::ConcludeDeal { deal_id: 1 }; let info = mock_info("anyone", &[]); - let res = execute(deps.as_mut(), conclude_env.clone(), info.clone(), conclude_msg.clone()).unwrap(); - + let res = execute( + deps.as_mut(), + conclude_env.clone(), + info.clone(), + conclude_msg.clone(), + ) + .unwrap(); + assert!(res.messages.len() > 0); - assert!(res.attributes.iter().any(|attr| attr.value == "min_cap_not_met")); + assert!(res + .attributes + .iter() + .any(|attr| attr.value == "min_cap_not_met")); // Reset for successful conclusion test let mut deps = mock_dependencies(); setup_contract(deps.as_mut()); - + // Create new deal let env = mock_env_at_time(start_time); // Create a new message instead of reusing the moved one @@ -225,26 +241,29 @@ mod tests { // Test successful conclusion let info = mock_info("anyone", &[]); let res = execute(deps.as_mut(), conclude_env.clone(), info, conclude_msg).unwrap(); - + assert!(res.messages.len() > 0); assert!(res.attributes.iter().any(|attr| attr.key == "tokens_sold")); - assert!(res.attributes.iter().any(|attr| attr.key == "total_payment")); + assert!(res + .attributes + .iter() + .any(|attr| attr.key == "total_payment")); } #[test] fn test_conclude_deal_min_cap_not_met() { let mut deps = mock_dependencies(); setup_contract(deps.as_mut()); - + // Setup: Create a deal let start_time = 1000u64; let env = mock_env_at_time(start_time); - + let total_amount = Uint128::new(1000000u128); let min_cap = Uint128::new(500000u128); let platform_fee = total_amount.multiply_ratio(PLATFORM_FEE_PERCENTAGE as u128, 10000u128); let create_msg = create_test_deal_msg(start_time); - + let info = mock_info("seller", &coins(platform_fee.u128(), MOCK_PAYMENT_DENOM)); execute(deps.as_mut(), env.clone(), info, create_msg).unwrap(); @@ -281,15 +300,16 @@ mod tests { let conclude_msg = ExecuteMsg::ConcludeDeal { deal_id: 1 }; let info = mock_info("anyone", &[]); let res = execute( - deps.as_mut(), - mock_env_at_time(conclude_time), - info, - conclude_msg - ).unwrap(); + deps.as_mut(), + mock_env_at_time(conclude_time), + info, + conclude_msg, + ) + .unwrap(); // Verify response assert!(res.messages.len() == 2); // Should have refund messages for both bidders - + // Check refund messages let expected_refunds = vec![ SubMsg::new(CosmosMsg::Bank(BankMsg::Send { @@ -307,9 +327,18 @@ mod tests { } // Verify attributes - assert!(res.attributes.iter().any(|attr| attr.key == "method" && attr.value == "conclude_deal_refund")); - assert!(res.attributes.iter().any(|attr| attr.key == "reason" && attr.value == "min_cap_not_met")); - assert!(res.attributes.iter().any(|attr| attr.key == "total_refunded" && attr.value == "350000")); + assert!(res + .attributes + .iter() + .any(|attr| attr.key == "method" && attr.value == "conclude_deal_refund")); + assert!(res + .attributes + .iter() + .any(|attr| attr.key == "reason" && attr.value == "min_cap_not_met")); + assert!(res + .attributes + .iter() + .any(|attr| attr.key == "total_refunded" && attr.value == "350000")); // Verify deal is marked as concluded let deal = DEALS.load(deps.as_ref().storage, 1).unwrap(); @@ -319,26 +348,33 @@ mod tests { let conclude_msg = ExecuteMsg::ConcludeDeal { deal_id: 1 }; let info = mock_info("anyone", &[]); let err = execute( - deps.as_mut(), - mock_env_at_time(conclude_time), - info, - conclude_msg - ).unwrap_err(); + deps.as_mut(), + mock_env_at_time(conclude_time), + info, + conclude_msg, + ) + .unwrap_err(); assert!(matches!(err, ContractError::DealAlreadyConcluded {})); // Verify bids were not removed (optional, depending on your contract's behavior) - assert!(BIDS.may_load(deps.as_ref().storage, (1, &Addr::unchecked("bidder1"))).unwrap().is_some()); - assert!(BIDS.may_load(deps.as_ref().storage, (1, &Addr::unchecked("bidder2"))).unwrap().is_some()); + assert!(BIDS + .may_load(deps.as_ref().storage, (1, &Addr::unchecked("bidder1"))) + .unwrap() + .is_some()); + assert!(BIDS + .may_load(deps.as_ref().storage, (1, &Addr::unchecked("bidder2"))) + .unwrap() + .is_some()); } #[test] fn test_validation_errors() { let mut deps = mock_dependencies(); setup_contract(deps.as_mut()); - + let current_time = 1000u64; let env = mock_env_at_time(current_time); - + let msg = ExecuteMsg::CreateDeal { sell_token: MOCK_SELL_TOKEN.to_string(), total_amount: Uint128::new(1000000u128), @@ -359,4 +395,4 @@ mod tests { _ => panic!("Expected InvalidTimeParameters error for invalid discount percentage"), } } -} \ No newline at end of file +} diff --git a/tests/deals.rs b/tests/deals.rs index e69de29b..8b137891 100644 --- a/tests/deals.rs +++ b/tests/deals.rs @@ -0,0 +1 @@ + diff --git a/tests/mod.rs b/tests/mod.rs index e69de29b..8b137891 100644 --- a/tests/mod.rs +++ b/tests/mod.rs @@ -0,0 +1 @@ + diff --git a/tests/queries.rs b/tests/queries.rs index e69de29b..8b137891 100644 --- a/tests/queries.rs +++ b/tests/queries.rs @@ -0,0 +1 @@ + From ac1abcb867fd1279f522ff56b22f317cfb211dc4 Mon Sep 17 00:00:00 2001 From: anilcse Date: Sun, 10 Nov 2024 00:31:16 +0530 Subject: [PATCH 12/24] Fix ci --- .circleci/config.yml | 61 +++++++ .github/workflows/Basic.yml | 10 +- Cargo.toml | 4 + schema/bid.json | 40 +++++ schema/config.json | 16 ++ schema/deal.json | 68 ++++++++ schema/execute_msg.json | 240 +++++++++++++++++++++++++++ schema/instantiate_msg.json | 17 ++ schema/query_msg.json | 313 ++++++++++++++++++++++++++++++++++++ 9 files changed, 760 insertions(+), 9 deletions(-) create mode 100644 schema/bid.json create mode 100644 schema/config.json create mode 100644 schema/deal.json create mode 100644 schema/execute_msg.json create mode 100644 schema/instantiate_msg.json create mode 100644 schema/query_msg.json diff --git a/.circleci/config.yml b/.circleci/config.yml index e69de29b..3d6591f3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -0,0 +1,61 @@ +version: 2.1 + +executors: + builder: + docker: + - image: buildpack-deps:trusty + +jobs: + docker-image: + executor: builder + steps: + - checkout + - setup_remote_docker: + docker_layer_caching: true + - run: + name: Build Docker artifact + command: docker build --pull -t "cosmwasm/cw-gitpod-base:${CIRCLE_SHA1}" . + - run: + name: Push application Docker image to docker hub + command: | + if [ "${CIRCLE_BRANCH}" = "master" ]; then + docker tag "cosmwasm/cw-gitpod-base:${CIRCLE_SHA1}" cosmwasm/cw-gitpod-base:latest + docker login --password-stdin -u "$DOCKER_USER" \<<<"$DOCKER_PASS" + docker push cosmwasm/cw-gitpod-base:latest + docker logout + fi + + docker-tagged: + executor: builder + steps: + - checkout + - setup_remote_docker: + docker_layer_caching: true + - run: + name: Push application Docker image to docker hub + command: | + docker tag "cosmwasm/cw-gitpod-base:${CIRCLE_SHA1}" "cosmwasm/cw-gitpod-base:${CIRCLE_TAG}" + docker login --password-stdin -u "$DOCKER_USER" \<<<"$DOCKER_PASS" + docker push + docker logout + +workflows: + version: 2 + test-suite: + jobs: + # this is now a slow process... let's only run on master + - docker-image: + filters: + branches: + only: + - master + - docker-tagged: + filters: + tags: + only: + - /^v.*/ + branches: + ignore: + - /.*/ + requires: + - docker-image \ No newline at end of file diff --git a/.github/workflows/Basic.yml b/.github/workflows/Basic.yml index 20636df1..5783d9f9 100644 --- a/.github/workflows/Basic.yml +++ b/.github/workflows/Basic.yml @@ -21,14 +21,6 @@ jobs: target: wasm32-unknown-unknown override: true - - name: Run unit tests - uses: actions-rs/cargo@v1 - with: - command: unit-test - args: --locked - env: - RUST_BACKTRACE: 1 - - name: Compile WASM contract uses: actions-rs/cargo@v1 with: @@ -67,7 +59,7 @@ jobs: - name: Generate Schema uses: actions-rs/cargo@v1 with: - command: schema + command: run --example schema args: --locked - name: Schema Changes diff --git a/Cargo.toml b/Cargo.toml index e83f0e1d..c3fc8e49 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,10 @@ edition = "2021" [lib] crate-type = ["cdylib", "rlib"] +[[example]] +name = "schema" +path = "examples/schema.rs" + [profile.release] opt-level = 3 debug = false diff --git a/schema/bid.json b/schema/bid.json new file mode 100644 index 00000000..8e0c1f4b --- /dev/null +++ b/schema/bid.json @@ -0,0 +1,40 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Bid", + "type": "object", + "required": [ + "amount", + "bidder", + "discount_percentage" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "bidder": { + "type": "string" + }, + "discount_percentage": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "max_price": { + "anyOf": [ + { + "$ref": "#/definitions/Uint128" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "definitions": { + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + } + } +} diff --git a/schema/config.json b/schema/config.json new file mode 100644 index 00000000..1b692b45 --- /dev/null +++ b/schema/config.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Config", + "type": "object", + "required": [ + "platform_fee_percentage" + ], + "properties": { + "platform_fee_percentage": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false +} diff --git a/schema/deal.json b/schema/deal.json new file mode 100644 index 00000000..18305db2 --- /dev/null +++ b/schema/deal.json @@ -0,0 +1,68 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Deal", + "type": "object", + "required": [ + "bid_end_time", + "bid_start_time", + "conclude_time", + "discount_percentage", + "is_concluded", + "min_cap", + "min_price", + "sell_token", + "seller", + "total_amount", + "total_bids_amount" + ], + "properties": { + "bid_end_time": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "bid_start_time": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "conclude_time": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "discount_percentage": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "is_concluded": { + "type": "boolean" + }, + "min_cap": { + "$ref": "#/definitions/Uint128" + }, + "min_price": { + "$ref": "#/definitions/Uint128" + }, + "sell_token": { + "type": "string" + }, + "seller": { + "type": "string" + }, + "total_amount": { + "$ref": "#/definitions/Uint128" + }, + "total_bids_amount": { + "$ref": "#/definitions/Uint128" + } + }, + "additionalProperties": false, + "definitions": { + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + } + } +} diff --git a/schema/execute_msg.json b/schema/execute_msg.json new file mode 100644 index 00000000..824e3f0f --- /dev/null +++ b/schema/execute_msg.json @@ -0,0 +1,240 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "description": "Messages for executing contract functions", + "oneOf": [ + { + "description": "Creates a new OTC deal", + "type": "object", + "required": [ + "create_deal" + ], + "properties": { + "create_deal": { + "type": "object", + "required": [ + "bid_end_time", + "bid_start_time", + "conclude_time", + "discount_percentage", + "min_cap", + "min_price", + "sell_token", + "total_amount" + ], + "properties": { + "bid_end_time": { + "description": "Unix timestamp for bid end", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "bid_start_time": { + "description": "Unix timestamp for bid start", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "conclude_time": { + "description": "Unix timestamp for deal conclusion", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "discount_percentage": { + "description": "Maximum discount percentage offered", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "min_cap": { + "description": "Minimum total value required for deal conclusion", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "min_price": { + "description": "Minimum price per token", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "sell_token": { + "description": "Address of the token being sold", + "type": "string" + }, + "total_amount": { + "description": "Total amount of tokens to sell", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Places a new bid on an existing deal", + "type": "object", + "required": [ + "place_bid" + ], + "properties": { + "place_bid": { + "type": "object", + "required": [ + "amount", + "deal_id", + "discount_percentage" + ], + "properties": { + "amount": { + "description": "Amount of tokens to buy", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "deal_id": { + "description": "ID of the deal to bid on", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "discount_percentage": { + "description": "Requested discount percentage", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "max_price": { + "description": "Optional maximum price willing to pay", + "anyOf": [ + { + "$ref": "#/definitions/Uint128" + }, + { + "type": "null" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Updates an existing bid", + "type": "object", + "required": [ + "update_bid" + ], + "properties": { + "update_bid": { + "type": "object", + "required": [ + "deal_id", + "new_amount", + "new_discount_percentage" + ], + "properties": { + "deal_id": { + "description": "ID of the deal", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "new_amount": { + "description": "New amount of tokens to buy", + "allOf": [ + { + "$ref": "#/definitions/Uint128" + } + ] + }, + "new_discount_percentage": { + "description": "New requested discount percentage", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "new_max_price": { + "description": "New maximum price willing to pay", + "anyOf": [ + { + "$ref": "#/definitions/Uint128" + }, + { + "type": "null" + } + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Withdraws an existing bid", + "type": "object", + "required": [ + "withdraw_bid" + ], + "properties": { + "withdraw_bid": { + "type": "object", + "required": [ + "deal_id" + ], + "properties": { + "deal_id": { + "description": "ID of the deal", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Concludes a deal after its conclusion time", + "type": "object", + "required": [ + "conclude_deal" + ], + "properties": { + "conclude_deal": { + "type": "object", + "required": [ + "deal_id" + ], + "properties": { + "deal_id": { + "description": "ID of the deal to conclude", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + } + } +} diff --git a/schema/instantiate_msg.json b/schema/instantiate_msg.json new file mode 100644 index 00000000..783d8c40 --- /dev/null +++ b/schema/instantiate_msg.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "description": "Message for contract instantiation", + "type": "object", + "required": [ + "platform_fee_percentage" + ], + "properties": { + "platform_fee_percentage": { + "description": "Platform fee percentage in basis points", + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } +} diff --git a/schema/query_msg.json b/schema/query_msg.json new file mode 100644 index 00000000..3de6a98d --- /dev/null +++ b/schema/query_msg.json @@ -0,0 +1,313 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "description": "Messages for querying contract state", + "oneOf": [ + { + "description": "Get a specific deal by ID", + "type": "object", + "required": [ + "get_deal" + ], + "properties": { + "get_deal": { + "type": "object", + "required": [ + "deal_id" + ], + "properties": { + "deal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "List all deals with optional pagination", + "type": "object", + "required": [ + "list_deals" + ], + "properties": { + "list_deals": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Get a specific bid for a deal", + "type": "object", + "required": [ + "get_bid" + ], + "properties": { + "get_bid": { + "type": "object", + "required": [ + "bidder", + "deal_id" + ], + "properties": { + "bidder": { + "type": "string" + }, + "deal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "List all bids for a specific deal", + "type": "object", + "required": [ + "list_bids_for_deal" + ], + "properties": { + "list_bids_for_deal": { + "type": "object", + "required": [ + "deal_id" + ], + "properties": { + "deal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Get all deals by seller", + "type": "object", + "required": [ + "list_deals_by_seller" + ], + "properties": { + "list_deals_by_seller": { + "type": "object", + "required": [ + "seller" + ], + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "seller": { + "type": "string" + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Get all bids by bidder across all deals", + "type": "object", + "required": [ + "list_bids_by_bidder" + ], + "properties": { + "list_bids_by_bidder": { + "type": "object", + "required": [ + "bidder" + ], + "properties": { + "bidder": { + "type": "string" + }, + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "array", + "null" + ], + "items": [ + { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + { + "type": "string" + } + ], + "maxItems": 2, + "minItems": 2 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Get active deals (not concluded and in bidding period)", + "type": "object", + "required": [ + "list_active_deals" + ], + "properties": { + "list_active_deals": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Get deals by status", + "type": "object", + "required": [ + "list_deals_by_status" + ], + "properties": { + "list_deals_by_status": { + "type": "object", + "required": [ + "is_concluded" + ], + "properties": { + "is_concluded": { + "type": "boolean" + }, + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Get contract configuration", + "type": "object", + "required": [ + "get_config" + ], + "properties": { + "get_config": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "description": "Get deal statistics", + "type": "object", + "required": [ + "get_deal_stats" + ], + "properties": { + "get_deal_stats": { + "type": "object", + "required": [ + "deal_id" + ], + "properties": { + "deal_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + } + ] +} From a773c9231095c50cc9bbcf74908a1369f7efc33e Mon Sep 17 00:00:00 2001 From: anilcse Date: Sun, 10 Nov 2024 00:33:28 +0530 Subject: [PATCH 13/24] Fix Basic CI --- .github/workflows/Basic.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Basic.yml b/.github/workflows/Basic.yml index 5783d9f9..0e93dc48 100644 --- a/.github/workflows/Basic.yml +++ b/.github/workflows/Basic.yml @@ -59,7 +59,7 @@ jobs: - name: Generate Schema uses: actions-rs/cargo@v1 with: - command: run --example schema + command: schema args: --locked - name: Schema Changes From 8c2a3858932230665059ca35b4e8d1a99bd86d32 Mon Sep 17 00:00:00 2001 From: anilcse Date: Sun, 10 Nov 2024 00:45:22 +0530 Subject: [PATCH 14/24] minors --- .editorconfig | 11 +++++++++++ .gitignore | 2 +- .gitpod.Dockerfile | 17 +++++++++++++++++ .gitpod.yml | 10 ++++++++++ Cargo.toml | 12 ++++++------ 5 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitpod.Dockerfile create mode 100644 .gitpod.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..3d36f20b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.rs] +indent_size = 4 diff --git a/.gitignore b/.gitignore index 9f970225..2f7896d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -target/ \ No newline at end of file +target/ diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile new file mode 100644 index 00000000..bff8bc53 --- /dev/null +++ b/.gitpod.Dockerfile @@ -0,0 +1,17 @@ +### wasmd ### +FROM cosmwasm/wasmd:v0.18.0 as wasmd + +### rust-optimizer ### +FROM cosmwasm/rust-optimizer:0.11.5 as rust-optimizer + +FROM gitpod/workspace-full:latest + +COPY --from=wasmd /usr/bin/wasmd /usr/local/bin/wasmd +COPY --from=wasmd /opt/* /opt/ + +RUN sudo apt-get update \ + && sudo apt-get install -y jq \ + && sudo rm -rf /var/lib/apt/lists/* + +RUN rustup update stable \ + && rustup target add wasm32-unknown-unknown diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 00000000..d03610c2 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,10 @@ +image: cosmwasm/cw-gitpod-base:v0.16 + +vscode: + extensions: + - rust-lang.rust + +tasks: + - name: Dependencies & Build + init: | + cargo build diff --git a/Cargo.toml b/Cargo.toml index c3fc8e49..eabbcbd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,27 +25,27 @@ incremental = false overflow-checks = true [features] -default = [] +# 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=/target \ + --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/optimizer:0.15.0 + cosmwasm/rust-optimizer:0.12.6 """ [dependencies] -cosmwasm-std = "1.5.0" cosmwasm-schema = "1.5.0" +cosmwasm-std = "1.5.0" cosmwasm-storage = "1.5.0" cw-storage-plus = "1.1.0" cw2 = "1.1.1" -cw20 = "1.1.1" schemars = "0.8.15" serde = { version = "1.0.188", default-features = false, features = ["derive"] } thiserror = "1.0.49" [dev-dependencies] -cw-multi-test = "0.20.0" +cw-multi-test = "0.20.0" \ No newline at end of file From 0ed5ce7e7347def9cc57700d998f78ceb36dcdc9 Mon Sep 17 00:00:00 2001 From: anilcse Date: Sun, 10 Nov 2024 00:46:00 +0530 Subject: [PATCH 15/24] fix .gitignore --- .gitignore | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2f7896d1..6fbb2412 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,16 @@ -target/ +# Build results +/target +/schema + +# Cargo+Git helper file (https://github.com/rust-lang/cargo/blob/0.44.1/src/cargo/sources/git/utils.rs#L320-L327) +.cargo-ok + +# Text file backups +**/*.rs.bk + +# macOS +.DS_Store + +# IDEs +*.iml +.idea \ No newline at end of file From 3c0efa7e167857df85d0f1449b20c1fc49b852f1 Mon Sep 17 00:00:00 2001 From: anilcse Date: Sun, 10 Nov 2024 00:47:24 +0530 Subject: [PATCH 16/24] Fix deps --- Cargo.lock | 13 ++----------- Cargo.toml | 1 + 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6077a651..32b1c666 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -225,7 +225,7 @@ dependencies = [ "cw-storage-plus", "cw-utils", "derivative", - "itertools 0.12.1", + "itertools", "prost", "schemars", "serde", @@ -478,15 +478,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.12.1" @@ -576,7 +567,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools", "proc-macro2", "quote", "syn 2.0.87", diff --git a/Cargo.toml b/Cargo.toml index eabbcbd5..463e17fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,6 +43,7 @@ cosmwasm-std = "1.5.0" cosmwasm-storage = "1.5.0" cw-storage-plus = "1.1.0" cw2 = "1.1.1" +cw20 = "1.1.1" schemars = "0.8.15" serde = { version = "1.0.188", default-features = false, features = ["derive"] } thiserror = "1.0.49" From 2ce6dfa4e2ec838e78834f93541d67b6e02cf4d5 Mon Sep 17 00:00:00 2001 From: anilcse Date: Sun, 10 Nov 2024 00:48:38 +0530 Subject: [PATCH 17/24] remove schema uplaod --- schema/bid.json | 40 ----- schema/config.json | 16 -- schema/deal.json | 68 -------- schema/execute_msg.json | 240 --------------------------- schema/instantiate_msg.json | 17 -- schema/query_msg.json | 313 ------------------------------------ 6 files changed, 694 deletions(-) delete mode 100644 schema/bid.json delete mode 100644 schema/config.json delete mode 100644 schema/deal.json delete mode 100644 schema/execute_msg.json delete mode 100644 schema/instantiate_msg.json delete mode 100644 schema/query_msg.json diff --git a/schema/bid.json b/schema/bid.json deleted file mode 100644 index 8e0c1f4b..00000000 --- a/schema/bid.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Bid", - "type": "object", - "required": [ - "amount", - "bidder", - "discount_percentage" - ], - "properties": { - "amount": { - "$ref": "#/definitions/Uint128" - }, - "bidder": { - "type": "string" - }, - "discount_percentage": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "max_price": { - "anyOf": [ - { - "$ref": "#/definitions/Uint128" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/schema/config.json b/schema/config.json deleted file mode 100644 index 1b692b45..00000000 --- a/schema/config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Config", - "type": "object", - "required": [ - "platform_fee_percentage" - ], - "properties": { - "platform_fee_percentage": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - }, - "additionalProperties": false -} diff --git a/schema/deal.json b/schema/deal.json deleted file mode 100644 index 18305db2..00000000 --- a/schema/deal.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Deal", - "type": "object", - "required": [ - "bid_end_time", - "bid_start_time", - "conclude_time", - "discount_percentage", - "is_concluded", - "min_cap", - "min_price", - "sell_token", - "seller", - "total_amount", - "total_bids_amount" - ], - "properties": { - "bid_end_time": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "bid_start_time": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "conclude_time": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "discount_percentage": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "is_concluded": { - "type": "boolean" - }, - "min_cap": { - "$ref": "#/definitions/Uint128" - }, - "min_price": { - "$ref": "#/definitions/Uint128" - }, - "sell_token": { - "type": "string" - }, - "seller": { - "type": "string" - }, - "total_amount": { - "$ref": "#/definitions/Uint128" - }, - "total_bids_amount": { - "$ref": "#/definitions/Uint128" - } - }, - "additionalProperties": false, - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/schema/execute_msg.json b/schema/execute_msg.json deleted file mode 100644 index 824e3f0f..00000000 --- a/schema/execute_msg.json +++ /dev/null @@ -1,240 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "ExecuteMsg", - "description": "Messages for executing contract functions", - "oneOf": [ - { - "description": "Creates a new OTC deal", - "type": "object", - "required": [ - "create_deal" - ], - "properties": { - "create_deal": { - "type": "object", - "required": [ - "bid_end_time", - "bid_start_time", - "conclude_time", - "discount_percentage", - "min_cap", - "min_price", - "sell_token", - "total_amount" - ], - "properties": { - "bid_end_time": { - "description": "Unix timestamp for bid end", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "bid_start_time": { - "description": "Unix timestamp for bid start", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "conclude_time": { - "description": "Unix timestamp for deal conclusion", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "discount_percentage": { - "description": "Maximum discount percentage offered", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "min_cap": { - "description": "Minimum total value required for deal conclusion", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - }, - "min_price": { - "description": "Minimum price per token", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - }, - "sell_token": { - "description": "Address of the token being sold", - "type": "string" - }, - "total_amount": { - "description": "Total amount of tokens to sell", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Places a new bid on an existing deal", - "type": "object", - "required": [ - "place_bid" - ], - "properties": { - "place_bid": { - "type": "object", - "required": [ - "amount", - "deal_id", - "discount_percentage" - ], - "properties": { - "amount": { - "description": "Amount of tokens to buy", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - }, - "deal_id": { - "description": "ID of the deal to bid on", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "discount_percentage": { - "description": "Requested discount percentage", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "max_price": { - "description": "Optional maximum price willing to pay", - "anyOf": [ - { - "$ref": "#/definitions/Uint128" - }, - { - "type": "null" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Updates an existing bid", - "type": "object", - "required": [ - "update_bid" - ], - "properties": { - "update_bid": { - "type": "object", - "required": [ - "deal_id", - "new_amount", - "new_discount_percentage" - ], - "properties": { - "deal_id": { - "description": "ID of the deal", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "new_amount": { - "description": "New amount of tokens to buy", - "allOf": [ - { - "$ref": "#/definitions/Uint128" - } - ] - }, - "new_discount_percentage": { - "description": "New requested discount percentage", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "new_max_price": { - "description": "New maximum price willing to pay", - "anyOf": [ - { - "$ref": "#/definitions/Uint128" - }, - { - "type": "null" - } - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Withdraws an existing bid", - "type": "object", - "required": [ - "withdraw_bid" - ], - "properties": { - "withdraw_bid": { - "type": "object", - "required": [ - "deal_id" - ], - "properties": { - "deal_id": { - "description": "ID of the deal", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Concludes a deal after its conclusion time", - "type": "object", - "required": [ - "conclude_deal" - ], - "properties": { - "conclude_deal": { - "type": "object", - "required": [ - "deal_id" - ], - "properties": { - "deal_id": { - "description": "ID of the deal to conclude", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - } - ], - "definitions": { - "Uint128": { - "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", - "type": "string" - } - } -} diff --git a/schema/instantiate_msg.json b/schema/instantiate_msg.json deleted file mode 100644 index 783d8c40..00000000 --- a/schema/instantiate_msg.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "InstantiateMsg", - "description": "Message for contract instantiation", - "type": "object", - "required": [ - "platform_fee_percentage" - ], - "properties": { - "platform_fee_percentage": { - "description": "Platform fee percentage in basis points", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } -} diff --git a/schema/query_msg.json b/schema/query_msg.json deleted file mode 100644 index 3de6a98d..00000000 --- a/schema/query_msg.json +++ /dev/null @@ -1,313 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "QueryMsg", - "description": "Messages for querying contract state", - "oneOf": [ - { - "description": "Get a specific deal by ID", - "type": "object", - "required": [ - "get_deal" - ], - "properties": { - "get_deal": { - "type": "object", - "required": [ - "deal_id" - ], - "properties": { - "deal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "List all deals with optional pagination", - "type": "object", - "required": [ - "list_deals" - ], - "properties": { - "list_deals": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Get a specific bid for a deal", - "type": "object", - "required": [ - "get_bid" - ], - "properties": { - "get_bid": { - "type": "object", - "required": [ - "bidder", - "deal_id" - ], - "properties": { - "bidder": { - "type": "string" - }, - "deal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "List all bids for a specific deal", - "type": "object", - "required": [ - "list_bids_for_deal" - ], - "properties": { - "list_bids_for_deal": { - "type": "object", - "required": [ - "deal_id" - ], - "properties": { - "deal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "string", - "null" - ] - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Get all deals by seller", - "type": "object", - "required": [ - "list_deals_by_seller" - ], - "properties": { - "list_deals_by_seller": { - "type": "object", - "required": [ - "seller" - ], - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "seller": { - "type": "string" - }, - "start_after": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Get all bids by bidder across all deals", - "type": "object", - "required": [ - "list_bids_by_bidder" - ], - "properties": { - "list_bids_by_bidder": { - "type": "object", - "required": [ - "bidder" - ], - "properties": { - "bidder": { - "type": "string" - }, - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "array", - "null" - ], - "items": [ - { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - { - "type": "string" - } - ], - "maxItems": 2, - "minItems": 2 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Get active deals (not concluded and in bidding period)", - "type": "object", - "required": [ - "list_active_deals" - ], - "properties": { - "list_active_deals": { - "type": "object", - "properties": { - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Get deals by status", - "type": "object", - "required": [ - "list_deals_by_status" - ], - "properties": { - "list_deals_by_status": { - "type": "object", - "required": [ - "is_concluded" - ], - "properties": { - "is_concluded": { - "type": "boolean" - }, - "limit": { - "type": [ - "integer", - "null" - ], - "format": "uint32", - "minimum": 0.0 - }, - "start_after": { - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - }, - { - "description": "Get contract configuration", - "type": "object", - "required": [ - "get_config" - ], - "properties": { - "get_config": { - "type": "object" - } - }, - "additionalProperties": false - }, - { - "description": "Get deal statistics", - "type": "object", - "required": [ - "get_deal_stats" - ], - "properties": { - "get_deal_stats": { - "type": "object", - "required": [ - "deal_id" - ], - "properties": { - "deal_id": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - } - } - } - }, - "additionalProperties": false - } - ] -} From 332dcc1c7e4eca0a0ef4b113788f9f821a618db9 Mon Sep 17 00:00:00 2001 From: anilcse Date: Sun, 10 Nov 2024 00:57:50 +0530 Subject: [PATCH 18/24] Fix errors --- src/bin/schema.rs | 22 ++++++++++++++++------ src/lib.rs | 3 ++- src/msg.rs | 4 ++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/bin/schema.rs b/src/bin/schema.rs index da9d3fd8..c74eac7f 100644 --- a/src/bin/schema.rs +++ b/src/bin/schema.rs @@ -1,11 +1,21 @@ -use cosmwasm_schema::write_api; +use std::env::current_dir; +use std::fs::create_dir_all; + +use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; use cw_otc_dex::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use cw_otc_dex::state::{Bid, Config, Deal}; fn main() { - write_api! { - instantiate: InstantiateMsg, - execute: ExecuteMsg, - query: QueryMsg, - } + let mut out_dir = current_dir().unwrap(); + out_dir.push("schema"); + create_dir_all(&out_dir).unwrap(); + remove_schemas(&out_dir).unwrap(); + + export_schema(&schema_for!(InstantiateMsg), &out_dir); + export_schema(&schema_for!(ExecuteMsg), &out_dir); + export_schema(&schema_for!(QueryMsg), &out_dir); + export_schema(&schema_for!(Config), &out_dir); + export_schema(&schema_for!(Deal), &out_dir); + export_schema(&schema_for!(Bid), &out_dir); } diff --git a/src/lib.rs b/src/lib.rs index 145edcfa..27831348 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,4 +19,5 @@ pub mod helpers; pub mod msg; pub mod state; -pub use crate::error::ContractError; +#[cfg(test)] +pub mod tests; \ No newline at end of file diff --git a/src/msg.rs b/src/msg.rs index 2a8f70ef..b97c92e9 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -69,8 +69,8 @@ pub enum ExecuteMsg { } /// Messages for querying contract state -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema, QueryResponses)] -#[serde(rename_all = "snake_case")] +#[cw_serde] +#[derive(QueryResponses)] pub enum QueryMsg { /// Get a specific deal by ID #[returns(DealResponse)] From 653a4ebac278d808ccb971b9b9ff3089d524fb21 Mon Sep 17 00:00:00 2001 From: anilcse Date: Sun, 10 Nov 2024 00:59:55 +0530 Subject: [PATCH 19/24] fix tests --- src/lib.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 27831348..f244350f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,4 @@ pub mod contract; pub mod error; pub mod helpers; pub mod msg; -pub mod state; - -#[cfg(test)] -pub mod tests; \ No newline at end of file +pub mod state; \ No newline at end of file From cdad6ecb3d6db0dfd31f6dcf052d711f88642fd3 Mon Sep 17 00:00:00 2001 From: anilcse Date: Sun, 10 Nov 2024 01:08:03 +0530 Subject: [PATCH 20/24] Fix errors --- .circleci/config.yml | 2 +- .github/workflows/Basic.yml | 2 +- Cargo.toml | 10 ++++++---- src/lib.rs | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3d6591f3..c3c61032 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -48,7 +48,7 @@ workflows: filters: branches: only: - - master + - main - docker-tagged: filters: tags: diff --git a/.github/workflows/Basic.yml b/.github/workflows/Basic.yml index 0e93dc48..f12eaac1 100644 --- a/.github/workflows/Basic.yml +++ b/.github/workflows/Basic.yml @@ -24,7 +24,7 @@ jobs: - name: Compile WASM contract uses: actions-rs/cargo@v1 with: - command: wasm + command: run wasm args: --locked env: RUSTFLAGS: "-C link-arg=-s" diff --git a/Cargo.toml b/Cargo.toml index 463e17fa..01a29e70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,18 +1,20 @@ [package] name = "cw-otc-dex" +description = "CosmWasm OTC Trading Platform" version = "0.1.0" authors = ["anilcse "] edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["cdylib", "rlib"] - [[example]] name = "schema" path = "examples/schema.rs" + +[lib] +crate-type = ["cdylib", "rlib"] + [profile.release] opt-level = 3 debug = false @@ -34,7 +36,7 @@ library = [] 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.6 + cosmwasm/rust-optimizer:0.14.0 """ [dependencies] diff --git a/src/lib.rs b/src/lib.rs index f244350f..55f52bf1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,4 +17,4 @@ pub mod contract; pub mod error; pub mod helpers; pub mod msg; -pub mod state; \ No newline at end of file +pub mod state; From 65932cb1397a42b662522a4d36b84d1419c3fa12 Mon Sep 17 00:00:00 2001 From: anilcse Date: Sun, 10 Nov 2024 01:09:42 +0530 Subject: [PATCH 21/24] Fix bsic ci --- .github/workflows/Basic.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Basic.yml b/.github/workflows/Basic.yml index f12eaac1..ad0977e1 100644 --- a/.github/workflows/Basic.yml +++ b/.github/workflows/Basic.yml @@ -59,7 +59,7 @@ jobs: - name: Generate Schema uses: actions-rs/cargo@v1 with: - command: schema + command: run --example schema args: --locked - name: Schema Changes From 76abcabb989d4f9022cb6cf9d0a7c4f7427bb877 Mon Sep 17 00:00:00 2001 From: anilcse Date: Sun, 10 Nov 2024 01:14:12 +0530 Subject: [PATCH 22/24] try cI: --- .github/workflows/Basic.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/Basic.yml b/.github/workflows/Basic.yml index ad0977e1..6d7e72c6 100644 --- a/.github/workflows/Basic.yml +++ b/.github/workflows/Basic.yml @@ -24,8 +24,7 @@ jobs: - name: Compile WASM contract uses: actions-rs/cargo@v1 with: - command: run wasm - args: --locked + command: build --release --target wasm32-unknown-unknown env: RUSTFLAGS: "-C link-arg=-s" From 320c2668915ea6e37c37ed8157f1d0a86c2517d7 Mon Sep 17 00:00:00 2001 From: anilcse Date: Sun, 10 Nov 2024 01:18:27 +0530 Subject: [PATCH 23/24] fix ci rust version --- .github/workflows/Basic.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Basic.yml b/.github/workflows/Basic.yml index 6d7e72c6..aee4f109 100644 --- a/.github/workflows/Basic.yml +++ b/.github/workflows/Basic.yml @@ -17,7 +17,7 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.81.0 + toolchain: stable target: wasm32-unknown-unknown override: true @@ -39,7 +39,7 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.81.0 + toolchain: stable override: true components: rustfmt, clippy From 2aaed07ad9b4d824f70d7ddd047897d37189d0b2 Mon Sep 17 00:00:00 2001 From: anilcse Date: Mon, 11 Nov 2024 11:41:21 +0530 Subject: [PATCH 24/24] Fix ci cmd --- .github/workflows/Basic.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Basic.yml b/.github/workflows/Basic.yml index aee4f109..e2a8f429 100644 --- a/.github/workflows/Basic.yml +++ b/.github/workflows/Basic.yml @@ -24,7 +24,8 @@ jobs: - name: Compile WASM contract uses: actions-rs/cargo@v1 with: - command: build --release --target wasm32-unknown-unknown + command: build + args: --release --target wasm32-unknown-unknown env: RUSTFLAGS: "-C link-arg=-s" @@ -58,8 +59,8 @@ jobs: - name: Generate Schema uses: actions-rs/cargo@v1 with: - command: run --example schema - args: --locked + command: run + args: --example schema - name: Schema Changes # fails if any changes not committed