Skip to content

Commit a38ff17

Browse files
authored
Merge pull request #109 from opentensor/fix/roman/wallet.create_from_uri
Fix `wallet.create_coldkey_from_uri broken`
2 parents 8708eb6 + ea39ff9 commit a38ff17

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

src/python_bindings.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ except argparse.ArgumentError:
11011101
}
11021102

11031103
#[pyo3(
1104-
signature = (uri, use_password=None, overwrite=None, suppress=None, save_coldkey_to_env=None, coldkey_password=None)
1104+
signature = (uri, use_password=false, overwrite=false, suppress=true, save_coldkey_to_env=false, coldkey_password=None)
11051105
)]
11061106
fn create_coldkey_from_uri(
11071107
&mut self,
@@ -1131,7 +1131,7 @@ except argparse.ArgumentError:
11311131
}
11321132

11331133
#[pyo3(
1134-
signature = (uri, use_password=None, overwrite=None, suppress=None, save_hotkey_to_env=None, hotkey_password=None)
1134+
signature = (uri, use_password=false, overwrite=false, suppress=true, save_hotkey_to_env=false, hotkey_password=None)
11351135
)]
11361136
fn create_hotkey_from_uri(
11371137
&mut self,

src/wallet.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,6 @@ impl Wallet {
463463
if !suppress {
464464
if let Some(m) = keypair.mnemonic() {
465465
display_mnemonic_msg(m, "coldkey");
466-
} else {
467-
return Err(KeyFileError::Generic("Failed to get mnemonic".to_string()));
468466
}
469467
}
470468

@@ -495,8 +493,6 @@ impl Wallet {
495493
if !suppress {
496494
if let Some(m) = keypair.mnemonic() {
497495
display_mnemonic_msg(m, "hotkey");
498-
} else {
499-
return Err(KeyFileError::Generic("Failed to get mnemonic".to_string()));
500496
}
501497
}
502498

tests/test_wallet.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,35 @@ def test_wallet_string_representation_with_custom_arguments():
195195
assert w.name == wallet_name
196196
assert w.hotkey_str == wallet_hotkey
197197
assert w.path == wallet_path
198+
199+
200+
def test_create_coldkey_from_uri():
201+
"""Tests create_coldkey_from_uri method."""
202+
# Preps
203+
wallet_name = "test_wallet"
204+
wallet_hotkey = "test_hotkey"
205+
wallet_path = "/tmp/tests_wallets/"
206+
207+
# Call
208+
w = Wallet(name=wallet_name, hotkey=wallet_hotkey, path=wallet_path)
209+
w.create_coldkey_from_uri("//test", use_password=False, overwrite=True)
210+
211+
# Asserts
212+
assert w.coldkey.ss58_address is not None
213+
assert w.coldkeypub.ss58_address is not None
214+
215+
216+
def test_hotkey_coldkey_from_uri():
217+
"""Tests create_coldkey_from_uri method."""
218+
# Preps
219+
wallet_name = "test_wallet"
220+
wallet_hotkey = "test_hotkey"
221+
wallet_path = "/tmp/tests_wallets/"
222+
223+
# Call
224+
w = Wallet(name=wallet_name, hotkey=wallet_hotkey, path=wallet_path)
225+
w.create_hotkey_from_uri("//test", use_password=False, overwrite=True)
226+
227+
# Asserts
228+
assert w.coldkey.ss58_address is not None
229+
assert w.coldkeypub.ss58_address is not None

0 commit comments

Comments
 (0)