Esempio n. 1
0
    def transferFunds(self, source, destination, amountStr, memo="memo", force=False, waitForTransBlock=False):
        assert isinstance(amountStr, str)
        assert(source)
        assert(isinstance(source, Account))
        assert(destination)
        assert(isinstance(destination, Account))

        cmd="%s %s -v transfer -j %s %s" % (
            Utils.EnuClientPath, self.endpointArgs, source.name, destination.name)
        cmdArr=cmd.split()
        cmdArr.append(amountStr)
        cmdArr.append(memo)
        if force:
            cmdArr.append("-f")
        s=" ".join(cmdArr)
        if Utils.Debug: Utils.Print("cmd: %s" % (s))
        trans=None
        try:
            trans=Utils.runCmdArrReturnJson(cmdArr)
        except subprocess.CalledProcessError as ex:
            msg=ex.output.decode("utf-8")
            Utils.Print("ERROR: Exception during funds transfer. %s" % (msg))
            return None

        assert(trans)
        transId=Node.getTransId(trans)
        if waitForTransBlock and not self.waitForTransInBlock(transId):
            return None

        return trans
Esempio n. 2
0
    def transferFunds(self, source, destination, amountStr, memo="memo", force=False, waitForTransBlock=False):
        assert isinstance(amountStr, str)
        assert(source)
        assert(isinstance(source, Account))
        assert(destination)
        assert(isinstance(destination, Account))

        cmd="%s %s -v transfer -j %s %s" % (
            Utils.EosClientPath, self.endpointArgs, source.name, destination.name)
        cmdArr=cmd.split()
        cmdArr.append(amountStr)
        cmdArr.append(memo)
        if force:
            cmdArr.append("-f")
        s=" ".join(cmdArr)
        if Utils.Debug: Utils.Print("cmd: %s" % (s))
        trans=None
        try:
            trans=Utils.runCmdArrReturnJson(cmdArr)
        except subprocess.CalledProcessError as ex:
            msg=ex.output.decode("utf-8")
            Utils.Print("ERROR: Exception during funds transfer. %s" % (msg))
            return None

        assert(trans)
        transId=Node.getTransId(trans)
        if waitForTransBlock and not self.waitForTransInBlock(transId):
            return None

        return trans
Esempio n. 3
0
 def get_block(self, blockNum):
     request_body = {"block_num_or_id": blockNum}
     return Utils.runCmdArrReturnJson([
         'curl', '-X', 'POST', '-H', 'Content-Type: application/json', '-H',
         'Accept: application/json', self.endpoint + 'v1/chain/get_block',
         '--data',
         json.dumps(request_body)
     ])
Esempio n. 4
0
 def pushMessage(self, account, action, data, opts, silentErrors=False):
     cmd="%s %s push action -j %s %s" % (Utils.EnuClientPath, self.endpointArgs, account, action)
     cmdArr=cmd.split()
     if data is not None:
         cmdArr.append(data)
     if opts is not None:
         cmdArr += opts.split()
     s=" ".join(cmdArr)
     if Utils.Debug: Utils.Print("cmd: %s" % (s))
     try:
         trans=Utils.runCmdArrReturnJson(cmdArr)
         return (True, trans)
     except subprocess.CalledProcessError as ex:
         msg=ex.output.decode("utf-8")
         if not silentErrors:
             Utils.Print("ERROR: Exception during push message. %s" % (msg))
         return (False, msg)
Esempio n. 5
0
 def pushMessage(self, account, action, data, opts, silentErrors=False):
     cmd="%s %s push action -j %s %s" % (Utils.EosClientPath, self.endpointArgs, account, action)
     cmdArr=cmd.split()
     if data is not None:
         cmdArr.append(data)
     if opts is not None:
         cmdArr += opts.split()
     s=" ".join(cmdArr)
     if Utils.Debug: Utils.Print("cmd: %s" % (s))
     try:
         trans=Utils.runCmdArrReturnJson(cmdArr)
         return (True, trans)
     except subprocess.CalledProcessError as ex:
         msg=ex.output.decode("utf-8")
         if not silentErrors:
             Utils.Print("ERROR: Exception during push message. %s" % (msg))
         return (False, msg)
Esempio n. 6
0
 def get_info(self):
     return Utils.runCmdArrReturnJson([
         'curl', '-H', 'Accept: application/json',
         self.endpoint + 'v1/chain/get_info'
     ])