Replace wallet.core with multiversx_sdk_wallet#186
Conversation
| "multiversx-sdk-rust-contract-builder==4.0.2", | ||
| "multiversx-sdk-network-providers==0.6.4" | ||
| "multiversx-sdk-network-providers==0.6.4", | ||
| "multiversx-sdk-wallet==0.4.1" |
There was a problem hiding this comment.
Let's check if one of the following isn't used anymore:
"pycryptodomex",
"cryptography==36.0.2",
If not used, can be removed from setup.py and requirements.txt.
There was a problem hiding this comment.
Removed "pycryptodomex"
|
|
||
| def test_generate_pair_pem(self): | ||
| secret_key, pubkey = generate_pair() | ||
| mnemonic = Mnemonic.generate() |
There was a problem hiding this comment.
Perhaps this test can be removed, as well, since it does not test a functionality defined by multiversx_sdk_cli.
| from multiversx_sdk_cli.wallet.core import bytes_to_binary_string, generate_mnemonic_from_entropy, split_to_fixed_size_slices | ||
| from multiversx_sdk_cli.wallet import pem | ||
| from multiversx_sdk_wallet.mnemonic import Mnemonic | ||
| from multiversx_sdk_wallet.core import mnemonic_to_bip39seed, bip39seed_to_secret_key |
There was a problem hiding this comment.
If not used (should not be used), can be removed.
There was a problem hiding this comment.
it is used in the test test_derive_secret_key, but I've deleted the test because it's no longer relevant since we are using the wallet package.
| } | ||
|
|
||
| export PYTHONPATH=$(absolute_path ../../) | ||
| export PYTHONPATH=$PYTHONPATH::$(absolute_path ../../) |
There was a problem hiding this comment.
I think we can undo this line.
| ${CLI} wallet derive ./testdata-out/myaccount.pem || return 1 | ||
| assertFileExists "./testdata-out/myaccount.pem" || return 1 | ||
| echo "foo bar\n" | ${CLI} wallet derive --mnemonic ./testdata-out/myaccount-from-mnemonic.pem || return 1 | ||
| echo -e "moral volcano peasant pass circle pen over picture flat shop clap goat never lyrics gather prepare woman film husband gravity behind test tiger improve\n" | ${CLI} wallet derive --mnemonic ./testdata-out/myaccount-from-mnemonic.pem || return 1 |
|
|
||
| testGenerationWithSpaces() { | ||
| echo "testGenerationWithSpaces" | ||
| echo -e "moral volcano peasant pass circle pen over picture flat shop clap goat never lyrics gather prepare woman film husband gravity behind test tiger improve " | ${CLI} wallet derive --mnemonic ./testdata-out/myaccount-from-mnemonic.pem || return 1 |
| mnemonic = generate_mnemonic() | ||
| print(f"Mnemonic: {mnemonic}") | ||
| secret_key, pubkey = wallet.derive_keys(mnemonic) | ||
| mnemonic = Mnemonic.generate() |
| json_file = prepare_file(args.output_path, ".json") | ||
| password = getpass.getpass("Enter a new password:") | ||
| save_to_key_file(json_file, secret_key, pubkey, password) | ||
| save_to_key_file(json_file, secret_key.hex(), pubkey.hex(), password) |
There was a problem hiding this comment.
All right. In a future PR, save_to_key_file can be replaced by the new functions from multiversx-sdk-wallet.
| pem.write(pem_file, secret_key, pubkey, name=address.bech32()) | ||
| if ask_mnemonic: | ||
| mnemonic = input("Enter mnemonic:\n").rstrip().replace("\n", "") | ||
| print(mnemonic, 'asad') |
There was a problem hiding this comment.
Remove debugging print.
| pubkey = secret_key.generate_public_key() | ||
| else: | ||
| mnemonic = Mnemonic.generate() | ||
| secret_key = mnemonic.derive_key(index) |
There was a problem hiding this comment.
Now I see that the following can be extracted after if-else (being the same):
secret_key = mnemonic.derive_key(index)
pubkey = secret_key.generate_public_key()
| secret_key = mnemonic.derive_key(index) | ||
| pubkey = secret_key.generate_public_key() | ||
|
|
||
| secret_key = mnemonic.derive_key(index) |
There was a problem hiding this comment.
Now I see that, above, mnemonic = input(...) can be mnemonic_str = input(...), since below it, the same variable is used, but it has a different type - works, of course, but can be adjusted.
There was a problem hiding this comment.
Will do it in the next pr.
In this PR the a part of the
walletpackage was replaced with themultiversx_sdk_walletpackage. In this PR onlywallet.corewas replaced. A full replacement will come in a later PR.