Example #1
0
File: iost.py Project: quiz42/pyost
    def exec_tx(self, tx: Transaction) -> TxReceipt:
        """Executes a `Transaction` serialized as a `TransactionRequest`.
        If the `Transaction` has no publisher set, signs it with the default `publisher`.

        Note:
            REST API: POST "/execTx" (tx in the body)

        Args:
            tx: The `Transaction` to serialize.

        Returns:
            The receipt of the transaction as a `TxReceipt` object.
        """
        if tx.publisher is None:
            if self.publisher is None:
                raise ValueError('No publisher has signed the transaction.')
            self.publisher.sign_publish(tx)

        tr: pb.TxReceipt = self._stub.ExecTransaction(tx.to_request_raw())
        return TxReceipt().from_raw(tr)
Example #2
0
File: iost.py Project: quiz42/pyost
    def send_tx(self, tx: Transaction) -> str:
        """Sends a `Transaction` serialized as a `TransactionRequest`.
        If the `Transaction` has no publisher set, signs it with the default `publisher`.

        Notes:
            REST API: POST "/sendTx" (tx in the body)

        Args:
            tx: The `Transaction` to serialize.

        Returns:
            The hash value of the `Transaction` received by the node.
        """
        if tx.publisher == '':
            if self.publisher is None:
                raise ValueError('No publisher has signed the transaction.')
            self.publisher.sign_publish(tx)

        res: pb.SendTransactionResponse = self._stub.SendTransaction(
            tx.to_request_raw())
        return res.hash