forked from maidsafe/autonomi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a592c08
commit 89ed7f6
Showing
7 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
extern crate tracing; | ||
|
||
pub mod client; | ||
pub mod wallet; | ||
#[cfg(feature = "data")] | ||
mod self_encryption; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use sn_evm::wallet::{get_random_private_key,create_a_evm_wallet,create_file_with_keys}; | ||
|
||
|
||
pub fn create_evm_wallet() { | ||
let wallet_private_key = get_random_private_key(); | ||
let wallet_public_key = create_a_evm_wallet(&wallet_private_key); | ||
let file_path = create_file_with_keys(wallet_private_key, wallet_public_key); | ||
println!("A file is created with the path: {}", file_path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2024 MaidSafe.net limited. | ||
// | ||
// This SAFE Network Software is licensed to you under The General Public License (GPL), version 3. | ||
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed | ||
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. Please review the Licences for the specific language governing | ||
// permissions and limitations relating to use of the SAFE Network Software. | ||
|
||
use autonomi::Multiaddr; | ||
use autonomi::wallet::*; | ||
use color_eyre::{ | ||
eyre::{bail, Context}, | ||
Result, | ||
}; | ||
|
||
|
||
pub fn create(peers: Vec<Multiaddr>) -> Result<()> { | ||
create_evm_wallet(); | ||
Ok(()) | ||
} | ||
|
||
pub fn balance(peers: Vec<Multiaddr>) -> Result<()> { | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use evmlib::{wallet::{get_random_private_key_for_wallet, Wallet}, Network}; | ||
use evmlib::utils::get_evm_network_from_env; | ||
use std::fs::File; | ||
use std::io::Write; | ||
use std::path::Path; | ||
|
||
pub fn get_random_private_key() -> String { | ||
get_random_private_key_for_wallet() | ||
} | ||
|
||
pub fn create_a_evm_wallet(private_key: &String) -> String { | ||
let network = get_evm_network_from_env() | ||
.expect("Failed to get EVM network from environment variables"); | ||
let wallet = Wallet::new_from_private_key(network, &private_key) | ||
.expect("Could not init deployer wallet"); | ||
hex::encode(wallet.address()) | ||
} | ||
|
||
pub fn create_file_with_keys(private_key: String, public_key: String) -> String { | ||
let mut file = File::create(public_key.clone()).expect("could not create file"); | ||
file.write_all(private_key.as_bytes()).expect("Not able to write into file"); | ||
let file_path = Path::new(&public_key).canonicalize().expect("Not able to find the absolute path for the file"); | ||
file_path.to_string_lossy().to_string() | ||
} |