Skip to content

Commit

Permalink
remove validator pubkey interface
Browse files Browse the repository at this point in the history
  • Loading branch information
popenta committed Dec 12, 2024
1 parent 88d16ad commit 88843cb
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
},
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"python.languageServer": "Pylance"
"python.languageServer": "Pylance",
"black-formatter.args": ["--line-length=100"]
}
5 changes: 0 additions & 5 deletions multiversx_sdk/core/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ class INetworkConfig(Protocol):
gas_price_modifier: float


class IValidatorPublicKey(Protocol):
def hex(self) -> str:
...


class IAccount(Protocol):
@property
def address(self) -> Address:
Expand Down
1 change: 1 addition & 0 deletions multiversx_sdk/core/transaction_computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self) -> None:
pass

def compute_transaction_fee(self, transaction: Transaction, network_config: INetworkConfig) -> int:
"""`TransactionsFactoryConfig` can be used here as the `network_config`."""
move_balance_gas = network_config.min_gas_limit + len(transaction.data) * network_config.gas_per_data_byte
if move_balance_gas > transaction.gas_limit:
raise NotEnoughGasError(transaction.gas_limit)
Expand Down
15 changes: 8 additions & 7 deletions multiversx_sdk/delegation/delegation_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
from multiversx_sdk.core import (Address, Transaction, TransactionComputer,
TransactionOnNetwork,
TransactionsFactoryConfig)
from multiversx_sdk.core.interfaces import IAccount, IValidatorPublicKey
from multiversx_sdk.core.interfaces import IAccount
from multiversx_sdk.delegation.delegation_transactions_factory import \
DelegationTransactionsFactory
from multiversx_sdk.delegation.delegation_transactions_outcome_parser import \
DelegationTransactionsOutcomeParser
from multiversx_sdk.delegation.delegation_transactions_outcome_parser_types import \
CreateNewDelegationContractOutcome
from multiversx_sdk.network_providers.resources import AwaitingOptions
from multiversx_sdk.wallet.validator_keys import ValidatorPublicKey


class INetworkProvider(Protocol):
Expand Down Expand Up @@ -60,7 +61,7 @@ def create_transaction_for_adding_nodes(self,
sender: IAccount,
nonce: int,
delegation_contract: Address,
public_keys: Sequence[IValidatorPublicKey],
public_keys: Sequence[ValidatorPublicKey],
signed_messages: Sequence[bytes],
guardian: Optional[Address] = None,
relayer: Optional[Address] = None) -> Transaction:
Expand All @@ -82,7 +83,7 @@ def create_transaction_for_removing_nodes(self,
sender: IAccount,
nonce: int,
delegation_contract: Address,
public_keys: Sequence[IValidatorPublicKey],
public_keys: Sequence[ValidatorPublicKey],
guardian: Optional[Address] = None,
relayer: Optional[Address] = None) -> Transaction:
transaction = self.factory.create_transaction_for_removing_nodes(
Expand All @@ -102,7 +103,7 @@ def create_transaction_for_staking_nodes(self,
sender: IAccount,
nonce: int,
delegation_contract: Address,
public_keys: Sequence[IValidatorPublicKey],
public_keys: Sequence[ValidatorPublicKey],
guardian: Optional[Address] = None,
relayer: Optional[Address] = None) -> Transaction:
transaction = self.factory.create_transaction_for_staking_nodes(
Expand All @@ -122,7 +123,7 @@ def create_transaction_for_unbonding_nodes(self,
sender: IAccount,
nonce: int,
delegation_contract: Address,
public_keys: Sequence[IValidatorPublicKey],
public_keys: Sequence[ValidatorPublicKey],
guardian: Optional[Address] = None,
relayer: Optional[Address] = None) -> Transaction:
transaction = self.factory.create_transaction_for_unbonding_nodes(
Expand All @@ -142,7 +143,7 @@ def create_transaction_for_unstaking_nodes(self,
sender: IAccount,
nonce: int,
delegation_contract: Address,
public_keys: Sequence[IValidatorPublicKey],
public_keys: Sequence[ValidatorPublicKey],
guardian: Optional[Address] = None,
relayer: Optional[Address] = None) -> Transaction:
transaction = self.factory.create_transaction_for_unstaking_nodes(
Expand All @@ -162,7 +163,7 @@ def create_transaction_for_unjailing_nodes(self,
sender: IAccount,
nonce: int,
delegation_contract: Address,
public_keys: Sequence[IValidatorPublicKey],
public_keys: Sequence[ValidatorPublicKey],
amount: int,
guardian: Optional[Address] = None,
relayer: Optional[Address] = None) -> Transaction:
Expand Down
14 changes: 7 additions & 7 deletions multiversx_sdk/delegation/delegation_transactions_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from multiversx_sdk.builders.transaction_builder import TransactionBuilder
from multiversx_sdk.core import Address, Transaction
from multiversx_sdk.core.constants import DELEGATION_MANAGER_SC_ADDRESS_HEX
from multiversx_sdk.core.interfaces import IValidatorPublicKey
from multiversx_sdk.core.transactions_factory_config import \
TransactionsFactoryConfig
from multiversx_sdk.delegation.errors import ListsLengthMismatchError
from multiversx_sdk.wallet.validator_keys import ValidatorPublicKey


class DelegationTransactionsFactory:
Expand Down Expand Up @@ -46,7 +46,7 @@ def create_transaction_for_new_delegation_contract(self,
def create_transaction_for_adding_nodes(self,
sender: Address,
delegation_contract: Address,
public_keys: Sequence[IValidatorPublicKey],
public_keys: Sequence[ValidatorPublicKey],
signed_messages: Sequence[bytes]) -> Transaction:
if len(public_keys) != len(signed_messages):
raise ListsLengthMismatchError("The number of public keys should match the number of signed messages")
Expand Down Expand Up @@ -75,7 +75,7 @@ def _compute_execution_gas_limit_for_nodes_management(self, num_nodes: int) -> i
def create_transaction_for_removing_nodes(self,
sender: Address,
delegation_contract: Address,
public_keys: Sequence[IValidatorPublicKey]) -> Transaction:
public_keys: Sequence[ValidatorPublicKey]) -> Transaction:
num_nodes = len(public_keys)

parts = ["removeNodes"]
Expand All @@ -96,7 +96,7 @@ def create_transaction_for_removing_nodes(self,
def create_transaction_for_staking_nodes(self,
sender: Address,
delegation_contract: Address,
public_keys: Sequence[IValidatorPublicKey]) -> Transaction:
public_keys: Sequence[ValidatorPublicKey]) -> Transaction:
num_nodes = len(public_keys)

parts = ["stakeNodes"]
Expand All @@ -118,7 +118,7 @@ def create_transaction_for_staking_nodes(self,
def create_transaction_for_unbonding_nodes(self,
sender: Address,
delegation_contract: Address,
public_keys: Sequence[IValidatorPublicKey]) -> Transaction:
public_keys: Sequence[ValidatorPublicKey]) -> Transaction:
num_nodes = len(public_keys)

parts = ["unBondNodes"]
Expand All @@ -140,7 +140,7 @@ def create_transaction_for_unbonding_nodes(self,
def create_transaction_for_unstaking_nodes(self,
sender: Address,
delegation_contract: Address,
public_keys: Sequence[IValidatorPublicKey]) -> Transaction:
public_keys: Sequence[ValidatorPublicKey]) -> Transaction:
num_nodes = len(public_keys)

parts = ["unStakeNodes"]
Expand All @@ -162,7 +162,7 @@ def create_transaction_for_unstaking_nodes(self,
def create_transaction_for_unjailing_nodes(self,
sender: Address,
delegation_contract: Address,
public_keys: Sequence[IValidatorPublicKey],
public_keys: Sequence[ValidatorPublicKey],
amount: int) -> Transaction:
num_nodes = len(public_keys)

Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pytest
pytest-cov
flake8
autopep8
black
pre-commit
ipykernel
sphinx
Expand Down

0 comments on commit 88843cb

Please sign in to comment.