Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perform args validation on command #485

Merged
merged 3 commits into from
Feb 27, 2025
Merged

Perform args validation on command #485

merged 3 commits into from
Feb 27, 2025

Conversation

popenta
Copy link
Collaborator

@popenta popenta commented Feb 20, 2025

No description provided.

@popenta popenta self-assigned this Feb 20, 2025
@popenta popenta marked this pull request as draft February 20, 2025 14:49
Base automatically changed from switch-to-sdk-native-auth-client to feat/next February 25, 2025 12:48
@popenta popenta marked this pull request as ready for review February 25, 2025 12:49
raise InvalidArgumentsError("One of --relayer-pem, --relayer-keyfile, or --relayer-ledger must be provided")


def ensure_broadcast_args(args: Any):
Copy link
Contributor

Choose a reason for hiding this comment

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

This is more like "validate_broadcast_args", since neither is required.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

renamed to validate_broadcast_args.

from multiversx_sdk_cli.errors import InvalidArgumentsError


def ensure_required_transaction_args_are_provided(args: Any):
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Maybe we can use "validate" or "check" instead of "ensure"? Since the word "ensure" makes us think about required arguments.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

"""Ensure that gas_limit is provided."""
if hasattr(args, "gas_limit") and not args.gas_limit:
if hasattr(args, "estimate_gas") and not args.estimate_gas:
raise InvalidArgumentsError("If --gas-limit not provided, --estimate-gas must be provided")
Copy link
Contributor

Choose a reason for hiding this comment

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

But we will drop --estimate-gas in the near future, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's been already dropped in a future PR.


if chain_id:
return chain_id
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

else statement can be dropped, and remaining lines unindent-ed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

indeed, done

@popenta popenta merged commit 9a06b1e into feat/next Feb 27, 2025
10 of 12 checks passed
@popenta popenta deleted the args-validation branch February 27, 2025 11:46
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.

3 participants