diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 24757526..8dd1900f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] - python-version: [3.8] + python-version: [3.8, 3.11] steps: - uses: actions/checkout@v2 diff --git a/multiversx_sdk_cli/cli_contracts.py b/multiversx_sdk_cli/cli_contracts.py index e36ad61e..ebf431e4 100644 --- a/multiversx_sdk_cli/cli_contracts.py +++ b/multiversx_sdk_cli/cli_contracts.py @@ -463,7 +463,7 @@ def do_reproducible_build(args: Any): utils.ensure_folder(output_path) options = args.__dict__ - no_wasm_opt = options.get("no-wasm-opt", True) + no_wasm_opt = options.get("no_wasm_opt", False) if not is_docker_installed(): raise DockerMissingError() diff --git a/multiversx_sdk_cli/cli_shared.py b/multiversx_sdk_cli/cli_shared.py index 2438695e..75fa665d 100644 --- a/multiversx_sdk_cli/cli_shared.py +++ b/multiversx_sdk_cli/cli_shared.py @@ -21,6 +21,7 @@ from multiversx_sdk_cli.ledger.ledger_functions import do_get_ledger_address from multiversx_sdk_cli.simulation import Simulator from multiversx_sdk_cli.transactions import send_and_wait_for_result +from multiversx_sdk_cli.utils import log_explorer_transaction from multiversx_sdk_cli.ux import show_warning @@ -274,8 +275,16 @@ def send_or_simulate(tx: ITransaction, args: Any, dump_output: bool = True) -> C simulation = Simulator(proxy).run(tx) output_builder.set_simulation_results(simulation) finally: + output_transaction = output_builder.build() + if dump_output: - utils.dump_out_json(output_builder.build(), outfile=outfile) + utils.dump_out_json(output_transaction, outfile=outfile) + + if send_only: + log_explorer_transaction( + chain=output_transaction["emittedTransaction"]["chainID"], + transaction_hash=output_transaction["emittedTransactionHash"] + ) return output_builder diff --git a/multiversx_sdk_cli/cli_wallet.py b/multiversx_sdk_cli/cli_wallet.py index 523f8159..57bfbb6c 100644 --- a/multiversx_sdk_cli/cli_wallet.py +++ b/multiversx_sdk_cli/cli_wallet.py @@ -20,6 +20,9 @@ WALLET_FORMAT_KEYSTORE_MNEMONIC = "keystore-mnemonic" WALLET_FORMAT_KEYSTORE_SECRET_KEY = "keystore-secret-key" WALLET_FORMAT_PEM = "pem" +WALLET_FORMAT_ADDRESS_BECH32 = "address-bech32" +WALLET_FORMAT_ADDRESS_HEX = "address-hex" + WALLET_FORMATS = [ WALLET_FORMAT_RAW_MNEMONIC, WALLET_FORMAT_KEYSTORE_MNEMONIC, @@ -27,6 +30,8 @@ WALLET_FORMAT_PEM, ] +WALLET_FORMATS_AND_ADDRESSES = [*WALLET_FORMATS, WALLET_FORMAT_ADDRESS_BECH32, WALLET_FORMAT_ADDRESS_HEX] + def setup_parser(args: List[str], subparsers: Any) -> Any: parser = cli_shared.add_group_subparser( @@ -56,7 +61,7 @@ def setup_parser(args: List[str], subparsers: Any) -> Any: sub.add_argument("--infile", help="path to the input file") sub.add_argument("--outfile", help="path to the output file") sub.add_argument("--in-format", required=True, choices=WALLET_FORMATS, help="the format of the input file") - sub.add_argument("--out-format", required=True, choices=WALLET_FORMATS, help="the format of the output file") + sub.add_argument("--out-format", required=True, choices=WALLET_FORMATS_AND_ADDRESSES, help="the format of the output file") sub.add_argument("--address-index", help=f"the address index, if input format is {WALLET_FORMAT_RAW_MNEMONIC}, {WALLET_FORMAT_KEYSTORE_MNEMONIC} or {WALLET_FORMAT_PEM} (with multiple entries) and the output format is {WALLET_FORMAT_KEYSTORE_SECRET_KEY} or {WALLET_FORMAT_PEM}", type=int, default=0) sub.add_argument("--address-hrp", help=f"the human-readable part of the address, when the output format is {WALLET_FORMAT_KEYSTORE_SECRET_KEY} or {WALLET_FORMAT_PEM} (default: %(default)s)", type=str, default=DEFAULT_HRP) sub.set_defaults(func=convert_wallet) @@ -209,6 +214,23 @@ def _create_wallet_content( pem = UserPEM(address.bech32(), secret_key) return pem.to_text() + if out_format == WALLET_FORMAT_ADDRESS_BECH32: + if mnemonic: + secret_key = mnemonic.derive_key(address_index) + assert secret_key is not None + + pubkey = secret_key.generate_public_key() + address = pubkey.to_address(address_hrp) + return address.bech32() + + if out_format == WALLET_FORMAT_ADDRESS_HEX: + if mnemonic: + secret_key = mnemonic.derive_key(address_index) + assert secret_key is not None + + pubkey = secret_key.generate_public_key() + return pubkey.hex() + raise KnownError(f"Cannot create wallet, unknown output format: <{out_format}>. Make sure to use one of following: {WALLET_FORMATS}.") diff --git a/multiversx_sdk_cli/config.py b/multiversx_sdk_cli/config.py index 638a22e4..863e64f7 100644 --- a/multiversx_sdk_cli/config.py +++ b/multiversx_sdk_cli/config.py @@ -145,7 +145,7 @@ def _guard_valid_config_deletion(name: str): def get_defaults() -> Dict[str, Any]: return { - "dependencies.vmtools.tag": "latest", + "dependencies.vmtools.tag": "v1.4.60", "dependencies.mx_sdk_rs.tag": "latest", "dependencies.vmtools.urlTemplate.linux": "https://github.com/multiversx/mx-chain-vm-go/archive/{TAG}.tar.gz", "dependencies.vmtools.urlTemplate.osx": "https://github.com/multiversx/mx-chain-vm-go/archive/{TAG}.tar.gz", diff --git a/multiversx_sdk_cli/tests/test_cli_wallet.py b/multiversx_sdk_cli/tests/test_cli_wallet.py index 86b29ba4..b6353fb7 100644 --- a/multiversx_sdk_cli/tests/test_cli_wallet.py +++ b/multiversx_sdk_cli/tests/test_cli_wallet.py @@ -217,6 +217,28 @@ def test_wallet_bech32_decode(capsys: Any): assert out == "0139472eff6886771a982f3083da5d421f24c29181e63888228dc81ca60d69e1" +def test_wallet_convert_pem_to_bech32_address(capsys: Any): + infile = testdata_path / "alice.pem" + + main([ + "wallet", "convert", "--infile", str(infile), "--in-format", "pem", "--out-format", "address-bech32" + ]) + + out = _read_stdout(capsys).strip("Output:\n\n") + assert out == "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th" + + +def test_wallet_convert_pem_to_pubkey(capsys: Any): + infile = testdata_path / "alice.pem" + + main([ + "wallet", "convert", "--infile", str(infile), "--in-format", "pem", "--out-format", "address-hex" + ]) + + out = _read_stdout(capsys).strip("Output:\n\n") + assert out == "0139472eff6886771a982f3083da5d421f24c29181e63888228dc81ca60d69e1" + + def _read_stdout_mnemonic(capsys: Any) -> str: return _read_stdout(capsys).replace("Mnemonic:", "").strip() diff --git a/pyproject.toml b/pyproject.toml index 702b77e9..b4476a0e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "multiversx-sdk-cli" -version = "8.0.0" +version = "8.1.2" authors = [ { name="MultiversX" }, ]