Skip to content

Commit

Permalink
Add Sign data to Ethereum API
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximFischuk committed Jan 30, 2024
1 parent a8bdfbe commit 9445db2
Show file tree
Hide file tree
Showing 14 changed files with 560 additions and 434 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ rustify = "0.5.3"
rustify_derive = "0.5.2"
eth_checksum = "0.1.2"
base64 = "0.21.0"
hex = "0.4.3"

[dev-dependencies]
tokio = { version = "1.20.1", features = ["full"] }
wiremock = "0.5.17"
secp256k1 = "0.26.0"
hex = "0.4.3"
15 changes: 11 additions & 4 deletions examples/ethereum_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ async fn main() {
)
.unwrap();

let created_account = quorum_vault_client::api::create_account(&client, "quorum")
let created_account = quorum_vault_client::api::ethereum::create_account(&client, "quorum")
.await
.unwrap();
println!("result: {:?}", created_account);

let addresses = quorum_vault_client::api::list_accounts(&client, "quorum")
let addresses = quorum_vault_client::api::ethereum::list_accounts(&client, "quorum")
.await
.unwrap();
println!("addresses: {:?}", addresses);

let address = addresses.keys.first().copied().unwrap();

let result = quorum_vault_client::api::read_account(&client, "quorum", address)
let result = quorum_vault_client::api::ethereum::read_account(&client, "quorum", address)
.await
.unwrap();
println!("result: {:?}", result);
Expand All @@ -39,8 +39,15 @@ async fn main() {

tx.gas_price = Some(U256::from(1));

let signature = quorum_vault_client::api::sign_transaction(&client, "quorum", 1, tx)
let signature = quorum_vault_client::api::ethereum::sign_transaction(&client, "quorum", 1, tx)
.await
.unwrap();
println!("signature: {:?}", signature);

let data = b"Hello, world!";
let signature2 = quorum_vault_client::api::ethereum::sign(&client, "quorum", address, data)
.await
.unwrap();

println!("signature2: {:?}", signature2);
}
14 changes: 7 additions & 7 deletions examples/keys.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use quorum_vault_client::api::KeyCryptoAlgorithm;
use quorum_vault_client::api::keys::KeyCryptoAlgorithm;
use vaultrs::client::{VaultClient, VaultClientSettingsBuilder};

#[tokio::main]
Expand All @@ -15,7 +15,7 @@ async fn main() {

let key_id = "some-id";

let new_key = quorum_vault_client::api::create_key(
let new_key = quorum_vault_client::api::keys::create_key(
&client,
"quorum",
key_id,
Expand All @@ -28,23 +28,23 @@ async fn main() {
.unwrap();
println!("key: {new_key:?}");

let keys = quorum_vault_client::api::list_keys(&client, "quorum")
let keys = quorum_vault_client::api::keys::list_keys(&client, "quorum")
.await
.unwrap();
println!("keys: {keys:?}");

let read_key = quorum_vault_client::api::read_key(&client, "quorum", key_id)
let read_key = quorum_vault_client::api::keys::read_key(&client, "quorum", key_id)
.await
.unwrap();
println!("read_key: {read_key:?}");

let signature =
quorum_vault_client::api::sign(&client, "quorum", key_id, "some-data".as_bytes())
quorum_vault_client::api::keys::sign(&client, "quorum", key_id, "some-data".as_bytes())
.await
.unwrap();
println!("signature: {signature:?}");

let updated_tags = quorum_vault_client::api::update_key_tags(
let updated_tags = quorum_vault_client::api::keys::update_key_tags(
&client,
"quorum",
key_id,
Expand All @@ -56,7 +56,7 @@ async fn main() {
.unwrap();
println!("updated_tags: {updated_tags:?}");

quorum_vault_client::api::destroy_key(&client, "quorum", "some-id")
quorum_vault_client::api::keys::destroy_key(&client, "quorum", "some-id")
.await
.unwrap();
println!("destroyed key: {key_id}");
Expand Down
17 changes: 10 additions & 7 deletions examples/zksnarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,29 @@ async fn main() {
.unwrap();

// Create a new account
let account = quorum_vault_client::api::create_zksnarks_account(&client, "quorum")
let account = quorum_vault_client::api::zksnarks::create_zksnarks_account(&client, "quorum")
.await
.unwrap();
println!("account: {:?}", account);

// Read the account
let account =
quorum_vault_client::api::read_zksnarks_account(&client, "quorum", &account.public_key)
.await
.unwrap();
let account = quorum_vault_client::api::zksnarks::read_zksnarks_account(
&client,
"quorum",
&account.public_key,
)
.await
.unwrap();
println!("account: {:?}", account);

// List the accounts
let accounts = quorum_vault_client::api::list_zksnarks_accounts(&client, "quorum")
let accounts = quorum_vault_client::api::zksnarks::list_zksnarks_accounts(&client, "quorum")
.await
.unwrap();
println!("accounts: {:?}", accounts);

// Sign a message
let signature = quorum_vault_client::api::zksnarks_sign(
let signature = quorum_vault_client::api::zksnarks::zksnarks_sign(
&client,
"quorum",
&account.public_key,
Expand Down
Loading

0 comments on commit 9445db2

Please sign in to comment.