Query Base Classes
OracleQuery
¶
Bases: Serializable
Oracle Query
An OracleQuery specifies how to pose a question to the Tellor Oracle and how to format/interpret the response.
The OracleQuery class serves as the base class for all Queries, and implements default behaviors. Each subclass corresponds to a unique Query Type supported by the TellorX network.
All public attributes of an OracleQuery represent a parameter that can be used to customize the query.
The base class provides:
-
Generation of the query
descriptor
JSON string. This string provides a simple platform and language independent way to identify a query. -
Calculation of the
id
field fromquery_data
. This value is used for theTellorX.Oracle.tipQuery()
andTellorX.Oracle.submitValue()
contract calls.
Subclasses must provide:
- Encoding of the
descriptor
string to compute thequery_data
attribute, which is used for thedata
field of aTellorX.Oracle.tipQuery()
contract call.
Source code in telliot_feeds/queries/query.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
value_type: ValueType
property
¶
Returns the ValueType expected by the current Query configuration
The value type defines required data type/structure of the
value
submitted to the contract through
TellorX.Oracle.submitValue()
This method must be implemented by subclasses
descriptor: str
property
¶
Get the query descriptor string.
The Query descriptor is a unique string representation of the query, including all parameter values. The string must be in valid JSON format (http://www.json.org).
query_id: bytes
property
¶
Returns the query id
for use with the
TellorX.Oracle.tipQuery()
and TellorX.Oracle.submitValue()
contract calls.
query_data: bytes
property
¶
Encode the query descriptor
to create the query data
field for
use in the TellorX.Oracle.tipQuery()
contract call.
This method must be implemented by subclasses
get_query_from_data(query_data)
staticmethod
¶
Recreate an oracle query from query_data
Source code in telliot_feeds/queries/query.py
90 91 92 93 |
|
JsonQuery
¶
Bases: OracleQuery
An Oracle Query that uses JSON-encoding to compute the query_data.
Source code in telliot_feeds/queries/json_query.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
query_data: bytes
property
¶
Encode the query descriptor
to create the query data
field for
use in the TellorX.Oracle.tipQuery()
contract call.
get_query_from_data(query_data)
staticmethod
¶
Recreate an oracle query from query_data
Source code in telliot_feeds/queries/json_query.py
16 17 18 19 20 21 |
|
AbiQuery
¶
Bases: OracleQuery
An Oracle Query that uses ABI-encoding to compute the query_data.
Attributes:
Name | Type | Description |
---|---|---|
abi |
ClassVar[list[dict[str, str]]]
|
The ABI used for encoding/decoding parameters.
Each subclass must defind the ABI.
The ABI is an ordered list, with one entry for each query parameter.
Each parameter should include a dict with two entries:
{"name": |
Source code in telliot_feeds/queries/abi_query.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
query_data: bytes
property
¶
Encode the query type and parameters to create the query data.
This method uses ABI encoding to encode the query's parameter values.
get_query_from_data(query_data)
staticmethod
¶
Recreate an oracle query from the query_data
field
Source code in telliot_feeds/queries/abi_query.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|