Skip to content

Commit bdf10de

Browse files
Merge pull request #3 from waves-rust/0.3.0
0.3.0
2 parents ea39ec9 + 11caa15 commit bdf10de

25 files changed

Lines changed: 1198 additions & 268 deletions

Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "wavesplatform"
3-
version = "0.2.4"
3+
version = "0.3.0"
44
authors = ["peterz <peterz@rambler.ru>", "DEADBLACKCLOVER <deadblackclover@protonmail.com>"]
5-
description = "Library to work with Waves blockchain (https://wavesplatform.com)"
5+
description = "Library to work with Waves blockchain (https://waves.tech/)"
66
edition = "2018"
77
license = "MIT"
88
readme = "README.md"
@@ -20,3 +20,7 @@ curve25519-dalek = "2.1.3"
2020
ed25519-dalek = "1.0.1"
2121
sha2 = "0.8.0"
2222
sha3 = "0.8.0"
23+
24+
reqwest = { version = "0.11.12", features = ["json"] }
25+
serde = { version = "1.0.145", features = ["derive"] }
26+
tokio = { version = "1.21.2", features = ["full"] }

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
![crates.io](https://img.shields.io/crates/v/wavesplatform.svg)
44
![docs.rs](https://docs.rs/wavesplatform/badge.svg)
55

6-
Library to work with [Waves blockchain](https://wavesplatform.com)
6+
Library to work with [Waves blockchain](https://waves.tech/)
77

88
# Usage
99
```rust

examples/get_address_by_alias.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use wavesplatform::node::{Node, MAINNET_URL};
2+
3+
#[tokio::main]
4+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
5+
let node = Node::from_url(MAINNET_URL);
6+
7+
// Assemble all the puzzles
8+
let result = node.get_address_by_alias("vlzhr").await?;
9+
10+
println!("vlzhr -> {}", result.address());
11+
12+
Ok(())
13+
}

examples/get_assets_details.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use wavesplatform::node::{Node, MAINNET_URL};
2+
3+
#[tokio::main]
4+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
5+
let node = Node::from_url(MAINNET_URL);
6+
7+
// Tether USD token
8+
let result = node
9+
.get_assets_details("34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ")
10+
.await?;
11+
12+
println!("{:?}", result);
13+
14+
Ok(())
15+
}

examples/get_balance.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use wavesplatform::node::{Node, MAINNET_URL};
2+
3+
#[tokio::main]
4+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
5+
let node = Node::from_url(MAINNET_URL);
6+
7+
// If it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck.
8+
let result = node
9+
.get_balance("3PEktVux2RhchSN63DsDo4b4mz4QqzKSeDv")
10+
.await?;
11+
12+
println!("Balance: {} WAVES", result.balance());
13+
14+
let result = node
15+
.get_balance_details("3PEktVux2RhchSN63DsDo4b4mz4QqzKSeDv")
16+
.await?;
17+
18+
println!("Regular balance: {} WAVES", result.regular());
19+
20+
Ok(())
21+
}

examples/get_blocks.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use wavesplatform::node::{Node, MAINNET_URL};
2+
3+
#[tokio::main]
4+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
5+
let node = Node::from_url(MAINNET_URL);
6+
7+
let result = node.get_blocks_last().await?;
8+
9+
println!("{:?}", result);
10+
11+
let result = node
12+
.get_blocks_headers_at_height(result.height() - 10)
13+
.await?;
14+
15+
println!("{:?}", result);
16+
17+
let result = node.get_blocks_headers(&result.id()).await?;
18+
19+
println!("{:?}", result);
20+
21+
Ok(())
22+
}

examples/get_leasing_info.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use wavesplatform::node::{Node, MAINNET_URL};
2+
3+
#[tokio::main]
4+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
5+
let node = Node::from_url(MAINNET_URL);
6+
7+
let result = node
8+
.get_leasing_info("YwVPf35VckF4Yu5XwF18P9VwWwfQVGAQmqDp4bpgtuV")
9+
.await?;
10+
11+
println!("{:?}", result);
12+
13+
Ok(())
14+
}

examples/get_node_version.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use wavesplatform::node::{Node, MAINNET_URL};
2+
3+
#[tokio::main]
4+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
5+
let node = Node::from_url(MAINNET_URL);
6+
7+
let result = node.get_node_version().await?;
8+
9+
println!("Version: {}", result.version());
10+
11+
Ok(())
12+
}

examples/get_transactions.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use wavesplatform::node::{Node, MAINNET_URL};
2+
3+
#[tokio::main]
4+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
5+
let node = Node::from_url(MAINNET_URL);
6+
7+
let result = node
8+
.get_transactions_info("YwVPf35VckF4Yu5XwF18P9VwWwfQVGAQmqDp4bpgtuV")
9+
.await?;
10+
11+
println!("{:?}", result);
12+
13+
let result = node
14+
.get_transactions_status("YwVPf35VckF4Yu5XwF18P9VwWwfQVGAQmqDp4bpgtuV")
15+
.await?;
16+
17+
println!("{}", result.status());
18+
19+
Ok(())
20+
}

examples/sign_transaction.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use std::time::{SystemTime, UNIX_EPOCH};
2+
use wavesplatform::account::{PrivateKeyAccount, TESTNET};
3+
use wavesplatform::base58::*;
4+
use wavesplatform::seed::*;
5+
use wavesplatform::transaction::*;
6+
7+
fn main() {
8+
let phrase = generate_phrase();
9+
let account = PrivateKeyAccount::from_seed(&phrase);
10+
println!(
11+
"My TESTNET address: {}",
12+
account.public_key().to_address(TESTNET).to_string()
13+
);
14+
15+
let ts = SystemTime::now()
16+
.duration_since(UNIX_EPOCH)
17+
.unwrap()
18+
.as_secs()
19+
* 1000;
20+
let tx = Transaction::new_alias(&account.public_key(), "rhino", TESTNET, 100000, ts);
21+
println!("ID is {}", tx.id().to_string());
22+
let ptx = account.sign_transaction(tx);
23+
println!(
24+
"Proofs are {:?}",
25+
ptx.proofs
26+
.iter()
27+
.map(|p| p.to_base58())
28+
.collect::<Vec<String>>()
29+
);
30+
}

0 commit comments

Comments
 (0)