From 32603100b9f90ed709c5c0c01c66a408ddb2be9a Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Tue, 3 Dec 2024 13:32:53 +0200 Subject: [PATCH] fix hardcoded address to use config hrp --- .../delegation/staking_provider.py | 3 +- multiversx_sdk_cli/validators/core.py | 30 +++++++++---------- pyproject.toml | 2 +- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/multiversx_sdk_cli/delegation/staking_provider.py b/multiversx_sdk_cli/delegation/staking_provider.py index 418418dc..977e7424 100644 --- a/multiversx_sdk_cli/delegation/staking_provider.py +++ b/multiversx_sdk_cli/delegation/staking_provider.py @@ -5,6 +5,7 @@ Transaction, ValidatorPublicKey) from multiversx_sdk.core.serializer import args_to_string +from multiversx_sdk_cli.config import get_address_hrp from multiversx_sdk_cli.errors import BadUsage from multiversx_sdk_cli.interfaces import IAddress, ITransaction from multiversx_sdk_cli.validators.validators_file import ValidatorsFile @@ -408,7 +409,7 @@ def prepare_transaction_for_setting_metadata(self, owner: IAccount, args: Any) - return tx def prepare_transaction_for_creating_delegation_contract_from_validator(self, owner: IAccount, args: Any) -> ITransaction: - receiver = "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqylllslmq6y6" + receiver = Address.new_from_hex("000000000000000000010000000000000000000000000000000000000004ffff", get_address_hrp()).to_bech32() max_cap = int(args.max_cap) fee = int(args.fee) data = "makeNewContractFromValidatorData@" + args_to_string([max_cap, fee]) diff --git a/multiversx_sdk_cli/validators/core.py b/multiversx_sdk_cli/validators/core.py index 0e6e9f95..f71d64ee 100644 --- a/multiversx_sdk_cli/validators/core.py +++ b/multiversx_sdk_cli/validators/core.py @@ -8,14 +8,14 @@ from multiversx_sdk_cli.accounts import Account from multiversx_sdk_cli.cli_password import load_password from multiversx_sdk_cli.config import (GAS_PER_DATA_BYTE, MIN_GAS_LIMIT, - MetaChainSystemSCsCost) + MetaChainSystemSCsCost, get_address_hrp) from multiversx_sdk_cli.contracts import prepare_execute_transaction_data from multiversx_sdk_cli.errors import BadUsage from multiversx_sdk_cli.validators.validators_file import ValidatorsFile logger = logging.getLogger("validators") -VALIDATORS_SMART_CONTRACT_ADDRESS = "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqplllst77y4l" +VALIDATORS_SMART_CONTRACT_ADDRESS_HEX = "000000000000000000010000000000000000000000000000000000000001ffff" def prepare_args_for_stake(args: Any): @@ -36,7 +36,7 @@ def prepare_args_for_stake(args: Any): data, gas_limit = prepare_transaction_data_for_stake(node_operator.address, validators_file_path, reward_address) args.data = data - args.receiver = VALIDATORS_SMART_CONTRACT_ADDRESS + args.receiver = Address.new_from_hex(VALIDATORS_SMART_CONTRACT_ADDRESS_HEX, get_address_hrp()).to_bech32() if args.estimate_gas: args.gas_limit = gas_limit @@ -74,7 +74,7 @@ def prepare_transaction_data_for_stake(node_operator_address: Address, validator def prepare_args_for_top_up(args: Any): args.data = 'stake' - args.receiver = VALIDATORS_SMART_CONTRACT_ADDRESS + args.receiver = Address.new_from_hex(VALIDATORS_SMART_CONTRACT_ADDRESS_HEX, get_address_hrp()).to_bech32() if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args.data, MetaChainSystemSCsCost.STAKE, 1) @@ -83,7 +83,7 @@ def prepare_args_for_top_up(args: Any): def prepare_args_for_unstake(args: Any): parsed_keys, num_keys = utils.parse_keys(args.nodes_public_keys) args.data = 'unStake' + parsed_keys - args.receiver = VALIDATORS_SMART_CONTRACT_ADDRESS + args.receiver = Address.new_from_hex(VALIDATORS_SMART_CONTRACT_ADDRESS_HEX, get_address_hrp()).to_bech32() if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args.data, MetaChainSystemSCsCost.UNSTAKE, num_keys) @@ -92,7 +92,7 @@ def prepare_args_for_unstake(args: Any): def prepare_args_for_unbond(args: Any): parsed_keys, num_keys = utils.parse_keys(args.nodes_public_keys) args.data = 'unBond' + parsed_keys - args.receiver = VALIDATORS_SMART_CONTRACT_ADDRESS + args.receiver = Address.new_from_hex(VALIDATORS_SMART_CONTRACT_ADDRESS_HEX, get_address_hrp()).to_bech32() if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args.data, MetaChainSystemSCsCost.UNBOND, num_keys) @@ -101,7 +101,7 @@ def prepare_args_for_unbond(args: Any): def prepare_args_for_unjail(args: Any): parsed_keys, num_keys = utils.parse_keys(args.nodes_public_keys) args.data = 'unJail' + parsed_keys - args.receiver = VALIDATORS_SMART_CONTRACT_ADDRESS + args.receiver = Address.new_from_hex(VALIDATORS_SMART_CONTRACT_ADDRESS_HEX, get_address_hrp()).to_bech32() if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args.data, MetaChainSystemSCsCost.UNJAIL, num_keys) @@ -110,7 +110,7 @@ def prepare_args_for_unjail(args: Any): def prepare_args_for_change_reward_address(args: Any): reward_address = Address.new_from_bech32(args.reward_address) args.data = 'changeRewardAddress@' + reward_address.hex() - args.receiver = VALIDATORS_SMART_CONTRACT_ADDRESS + args.receiver = Address.new_from_hex(VALIDATORS_SMART_CONTRACT_ADDRESS_HEX, get_address_hrp()).to_bech32() if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args.data, MetaChainSystemSCsCost.CHANGE_REWARD_ADDRESS) @@ -118,7 +118,7 @@ def prepare_args_for_change_reward_address(args: Any): def prepare_args_for_claim(args: Any): args.data = 'claim' - args.receiver = VALIDATORS_SMART_CONTRACT_ADDRESS + args.receiver = Address.new_from_hex(VALIDATORS_SMART_CONTRACT_ADDRESS_HEX, get_address_hrp()).to_bech32() if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args.data, MetaChainSystemSCsCost.CLAIM) @@ -128,7 +128,7 @@ def prepare_args_for_unstake_nodes(args: Any): parsed_keys, num_keys = utils.parse_keys(args.nodes_public_keys) args.data = 'unStakeNodes' + parsed_keys - args.receiver = VALIDATORS_SMART_CONTRACT_ADDRESS + args.receiver = Address.new_from_hex(VALIDATORS_SMART_CONTRACT_ADDRESS_HEX, get_address_hrp()).to_bech32() if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args.data, MetaChainSystemSCsCost.UNSTAKE, num_keys) @@ -137,7 +137,7 @@ def prepare_args_for_unstake_tokens(args: Any): args.data = 'unStakeTokens' args.data += '@' + utils.str_int_to_hex_str(str(args.unstake_value)) - args.receiver = VALIDATORS_SMART_CONTRACT_ADDRESS + args.receiver = Address.new_from_hex(VALIDATORS_SMART_CONTRACT_ADDRESS_HEX, get_address_hrp()).to_bech32() if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args.data, MetaChainSystemSCsCost.UNSTAKE_TOKENS) @@ -146,7 +146,7 @@ def prepare_args_for_unbond_nodes(args: Any): parsed_keys, num_keys = utils.parse_keys(args.nodes_public_keys) args.data = 'unBondNodes' + parsed_keys - args.receiver = VALIDATORS_SMART_CONTRACT_ADDRESS + args.receiver = Address.new_from_hex(VALIDATORS_SMART_CONTRACT_ADDRESS_HEX, get_address_hrp()).to_bech32() if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args.data, MetaChainSystemSCsCost.UNBOND, num_keys) @@ -155,7 +155,7 @@ def prepare_args_for_unbond_tokens(args: Any): args.data = 'unBondTokens' args.data += '@' + utils.str_int_to_hex_str(str(args.unbond_value)) - args.receiver = VALIDATORS_SMART_CONTRACT_ADDRESS + args.receiver = Address.new_from_hex(VALIDATORS_SMART_CONTRACT_ADDRESS_HEX, get_address_hrp()).to_bech32() if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args.data, MetaChainSystemSCsCost.UNBOND_TOKENS) @@ -163,7 +163,7 @@ def prepare_args_for_unbond_tokens(args: Any): def prepare_args_for_clean_registered_data(args: Any): args.data = 'cleanRegisteredData' - args.receiver = VALIDATORS_SMART_CONTRACT_ADDRESS + args.receiver = Address.new_from_hex(VALIDATORS_SMART_CONTRACT_ADDRESS_HEX, get_address_hrp()).to_bech32() if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args.data, MetaChainSystemSCsCost.STAKE) @@ -172,7 +172,7 @@ def prepare_args_for_restake_unstaked_nodes(args: Any): parsed_keys, num_keys = utils.parse_keys(args.nodes_public_keys) args.data = 'reStakeUnStakedNodes' + parsed_keys - args.receiver = VALIDATORS_SMART_CONTRACT_ADDRESS + args.receiver = Address.new_from_hex(VALIDATORS_SMART_CONTRACT_ADDRESS_HEX, get_address_hrp()).to_bech32() if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args.data, MetaChainSystemSCsCost.STAKE, num_keys) diff --git a/pyproject.toml b/pyproject.toml index 0002f4ee..b6e91c5e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "multiversx-sdk-cli" -version = "9.9.0" +version = "9.9.1" authors = [ { name="MultiversX" }, ]