Skip to content

Commit d875ddc

Browse files
committed
fixes after review
1 parent dafbd5d commit d875ddc

5 files changed

Lines changed: 51 additions & 60 deletions

File tree

CLI.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ TOP-LEVEL OPTIONS:
3030
-v, --version show program's version number and exit
3131
--verbose
3232
--log-level {debug,info,warning,error}
33-
default: debug
33+
default: info
3434
3535
----------------------
3636
COMMAND GROUPS summary
@@ -5822,12 +5822,11 @@ usage: mxpy config-wallet new [-h] ...
58225822
Creates a new wallet config and sets it as the active wallet.
58235823
58245824
positional arguments:
5825-
alias the alias of the wallet
5825+
alias the alias of the wallet
58265826
58275827
options:
5828-
-h, --help show this help message and exit
5829-
--path PATH the absolute path to the wallet file
5830-
--template TEMPLATE a wallet config from which to create the new config
5828+
-h, --help show this help message and exit
5829+
--path PATH the absolute path to the wallet file
58315830
58325831
```
58335832
### ConfigWallet.List
@@ -5891,31 +5890,31 @@ options:
58915890
--alias ALIAS the alias of the wallet
58925891
58935892
```
5894-
### ConfigWallet.Set
5893+
### ConfigWallet.Switch
58955894

58965895

58975896
```
5898-
$ mxpy config-wallet delete --help
5899-
usage: mxpy config-wallet delete [-h] ...
5900-
5901-
Deletes a config value from the specified wallet.
5897+
$ mxpy config-wallet switch --help
5898+
usage: mxpy config-wallet switch [-h] ...
59025899
5903-
positional arguments:
5904-
value the value to delete for the specified address
5900+
Switch to a different wallet.
59055901
59065902
options:
59075903
-h, --help show this help message and exit
59085904
--alias ALIAS the alias of the wallet
59095905
59105906
```
5911-
### ConfigWallet.Switch
5907+
### ConfigWallet.Delete
59125908

59135909

59145910
```
5915-
$ mxpy config-wallet switch --help
5916-
usage: mxpy config-wallet switch [-h] ...
5911+
$ mxpy config-wallet delete --help
5912+
usage: mxpy config-wallet delete [-h] ...
59175913
5918-
Switch to a different wallet.
5914+
Deletes a config value from the specified wallet.
5915+
5916+
positional arguments:
5917+
value the value to delete for the specified address
59195918
59205919
options:
59215920
-h, --help show this help message and exit
@@ -5941,7 +5940,7 @@ options:
59415940

59425941
```
59435942
$ mxpy config-wallet reset --help
5944-
usage: mxpy address reset [-h] ...
5943+
usage: mxpy config-wallet reset [-h] ...
59455944
59465945
Deletes the config file. No default wallet will be set.
59475946

CLI.md.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ generate() {
201201
command "ConfigWallet.Dump" "config-wallet dump"
202202
command "ConfigWallet.Get" "config-wallet get"
203203
command "ConfigWallet.Set" "config-wallet set"
204-
command "ConfigWallet.Set" "config-wallet delete"
205204
command "ConfigWallet.Switch" "config-wallet switch"
205+
command "ConfigWallet.Delete" "config-wallet delete"
206206
command "ConfigWallet.Remove" "config-wallet remove"
207207
command "ConfigWallet.Reset" "config-wallet reset"
208208

multiversx_sdk_cli/cli_config_wallet.py

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
get_value,
1212
read_wallet_config_file,
1313
resolve_wallet_config_path,
14-
set_active,
1514
set_value,
15+
switch_wallet,
1616
)
1717
from multiversx_sdk_cli.utils import dump_out_json
1818
from multiversx_sdk_cli.ux import confirm_continuation
@@ -31,15 +31,10 @@ def setup_parser(subparsers: Any) -> Any:
3131
)
3232
sub.add_argument("alias", type=str, help="the alias of the wallet")
3333
sub.add_argument("--path", type=str, required=False, help="the absolute path to the wallet file")
34-
sub.add_argument(
35-
"--template",
36-
required=False,
37-
help="a wallet config from which to create the new config",
38-
)
3934
sub.set_defaults(func=new_wallet_config)
4035

4136
sub = cli_shared.add_command_subparser(subparsers, "config-wallet", "list", "List configured wallets")
42-
sub.set_defaults(func=list_addresses)
37+
sub.set_defaults(func=list_wallets)
4338

4439
sub = cli_shared.add_command_subparser(subparsers, "config-wallet", "dump", "Dumps the active wallet.")
4540
sub.set_defaults(func=dump)
@@ -49,26 +44,26 @@ def setup_parser(subparsers: Any) -> Any:
4944
)
5045
sub.add_argument("value", type=str, help="the value to get from the specified wallet (e.g. path)")
5146
_add_alias_arg(sub)
52-
sub.set_defaults(func=get_address_config_value)
47+
sub.set_defaults(func=get_wallet_config_value)
5348

5449
sub = cli_shared.add_command_subparser(
5550
subparsers, "config-wallet", "set", "Sets a config value for the specified wallet."
5651
)
5752
sub.add_argument("key", type=str, help="the key to set for the specified wallet (e.g. index)")
5853
sub.add_argument("value", type=str, help="the value to set for the specified key")
5954
_add_alias_arg(sub)
60-
sub.set_defaults(func=set_address_config_value)
55+
sub.set_defaults(func=set_wallet_config_value)
6156

6257
sub = cli_shared.add_command_subparser(
6358
subparsers, "config-wallet", "delete", "Deletes a config value from the specified wallet."
6459
)
6560
sub.add_argument("value", type=str, help="the value to delete for the specified address")
6661
_add_alias_arg(sub)
67-
sub.set_defaults(func=delete_address_config_value)
62+
sub.set_defaults(func=delete_wallet_config_value)
6863

6964
sub = cli_shared.add_command_subparser(subparsers, "config-wallet", "switch", "Switch to a different wallet.")
7065
_add_alias_arg(sub)
71-
sub.set_defaults(func=switch_address)
66+
sub.set_defaults(func=switch_wallet_to_active)
7267

7368
sub = cli_shared.add_command_subparser(
7469
subparsers,
@@ -77,15 +72,15 @@ def setup_parser(subparsers: Any) -> Any:
7772
"Removes a wallet from the config using the alias. No default wallet will be set. Use `config-wallet switch` to set a new wallet.",
7873
)
7974
_add_alias_arg(sub)
80-
sub.set_defaults(func=remove_address)
75+
sub.set_defaults(func=remove_wallet)
8176

8277
sub = cli_shared.add_command_subparser(
8378
subparsers,
84-
"address",
79+
"config-wallet",
8580
"reset",
8681
"Deletes the config file. No default wallet will be set.",
8782
)
88-
sub.set_defaults(func=delete_address_config_file)
83+
sub.set_defaults(func=delete_wallet_config_file)
8984

9085
parser.epilog = cli_shared.build_group_epilog(subparsers)
9186
return subparsers
@@ -96,53 +91,53 @@ def _add_alias_arg(sub: Any):
9691

9792

9893
def new_wallet_config(args: Any):
99-
create_new_wallet_config(name=args.alias, path=args.path, template=args.template)
94+
create_new_wallet_config(name=args.alias, path=args.path)
10095
dump_out_json(get_active_wallet())
10196

10297

103-
def list_addresses(args: Any):
104-
_ensure_address_config_file_exists()
98+
def list_wallets(args: Any):
99+
_ensure_wallet_config_file_exists()
105100

106101
data = read_wallet_config_file()
107102
dump_out_json(data)
108103

109104

110105
def dump(args: Any):
111-
_ensure_address_config_file_exists()
106+
_ensure_wallet_config_file_exists()
112107
dump_out_json(get_active_wallet())
113108

114109

115-
def get_address_config_value(args: Any):
116-
_ensure_address_config_file_exists()
110+
def get_wallet_config_value(args: Any):
111+
_ensure_wallet_config_file_exists()
117112
value = get_value(args.value, args.alias)
118113
print(value)
119114

120115

121-
def set_address_config_value(args: Any):
122-
_ensure_address_config_file_exists()
116+
def set_wallet_config_value(args: Any):
117+
_ensure_wallet_config_file_exists()
123118
set_value(args.key, args.value, args.alias)
124119

125120

126-
def delete_address_config_value(args: Any):
127-
_ensure_address_config_file_exists()
121+
def delete_wallet_config_value(args: Any):
122+
_ensure_wallet_config_file_exists()
128123

129124
delete_config_value(args.value, args.alias)
130125
dump_out_json(get_active_wallet())
131126

132127

133-
def switch_address(args: Any):
134-
_ensure_address_config_file_exists()
128+
def switch_wallet_to_active(args: Any):
129+
_ensure_wallet_config_file_exists()
135130

136-
set_active(args.alias)
131+
switch_wallet(args.alias)
137132
dump_out_json(get_active_wallet())
138133

139134

140-
def remove_address(args: Any):
141-
_ensure_address_config_file_exists()
135+
def remove_wallet(args: Any):
136+
_ensure_wallet_config_file_exists()
142137
delete_alias(args.alias)
143138

144139

145-
def delete_address_config_file(args: Any):
140+
def delete_wallet_config_file(args: Any):
146141
address_file = resolve_wallet_config_path()
147142
if not address_file.is_file():
148143
logger.info("Wallet config file not found. Aborting...")
@@ -153,7 +148,7 @@ def delete_address_config_file(args: Any):
153148
logger.info("Successfully deleted the address config file.")
154149

155150

156-
def _ensure_address_config_file_exists():
151+
def _ensure_wallet_config_file_exists():
157152
address_file = resolve_wallet_config_path()
158153
if not address_file.is_file():
159154
logger.info("Wallet config file not found. Aborting...")

multiversx_sdk_cli/cli_shared.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def load_wallet_by_alias(alias: str, hrp: str) -> Account:
382382
raise UnknownWalletAliasError(alias)
383383

384384
logger.info(f"Using sender [{alias}] from wallet config.")
385-
return _load_wallet_from_address_config(wallet=wallet, hrp=hrp)
385+
return _load_wallet_from_wallet_config(wallet=wallet, hrp=hrp)
386386

387387

388388
def load_default_wallet(hrp: str) -> Account:
@@ -394,10 +394,10 @@ def load_default_wallet(hrp: str) -> Account:
394394
alias_of_default_wallet = read_wallet_config_file().get("active", "")
395395
logger.info(f"Using sender [{alias_of_default_wallet}] from wallet config.")
396396

397-
return _load_wallet_from_address_config(wallet=active_wallet, hrp=hrp)
397+
return _load_wallet_from_wallet_config(wallet=active_wallet, hrp=hrp)
398398

399399

400-
def _load_wallet_from_address_config(wallet: dict[str, str], hrp: str) -> Account:
400+
def _load_wallet_from_wallet_config(wallet: dict[str, str], hrp: str) -> Account:
401401
wallet_path = wallet.get("path", None)
402402
if not wallet_path:
403403
raise AddressConfigFileError("'path' field must be set in the wallet config.")

multiversx_sdk_cli/config_wallet.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def _write_file(data: dict[str, Any]):
110110
write_json_file(str(env_path), data)
111111

112112

113-
def set_active(name: str):
113+
def switch_wallet(name: str):
114114
"""Switches to the wallet configuration with the given name."""
115115
data = read_wallet_config_file()
116116
_guard_valid_wallet_name(data, name)
@@ -124,14 +124,11 @@ def _guard_valid_wallet_name(env: Any, name: str):
124124
raise UnknownWalletAliasError(name)
125125

126126

127-
def create_new_wallet_config(name: str, path: Optional[str] = None, template: Optional[str] = None):
128-
"""Creates a new wallet config with the given name and optional template and sets it as the default wallet."""
127+
def create_new_wallet_config(name: str, path: Optional[str] = None):
128+
"""Creates a new wallet config with the given name and sets it as the default wallet."""
129129
data = read_wallet_config_file()
130130
_guard_alias_unique(data, name)
131131
new_wallet = {}
132-
if template:
133-
_guard_valid_wallet_name(data, template)
134-
new_wallet = data["wallets"][template]
135132

136133
if path:
137134
new_wallet["path"] = path
@@ -143,8 +140,8 @@ def create_new_wallet_config(name: str, path: Optional[str] = None, template: Op
143140

144141

145142
def _guard_alias_unique(env: Any, name: str):
146-
envs = env.get("wallets", {})
147-
if name in envs:
143+
wallets = env.get("wallets", {})
144+
if name in wallets:
148145
raise AliasAlreadyExistsError(name)
149146

150147

0 commit comments

Comments
 (0)