Skip to content

Environment config#519

Merged
popenta merged 17 commits intofeat/nextfrom
environment-config
Jun 12, 2025
Merged

Environment config#519
popenta merged 17 commits intofeat/nextfrom
environment-config

Conversation

@popenta
Copy link
Copy Markdown
Collaborator

@popenta popenta commented May 27, 2025

Added the possibility for user to create custom configs. Things like proxy url, explorer url, default hrp and whether or not to ask for confirmation before sending a transaction can be set in the config. In case --proxy is not provided, the proxy will be fetched from the config.

An user made config can look like this:

{
    "default_address_hrp": "erd",
    "ask_confirmation": "false",
    "proxy_url": "https://devnet-gateway.multiversx.com",
    "explorer_url": "https://devnet-explorer.multiversx.com"
}

@popenta popenta self-assigned this May 27, 2025
@popenta popenta marked this pull request as draft May 27, 2025 10:53
@popenta popenta marked this pull request as ready for review May 27, 2025 14:29
Copy link
Copy Markdown
Contributor

@andreibancioiu andreibancioiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed internally, we can separate "environments" from the existing configuration.

Comment thread multiversx_sdk_cli/config.py Outdated
return get_value("explorer_url")


@cache
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine, because user cannot switch environments in a single invocation of mxpy. If that would happen (no support, though), this memoization would lead to bugs.


def get_defaults() -> dict[str, Any]:
return {
"dependencies.vmtools.tag": "v1.5.24",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for doing the cleanup.

danielailie
danielailie previously approved these changes Jun 3, 2025
Comment thread CLI.md.sh
command "Environment.Set" "env set"
command "Environment.Get" "env get"
command "Environment.Dump" "env dump"
command "Environment.Switch" "env switch"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch sounds good. Though, about set & get, let's double check with @ccorcoveanu whether this is fine.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get and set sound good (also git has get and set methods for config). what I am thinking is, do we need dump? Or should get without any arguments actually dump the active config?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get without args dumping the entire config sounds good. I've done it with dump to match the mxpy config dump command.

)
sub.set_defaults(func=new_env)

sub = cli_shared.add_command_subparser(subparsers, "env", "get", "Gets an env value from the active environment.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe get-value instead of get and set-value instead of set? Just an opinion.

@popenta popenta changed the base branch from feat/configs to feat/next June 5, 2025 10:25
@popenta popenta dismissed danielailie’s stale review June 5, 2025 10:25

The base branch was changed.

Comment thread CLI.md.sh
command "Environment.Set" "env set"
command "Environment.Get" "env get"
command "Environment.Dump" "env dump"
command "Environment.Switch" "env switch"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get and set sound good (also git has get and set methods for config). what I am thinking is, do we need dump? Or should get without any arguments actually dump the active config?

Comment thread multiversx_sdk_cli/cli_dns.py Outdated


def dns_resolve(args: Any):
cli_shared.set_proxy_from_config_if_not_provided(args)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a suggestion/question. This set_proxy_from_config_if_not_provided call in all of the handlers seem like something that will end up refactored at some point. I would suggest a higher order function or component which keeps these implementations clean without caring about configs. So whoever calls this higher in the stack will call -

handle(dns_resolve, args)

def handle(f, args):
  args = fill(args)
  f(args)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea. done

@popenta popenta merged commit 7f8b7bf into feat/next Jun 12, 2025
11 of 13 checks passed
@popenta popenta deleted the environment-config branch June 12, 2025 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants