This commit is contained in:
parent
08c8770942
commit
fca75cceec
@ -10,9 +10,9 @@ use ethers::types::{Address, U256};
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
|
|
||||||
use crate::hero_vault::{keypair, symmetric, ethereum, kvs};
|
use crate::vault::{keypair, symmetric, ethereum, kvs};
|
||||||
use crate::hero_vault::kvs::{KVStore, DefaultStore};
|
use crate::vault::kvs::{KVStore, DefaultStore};
|
||||||
use crate::hero_vault::ethereum::prepare_function_arguments;
|
use crate::vault::ethereum::prepare_function_arguments;
|
||||||
|
|
||||||
// Global Tokio runtime for blocking async operations
|
// Global Tokio runtime for blocking async operations
|
||||||
static RUNTIME: Lazy<Mutex<Runtime>> = Lazy::new(|| {
|
static RUNTIME: Lazy<Mutex<Runtime>> = Lazy::new(|| {
|
||||||
|
@ -157,4 +157,4 @@ The module supports multiple Ethereum networks, including:
|
|||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
For examples of how to use the Hero Vault module, see the `examples/hero_vault` directory.
|
For examples of how to use the Hero Vault module, see the `examples/vault` directory.
|
||||||
|
@ -189,7 +189,7 @@ The module uses the `CryptoError` type for handling errors that can occur during
|
|||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
For examples of how to use the Ethereum module, see the `examples/hero_vault` directory, particularly:
|
For examples of how to use the Ethereum module, see the `examples/vault` directory, particularly:
|
||||||
|
|
||||||
- `contract_example.rhai` - Demonstrates loading a contract ABI and interacting with smart contracts
|
- `contract_example.rhai` - Demonstrates loading a contract ABI and interacting with smart contracts
|
||||||
- `agung_simple_transfer.rhai` - Shows how to perform a simple ETH transfer on the Agung network
|
- `agung_simple_transfer.rhai` - Shows how to perform a simple ETH transfer on the Agung network
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use ethers::prelude::*;
|
use ethers::prelude::*;
|
||||||
|
|
||||||
use crate::hero_vault::error::CryptoError;
|
use crate::vault::error::CryptoError;
|
||||||
use super::networks;
|
use super::networks;
|
||||||
|
|
||||||
/// Creates a provider for a specific network.
|
/// Creates a provider for a specific network.
|
||||||
|
@ -9,8 +9,8 @@ use tokio::runtime::Runtime;
|
|||||||
use ethers::types::Address;
|
use ethers::types::Address;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use crate::hero_vault::error::CryptoError;
|
use crate::vault::error::CryptoError;
|
||||||
use crate::hero_vault::kvs::{self, KVStore, DefaultStore};
|
use crate::vault::kvs::{self, KVStore, DefaultStore};
|
||||||
use super::wallet::EthereumWallet;
|
use super::wallet::EthereumWallet;
|
||||||
use super::networks;
|
use super::networks;
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ fn load_wallets() -> Vec<EthereumWallet> {
|
|||||||
/// Creates an Ethereum wallet from the currently selected keypair.
|
/// Creates an Ethereum wallet from the currently selected keypair.
|
||||||
pub fn create_ethereum_wallet() -> Result<EthereumWallet, CryptoError> {
|
pub fn create_ethereum_wallet() -> Result<EthereumWallet, CryptoError> {
|
||||||
// Get the currently selected keypair
|
// Get the currently selected keypair
|
||||||
let keypair = crate::hero_vault::keypair::get_selected_keypair()?;
|
let keypair = crate::vault::keypair::get_selected_keypair()?;
|
||||||
|
|
||||||
// Create an Ethereum wallet from the keypair
|
// Create an Ethereum wallet from the keypair
|
||||||
let wallet = EthereumWallet::from_keypair(&keypair)?;
|
let wallet = EthereumWallet::from_keypair(&keypair)?;
|
||||||
@ -206,7 +206,7 @@ pub fn create_ethereum_wallet() -> Result<EthereumWallet, CryptoError> {
|
|||||||
/// Creates an Ethereum wallet from a name and the currently selected keypair.
|
/// Creates an Ethereum wallet from a name and the currently selected keypair.
|
||||||
pub fn create_ethereum_wallet_from_name(name: &str) -> Result<EthereumWallet, CryptoError> {
|
pub fn create_ethereum_wallet_from_name(name: &str) -> Result<EthereumWallet, CryptoError> {
|
||||||
// Get the currently selected keypair
|
// Get the currently selected keypair
|
||||||
let keypair = crate::hero_vault::keypair::get_selected_keypair()?;
|
let keypair = crate::vault::keypair::get_selected_keypair()?;
|
||||||
|
|
||||||
// Create an Ethereum wallet from the name and keypair
|
// Create an Ethereum wallet from the name and keypair
|
||||||
let wallet = EthereumWallet::from_name_and_keypair(name, &keypair)?;
|
let wallet = EthereumWallet::from_name_and_keypair(name, &keypair)?;
|
||||||
|
@ -220,14 +220,14 @@ To include the Hero Vault Keypair module in your Rust project, add the following
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
hero_vault = "0.1.0" # Replace with the actual version
|
vault = "0.1.0" # Replace with the actual version
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, you can import and use the module in your Rust code:
|
Then, you can import and use the module in your Rust code:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use hero_vault::vault::keypair::{KeySpace, KeyPair};
|
use vault::vault::keypair::{KeySpace, KeyPair};
|
||||||
use hero_vault::vault::error::CryptoError;
|
use vault::vault::error::CryptoError;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
@ -263,7 +263,7 @@ The module uses the `CryptoError` type for handling errors that can occur during
|
|||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
For examples of how to use the Keypair module, see the `examples/hero_vault` directory, particularly:
|
For examples of how to use the Keypair module, see the `examples/vault` directory, particularly:
|
||||||
|
|
||||||
- `example.rhai` - Basic example demonstrating key management and signing
|
- `example.rhai` - Basic example demonstrating key management and signing
|
||||||
- `advanced_example.rhai` - Advanced example with error handling
|
- `advanced_example.rhai` - Advanced example with error handling
|
||||||
|
@ -143,7 +143,7 @@ The module uses the `CryptoError` type for handling errors that can occur during
|
|||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
For examples of how to use the KVS module, see the `examples/hero_vault` directory. While there may not be specific examples for the KVS module, the general pattern of usage is similar to the key space management examples.
|
For examples of how to use the KVS module, see the `examples/vault` directory. While there may not be specific examples for the KVS module, the general pattern of usage is similar to the key space management examples.
|
||||||
|
|
||||||
A basic usage example:
|
A basic usage example:
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! IndexedDB-backed key-value store implementation for WebAssembly.
|
//! IndexedDB-backed key-value store implementation for WebAssembly.
|
||||||
|
|
||||||
use crate::hero_vault::kvs::error::{KvsError, Result};
|
use crate::vault::kvs::error::{KvsError, Result};
|
||||||
use serde::{de::DeserializeOwned, Serialize};
|
use serde::{de::DeserializeOwned, Serialize};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! Key space management functionality for KVStore
|
//! Key space management functionality for KVStore
|
||||||
|
|
||||||
use crate::hero_vault::kvs::{KVStore, Result};
|
use crate::vault::kvs::{KVStore, Result};
|
||||||
use crate::hero_vault::{keypair, symmetric};
|
use crate::vault::{keypair, symmetric};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
const KEY_SPACE_STORE_NAME: &str = "key-spaces";
|
const KEY_SPACE_STORE_NAME: &str = "key-spaces";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! SlateDB-backed key-value store implementation.
|
//! SlateDB-backed key-value store implementation.
|
||||||
|
|
||||||
use crate::hero_vault::kvs::error::{KvsError, Result};
|
use crate::vault::kvs::error::{KvsError, Result};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use serde::{de::DeserializeOwned, Serialize};
|
use serde::{de::DeserializeOwned, Serialize};
|
||||||
|
@ -92,7 +92,7 @@ The module uses the `CryptoError` type for handling errors that can occur during
|
|||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
For examples of how to use the Symmetric Encryption module, see the `examples/hero_vault` directory, particularly:
|
For examples of how to use the Symmetric Encryption module, see the `examples/vault` directory, particularly:
|
||||||
|
|
||||||
- `example.rhai` - Basic example demonstrating symmetric encryption
|
- `example.rhai` - Basic example demonstrating symmetric encryption
|
||||||
- `advanced_example.rhai` - Advanced example with error handling
|
- `advanced_example.rhai` - Advanced example with error handling
|
||||||
|
Loading…
Reference in New Issue
Block a user