def test_converter_tx_results(self):
     """
     Test with different sample transaction results which made from JSON RPC API V2 or V3.
     """
     for tx_result in self.tx_results:
         convert_transaction_result(tx_result)
         self.assertTrue(validate_transaction_result(tx_result))
Esempio n. 2
0
    def get_transaction_result(self, tx_hash: str):
        """
        Returns the transaction result requested by transaction hash.
        Delegates to icx_getTransactionResult RPC method.

        :param tx_hash: Hash of a transaction prefixed with '0x'
        :return A transaction result object
        """
        if is_T_HASH(tx_hash):
            params = {'txHash': tx_hash}
            result = self.__provider.make_request('icx_getTransactionResult', params)
            convert_transaction_result(result)
            return result
        else:
            raise DataTypeException("This hash value is unrecognized.")
Esempio n. 3
0
    def _process_transaction_in_local(self, request: dict) -> dict:
        params = TypeConverter.convert(request, ParamType.TRANSACTION_PARAMS_DATA)
        params['txHash'] = create_tx_hash()
        tx = {
            'method': 'icx_sendTransaction',
            'params': params
        }

        prev_block, tx_results = self._make_and_req_block([tx])
        self._write_precommit_state(prev_block)

        # convert TX result as sdk style
        convert_transaction_result(tx_results[0])

        return tx_results[0]
Esempio n. 4
0
    def get_transaction_result(self,
                               tx_hash: str,
                               full_response: bool = False) -> dict:
        """
        Returns the transaction result requested by transaction hash.
        Delegates to icx_getTransactionResult RPC method.

        :param tx_hash: Hash of a transaction prefixed with '0x'
        :param full_response: Boolean to check whether get naive dict or refined data from server
        :return A transaction result object
        """
        if not is_T_HASH(tx_hash):
            raise DataTypeException("This hash value is unrecognized.")

        params = {'txHash': tx_hash}
        result = self.__provider.make_request('icx_getTransactionResult',
                                              params, full_response)

        if not full_response:
            convert_transaction_result(result)

        return result