Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
gus-opentensor committed Aug 26, 2024
1 parent 411d7be commit 722c9e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use schnorrkel::{
use serde_json::json;
use sp_core::crypto::Ss58Codec;
use sp_core::{sr25519, Pair};
use std::fs::{File, OpenOptions};
use std::fs::OpenOptions;
use std::io::Write;
use std::os::unix::fs::PermissionsExt;
use std::path::Path;
Expand Down Expand Up @@ -226,7 +226,7 @@ pub fn create_hotkey(mnemonic: Mnemonic, name: &str) -> Keypair {
ss58_address: Some(hotkey_pair.public().to_ss58check()),
};
let path = BT_WALLET_PATH;
let hotkey_path = hotkey_file(&path, name);
let hotkey_path = hotkey_file(path, name);
// Ensure the directory exists before writing the file
if let Some(parent) = hotkey_path.parent() {
std::fs::create_dir_all(parent).expect("Failed to create directory");
Expand All @@ -243,7 +243,7 @@ pub fn create_hotkey(mnemonic: Mnemonic, name: &str) -> Keypair {
#[cfg(test)]
mod tests {
use super::*;
use bip39::{Language, Mnemonic};
use bip39::Language;
use rand::Rng;

#[test]
Expand Down
8 changes: 3 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ use pyo3::prelude::*;
mod keypair;
mod wallet;
use crate::keypair::*;
use sp_core::ByteArray;
use sp_core::Pair;
use wallet::{Keyfile, Wallet};

#[pyfunction]
Expand All @@ -21,16 +19,16 @@ fn create_hotkey_pair(num_words: u32, name: &str) -> PyResult<PyObject> {
let keypair_dict = pyo3::types::PyDict::new_bound(py);
keypair_dict.set_item(
"public_key",
hotkey_pair.public_key.map(|pk| hex::encode(pk)),
hotkey_pair.public_key.map(hex::encode),
)?;
keypair_dict.set_item(
"private_key",
hotkey_pair.private_key.map(|pk| hex::encode(pk)),
hotkey_pair.private_key.map(hex::encode),
)?;
keypair_dict.set_item("mnemonic", hotkey_pair.mnemonic)?;
keypair_dict.set_item(
"seed_hex",
hotkey_pair.seed_hex.map(|seed| hex::encode(seed)),
hotkey_pair.seed_hex.map(hex::encode),
)?;
keypair_dict.set_item("ss58_address", hotkey_pair.ss58_address)?;
Ok(keypair_dict.to_object(py))
Expand Down
2 changes: 1 addition & 1 deletion src/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pyo3::prelude::*;
use std::path::{Path, PathBuf};
use std::path::PathBuf;

const BT_WALLET_NAME: &str = "default";
pub const BT_WALLET_PATH: &str = "~/.bittensor/wallets/";
Expand Down

0 comments on commit 722c9e9

Please sign in to comment.