-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more APIs and use the model from the services repository
- Loading branch information
Showing
15 changed files
with
1,853 additions
and
242 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
[package] | ||
name = "cowprotocol-api-rs" | ||
name = "cowprotocol-client" | ||
version = "0.1.0" | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
license = "MIT OR Apache-2.0" | ||
|
||
[dependencies] | ||
alloy-primitives = { version = "0.8.9", features = ["serde"] } | ||
reqwest = { version = "0.12.8", default-features = false, features = ["json", "rustls-tls"] } | ||
serde = { version = "1.0.213", features = ["derive"] } | ||
serde_json = { version = "1.0.132" } | ||
thiserror = "1.0.65" | ||
tokio = { version = "1.41.0", features = ["macros", "rt", "rt-multi-thread"] } | ||
alloy-primitives = { version = "0.8.19", features = ["serde"] } | ||
ethereum-types = "0.14.1" | ||
reqwest = { version = "0.12.12", default-features = false, features = ["json", "rustls-tls"] } | ||
serde = { version = "1.0.217", features = ["derive"] } | ||
serde_json = { version = "1.0.137" } | ||
thiserror = "2.0.11" | ||
|
||
cowprotocol-solvers-dto-alloy = {git = "https://github.com/cakevm/cowprotocol-solvers-dto-alloy", rev = "298feba"} | ||
services-model = { git = "https://github.com/cowprotocol/services", rev = "01f35f8", package = "model"} | ||
|
||
[dev-dependencies] | ||
tokio = { version = "1.43.0", features = ["macros", "rt", "rt-multi-thread"] } | ||
eyre = "0.6.12" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2025 cakevm | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
# CoW Protocol REST API client | ||
|
||
This crate provides an async client for interacting with the [CoW Protocol REST API](https://api.cow.fi/docs/#/). | ||
This crate provides an async client for interacting with the [CoW Protocol REST API](https://api.cow.fi/docs/#/). The benefit is to use typed models as they have been intended by the [Cow Protocol service](https://github.com/cowprotocol/services). | ||
|
||
# Usage | ||
## Status | ||
The crate is currently just a showcase and not for productive use. Generated clients can be difficult to use when dealing with byte types like U256, Address, etc. This client directly uses some models from the [services](https://github.com/cowprotocol/services) repository, ensuring compatibility with the API. The long-term goal is to migrate everything to use [Alloy](https://github.com/alloy-rs/alloy) types or have some converter. This crate currently supports a limited set of API endpoints. If you need additional endpoints, please open an issue or a PR. | ||
|
||
Current concept for types: | ||
- The functions from this client accepting [alloy_primitives](https://docs.rs/alloy-primitives/latest/alloy_primitives/) | ||
- The return types can be models from [services](https://github.com/cowprotocol/services) with [ethereum-types](https://crates.io/crates/ethereum-types) or like Auction from this crate. | ||
|
||
Future concept for types: | ||
- Alloy for all types | ||
|
||
## Usage | ||
See the [examples](./examples) directory for usage examples. | ||
|
||
# Features | ||
Currently only supports the `GET /auction` and `GET /solver_competition/latest` endpoint. | ||
## Acknowledgements | ||
Many thanks to the [CoW Protocol](https://github.com/cowprotocol) team for making their service open source. This project uses the models from the [services](https://github.com/cowprotocol/services) repository. | ||
|
||
# License | ||
This project is licensed under the [Apache 2.0](./LICENSE). | ||
## License | ||
This project is dual licensed under [Apache 2.0](./LICENSE-APACHE) or [MIT](./LICENSE-MIT). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use alloy_primitives::FixedBytes; | ||
use cowprotocol_client::client::{OrderBookApiClient, OrderBookApiConfig}; | ||
use cowprotocol_solvers_dto_alloy::order_uid::OrderUid; | ||
use std::str::FromStr; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let client = OrderBookApiClient::new(OrderBookApiConfig::default()); | ||
let order_uid = OrderUid( | ||
FixedBytes::<56>::from_str( | ||
"0x1e1e4b3c27038cfe9b63c7c662ece8e722667f0b4316d502ee29dad6c49392c0891a539d008f69e62f22902877cce54a58644cae67875b9f", | ||
) | ||
.unwrap(), | ||
); | ||
match client.get_order(&order_uid).await { | ||
Ok(order) => { | ||
println!("{:?}", order); | ||
} | ||
Err(e) => { | ||
println!("{:?}", e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use alloy_primitives::TxHash; | ||
use cowprotocol_client::client::{OrderBookApiClient, OrderBookApiConfig}; | ||
use eyre::Result; | ||
use std::str::FromStr; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let client = OrderBookApiClient::new(OrderBookApiConfig::default()); | ||
let tx_hash = TxHash::from_str("0xd0405ae34a75f394ec20493988674ac8912787edbfdcd673b59239bd46ac1684")?; | ||
let solver_competition_latest = client.solver_competition_by_tx_hash(&tx_hash).await?; | ||
println!("{:#?}", solver_competition_latest); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters