示例#1
0
    def get_pri_key(self, addr, pww):
        method_nm = "getPriKey"

        p_list = [self.chain, addr, pww]
        request = get_top(method_nm, p_list, self.url4)
        resp_d, rstr = SendRequest.send_request(request)
        return resp_d.get('result')
示例#2
0
 def getaccounts(self):
     method_nm = "getAccountList"
     length = 287
     p_list = [self.chain, self.asset, length]
     request = get_top(method_nm, p_list, self.url3)
     resp1, rstr = SendRequest.send_request(request)
     results_d = resp1.get("result")
     return results_d
示例#3
0
    def get_account_balance(self):
        method_nm = "getAccountBalance"
        for receiver in self.receivers:
            p_list = [self.chain, self.chain, self.asset, receiver]
            request = get_top(method_nm, p_list, self.url3)
            response = SendRequest.send_request(request)
            results_d, rstr = json.loads(response.text)

            total_balance = results_d.get("totalBalance")
            print("totalBalance: " + receiver + ":  " + str(total_balance))
    def get_contract_prod_reviews(self, contract):
        return_type = "() return String"

        method_nm = "invokeView"
        contract_methodname = "getAllProductIds"
        args = []
        p_list = [self.chain, contract, contract_methodname, return_type, args]
        request = get_top(method_nm, p_list, self.url3)
        resp1 = SendRequest.send_request(request)

        return_type = "(String productId) return Ljava/util/List;";
        request_type = "getReviews"

        thelist = resp1[0].get("result").get("result")
        res = json.loads(thelist)

        for item in res:
            args = [item]
            p_list = [self.chain, contract, request_type, return_type, args]
            request = get_top(method_nm, p_list, self.url3)
            ans1, ans2 = SendRequest.send_request(request)
            newstr = ans1.get("result").get("result")
            # print("old: ", newstr)
            listem = ["\r\n", '\n', '\\']
            for i in listem:
                newstr = newstr.replace(i, '')

            io = StringIO(newstr)
            newj = json.load(io)
            print(newj[0].get("productId"))

            for j in newj:
                print('-->', j.get("comments"))
            print()


            # print(ndict.get("productId"))
            # cstr = ndict[0].get("comments")
            # dstr = cstr.strip("\r").strip("\n").strip("\\s")
            # print(dstr)
            # print()
        return
    def doit(self, method_nm, p_list, four=0):   #use url for url4
        if four:
            url = self.url4
        else:
            url = self.url3
        request = get_top(method_nm, p_list, url)
        response_d = SendRequest.send_request(request)

        print("  ANSWER to query ", method_nm, " is: ")
        print(url)
        print(" ---------> The response is: " + json.dumps(response_d) + " ---------> \n\n")
示例#6
0
    def get_contract_prod_ids(self, contract):
        return_type = "() return String"

        method_nm = "invokeView"
        contract_methodname = "getAllProductIds"
        args = []
        p_list = [self.chain, contract, contract_methodname, return_type, args]
        request = get_top(method_nm, p_list, self.url3)
        resp1 = SendRequest.send_request(request)
        # results_d, rstr = resp1.get("result")
        print(resp1)
        return resp1
    def doit(self, method_nm, p_list, four=0):  #use url for url4
        if four:
            url = self.url4
        else:
            url = self.url3
        request = get_top(method_nm, p_list, url)
        the_answer = SendRequest.send_request(request)

        print("stat: ", the_answer)
        print("  ANSWER to query ", method_nm, " is: ")
        #        print(" ---------> The response is: " + the_answer.text + " ---------> \n\n")
        return the_answer
示例#8
0
    def transfer(self, base_amt):      #ch assetid address toaddy pw amt rem
        method_nm = 'transfer'
        multiplier = 10**8
        amt = base_amt * multiplier
        #amt = 2000 * (10**8) - 2000

        for receiver in self.receivers:
            print("doing this receiver: ", receiver)
            p_list = [self.chain, self.asset, self.sender, receiver, self.pw, amt, self.remark]
            request = get_top(method_nm, p_list, self.url4)
            resp1, rstr = SendRequest.send_request(request)
            print("resp1: ", rstr)
    def create_account(self):
        rg = 1
        for i in range(rg):
            method_nm = "createAccount"
            p_list = [self.chain, 1, self.pw]
            request = get_top(method_nm, p_list, self.url4)
            response, rstr = SendRequest.send_request(request)
            results_d = response.get("result")

            addr = results_d[0]
            pri_key = self.aks_obj.get_pri_key(addr, self.pw)
            response2 = self.aks_obj.import_pri_key(pri_key)
            bigstr = "\n---created this account: " + addr + "  prikey: " + pri_key + "  pw: " + self.pw
            print("-----" + bigstr)
            logging.info(bigstr)

        print(rstr)
示例#10
0
    def call_contract(self, val, args):
        multiplier = (10**8)
        value_asset = val * multiplier
        gas_limit = 9900000
        gas_price = 25  # anything 25 or over will work
        remark = "call contract"

        method_nm = "contractCall"
        contract_methodname = "writeReview"
        p_list = [
            self.chain, self.sender, self.pw, value_asset, gas_limit,
            gas_price, self.contract, contract_methodname, self.contract_desc,
            args, remark
        ]
        request = get_top(method_nm, p_list, self.url4)
        resp1 = SendRequest.send_request(request)
        results_d, rstr = resp1.get("result")
        print(rstr)
        return rstr
示例#11
0
 def import_pri_key(self, pri_key):
     method_nm = "importPriKey"
     p_list = [self.chain, pri_key, self.pw]
     request = get_top(method_nm, p_list, self.url3)
     resp_d, rstr = SendRequest.send_request(request)
     return resp_d.get('result')
示例#12
0
 def get_account_byprikey(self, pk):
     method_nm = "getAddressByPriKey"
     p_list = [self.chain, pk]
     request = get_top(method_nm, p_list, self.url3)
     resp_d, rstr = SendRequest.send_request(request)
     return resp_d.get('result')