Skip to content

Refactoring: Remove validators wrapper#547

Merged
popenta merged 5 commits intofeat/nextfrom
remove-validators-wrapper
Sep 25, 2025
Merged

Refactoring: Remove validators wrapper#547
popenta merged 5 commits intofeat/nextfrom
remove-validators-wrapper

Conversation

@popenta
Copy link
Collaborator

@popenta popenta commented Sep 18, 2025

No description provided.

@popenta popenta self-assigned this Sep 18, 2025
@popenta popenta marked this pull request as draft September 18, 2025 13:22
@popenta popenta marked this pull request as ready for review September 23, 2025 13:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the validators functionality by removing the local ValidatorsController wrapper class and replacing it with direct usage of the ValidatorsController from the multiversx_sdk package. The refactoring simplifies the codebase by eliminating redundant wrapper code and standardizes the interface to match the SDK's API.

  • Removes the entire validators.py file containing the local ValidatorsController wrapper
  • Updates import statements to use ValidatorsController directly from multiversx_sdk
  • Refactors all validator transaction creation calls to use the SDK's direct API instead of the wrapper methods

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
multiversx_sdk_cli/validators.py Complete removal of the local ValidatorsController wrapper class
multiversx_sdk_cli/cli_validators.py Updated imports and refactored all function calls to use SDK's ValidatorsController directly

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +177 to +193
guardian=guardian_and_relayer_data.guardian_address,
relayer=guardian_and_relayer_data.relayer_address,
gas_limit=args.gas_limit,
gas_price=args.gas_price,
nonce=sender.nonce,
version=args.version,
options=args.options,
guardian_and_relayer_data=guardian_and_relayer_data,
)
else:
validators_signers = _load_validators_signers(args.validators_pem)
tx = controller.create_transaction_for_staking(
sender=sender,
validators=validators_signers,
native_amount=native_amount,
gas_limit=args.gas_limit,
gas_price=args.gas_price,
nonce=sender.nonce,
version=args.version,
options=args.options,
validators_file=validators_signers,
amount=native_amount,
rewards_address=rewards_address,
guardian_and_relayer_data=guardian_and_relayer_data,
guardian=guardian_and_relayer_data.guardian_address,
relayer=guardian_and_relayer_data.relayer_address,
gas_limit=args.gas_limit,
gas_price=args.gas_price,
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

[nitpick] The parameter order and naming in the new API calls don't follow a consistent pattern. For example, sender and nonce are first in one call but sender, nonce, validators_file in another. Consider grouping related parameters consistently (e.g., transaction metadata like nonce, gas_limit, gas_price together).

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Sender, nonce, always first. Validators file third, when necessary. Thus, seems fine.

Comment on lines 238 to 246
tx = controller.create_transaction_for_unstaking(
sender=sender,
keys=keys,
native_amount=native_amount,
nonce=sender.nonce,
public_keys=keys,
guardian=guardian_and_relayer_data.guardian_address,
relayer=guardian_and_relayer_data.relayer_address,
gas_limit=args.gas_limit,
gas_price=args.gas_price,
nonce=sender.nonce,
version=args.version,
options=args.options,
guardian_and_relayer_data=guardian_and_relayer_data,
)
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

The args.value parameter that was previously used as native_amount has been removed from this call, but the SDK's create_transaction_for_unstaking method likely expects a value parameter. This could result in missing transaction value data.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@andreibancioiu andreibancioiu Sep 24, 2025

Choose a reason for hiding this comment

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

guardian=guardian_and_relayer_data.guardian_address,
relayer=guardian_and_relayer_data.relayer_address,
gas_limit=args.gas_limit,
gas_price=args.gas_price,
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

Similar to the unstaking method, the args.value parameter that was previously used as native_amount has been removed. The unbonding transaction may require a value parameter to function correctly.

Suggested change
gas_price=args.gas_price,
gas_price=args.gas_price,
value=args.value,

Copilot uses AI. Check for mistakes.
guardian=guardian_and_relayer_data.guardian_address,
relayer=guardian_and_relayer_data.relayer_address,
gas_limit=args.gas_limit,
gas_price=args.gas_price,
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

The args.value parameter that was previously used as native_amount has been removed from this call as well. This transaction type may also require a value parameter.

Suggested change
gas_price=args.gas_price,
gas_price=args.gas_price,
value=getattr(args, "value", 0),

Copilot uses AI. Check for mistakes.
andreibancioiu
andreibancioiu previously approved these changes Sep 24, 2025
Base automatically changed from multisig-refactoring to feat/next September 25, 2025 07:22
@popenta popenta dismissed andreibancioiu’s stale review September 25, 2025 07:22

The base branch was changed.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@popenta popenta merged commit 470007b into feat/next Sep 25, 2025
12 of 15 checks passed
@popenta popenta deleted the remove-validators-wrapper branch September 25, 2025 08:09
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