Skip to content

Delegation refactoring#542

Merged
popenta merged 5 commits into
feat/nextfrom
delegation-refactoring
Sep 22, 2025
Merged

Delegation refactoring#542
popenta merged 5 commits into
feat/nextfrom
delegation-refactoring

Conversation

@popenta
Copy link
Copy Markdown
Collaborator

@popenta popenta commented Sep 16, 2025

Removed the Delegation Wrapper, now using the DelegationController within sdk-py.

@popenta popenta self-assigned this Sep 16, 2025
Copy link
Copy Markdown

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 delegation functionality by removing the custom DelegationOperations wrapper class and integrating the DelegationController from the updated MultiversX SDK.

  • Upgrades MultiversX SDK from version 2.0.1 to 2.2.0
  • Removes the custom delegation wrapper and uses the SDK's native DelegationController
  • Updates all delegation operations to use the new controller API patterns

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

File Description
pyproject.toml Updates MultiversX SDK dependency to version 2.2.0
multiversx_sdk_cli/delegation.py Removes the entire DelegationOperations wrapper class
multiversx_sdk_cli/cli_delegation.py Refactors to use DelegationController and ValidatorsController from SDK
multiversx_sdk_cli/tests/test_cli_staking_provider.py Updates gas limit test value to match new SDK behavior

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

Comment thread multiversx_sdk_cli/cli_delegation.py Outdated
total_delegation_cap=int(args.total_delegation_cap),
service_fee=int(args.service_fee),
guardian=guardian_and_relayer_data.guardian.address if guardian_and_relayer_data.guardian else None,
relayer=guardian_and_relayer_data.relayer.address if guardian_and_relayer_data.relayer else None,
Copy link

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

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

[nitpick] The pattern guardian_and_relayer_data.guardian.address if guardian_and_relayer_data.guardian else None is repeated throughout the file. Consider extracting this logic into a helper function to reduce duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
@popenta popenta changed the base branch from main to feat/next September 17, 2025 10:16
danielailie
danielailie previously approved these changes Sep 17, 2025
Comment on lines +1148 to +1153
if args.options:
transaction.options = args.options
altered = True

if args.version != DEFAULT_TX_VERSION:
transaction.version = args.version
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.

We can check if different from the fields of transaction (flow optimization).

return cast(list[str], parsed)


def _options_set_for_hash_signing(args: Any) -> bool:
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.

should prefix, since it returns bool?

Comment on lines +394 to +395
if _options_set_for_hash_signing(args):
acc.use_hash_signing = True
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.

Can this be refactored to be written only once?

Oh, it's not on all flows, sorry (not on LedgerAccount).


def initialize_gas_limit_estimator(args: Any) -> Union[GasLimitEstimator, None]:
# if gas limit is provided, we don't need GasLimitEstimator
if hasattr(args, "gas_limit") and args.gas_limit:
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.

👍

@popenta popenta merged commit 390e2d9 into feat/next Sep 22, 2025
14 of 17 checks passed
@popenta popenta deleted the delegation-refactoring branch September 22, 2025 12:37
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