示例#1
0
    def add_change_ownerid(actions: List, validator_info: EntityResponse):
        print("--------Change owner id-----\n")
        print(
            f"{bcolors.WARNING}\nPlease ensure you set owner account to a valid Radix account that you control (such "
            f"as one created with the Desktop Wallet), as this will also be where any validator fee emissions will be "
            f"credited. It is strongly advised to NOT use the Radix account of your node itself.{bcolors.ENDC} "
        )
        owner = [
            x for x in validator_info.data_objects
            if x.type == 'PreparedValidatorOwner'
        ]
        current_value = owner[0]["owner"]["address"]
        Helpers.print_coloured_line(
            f"\nCurrent settings for owner id={current_value}")

        owner_id = input(
            "\nEnter the new owner id or press Enter not to change:").strip()
        if owner_id != "":
            if owner_id != current_value:
                actions.append(Action.set_validator_owner(owner_id))
                return actions
            Helpers.print_coloured_line(
                "Owner entered is same . So action will not be applied",
                bcolors.WARNING)

        return actions
示例#2
0
 def registration(actions: List, validator_info: EntityResponse, health):
     value_to_set = None
     print("\n--------Registration-----\n")
     registration = [
         x for x in validator_info.data_objects
         if x.type == 'PreparedValidatorRegistered'
     ]
     Helpers.print_coloured_line(
         f"Current registration status: {registration[0].registered}",
         bcolors.OKBLUE)
     ask_registration = input(
         Helpers.print_coloured_line(
             "\nEnter the new registration setting [true/false].Press enter if no change required ",
             bcolors.BOLD,
             return_string=True))
     if ask_registration.lower() == "true" or ask_registration.lower(
     ) == "false":
         value_to_set = json.loads(ask_registration.lower())
         actions.append(Action.set_validator_registeration(value_to_set))
         return actions
     else:
         Helpers.print_coloured_line(
             "There are no changes to apply or user input is wrong",
             bcolors.WARNING)
     return actions
示例#3
0
    def check_health(self):
        Helpers.print_coloured_line("Checking status of the node\n", bcolors.BOLD)
        health = self.health()

        if health["status"] != "UP":
            Helpers.print_coloured_line(
                f"Node status is {health['status']} Rerun the command once node is completely synced",
                bcolors.WARNING)
            proceed = input(print("Do you want to continue [Y/n]?"))
            if not Helpers.check_Yes(proceed):
                sys.exit()
        return health    
示例#4
0
    def add_validation_fee(actions: List, validator_info: EntityResponse):
        print("\n--------Validator fees-----\n")

        print(
            f"{bcolors.WARNING}\nValidator fee may be decreased at any time, but increasing it incurs a delay of "
            f"approx. 2 weeks. Please set it carefully{bcolors.ENDC}")
        validator_fee = [
            x for x in validator_info.data_objects
            if x.type == 'PreparedValidatorFee'
        ]
        Helpers.print_coloured_line(
            f"Current validator fees are {int(validator_fee[0]['fee']) / 100}",
            bcolors.OKBLUE)
        ask_validator_fee_setup = input(
            "Do you want to setup or update validator fees [Y/n]?:")
        if Helpers.check_Yes(ask_validator_fee_setup):
            validatorFee = int(Helpers.check_validatorFee_input() * 100)
            actions.append(Action.set_validator_fee(validatorFee))
            return actions
        return actions
示例#5
0
 def validator_metadata(actions: List, validator_info: EntityResponse,
                        health):
     print("\n--------Update validator meta info-----\n")
     validatorMetadata = [
         x for x in validator_info.data_objects
         if x.type == 'ValidatorMetadata'
     ]
     Helpers.print_coloured_line(
         f"Current name: {validatorMetadata[0]['name']}", bcolors.OKBLUE)
     Helpers.print_coloured_line(
         f"Current url: {validatorMetadata[0]['url']}", bcolors.OKBLUE)
     ask_add_or_change_info = input(
         "\nDo you want add/change the validator name and info url [Y/n]?")
     if Helpers.check_Yes(ask_add_or_change_info):
         validator_name = input(
             Helpers.print_coloured_line(
                 f"Enter the Name of your validator to be updated:",
                 bcolors.OKBLUE,
                 return_string=True))
         validator_url = input(
             Helpers.print_coloured_line(
                 f"Enter Info URL of your validator to be updated:",
                 bcolors.OKBLUE,
                 return_string=True))
         actions.append(
             Action.set_validator_metadata(validator_name, validator_url))
         return actions
     return actions
示例#6
0
 def setup_update_delegation(actions: List, validator_info: EntityResponse):
     print("--------Allow delegation-----\n")
     print(
         f"{bcolors.WARNING}\nEnabling allowDelegation means anyone can delegate stake to your node. Disabling it "
         f"later will not remove this stake.{bcolors.ENDC}")
     allow_delegation = [
         x for x in validator_info.data_objects
         if x.type == 'ValidatorAllowDelegation'
     ]
     current_value: bool = allow_delegation[0]['allow_delegation']
     Helpers.print_coloured_line(
         f"\nCurrent setting for allowing delegation : {current_value}",
         bcolors.BOLD)
     allow_delegation = input(
         Helpers.print_coloured_line(
             "\nEnter the new allow delegation setting [true/false].Press enter if no change required ",
             bcolors.BOLD,
             return_string=True))
     if allow_delegation.lower() == "true":
         if not bool(current_value):
             actions.append(
                 Action.set_validator_allow_delegation(
                     json.loads(allow_delegation.lower())))
             return actions
         else:
             Helpers.print_coloured_line(
                 f"\nThere is no change in the delegation status from the current one {current_value}"
                 f". So not updating this action", bcolors.WARNING)
     elif allow_delegation.lower() == "false":
         if bool(current_value):
             actions.append(
                 Action.set_validator_allow_delegation(
                     json.loads(allow_delegation.lower())))
             return actions
         else:
             Helpers.print_coloured_line(
                 f"\nThere is no change in the delegation status from the current one {validator_info['allowDelegation']}"
                 f"\nSo not updating this action")
     return actions