Skip to content

Commit

Permalink
ci(infrastructure): codecov, crates.io
Browse files Browse the repository at this point in the history
  • Loading branch information
phnaharris committed Nov 5, 2023
1 parent 71ca304 commit 0fe2b33
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 9 deletions.
21 changes: 21 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ref: https://docs.codecov.com/docs/codecovyml-reference
coverage:
# Hold ourselves to a high bar
range: 85..100
round: down
precision: 1
status:
# ref: https://docs.codecov.com/docs/commit-status
project:
default:
# Avoid false negatives
threshold: 1%

# Test files aren't important for coverage
ignore:
- "tests"

# Make comments less noisy
comment:
layout: "files"
require_changes: true
12 changes: 12 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
on:
push:
branches: [main]
name: main
jobs:
codecov:
runs-on: ubuntu-latest
steps:
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ name = "symbiosis-api"
version = "0.1.0"
edition = "2021"
authors = ["phnaharris <phnanh.harris@gmail.com>"]
license = "GPL-3.0-or-later"
description = "A high-level binding for Symbiosis API, written in Rust."
repository = "https://github.com/phnaharris/symbiosis-api-rs.git"
keywords = ["symbiosis", "api", "swap", "bridge", "web3"]
categories = ["api-bindings", "development-tools"]
readme = "README.md"

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

[dependencies]
anyhow = "1.0.75"
ethers-core = { git = "https://github.com/gakonst/ethers-rs", features = [
"legacy",
] }
ethers-core = { version = "2.0.10", features = ["legacy"] }
reqwest = { version = "0.11.22", features = ["json"] }
serde = "1.0.189"
serde_json = "1.0.107"
Expand Down
66 changes: 60 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,64 @@
# Symbiosis API Binding Written in Rust (currently support api-v2)
# symbiosis-api

You can find the Swagger of Symbiosis API at
[this URL](https://api-v2.symbiosis.finance/crosschain/docs/).
[![Crates.io](https://img.shields.io/crates/v/symbiosis-api.svg)](https://crates.io/crates/symbiosis-api)
[![Documentation](https://docs.rs/symbiosis-api/badge.svg)](https://docs.rs/symbiosis-api/)
[![Codecov](https://codecov.io/github/phnaharris/symbiosis-api/coverage.svg?branch=main)](https://codecov.io/gh/phnaharris/symbiosis-api)
[![Build Status](https://github.com/phnaharris/symbiosis-api-rs/actions/workflows/main.yml/badge.svg)](https://github.com/phnaharris/symbiosis-api-rs/actions/workflows/main.yml)

# Installation
A high-level binding for Symbiosis API, written in Rust.

```bash
cargo add symbiosis-api
Symbiosis API allows you to integrate the functionalities of the Symbiosis Protocol into your
application, platform or protocol.

By integrating the Symbiosis API, you can quickly and effectively enable decentralized
cross-chain swaps and cross-chain liquidity management for your users.

This crate uses the [reqwest] crate for a convenient, higher-level HTTP Client, for request and
response, to and from Symbiosis, and [serde] for serialize and deserialize from and to
appropriate data format.

## Examples

Let's start out swapping from ETH on Ethereum to MNT on Mantle network.

```rust
use symbiosis_api::{
types::{
request::{Request, SwappingExactInBody},
response::Response,
Token, TokenAmount,
},
SymbiosisApi,
};
use ethers_core::types::{Address, Chain, U256};

#[tokio::main]
async fn main() -> Result<Response, anyhow::Error> {
// initialize the `SymbiosisApi` client
let symbiosis = SymbiosisApi::builder().with_partner_id("your_partner_id").build();

// preparing the request body
let address: Address = "0x690b9a9e9aa1c9db991c7721a92d351db4fac990".parse()?;
let eth_mainnet = Token::builder().build();
let eth_mainnet_amount = TokenAmount::new(eth_mainnet, U256::from(1000000000000000u64)); // 0.001 ETH
let mnt_mantle = Token::builder().chain_id(Chain::Mantle).build();
let swap_exact_in = SwappingExactInBody::builder()
.token_amount_in(eth_mainnet_amount)
.token_out(mnt_mantle)
.from(address)
.to(address)
.build();
let req = Request::SwappingExactIn(swap_exact_in);

// send the request and receive the response back
let resp = symbiosis.post_v1_swapping_exact_in(req)?.send().await?;

return anyhow::Ok(resp);
}
```

For more examples, take a look at the `examples/` directory.

Current version: 0.1.0

License: GPL-3.0-or-later
12 changes: 12 additions & 0 deletions README.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# {{crate}}

[![Crates.io](https://img.shields.io/crates/v/symbiosis-api.svg)](https://crates.io/crates/symbiosis-api)
[![Documentation](https://docs.rs/symbiosis-api/badge.svg)](https://docs.rs/symbiosis-api/)
[![Codecov](https://codecov.io/github/phnaharris/symbiosis-api/coverage.svg?branch=main)](https://codecov.io/gh/phnaharris/symbiosis-api)
[![Build Status](https://github.com/phnaharris/symbiosis-api-rs/actions/workflows/main.yml/badge.svg)](https://github.com/phnaharris/symbiosis-api-rs/actions/workflows/main.yml)

{{readme}}

Current version: {{version}}

License: {{license}}

0 comments on commit 0fe2b33

Please sign in to comment.