Skip to content
This repository was archived by the owner on Sep 26, 2020. It is now read-only.

Commit ffa6cf4

Browse files
Kristjan Kosicspkjp
andauthored
release: 2.0.0 (#66)
* chore: initial migration to rust2018 edition * test: initial test to green, rust 2018 adjustment * chore: remove fixes (v2) works with this * tests(node): refactor node endpoint tests for v26 * ref: introduce common.rs * ref(test): further split models into struct files * test: block transactions test * fix: add request error heuristic * ref: split models in files * fix: uses and tests * test: blocks test new fixtures running * ref: organized asserts and mockito * test(delegates): updated models and fixtures * tests: peer tests operational for v2.6 * tests: transaction test fixtures, adjusting to v2.6 * test: votes updates of fixtures * test(wallet): test_all operational * tests: wallet fixtures and tests * style: cargo fmt run * ref: style * style: fmt * chore: clippy lint * style: clippy doctest * ref: better naming of custom deser methog * ref: remove redundand .clone() * feat(node): implement `node/fees` endpoint * style: clippy lint fixes * chore: changelog info * fix: remove duplicate struct * ref: cleanup tests * ref: add meta tests for blocks * fix: remove redundand clone() * test: implement locks and new fixtures * test: implement wallets/search * test: unconfirmed transactions `transactions/unconfirmed/**` * chore: handle status error response from transaction/post * feat: adjust to different fee api return changes * style: format json fixtures * test: asset support and new fixtures added * style: clippy happy * test: bridgechain update and resignation assets * test: fee statistics all values * ref: split large assert files into separate ones * ref(tests): reduced fixture data size * feat: aip103 - initial magistrate implementation * feat: remove POST payload as Option. Changed post method * feat(test): added configurable test option for live peer test * docs: typo in comments * fix: locks search endpoint * style: clippy * test: added random_seed for manual live test option * test: added node test with optional live peer (serdes) * fix(test): handle live peer test no network locks scenario * style: clippy * feat: updated to latest reqwest and move to async/await as from rust 1.39 * ref: removed api prefixes from client (to handle pagination with res.meta) * ref: made generic methods public -> for pagination calls * ref: revert api prefix commit: 28f7bc7 * test: updated business fixtures * test: businesses endpoints * test: bridgechains * test: locks * test: wallets adjusting to new changes with attributes * test: fixed voters mock * chore: removing deprecated trait impl * chore: change log info * docs: changelog info added Co-authored-by: supaiku <1311798+supaiku0@users.noreply.github.com>
1 parent 2667f17 commit ffa6cf4

113 files changed

Lines changed: 23150 additions & 3802 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/target
22
**/*.rs.bk
33
Cargo.lock
4+
/.idea
5+

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## Unreleased
8+
## 2.0.0 - 2020-02-11
9+
10+
### Added
11+
- Async implementation of API calls
12+
- Core 2.6 model update
13+
- New 2.6 endpoints support
14+
- Full mock support
15+
16+
### Changed
17+
- Updated dependencies
18+
- Refactor/Restructure of internals
919

1020
## 1.0.0 - 2018-12-19
1121
- Initial Release

Cargo.toml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
[package]
22
name = "arkecosystem-client"
3-
version = "1.0.0"
4-
authors = ["Joshua Noack <joshua@ark.io>, Juan A. Martín <juan@ark.io>"]
3+
version = "2.0.0"
4+
authors = ["Joshua Noack <joshua@ark.io>, Kristjan Kosic <kristjan@ark.io>"]
55
description = "A simple Rust API client for the ARK Blockchain."
66
license = "MIT"
7+
edition = "2018"
78

89
[lib]
910
name = "arkecosystem_client"
1011
path = "src/lib.rs"
1112
doctest = false
1213

1314
[dependencies]
14-
reqwest = "0.9.22"
15-
serde = "1.0.102"
16-
serde_derive = "1.0.102"
17-
serde_json = "1.0.41"
15+
reqwest = { version = "0.10", features = ["json"] }
16+
tokio = { version = "0.2", features = ["full"] }
17+
serde = { version = "1.0", features = ["derive"] }
18+
serde_json = "1.0"
19+
serde_derive = "1.0"
20+
rand = "*"
1821

1922
[dev-dependencies]
20-
mockito = "0.21.0"
21-
assert_float_eq = "1.1.3"
23+
mockito = "0.22.0"
24+
25+
[features]
26+
network_test = []

src/api/blocks.rs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
use http::client::Client;
1+
use crate::http::client::Client;
22
use std::borrow::Borrow;
33

4-
use api::models::{Block, Transaction};
5-
use api::Result;
4+
use crate::api::models::block::Block;
5+
use crate::api::models::transaction::Transaction;
6+
7+
use crate::api::Result;
68

79
pub struct Blocks {
810
client: Client,
@@ -13,48 +15,55 @@ impl Blocks {
1315
Blocks { client }
1416
}
1517

16-
pub fn all(&self) -> Result<Vec<Block>> {
17-
self.all_params(Vec::<(String, String)>::new())
18+
pub async fn all(&mut self) -> Result<Vec<Block>> {
19+
self.all_params(Vec::<(String, String)>::new()).await
1820
}
1921

20-
pub fn all_params<I, K, V>(&self, parameters: I) -> Result<Vec<Block>>
22+
pub async fn all_params<I, K, V>(&mut self, parameters: I) -> Result<Vec<Block>>
2123
where
2224
I: IntoIterator,
2325
I::Item: Borrow<(K, V)>,
2426
K: AsRef<str>,
2527
V: AsRef<str>,
2628
{
27-
self.client.get_with_params("blocks", parameters)
29+
self.client.get_with_params("blocks", parameters).await
2830
}
2931

30-
pub fn show(&self, id: &str) -> Result<Block> {
32+
pub async fn show(&mut self, id: &str) -> Result<Block> {
3133
let endpoint = format!("blocks/{}", id);
3234

33-
self.client.get(&endpoint)
35+
self.client.get(&endpoint).await
3436
}
3537

36-
pub fn transactions(&self, id: &str) -> Result<Vec<Transaction>> {
38+
pub async fn transactions(&mut self, id: &str) -> Result<Vec<Transaction>> {
3739
self.transactions_params(id, Vec::<(String, String)>::new())
40+
.await
3841
}
3942

40-
pub fn transactions_params<I, K, V>(&self, id: &str, parameters: I) -> Result<Vec<Transaction>>
43+
pub async fn transactions_params<I, K, V>(
44+
&mut self,
45+
id: &str,
46+
parameters: I,
47+
) -> Result<Vec<Transaction>>
4148
where
4249
I: IntoIterator,
4350
I::Item: Borrow<(K, V)>,
4451
K: AsRef<str>,
4552
V: AsRef<str>,
4653
{
4754
let endpoint = format!("blocks/{}/transactions", id);
48-
self.client.get_with_params(&endpoint, parameters)
55+
self.client.get_with_params(&endpoint, parameters).await
4956
}
5057

51-
pub fn search<I, K, V>(&self, parameters: I) -> Result<Vec<Block>>
58+
pub async fn search<I, K, V>(&mut self, parameters: I) -> Result<Vec<Block>>
5259
where
5360
I: IntoIterator,
5461
I::Item: Borrow<(K, V)>,
5562
K: AsRef<str>,
5663
V: AsRef<str>,
5764
{
58-
self.client.get_with_params("blocks/search", parameters)
65+
self.client
66+
.get_with_params("blocks/search", parameters)
67+
.await
5968
}
6069
}

src/api/bridgechains.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
use crate::api::models::bridgechain::Bridgechain;
2+
use crate::api::Result;
3+
use crate::http::client::Client;
4+
use std::borrow::Borrow;
5+
use std::collections::HashMap;
6+
7+
pub struct Bridgechains {
8+
client: Client,
9+
}
10+
11+
impl Bridgechains {
12+
pub fn new(client: Client) -> Bridgechains {
13+
Bridgechains { client }
14+
}
15+
16+
pub async fn all(&mut self) -> Result<Vec<Bridgechain>> {
17+
self.all_params(Vec::<(String, String)>::new()).await
18+
}
19+
20+
pub async fn all_params<I, K, V>(&mut self, parameters: I) -> Result<Vec<Bridgechain>>
21+
where
22+
I: IntoIterator,
23+
I::Item: Borrow<(K, V)>,
24+
K: AsRef<str>,
25+
V: AsRef<str>,
26+
{
27+
self.client
28+
.get_with_params("bridgechains", parameters)
29+
.await
30+
}
31+
32+
pub async fn show(&mut self, genesis_hash: &str) -> Result<Bridgechain> {
33+
let endpoint = format!("bridgechains/{}", genesis_hash);
34+
self.client.get(&endpoint).await
35+
}
36+
37+
pub async fn search<I, K, V>(
38+
&mut self,
39+
payload: HashMap<&str, &str>,
40+
parameters: I,
41+
) -> Result<Vec<Bridgechain>>
42+
where
43+
I: IntoIterator,
44+
I::Item: Borrow<(K, V)>,
45+
K: AsRef<str>,
46+
V: AsRef<str>,
47+
{
48+
self.client
49+
.post_with_params("bridgechains/search", payload, parameters)
50+
.await
51+
}
52+
}

src/api/businesses.rs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
use crate::api::models::bridgechain::Bridgechain;
2+
use crate::api::models::business::Business;
3+
use crate::api::Result;
4+
use crate::http::client::Client;
5+
use std::borrow::Borrow;
6+
use std::collections::HashMap;
7+
8+
pub struct Businesses {
9+
client: Client,
10+
}
11+
12+
impl Businesses {
13+
pub fn new(client: Client) -> Businesses {
14+
Businesses { client }
15+
}
16+
17+
pub async fn all(&mut self) -> Result<Vec<Business>> {
18+
self.all_params(Vec::<(String, String)>::new()).await
19+
}
20+
21+
pub async fn all_params<I, K, V>(&mut self, parameters: I) -> Result<Vec<Business>>
22+
where
23+
I: IntoIterator,
24+
I::Item: Borrow<(K, V)>,
25+
K: AsRef<str>,
26+
V: AsRef<str>,
27+
{
28+
self.client.get_with_params("businesses", parameters).await
29+
}
30+
31+
pub async fn show(&mut self, ip_addr: &str) -> Result<Business> {
32+
let endpoint = format!("businesses/{}", ip_addr);
33+
self.client.get(&endpoint).await
34+
}
35+
36+
pub async fn search<I, K, V>(
37+
&mut self,
38+
payload: HashMap<&str, &str>,
39+
parameters: I,
40+
) -> Result<Vec<Business>>
41+
where
42+
I: IntoIterator,
43+
I::Item: Borrow<(K, V)>,
44+
K: AsRef<str>,
45+
V: AsRef<str>,
46+
{
47+
self.client
48+
.post_with_params("businesses/search", payload, parameters)
49+
.await
50+
}
51+
52+
pub async fn bridgechains(&mut self, id: &str) -> Result<Vec<Bridgechain>> {
53+
self.bridgechains_params(id, Vec::<(String, String)>::new())
54+
.await
55+
}
56+
57+
pub async fn bridgechains_params<I, K, V>(
58+
&mut self,
59+
id: &str,
60+
parameters: I,
61+
) -> Result<Vec<Bridgechain>>
62+
where
63+
I: IntoIterator,
64+
I::Item: Borrow<(K, V)>,
65+
K: AsRef<str>,
66+
V: AsRef<str>,
67+
{
68+
let endpoint = format!("businesses/{}/bridgechains", id);
69+
self.client.get_with_params(&endpoint, parameters).await
70+
}
71+
}

0 commit comments

Comments
 (0)