Example #1
0
 def getDelegateInfo(self, staking_blocknum, del_address, node_id, from_address=None):
     """
     Query current single delegation information
     :param staking_blocknum: Block height at the time of staking
     :param del_address: Client's account address
     :param node_id: Verifier's node ID
     :param from_address: Used to call the rpc call method
     :return:
     todo fill
     """
     del_address = bech32_address_bytes(del_address)
     data = rlp.encode([rlp.encode(int(1104)), rlp.encode(staking_blocknum), rlp.encode(del_address), rlp.encode(bytes.fromhex(node_id))])
     raw_data = call_obj(self, from_address, self.web3.stakingAddress, data)
     receive = json.loads(str(raw_data, encoding="utf8"))
     try:
         raw_data_dict = receive["Ret"]
         raw_data_dict["Released"] = int(raw_data_dict["Released"], 16)
         raw_data_dict["ReleasedHes"] = int(raw_data_dict["ReleasedHes"], 16)
         raw_data_dict["RestrictingPlan"] = int(raw_data_dict["RestrictingPlan"], 16)
         raw_data_dict["RestrictingPlanHes"] = int(raw_data_dict["RestrictingPlanHes"], 16)
         raw_data_dict["CumulativeIncome"] = int(raw_data_dict["CumulativeIncome"], 16)
         # raw_data_dict["Reduction"] = int(raw_data_dict["Reduction"], 16)
         receive["Ret"] = raw_data_dict
     except:...
     return receive
Example #2
0
 def getRestrictingInfo(self, account, from_address=None):
     """
     Get the lock position information.
     :param account: Locked account release account
     :param from_address: Used to call the rpc call method
     :return:
     todo fill
     """
     # if account[:2] == '0x':
     #     account = account[2:]
     account = bech32_address_bytes(account)
     data = rlp.encode([rlp.encode(int(4100)), rlp.encode(account)])
     raw_data = call_obj(self, from_address, self.web3.restrictingAddress, data)
     receive = json.loads(str(raw_data, encoding="ISO-8859-1"))
     try:
         raw_data_dict = receive["Ret"]
         raw_data_dict["balance"] = int(raw_data_dict["balance"], 16)
         raw_data_dict["Pledge"] = int(raw_data_dict["Pledge"], 16)
         raw_data_dict["debt"] = int(raw_data_dict["debt"], 16)
         if raw_data_dict["plans"]:
             for i in raw_data_dict["plans"]:
                 i["amount"] = int(i["amount"], 16)
         receive["Ret"] = raw_data_dict
     except:...
     return receive
Example #3
0
 def getStakingReward(self, from_address=None):
     data = rlp.encode([rlp.encode(int(1201))])
     raw_data = call_obj(self, from_address, self.web3.stakingAddress, data)
     receive = json.loads(str(raw_data, encoding="ISO-8859-1"))
     ret = receive["Ret"]
     receive["Ret"] = int(str(ret), 16)
     return receive
Example #4
0
 def checkDuplicateSign(self,
                        typ,
                        node_id,
                        block_number,
                        from_address=None):
     """
     Check if the node has been reported too much
     :param typ: Represents double sign type, 1:prepareBlock, 2: prepareVote, 3:viewChange
     :param check_address: Reported node address
     :param block_number: Duplicate-signed block height
     :param from_address: Used to call the rpc call method
     :return:
     todo fill
     """
     data = rlp.encode([
         rlp.encode(int(3001)),
         rlp.encode(int(typ)),
         rlp.encode(bytes.fromhex(node_id)),
         rlp.encode(block_number)
     ])
     raw_data = call_obj(self, from_address, self.web3.penaltyAddress, data)
     receive = str(raw_data, encoding="ISO-8859-1")
     if receive == "":
         return receive
     return json.loads(receive)
Example #5
0
 def getCandidateInfo(self, node_id, from_address=None):
     """
     Query the staking information of the current node
     :param node_id: Verifier's node ID
     :param from_address: Used to call the rpc call method
     :return:
     todo fill
     """
     data = rlp.encode([rlp.encode(int(1105)), rlp.encode(bytes.fromhex(node_id))])
     raw_data = call_obj(self, from_address, self.web3.stakingAddress, data)
     parse = str(raw_data, encoding="utf8").replace('\\', '').replace('"{', '{').replace('}"', '}')
     receive = json.loads(parse)
     try:
         raw_data_dict = receive["Ret"]
         raw_data_dict["Shares"] = int(raw_data_dict["Shares"], 16)
         raw_data_dict["Released"] = int(raw_data_dict["Released"], 16)
         raw_data_dict["ReleasedHes"] = int(raw_data_dict["ReleasedHes"], 16)
         raw_data_dict["RestrictingPlan"] = int(raw_data_dict["RestrictingPlan"], 16)
         raw_data_dict["RestrictingPlanHes"] = int(raw_data_dict["RestrictingPlanHes"], 16)
         raw_data_dict["DelegateRewardTotal"] = int(raw_data_dict["DelegateRewardTotal"], 16)
         raw_data_dict["DelegateTotal"] = int(raw_data_dict["DelegateTotal"], 16)
         raw_data_dict["DelegateTotalHes"] = int(raw_data_dict["DelegateTotalHes"], 16)
         receive["Ret"] = raw_data_dict
     except:...
     return receive
Example #6
0
 def getActiveVersion(self, from_address=None):
     """
     Query the chain effective version of the node
     :param from_address: Used to call the rpc call method
     :return:
     todo fill
     """
     data = rlp.encode([rlp.encode(int(2103))])
     return parse_data(call_obj(self, from_address, self.pipAddress, data))
Example #7
0
 def listProposal(self, from_address=None):
     """
     Query proposal list
     :param from_address: Used to call the rpc call method
     :return:
     todo fill
     """
     data = rlp.encode([rlp.encode(int(2102))])
     return parse_data(call_obj(self, from_address, self.pipAddress, data))
Example #8
0
 def getRelatedListByDelAddr(self, del_addr, from_address=None):
     """
     Query the NodeID and pledge ID of the node entrusted by the current account address
     :param del_addr: Client's account address
     :param from_address: Used to call the rpc call method
     :return:
     todo fill
     """
     del_addr = bech32_address_bytes(del_addr)
     data = rlp.encode([rlp.encode(int(1103)), rlp.encode(del_addr)])
     raw_data = call_obj(self, from_address, self.web3.stakingAddress, data)
     return parse_str(raw_data)
Example #9
0
 def listGovernParam(self, module=None, from_address=None):
     """
     Query governance parameter list
     :param module
     :param from_address: Used to call the rpc call method
     :return:
     todo fill
     """
     if module is None:
         module = ""
     data = rlp.encode([rlp.encode(int(2106)), rlp.encode(module)])
     return parse_data(call_obj(self, from_address, self.pipAddress, data))
Example #10
0
 def getGovernParamValue(self, module, name, from_address=None):
     """
     Query the current block height governance parameter value
     :param module: Parameter module
     :param name: parameter name
     :param from_address:
     :return:
     """
     data = rlp.encode(
         [rlp.encode(int(2104)),
          rlp.encode(module),
          rlp.encode(name)])
     return parse_data(call_obj(self, from_address, self.pipAddress, data))
Example #11
0
 def getTallyResult(self, proposal_id, from_address=None):
     """
     Query proposal results
     :param proposal_id: proposal id
     :param from_address: Used to call the rpc call method
     :return:
     todo fill
     """
     if proposal_id[:2] == '0x':
         proposal_id = proposal_id[2:]
     data = rlp.encode(
         [rlp.encode(int(2101)),
          rlp.encode(bytes.fromhex(proposal_id))])
     return parse_data(call_obj(self, from_address, self.pipAddress, data))
Example #12
0
 def getValidatorList(self, from_address=None):
     """
     Query the list of certified for the current consensus cycle
     :param from_address: Used to call the rpc call method
     :return:
     todo fill
     """
     data = rlp.encode([rlp.encode(int(1101))])
     raw_data = call_obj(self, from_address, self.web3.stakingAddress, data)
     parse = parse_str(raw_data)
     try:
         raw_data = parse["Ret"]
         for i in raw_data:
             i["Shares"] = int(i["Shares"], 16)
     except:...
     return parse
Example #13
0
 def getDelegateReward(self, from_address, node_ids=[]):
     node_id_bytes = [bytes.fromhex(node_id) for node_id in node_ids]
     tmp_from_address = bech32_address_bytes(from_address)
     data = [rlp.encode(int(5100)), rlp.encode(tmp_from_address), rlp.encode(node_id_bytes)]
     data = rlp.encode(data)
     raw_data = call_obj(self, from_address, self.web3.delegateRewardAddress, data)
     receive = json.loads(str(raw_data, encoding="ISO-8859-1"))
     try:
         raw_data_dict = receive["Ret"]
         result = []
         for d in raw_data_dict:
             d["reward"] = int(d["reward"], 16)
             result.append(d)
         receive["Ret"] = result
     except:...
     return receive
Example #14
0
 def getVerifierList(self, from_address=None):
     """
     Query the certified queue for the current billing cycle
     :param from_address: Used to call the rpc call method
     :return:
     todo fill
     """
     data = rlp.encode([rlp.encode(int(1100))])
     raw_data = call_obj(self, from_address, self.stakingAddress, data)
     parse = parse_str(raw_data)
     try:
         raw_data = parse["Ret"]
         for i in raw_data:
             i["Shares"] = int(i["Shares"], 16)
     except:
         ...
     return parse
Example #15
0
 def getCandidateList(self, from_address=None):
     """
     Query all real-time candidate lists
     :param from_address: Used to call the rpc call method
     :return:
     todo fill
     """
     data = rlp.encode([rlp.encode(int(1102))])
     raw_data = call_obj(self, from_address, self.web3.stakingAddress, data)
     parse = parse_str(raw_data)
     try:
         raw_data = parse["Ret"]
         for i in raw_data:
             i["Shares"] = int(i["Shares"], 16)
             i["Released"] = int(i["Released"], 16)
             i["ReleasedHes"] = int(i["ReleasedHes"], 16)
             i["RestrictingPlan"] = int(i["RestrictingPlan"], 16)
             i["RestrictingPlanHes"] = int(i["RestrictingPlanHes"], 16)
     except:...
     return parse
Example #16
0
 def getAccuVerifiersCount(self,
                           proposal_id,
                           block_hash,
                           from_address=None):
     """
     Query the cumulative number of votes for the proposal
     :param proposal_id:  proposal id
     :param block_hash: block hash
     :param from_address: Used to call the rpc call method
     :return:
     todo fill
     """
     if proposal_id[:2] == '0x':
         proposal_id = proposal_id[2:]
     if block_hash[:2] == '0x':
         block_hash = block_hash[2:]
     data = rlp.encode([
         rlp.encode(int(2105)),
         rlp.encode(bytes.fromhex(proposal_id)),
         rlp.encode(bytes.fromhex(block_hash))
     ])
     return parse_data(call_obj(self, from_address, self.pipAddress, data))
Example #17
0
 def getAvgPackTime(self, from_address=None):
     data = rlp.encode([rlp.encode(int(1202))])
     raw_data = call_obj(self, from_address, self.web3.stakingAddress, data)
     receive = json.loads(str(raw_data, encoding="ISO-8859-1"))
     return receive