def test_str_to_hex_str(self): my_str = "1000000" hex_str = Converters.str_int_to_hex_str(my_str) self.assertEqual("0f4240", hex_str) my_str = "100000000000000000" hex_str = Converters.str_int_to_hex_str(my_str) self.assertEqual("00016345785d8a0000", hex_str)
def prepare_args_for_create_new_staking_contract(args: Any): args.data = 'createNewDelegationContract' args.data += '@' + Converters.str_int_to_hex_str(str(args.total_delegation_cap)) args.data += '@' + Converters.str_int_to_hex_str(str(args.service_fee)) args.receiver = DELEGATION_MANAGER_SC_ADDRESS if args.estimate_gas: # factor is equals 2 because there 2 delegation manager operations when a contract is created args.gas_limit = estimate_system_sc_call(args, MetaChainSystemSCsCost.DELEGATION_MANAGER_OPS, factor=2)
def prepare_args_for_unjail(args: Any): parsed_keys, num_keys = Converters.parse_keys(args.nodes_public_keys) args.data = 'unJail' + parsed_keys args.receiver = AUCTION_SMART_CONTRACT_ADDRESS if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args, MetaChainSystemSCsCost.UNJAIL, num_keys)
def _prepare_args(command: str, args: Any): parsed_keys, num_keys = Converters.parse_keys(args.bls_keys) args.data = command + parsed_keys args.receiver = args.delegation_contract if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args, MetaChainSystemSCsCost.DELEGATION_OPS, num_keys + 1)
def prepare_args_for_unstake_nodes(args: Any): parsed_keys, num_keys = Converters.parse_keys(args.bls_keys) args.data = 'unStakeNodes' + parsed_keys args.receiver = args.delegation_contract if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args, MetaChainSystemSCsCost.DELEGATION_OPS + MetaChainSystemSCsCost.UNSTAKE, num_keys + 1)
def prepare_args_modify_delegation_cap(args: Any): data = 'modifyTotalDelegationCap' data += '@' + Converters.str_int_to_hex_str(str(args.delegation_cap)) args.data = data args.receiver = args.delegation_contract if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args, MetaChainSystemSCsCost.DELEGATION_OPS, 1)
def prepare_args_change_service_fee(args: Any): data = 'changeServiceFee' data += '@' + Converters.str_int_to_hex_str(str(args.service_fee)) args.data = data args.receiver = args.delegation_contract if args.estimate_gas: args.gas_limit = estimate_system_sc_call(args, MetaChainSystemSCsCost.DELEGATION_OPS, 1)
def prepare_args_for_unstake(args: Any): parsed_keys, num_keys = Converters.parse_keys(args.nodes_public_keys) args.data = 'unStake' + parsed_keys args.receiver = VALIDATORS_SMART_CONTRACT_ADDRESS if args.estimate_gas: args.gas_limit = estimate_system_sc_call( args, MetaChainSystemSCsCost.UNSTAKE, num_keys)
def prepare_args_for_unbond_tokens(args: Any): args.data = 'unBondTokens' args.data += '@' + Converters.str_int_to_hex_str(str(args.unbond_value)) args.receiver = VALIDATORS_SMART_CONTRACT_ADDRESS if args.estimate_gas: args.gas_limit = estimate_system_sc_call( args, MetaChainSystemSCsCost.UNBOND_TOKENS)
def test_parse_keys(self): keys = "myKey,newKey,anotherKey" parsed_keys, num_keys = Converters.parse_keys(keys) self.assertEqual(3, num_keys) self.assertEqual("@myKey@newKey@anotherKey", parsed_keys)