mxpy 5.0.0b1__tar.gz → 10.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mxpy-10.0.0/.gitignore +32 -0
- mxpy-10.0.0/PKG-INFO +81 -0
- mxpy-10.0.0/README.md +60 -0
- mxpy-10.0.0/multiversx_sdk_cli/args_validation.py +71 -0
- mxpy-10.0.0/multiversx_sdk_cli/base_transactions_controller.py +86 -0
- {mxpy-5.0.0b1 → mxpy-10.0.0}/multiversx_sdk_cli/cli.py +62 -25
- {mxpy-5.0.0b1 → mxpy-10.0.0}/multiversx_sdk_cli/cli_config.py +34 -5
- mxpy-10.0.0/multiversx_sdk_cli/cli_contracts.py +574 -0
- {mxpy-5.0.0b1 → mxpy-10.0.0}/multiversx_sdk_cli/cli_data.py +25 -13
- mxpy-10.0.0/multiversx_sdk_cli/cli_delegation.py +978 -0
- mxpy-10.0.0/multiversx_sdk_cli/cli_deps.py +79 -0
- mxpy-10.0.0/multiversx_sdk_cli/cli_dns.py +212 -0
- mxpy-10.0.0/multiversx_sdk_cli/cli_faucet.py +68 -0
- {mxpy-5.0.0b1 → mxpy-10.0.0}/multiversx_sdk_cli/cli_ledger.py +17 -5
- mxpy-10.0.0/multiversx_sdk_cli/cli_localnet.py +186 -0
- {mxpy-5.0.0b1 → mxpy-10.0.0}/multiversx_sdk_cli/cli_output.py +49 -26
- mxpy-10.0.0/multiversx_sdk_cli/cli_password.py +23 -0
- mxpy-10.0.0/multiversx_sdk_cli/cli_shared.py +580 -0
- mxpy-10.0.0/multiversx_sdk_cli/cli_transactions.py +245 -0
- mxpy-10.0.0/multiversx_sdk_cli/cli_validator_wallet.py +123 -0
- mxpy-10.0.0/multiversx_sdk_cli/cli_validators.py +523 -0
- mxpy-10.0.0/multiversx_sdk_cli/cli_wallet.py +379 -0
- {mxpy-5.0.0b1 → mxpy-10.0.0}/multiversx_sdk_cli/config.py +52 -91
- mxpy-10.0.0/multiversx_sdk_cli/constants.py +21 -0
- mxpy-10.0.0/multiversx_sdk_cli/contract_verification.py +169 -0
- mxpy-10.0.0/multiversx_sdk_cli/contracts.py +285 -0
- mxpy-10.0.0/multiversx_sdk_cli/cosign_transaction.py +29 -0
- mxpy-10.0.0/multiversx_sdk_cli/delegation.py +798 -0
- mxpy-10.0.0/multiversx_sdk_cli/dependencies/__init__.py +15 -0
- mxpy-10.0.0/multiversx_sdk_cli/dependencies/install.py +61 -0
- mxpy-10.0.0/multiversx_sdk_cli/dependencies/modules.py +201 -0
- mxpy-10.0.0/multiversx_sdk_cli/dependencies/resolution.py +19 -0
- mxpy-10.0.0/multiversx_sdk_cli/dns.py +163 -0
- {mxpy-5.0.0b1 → mxpy-10.0.0}/multiversx_sdk_cli/docker.py +30 -13
- {mxpy-5.0.0b1 → mxpy-10.0.0}/multiversx_sdk_cli/downloader.py +12 -13
- {mxpy-5.0.0b1 → mxpy-10.0.0}/multiversx_sdk_cli/errors.py +58 -66
- mxpy-10.0.0/multiversx_sdk_cli/guardian_relayer_data.py +16 -0
- mxpy-10.0.0/multiversx_sdk_cli/guards.py +13 -0
- mxpy-10.0.0/multiversx_sdk_cli/interfaces.py +16 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/config_default.py +66 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/config_general.py +26 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/config_networking.py +46 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/config_part.py +38 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/config_root.py +177 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/config_sharding.py +41 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/config_software.py +179 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/constants.py +8 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/genesis.py +10 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/genesis_json.py +54 -0
- {mxpy-5.0.0b1/multiversx_sdk_cli/testnet → mxpy-10.0.0/multiversx_sdk_cli/localnet}/genesis_smart_contracts_json.py +4 -4
- mxpy-10.0.0/multiversx_sdk_cli/localnet/libraries.py +18 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/node.py +27 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/node_config_toml.py +83 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/nodes_setup_json.py +39 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/p2p_toml.py +22 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/seednode_p2pKey.pem +4 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/step_build_software.py +85 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/step_clean.py +14 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/step_config.py +215 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/step_new.py +19 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/step_prerequisites.py +59 -0
- mxpy-10.0.0/multiversx_sdk_cli/localnet/step_start.py +250 -0
- {mxpy-5.0.0b1/multiversx_sdk_cli/testnet → mxpy-10.0.0/multiversx_sdk_cli/localnet}/wallets.py +11 -10
- mxpy-10.0.0/multiversx_sdk_cli/myprocess.py +33 -0
- mxpy-10.0.0/multiversx_sdk_cli/sign_verify.py +69 -0
- mxpy-10.0.0/multiversx_sdk_cli/simulation.py +34 -0
- mxpy-10.0.0/multiversx_sdk_cli/transactions.py +171 -0
- mxpy-10.0.0/multiversx_sdk_cli/utils.py +171 -0
- mxpy-10.0.0/multiversx_sdk_cli/ux.py +22 -0
- mxpy-10.0.0/multiversx_sdk_cli/validators.py +537 -0
- mxpy-10.0.0/multiversx_sdk_cli/version.py +28 -0
- {mxpy-5.0.0b1 → mxpy-10.0.0}/multiversx_sdk_cli/workstation.py +13 -1
- mxpy-10.0.0/pyproject.toml +44 -0
- mxpy-5.0.0b1/MANIFEST.in +0 -3
- mxpy-5.0.0b1/PKG-INFO +0 -19
- mxpy-5.0.0b1/README.md +0 -11
- mxpy-5.0.0b1/multiversx_sdk_cli/_version.py +0 -1
- mxpy-5.0.0b1/multiversx_sdk_cli/accounts.py +0 -158
- mxpy-5.0.0b1/multiversx_sdk_cli/accounts_repository.py +0 -83
- mxpy-5.0.0b1/multiversx_sdk_cli/cli_accounts.py +0 -62
- mxpy-5.0.0b1/multiversx_sdk_cli/cli_block.py +0 -31
- mxpy-5.0.0b1/multiversx_sdk_cli/cli_contracts.py +0 -455
- mxpy-5.0.0b1/multiversx_sdk_cli/cli_delegation.py +0 -257
- mxpy-5.0.0b1/multiversx_sdk_cli/cli_deps.py +0 -49
- mxpy-5.0.0b1/multiversx_sdk_cli/cli_dns.py +0 -118
- mxpy-5.0.0b1/multiversx_sdk_cli/cli_network.py +0 -52
- mxpy-5.0.0b1/multiversx_sdk_cli/cli_password.py +0 -8
- mxpy-5.0.0b1/multiversx_sdk_cli/cli_shared.py +0 -190
- mxpy-5.0.0b1/multiversx_sdk_cli/cli_testnet.py +0 -81
- mxpy-5.0.0b1/multiversx_sdk_cli/cli_transactions.py +0 -86
- mxpy-5.0.0b1/multiversx_sdk_cli/cli_validators.py +0 -205
- mxpy-5.0.0b1/multiversx_sdk_cli/cli_wallet.py +0 -153
- mxpy-5.0.0b1/multiversx_sdk_cli/constants.py +0 -6
- mxpy-5.0.0b1/multiversx_sdk_cli/contract_verification.py +0 -85
- mxpy-5.0.0b1/multiversx_sdk_cli/contracts.py +0 -282
- mxpy-5.0.0b1/multiversx_sdk_cli/delegation/__init__.py +0 -23
- mxpy-5.0.0b1/multiversx_sdk_cli/delegation/staking_provider.py +0 -173
- mxpy-5.0.0b1/multiversx_sdk_cli/dependencies/__init__.py +0 -3
- mxpy-5.0.0b1/multiversx_sdk_cli/dependencies/install.py +0 -77
- mxpy-5.0.0b1/multiversx_sdk_cli/dependencies/modules.py +0 -402
- mxpy-5.0.0b1/multiversx_sdk_cli/diskcache.py +0 -51
- mxpy-5.0.0b1/multiversx_sdk_cli/dns.py +0 -104
- mxpy-5.0.0b1/multiversx_sdk_cli/guards.py +0 -26
- mxpy-5.0.0b1/multiversx_sdk_cli/interfaces.py +0 -49
- mxpy-5.0.0b1/multiversx_sdk_cli/ledger/config.py +0 -38
- mxpy-5.0.0b1/multiversx_sdk_cli/ledger/ledger_app_handler.py +0 -150
- mxpy-5.0.0b1/multiversx_sdk_cli/ledger/ledger_functions.py +0 -39
- mxpy-5.0.0b1/multiversx_sdk_cli/myprocess.py +0 -108
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/__init__.py +0 -13
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/constants.py +0 -2
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/core.py +0 -93
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/eei_activation.py +0 -39
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/eei_checks.py +0 -60
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/eei_registry.py +0 -47
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/interfaces.py +0 -10
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/migrations.py +0 -21
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/project_base.py +0 -201
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/project_clang.py +0 -154
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/project_cpp.py +0 -110
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/project_rust.py +0 -288
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/project_sol.py +0 -21
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/__init__.py +0 -3
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/data/__init__.py +0 -0
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/data/common.py +0 -56
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/data/extracted_feature.py +0 -104
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/data/folder_report.py +0 -49
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/data/project_report.py +0 -56
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/data/report.py +0 -107
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/data/wasm_report.py +0 -46
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/do_report.py +0 -60
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/features/__init__.py +0 -0
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/features/features.py +0 -13
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/features/report_option.py +0 -29
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/features/size.py +0 -17
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/features/twiggy_paths_check.py +0 -58
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/format/__init__.py +0 -0
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/format/change_type.py +0 -37
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/format/format_options.py +0 -3
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/report/report_creator.py +0 -78
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/shared.py +0 -24
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/templates.py +0 -273
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/templates_config.py +0 -44
- mxpy-5.0.0b1/multiversx_sdk_cli/projects/templates_repository.py +0 -77
- mxpy-5.0.0b1/multiversx_sdk_cli/scope.py +0 -40
- mxpy-5.0.0b1/multiversx_sdk_cli/simulation.py +0 -29
- mxpy-5.0.0b1/multiversx_sdk_cli/testnet/__init__.py +0 -4
- mxpy-5.0.0b1/multiversx_sdk_cli/testnet/config.py +0 -359
- mxpy-5.0.0b1/multiversx_sdk_cli/testnet/core.py +0 -135
- mxpy-5.0.0b1/multiversx_sdk_cli/testnet/genesis.py +0 -24
- mxpy-5.0.0b1/multiversx_sdk_cli/testnet/genesis_json.py +0 -67
- mxpy-5.0.0b1/multiversx_sdk_cli/testnet/node_config_toml.py +0 -138
- mxpy-5.0.0b1/multiversx_sdk_cli/testnet/nodes_setup_json.py +0 -46
- mxpy-5.0.0b1/multiversx_sdk_cli/testnet/p2p_toml.py +0 -24
- mxpy-5.0.0b1/multiversx_sdk_cli/testnet/setup.py +0 -273
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/__init__.py +0 -0
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/local_verify_server.py +0 -29
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/test_accounts.py +0 -39
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/test_accounts_repository.py +0 -64
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/test_code_metadata.py +0 -18
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/test_contracts.py +0 -61
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/test_converters.py +0 -19
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/test_ledger.py +0 -19
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/test_modules.py +0 -24
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/test_playground_proxy.py +0 -28
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/test_proxy.py +0 -140
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/test_rust.py +0 -14
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/test_testnet.py +0 -73
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/test_transactions.py +0 -83
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/test_validators_core.py +0 -14
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/test_validators_file.py +0 -22
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/test_wallet.py +0 -137
- mxpy-5.0.0b1/multiversx_sdk_cli/tests/utils.py +0 -40
- mxpy-5.0.0b1/multiversx_sdk_cli/transactions.py +0 -269
- mxpy-5.0.0b1/multiversx_sdk_cli/utils.py +0 -292
- mxpy-5.0.0b1/multiversx_sdk_cli/validators/__init__.py +0 -28
- mxpy-5.0.0b1/multiversx_sdk_cli/validators/core.py +0 -189
- mxpy-5.0.0b1/multiversx_sdk_cli/validators/validators_file.py +0 -27
- mxpy-5.0.0b1/multiversx_sdk_cli/wallet/__init__.py +0 -0
- mxpy-5.0.0b1/multiversx_sdk_cli/wallet/bech32.py +0 -122
- mxpy-5.0.0b1/multiversx_sdk_cli/wallet/keyfile.py +0 -131
- mxpy-5.0.0b1/multiversx_sdk_cli/wallet/pem.py +0 -124
- mxpy-5.0.0b1/mxpy.egg-info/PKG-INFO +0 -19
- mxpy-5.0.0b1/mxpy.egg-info/SOURCES.txt +0 -130
- mxpy-5.0.0b1/mxpy.egg-info/dependency_links.txt +0 -1
- mxpy-5.0.0b1/mxpy.egg-info/entry_points.txt +0 -2
- mxpy-5.0.0b1/mxpy.egg-info/not-zip-safe +0 -1
- mxpy-5.0.0b1/mxpy.egg-info/requires.txt +0 -13
- mxpy-5.0.0b1/mxpy.egg-info/top_level.txt +0 -1
- mxpy-5.0.0b1/setup.cfg +0 -4
- mxpy-5.0.0b1/setup.py +0 -59
- {mxpy-5.0.0b1 → mxpy-10.0.0}/LICENSE +0 -0
- {mxpy-5.0.0b1 → mxpy-10.0.0}/multiversx_sdk_cli/__init__.py +0 -0
- {mxpy-5.0.0b1/multiversx_sdk_cli/ledger → mxpy-10.0.0/multiversx_sdk_cli/localnet}/__init__.py +0 -0
mxpy-10.0.0/.gitignore
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.eggs
|
|
2
|
+
dist
|
|
3
|
+
__pycache__
|
|
4
|
+
*.egg-info
|
|
5
|
+
*.py[cod]
|
|
6
|
+
*$py.class
|
|
7
|
+
.pytest_cache/
|
|
8
|
+
.idea
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# mypy
|
|
12
|
+
.mypy_cache/
|
|
13
|
+
|
|
14
|
+
# Sphinx documentation
|
|
15
|
+
docs/_build/
|
|
16
|
+
|
|
17
|
+
# Tags generated by ctags
|
|
18
|
+
tags
|
|
19
|
+
|
|
20
|
+
# Environments
|
|
21
|
+
.env
|
|
22
|
+
.venv
|
|
23
|
+
env/
|
|
24
|
+
venv/
|
|
25
|
+
ENV/
|
|
26
|
+
env.bak/
|
|
27
|
+
venv.bak/
|
|
28
|
+
|
|
29
|
+
# Typings
|
|
30
|
+
typings
|
|
31
|
+
|
|
32
|
+
multiversx_sdk_cli/tests/testdata-out
|
mxpy-10.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mxpy
|
|
3
|
+
Version: 10.0.0
|
|
4
|
+
Summary: MultiversX Smart Contracts Tools
|
|
5
|
+
Project-URL: Homepage, https://github.com/multiversx/mx-sdk-py-cli
|
|
6
|
+
Author: MultiversX
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Requires-Python: >=3.8
|
|
14
|
+
Requires-Dist: argcomplete==3.2.2
|
|
15
|
+
Requires-Dist: ledgercomm[hid]
|
|
16
|
+
Requires-Dist: multiversx-sdk[ledger]==1.2.0
|
|
17
|
+
Requires-Dist: requests<3.0.0,>=2.32.0
|
|
18
|
+
Requires-Dist: rich==13.3.4
|
|
19
|
+
Requires-Dist: toml>=0.10.2
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# Description
|
|
23
|
+
Python Command Line Tools for interacting with Multivers<sup>X</sup>.
|
|
24
|
+
|
|
25
|
+
## Documentation
|
|
26
|
+
[docs.multiversx.com](https://docs.multiversx.com/sdk-and-tools/sdk-py/)
|
|
27
|
+
|
|
28
|
+
## CLI
|
|
29
|
+
[CLI](CLI.md)
|
|
30
|
+
|
|
31
|
+
## Distribution
|
|
32
|
+
[pipx](https://docs.multiversx.com/sdk-and-tools/sdk-py/installing-mxpy/) [(PyPi)](https://pypi.org/project/multiversx-sdk-cli/#history)
|
|
33
|
+
|
|
34
|
+
## Development setup
|
|
35
|
+
|
|
36
|
+
Clone this repository and cd into it:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
git clone https://github.com/multiversx/mx-sdk-py-cli.git
|
|
40
|
+
cd mx-sdk-py-cli
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Virtual environment
|
|
44
|
+
|
|
45
|
+
Create a virtual environment and install the dependencies:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
python3 -m venv ./venv
|
|
49
|
+
source ./venv/bin/activate
|
|
50
|
+
pip install -r ./requirements.txt --upgrade
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Install development dependencies, as well:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
pip install -r ./requirements-dev.txt --upgrade
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Allow `pre-commit` to automatically run on `git commit`:
|
|
60
|
+
```
|
|
61
|
+
pre-commit install
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Above, `requirements.txt` should mirror the **dependencies** section of `pyproject.toml`.
|
|
65
|
+
|
|
66
|
+
If using VSCode, restart it or follow these steps:
|
|
67
|
+
- `Ctrl + Shift + P`
|
|
68
|
+
- _Select Interpreter_
|
|
69
|
+
- Choose `./venv/bin/python`.
|
|
70
|
+
|
|
71
|
+
### Using your local `mxpy`
|
|
72
|
+
|
|
73
|
+
If you want to test the modifications you locally made to `mxpy`, set `PYTHONPATH` with the path to your local repository path.
|
|
74
|
+
|
|
75
|
+
For example, if you cloned the repository at `~/mx-sdk-py-cli`, run:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
export PYTHONPATH="~/mx-sdk-py-cli"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Then `mxpy` will use the code in your local repository.
|
mxpy-10.0.0/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Description
|
|
2
|
+
Python Command Line Tools for interacting with Multivers<sup>X</sup>.
|
|
3
|
+
|
|
4
|
+
## Documentation
|
|
5
|
+
[docs.multiversx.com](https://docs.multiversx.com/sdk-and-tools/sdk-py/)
|
|
6
|
+
|
|
7
|
+
## CLI
|
|
8
|
+
[CLI](CLI.md)
|
|
9
|
+
|
|
10
|
+
## Distribution
|
|
11
|
+
[pipx](https://docs.multiversx.com/sdk-and-tools/sdk-py/installing-mxpy/) [(PyPi)](https://pypi.org/project/multiversx-sdk-cli/#history)
|
|
12
|
+
|
|
13
|
+
## Development setup
|
|
14
|
+
|
|
15
|
+
Clone this repository and cd into it:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
git clone https://github.com/multiversx/mx-sdk-py-cli.git
|
|
19
|
+
cd mx-sdk-py-cli
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Virtual environment
|
|
23
|
+
|
|
24
|
+
Create a virtual environment and install the dependencies:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
python3 -m venv ./venv
|
|
28
|
+
source ./venv/bin/activate
|
|
29
|
+
pip install -r ./requirements.txt --upgrade
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Install development dependencies, as well:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
pip install -r ./requirements-dev.txt --upgrade
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Allow `pre-commit` to automatically run on `git commit`:
|
|
39
|
+
```
|
|
40
|
+
pre-commit install
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Above, `requirements.txt` should mirror the **dependencies** section of `pyproject.toml`.
|
|
44
|
+
|
|
45
|
+
If using VSCode, restart it or follow these steps:
|
|
46
|
+
- `Ctrl + Shift + P`
|
|
47
|
+
- _Select Interpreter_
|
|
48
|
+
- Choose `./venv/bin/python`.
|
|
49
|
+
|
|
50
|
+
### Using your local `mxpy`
|
|
51
|
+
|
|
52
|
+
If you want to test the modifications you locally made to `mxpy`, set `PYTHONPATH` with the path to your local repository path.
|
|
53
|
+
|
|
54
|
+
For example, if you cloned the repository at `~/mx-sdk-py-cli`, run:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
export PYTHONPATH="~/mx-sdk-py-cli"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Then `mxpy` will use the code in your local repository.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from multiversx_sdk_cli.errors import InvalidArgumentsError
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def validate_transaction_args(args: Any):
|
|
7
|
+
validate_nonce_args(args)
|
|
8
|
+
validate_receiver_args(args)
|
|
9
|
+
validate_gas_limit_args(args)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def validate_nonce_args(args: Any):
|
|
13
|
+
"""If nonce is not provided, ensure that recall_nonce is provided. If recall_nonce is provided, ensure that proxy is provided."""
|
|
14
|
+
if hasattr(args, "nonce") and args.nonce is None:
|
|
15
|
+
if not args.recall_nonce:
|
|
16
|
+
raise InvalidArgumentsError("Either --nonce or --recall-nonce must be provided")
|
|
17
|
+
|
|
18
|
+
if hasattr(args, "proxy") and not args.proxy:
|
|
19
|
+
raise InvalidArgumentsError("--proxy must be provided if --recall-nonce is used")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def validate_receiver_args(args: Any):
|
|
23
|
+
"""Ensure that receiver is provided."""
|
|
24
|
+
if hasattr(args, "receiver") and not args.receiver:
|
|
25
|
+
raise InvalidArgumentsError("--receiver must be provided")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def validate_gas_limit_args(args: Any):
|
|
29
|
+
"""Ensure that gas_limit is provided."""
|
|
30
|
+
if hasattr(args, "gas_limit") and not args.gas_limit:
|
|
31
|
+
raise InvalidArgumentsError("--gas-limit must be provided")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def ensure_wallet_args_are_provided(args: Any):
|
|
35
|
+
signing_methods = [args.pem, args.keyfile, args.ledger]
|
|
36
|
+
|
|
37
|
+
if all(signing_methods):
|
|
38
|
+
raise InvalidArgumentsError("Only one of --pem, --keyfile, or --ledger must be provided")
|
|
39
|
+
|
|
40
|
+
if not any(signing_methods):
|
|
41
|
+
raise InvalidArgumentsError("One of --pem, --keyfile, or --ledger must be provided")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def ensure_relayer_wallet_args_are_provided(args: Any):
|
|
45
|
+
signing_methods = [args.relayer_pem, args.relayer_keyfile, args.relayer_ledger]
|
|
46
|
+
|
|
47
|
+
if all(signing_methods):
|
|
48
|
+
raise InvalidArgumentsError(
|
|
49
|
+
"Only one of --relayer-pem, --relayer-keyfile, or --relayer-ledger must be provided"
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
if not any(signing_methods):
|
|
53
|
+
raise InvalidArgumentsError("One of --relayer-pem, --relayer-keyfile, or --relayer-ledger must be provided")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def validate_broadcast_args(args: Any):
|
|
57
|
+
if args.send and args.simulate:
|
|
58
|
+
raise InvalidArgumentsError("Cannot both 'simulate' and 'send' a transaction")
|
|
59
|
+
|
|
60
|
+
if args.send or args.simulate:
|
|
61
|
+
validate_proxy_argument(args)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def validate_chain_id_args(args: Any):
|
|
65
|
+
if not args.chain and not args.proxy:
|
|
66
|
+
raise InvalidArgumentsError("Either --chain or --proxy must be provided")
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def validate_proxy_argument(args: Any):
|
|
70
|
+
if not args.proxy:
|
|
71
|
+
raise InvalidArgumentsError("--proxy must be provided")
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from typing import Optional, Union
|
|
2
|
+
|
|
3
|
+
from multiversx_sdk import LedgerAccount, Transaction, TransactionComputer
|
|
4
|
+
|
|
5
|
+
from multiversx_sdk_cli.constants import (
|
|
6
|
+
EXTRA_GAS_LIMIT_FOR_GUARDED_TRANSACTIONS,
|
|
7
|
+
EXTRA_GAS_LIMIT_FOR_RELAYED_TRANSACTIONS,
|
|
8
|
+
)
|
|
9
|
+
from multiversx_sdk_cli.cosign_transaction import cosign_transaction
|
|
10
|
+
from multiversx_sdk_cli.interfaces import IAccount
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class BaseTransactionsController:
|
|
14
|
+
def __init__(self) -> None:
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
def sign_transaction(
|
|
18
|
+
self,
|
|
19
|
+
transaction: Transaction,
|
|
20
|
+
sender: Optional[IAccount] = None,
|
|
21
|
+
guardian: Optional[IAccount] = None,
|
|
22
|
+
relayer: Optional[IAccount] = None,
|
|
23
|
+
guardian_service_url: Optional[str] = None,
|
|
24
|
+
guardian_2fa_code: Optional[str] = None,
|
|
25
|
+
):
|
|
26
|
+
"""Signs the transaction using the sender's account and, if required, additionally signs with the guardian's and relayer's accounts. Ensures the appropriate transaction options are set as needed."""
|
|
27
|
+
self._set_options_for_guarded_transaction_if_needed(transaction)
|
|
28
|
+
self._set_options_for_hash_signing_if_needed(transaction, sender, guardian, relayer)
|
|
29
|
+
|
|
30
|
+
if sender:
|
|
31
|
+
transaction.signature = sender.sign_transaction(transaction)
|
|
32
|
+
|
|
33
|
+
self._sign_guarded_transaction_if_guardian(
|
|
34
|
+
transaction,
|
|
35
|
+
guardian,
|
|
36
|
+
guardian_service_url,
|
|
37
|
+
guardian_2fa_code,
|
|
38
|
+
)
|
|
39
|
+
self._sign_relayed_transaction_if_relayer(transaction, relayer)
|
|
40
|
+
|
|
41
|
+
def add_extra_gas_limit_if_required(self, transaction: Transaction):
|
|
42
|
+
"""In case of guarded or relayed transactions, extra gas limit is added."""
|
|
43
|
+
if transaction.guardian:
|
|
44
|
+
transaction.gas_limit += EXTRA_GAS_LIMIT_FOR_GUARDED_TRANSACTIONS
|
|
45
|
+
|
|
46
|
+
if transaction.relayer:
|
|
47
|
+
transaction.gas_limit += EXTRA_GAS_LIMIT_FOR_RELAYED_TRANSACTIONS
|
|
48
|
+
|
|
49
|
+
def _set_options_for_guarded_transaction_if_needed(self, transaction: Transaction):
|
|
50
|
+
if transaction.guardian:
|
|
51
|
+
transaction_computer = TransactionComputer()
|
|
52
|
+
transaction_computer.apply_guardian(transaction, transaction.guardian)
|
|
53
|
+
|
|
54
|
+
def _set_options_for_hash_signing_if_needed(
|
|
55
|
+
self,
|
|
56
|
+
transaction: Transaction,
|
|
57
|
+
sender: Union[IAccount, None],
|
|
58
|
+
guardian: Union[IAccount, None],
|
|
59
|
+
relayer: Union[IAccount, None],
|
|
60
|
+
):
|
|
61
|
+
if (
|
|
62
|
+
isinstance(sender, LedgerAccount)
|
|
63
|
+
or isinstance(guardian, LedgerAccount)
|
|
64
|
+
or isinstance(relayer, LedgerAccount)
|
|
65
|
+
):
|
|
66
|
+
transaction_computer = TransactionComputer()
|
|
67
|
+
transaction_computer.apply_options_for_hash_signing(transaction)
|
|
68
|
+
|
|
69
|
+
def _sign_guarded_transaction_if_guardian(
|
|
70
|
+
self,
|
|
71
|
+
transaction: Transaction,
|
|
72
|
+
guardian: Union[IAccount, None],
|
|
73
|
+
guardian_service_url: Union[str, None],
|
|
74
|
+
guardian_2fa_code: Union[str, None],
|
|
75
|
+
) -> Transaction:
|
|
76
|
+
# If the guardian account is provided, we sign locally. Otherwise, we reach for the trusted cosign service.
|
|
77
|
+
if guardian:
|
|
78
|
+
transaction.guardian_signature = guardian.sign_transaction(transaction)
|
|
79
|
+
elif transaction.guardian and guardian_service_url and guardian_2fa_code:
|
|
80
|
+
cosign_transaction(transaction, guardian_service_url, guardian_2fa_code)
|
|
81
|
+
|
|
82
|
+
return transaction
|
|
83
|
+
|
|
84
|
+
def _sign_relayed_transaction_if_relayer(self, transaction: Transaction, relayer: Union[IAccount, None]):
|
|
85
|
+
if relayer and transaction.relayer:
|
|
86
|
+
transaction.relayer_signature = relayer.sign_transaction(transaction)
|
|
@@ -1,34 +1,39 @@
|
|
|
1
|
+
# PYTHON_ARGCOMPLETE_OK
|
|
1
2
|
import argparse
|
|
2
3
|
import logging
|
|
3
4
|
import sys
|
|
4
5
|
from argparse import ArgumentParser
|
|
5
|
-
from typing import Any
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
import argcomplete
|
|
9
|
+
from multiversx_sdk import LibraryConfig
|
|
10
|
+
from rich.logging import RichHandler
|
|
6
11
|
|
|
7
|
-
import multiversx_sdk_cli.cli_accounts
|
|
8
|
-
import multiversx_sdk_cli.cli_block
|
|
9
12
|
import multiversx_sdk_cli.cli_config
|
|
10
13
|
import multiversx_sdk_cli.cli_contracts
|
|
11
14
|
import multiversx_sdk_cli.cli_data
|
|
12
15
|
import multiversx_sdk_cli.cli_delegation
|
|
13
16
|
import multiversx_sdk_cli.cli_deps
|
|
14
17
|
import multiversx_sdk_cli.cli_dns
|
|
18
|
+
import multiversx_sdk_cli.cli_faucet
|
|
15
19
|
import multiversx_sdk_cli.cli_ledger
|
|
16
|
-
import multiversx_sdk_cli.
|
|
17
|
-
import multiversx_sdk_cli.cli_testnet
|
|
20
|
+
import multiversx_sdk_cli.cli_localnet
|
|
18
21
|
import multiversx_sdk_cli.cli_transactions
|
|
22
|
+
import multiversx_sdk_cli.cli_validator_wallet
|
|
19
23
|
import multiversx_sdk_cli.cli_validators
|
|
20
24
|
import multiversx_sdk_cli.cli_wallet
|
|
21
|
-
|
|
22
|
-
from multiversx_sdk_cli
|
|
25
|
+
import multiversx_sdk_cli.version
|
|
26
|
+
from multiversx_sdk_cli import config, errors, utils, ux
|
|
23
27
|
|
|
24
28
|
logger = logging.getLogger("cli")
|
|
25
29
|
|
|
26
30
|
|
|
27
|
-
def main(cli_args:
|
|
31
|
+
def main(cli_args: list[str] = sys.argv[1:]):
|
|
28
32
|
try:
|
|
29
33
|
_do_main(cli_args)
|
|
30
34
|
except errors.KnownError as err:
|
|
31
35
|
logger.critical(err.get_pretty())
|
|
36
|
+
ux.show_critical_error(err.get_pretty())
|
|
32
37
|
return 1
|
|
33
38
|
except KeyboardInterrupt:
|
|
34
39
|
print("process killed by user.")
|
|
@@ -36,18 +41,30 @@ def main(cli_args: List[str] = sys.argv[1:]):
|
|
|
36
41
|
return 0
|
|
37
42
|
|
|
38
43
|
|
|
39
|
-
def _do_main(cli_args:
|
|
40
|
-
|
|
41
|
-
scope.initialize()
|
|
42
|
-
|
|
44
|
+
def _do_main(cli_args: list[str]):
|
|
45
|
+
utils.ensure_folder(config.SDK_PATH)
|
|
43
46
|
argv_with_config_args = config.add_config_args(cli_args)
|
|
44
47
|
parser = setup_parser(argv_with_config_args)
|
|
48
|
+
argcomplete.autocomplete(parser)
|
|
45
49
|
args = parser.parse_args(argv_with_config_args)
|
|
46
50
|
|
|
47
51
|
if args.verbose:
|
|
48
|
-
logging.basicConfig(
|
|
52
|
+
logging.basicConfig(
|
|
53
|
+
level="DEBUG",
|
|
54
|
+
force=True,
|
|
55
|
+
format="%(name)s: %(message)s",
|
|
56
|
+
handlers=[RichHandler(show_time=False, rich_tracebacks=True)],
|
|
57
|
+
)
|
|
49
58
|
else:
|
|
50
|
-
logging.basicConfig(
|
|
59
|
+
logging.basicConfig(
|
|
60
|
+
level="INFO",
|
|
61
|
+
format="%(name)s: %(message)s",
|
|
62
|
+
handlers=[RichHandler(show_time=False, rich_tracebacks=True)],
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
verify_deprecated_entries_in_config_file()
|
|
66
|
+
default_hrp = config.get_address_hrp()
|
|
67
|
+
LibraryConfig.default_address_hrp = default_hrp
|
|
51
68
|
|
|
52
69
|
if not hasattr(args, "func"):
|
|
53
70
|
parser.print_help()
|
|
@@ -55,7 +72,7 @@ def _do_main(cli_args: List[str]):
|
|
|
55
72
|
args.func(args)
|
|
56
73
|
|
|
57
74
|
|
|
58
|
-
def setup_parser(args:
|
|
75
|
+
def setup_parser(args: list[str]):
|
|
59
76
|
parser = ArgumentParser(
|
|
60
77
|
prog="mxpy",
|
|
61
78
|
usage="mxpy [-h] [-v] [--verbose] COMMAND-GROUP [-h] COMMAND ...",
|
|
@@ -67,34 +84,41 @@ mxpy is part of the multiversx-sdk and consists of Command Line Tools and Python
|
|
|
67
84
|
for interacting with the Blockchain (in general) and with Smart Contracts (in particular).
|
|
68
85
|
|
|
69
86
|
mxpy targets a broad audience of users and developers.
|
|
70
|
-
|
|
87
|
+
|
|
88
|
+
See:
|
|
89
|
+
- https://docs.multiversx.com/sdk-and-tools/sdk-py
|
|
90
|
+
- https://docs.multiversx.com/sdk-and-tools/sdk-py/mxpy-cli
|
|
71
91
|
""",
|
|
72
|
-
formatter_class=argparse.RawDescriptionHelpFormatter
|
|
92
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
73
93
|
)
|
|
74
94
|
|
|
75
95
|
parser._positionals.title = "COMMAND GROUPS"
|
|
76
96
|
parser._optionals.title = "TOP-LEVEL OPTIONS"
|
|
77
|
-
|
|
78
|
-
parser.add_argument(
|
|
97
|
+
version = multiversx_sdk_cli.version.get_version()
|
|
98
|
+
parser.add_argument(
|
|
99
|
+
"-v",
|
|
100
|
+
"--version",
|
|
101
|
+
action="version",
|
|
102
|
+
version=f"MultiversX Python CLI (mxpy) {version}",
|
|
103
|
+
)
|
|
79
104
|
parser.add_argument("--verbose", action="store_true", default=False)
|
|
80
105
|
|
|
81
106
|
subparsers = parser.add_subparsers()
|
|
82
|
-
commands:
|
|
107
|
+
commands: list[Any] = []
|
|
83
108
|
|
|
84
109
|
commands.append(multiversx_sdk_cli.cli_contracts.setup_parser(args, subparsers))
|
|
85
110
|
commands.append(multiversx_sdk_cli.cli_transactions.setup_parser(args, subparsers))
|
|
86
111
|
commands.append(multiversx_sdk_cli.cli_validators.setup_parser(args, subparsers))
|
|
87
|
-
commands.append(multiversx_sdk_cli.cli_accounts.setup_parser(subparsers))
|
|
88
112
|
commands.append(multiversx_sdk_cli.cli_ledger.setup_parser(subparsers))
|
|
89
113
|
commands.append(multiversx_sdk_cli.cli_wallet.setup_parser(args, subparsers))
|
|
90
|
-
commands.append(multiversx_sdk_cli.
|
|
114
|
+
commands.append(multiversx_sdk_cli.cli_validator_wallet.setup_parser(args, subparsers))
|
|
91
115
|
commands.append(multiversx_sdk_cli.cli_deps.setup_parser(subparsers))
|
|
92
116
|
commands.append(multiversx_sdk_cli.cli_config.setup_parser(subparsers))
|
|
93
|
-
commands.append(multiversx_sdk_cli.
|
|
94
|
-
commands.append(multiversx_sdk_cli.cli_testnet.setup_parser(args, subparsers))
|
|
117
|
+
commands.append(multiversx_sdk_cli.cli_localnet.setup_parser(args, subparsers))
|
|
95
118
|
commands.append(multiversx_sdk_cli.cli_data.setup_parser(subparsers))
|
|
96
119
|
commands.append(multiversx_sdk_cli.cli_delegation.setup_parser(args, subparsers))
|
|
97
120
|
commands.append(multiversx_sdk_cli.cli_dns.setup_parser(args, subparsers))
|
|
121
|
+
commands.append(multiversx_sdk_cli.cli_faucet.setup_parser(args, subparsers))
|
|
98
122
|
|
|
99
123
|
parser.epilog = """
|
|
100
124
|
----------------------
|
|
@@ -102,11 +126,24 @@ COMMAND GROUPS summary
|
|
|
102
126
|
----------------------
|
|
103
127
|
"""
|
|
104
128
|
for choice, sub in subparsers.choices.items():
|
|
105
|
-
parser.epilog +=
|
|
129
|
+
parser.epilog += f"{choice.ljust(30)} {sub.description}\n"
|
|
106
130
|
|
|
107
131
|
return parser
|
|
108
132
|
|
|
109
133
|
|
|
134
|
+
def verify_deprecated_entries_in_config_file():
|
|
135
|
+
deprecated_keys = config.get_deprecated_entries_in_config_file()
|
|
136
|
+
if len(deprecated_keys) == 0:
|
|
137
|
+
return
|
|
138
|
+
|
|
139
|
+
config_path = config.resolve_config_path()
|
|
140
|
+
message = f"The following config entries are deprecated. Please access `{str(config_path)}` and remove them. \n"
|
|
141
|
+
for entry in deprecated_keys:
|
|
142
|
+
message += f"-> {entry} \n"
|
|
143
|
+
|
|
144
|
+
ux.show_warning(message.rstrip("\n"))
|
|
145
|
+
|
|
146
|
+
|
|
110
147
|
if __name__ == "__main__":
|
|
111
148
|
ret = main(sys.argv[1:])
|
|
112
149
|
sys.exit(ret)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
from multiversx_sdk_cli import cli_shared
|
|
2
1
|
import logging
|
|
2
|
+
import os
|
|
3
3
|
import sys
|
|
4
4
|
from typing import Any
|
|
5
5
|
|
|
6
|
-
from multiversx_sdk_cli import config, utils
|
|
6
|
+
from multiversx_sdk_cli import cli_shared, config, utils
|
|
7
|
+
from multiversx_sdk_cli.ux import confirm_continuation
|
|
7
8
|
|
|
8
9
|
logger = logging.getLogger("cli.config")
|
|
9
10
|
|
|
@@ -13,7 +14,12 @@ def setup_parser(subparsers: Any) -> Any:
|
|
|
13
14
|
subparsers = parser.add_subparsers()
|
|
14
15
|
|
|
15
16
|
sub = cli_shared.add_command_subparser(subparsers, "config", "dump", "Dumps configuration.")
|
|
16
|
-
sub.add_argument(
|
|
17
|
+
sub.add_argument(
|
|
18
|
+
"--defaults",
|
|
19
|
+
required=False,
|
|
20
|
+
help="dump defaults instead of local config",
|
|
21
|
+
action="store_true",
|
|
22
|
+
)
|
|
17
23
|
sub.set_defaults(func=dump)
|
|
18
24
|
|
|
19
25
|
sub = cli_shared.add_command_subparser(subparsers, "config", "get", "Gets a configuration value.")
|
|
@@ -31,7 +37,11 @@ def setup_parser(subparsers: Any) -> Any:
|
|
|
31
37
|
|
|
32
38
|
sub = cli_shared.add_command_subparser(subparsers, "config", "new", "Creates a new configuration.")
|
|
33
39
|
_add_name_arg(sub)
|
|
34
|
-
sub.add_argument(
|
|
40
|
+
sub.add_argument(
|
|
41
|
+
"--template",
|
|
42
|
+
required=False,
|
|
43
|
+
help="template from which to create the new config",
|
|
44
|
+
)
|
|
35
45
|
sub.set_defaults(func=new_config)
|
|
36
46
|
|
|
37
47
|
sub = cli_shared.add_command_subparser(subparsers, "config", "switch", "Switch to a different config")
|
|
@@ -41,6 +51,14 @@ def setup_parser(subparsers: Any) -> Any:
|
|
|
41
51
|
sub = cli_shared.add_command_subparser(subparsers, "config", "list", "List available configs")
|
|
42
52
|
sub.set_defaults(func=list_configs)
|
|
43
53
|
|
|
54
|
+
sub = cli_shared.add_command_subparser(
|
|
55
|
+
subparsers,
|
|
56
|
+
"config",
|
|
57
|
+
"reset",
|
|
58
|
+
"Deletes the config file. Default config will be used.",
|
|
59
|
+
)
|
|
60
|
+
sub.set_defaults(func=delete_config)
|
|
61
|
+
|
|
44
62
|
parser.epilog = cli_shared.build_group_epilog(subparsers)
|
|
45
63
|
return subparsers
|
|
46
64
|
|
|
@@ -89,8 +107,19 @@ def switch_config(args: Any):
|
|
|
89
107
|
|
|
90
108
|
def list_configs(args: Any):
|
|
91
109
|
data = config.read_file()
|
|
92
|
-
configurations = data.get(
|
|
110
|
+
configurations = data.get("configurations", {})
|
|
93
111
|
for config_name in configurations.keys():
|
|
94
112
|
if config_name == data.get("active", "default"):
|
|
95
113
|
config_name += "*"
|
|
96
114
|
print(config_name)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def delete_config(args: Any):
|
|
118
|
+
config_file = config.resolve_config_path()
|
|
119
|
+
if not config_file.is_file():
|
|
120
|
+
logger.info("Config file not found. Aborting...")
|
|
121
|
+
return
|
|
122
|
+
|
|
123
|
+
confirm_continuation(f"The file `{str(config_file)}` will be deleted. Do you want to continue? (y/n)")
|
|
124
|
+
os.remove(config_file)
|
|
125
|
+
logger.info("Successfully deleted the config file")
|