Contract Address Details

0x1975a649740DdD6e9f1D08d1A7b0105bFBE7eEA4

Contract Name
WitnetRequestBoardTrust..Default
Creator
0x102cb4–8586da at 0x24df38–ec4f26
Balance
0 Metis
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
3345227
Contract name:
WitnetRequestBoardTrustableDefault




Optimization enabled
true
Compiler version
v0.8.13+commit.abaa5c0e




Optimization runs
200
EVM Version
default




Verified at
2022-05-06 12:00:16.903401Z

Constructor Arguments

0000000000000000000000000000000000000000000000000000000000000001302e352e362d747275737461626c6500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020e90

Arg [0] (bool) : true
Arg [1] (bytes32) : 302e352e362d747275737461626c650000000000000000000000000000000000
Arg [2] (uint256) : 134800

              

Contract source code

// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
pragma experimental ABIEncoderV2;
// File: contracts\interfaces\IWitnetRequestBoardEvents.sol
/// @title Witnet Request Board emitting events interface.
/// @author The Witnet Foundation.
interface IWitnetRequestBoardEvents {
/// Emitted when a Witnet Data Request is posted to the WRB.
event PostedRequest(uint256 queryId, address from);
/// Emitted when a Witnet-solved result is reported to the WRB.
event PostedResult(uint256 queryId, address from);
/// Emitted when all data related to given query is deleted from the WRB.
event DeletedQuery(uint256 queryId, address from);
}
// File: contracts\interfaces\IWitnetRequestBoardReporter.sol
/// @title The Witnet Request Board Reporter interface.
/// @author The Witnet Foundation.
interface IWitnetRequestBoardReporter {
/// Reports the Witnet-provided result to a previously posted request.
/// @dev Will assume `block.timestamp` as the timestamp at which the request was solved.
/// @dev Fails if:
/// @dev - the `_queryId` is not in 'Posted' status.
/// @dev - provided `_drTxHash` is zero;
/// @dev - length of provided `_result` is zero.
/// @param _queryId The unique identifier of the data request.
/// @param _drTxHash The hash of the corresponding data request transaction in Witnet.
/// @param _result The result itself as bytes.
function reportResult(
uint256 _queryId,
bytes32 _drTxHash,
bytes calldata _result
) external;
/// Reports the Witnet-provided result to a previously posted request.
/// @dev Fails if:
/// @dev - called from unauthorized address;
/// @dev - the `_queryId` is not in 'Posted' status.
/// @dev - provided `_drTxHash` is zero;
/// @dev - length of provided `_result` is zero.
/// @param _queryId The unique query identifier
/// @param _timestamp The timestamp of the solving tally transaction in Witnet.
/// @param _drTxHash The hash of the corresponding data request transaction in Witnet.
/// @param _result The result itself as bytes.
function reportResult(
uint256 _queryId,
uint256 _timestamp,
bytes32 _drTxHash,
bytes calldata _result
) external;
/// Reports Witnet-provided results to multiple requests within a single EVM tx.
/// @dev Must emit a PostedResult event for every succesfully reported result.
/// @param _batchResults Array of BatchResult structs, every one containing:
/// - unique query identifier;
/// - timestamp of the solving tally txs in Witnet. If zero is provided, EVM-timestamp will be used instead;
/// - hash of the corresponding data request tx at the Witnet side-chain level;
/// - data request result in raw bytes.
/// @param _verbose If true, must emit a BatchReportError event for every failing report, if any.
function reportResultBatch(BatchResult[] calldata _batchResults, bool _verbose) external;
struct BatchResult {
uint256 queryId;
uint256 timestamp;
bytes32 drTxHash;
bytes cborBytes;
}
event BatchReportError(uint256 queryId, string reason);
}
// File: contracts\interfaces\IWitnetRequest.sol
/// @title The Witnet Data Request basic interface.
/// @author The Witnet Foundation.
interface IWitnetRequest {
/// A `IWitnetRequest` is constructed around a `bytes` value containing
/// a well-formed Witnet Data Request using Protocol Buffers.
function bytecode() external view returns (bytes memory);
/// Returns SHA256 hash of Witnet Data Request as CBOR-encoded bytes.
function hash() external view returns (bytes32);
}
// File: contracts\libs\Witnet.sol
library Witnet {
/// @notice Witnet function that computes the hash of a CBOR-encoded Data Request.
/// @param _bytecode CBOR-encoded RADON.
function hash(bytes memory _bytecode) internal pure returns (bytes32) {
return sha256(_bytecode);
}
/// Struct containing both request and response data related to every query posted to the Witnet Request Board
struct Query {
Request request;
Response response;
address from; // Address from which the request was posted.
}
/// Possible status of a Witnet query.
enum QueryStatus {
Unknown,
Posted,
Reported,
Deleted
}
/// Data kept in EVM-storage for every Request posted to the Witnet Request Board.
struct Request {
IWitnetRequest addr; // The contract containing the Data Request which execution has been requested.
address requester; // Address from which the request was posted.
bytes32 hash; // Hash of the Data Request whose execution has been requested.
uint256 gasprice; // Minimum gas price the DR resolver should pay on the solving tx.
uint256 reward; // Escrowed reward to be paid to the DR resolver.
}
/// Data kept in EVM-storage containing Witnet-provided response metadata and result.
struct Response {
address reporter; // Address from which the result was reported.
uint256 timestamp; // Timestamp of the Witnet-provided result.
bytes32 drTxHash; // Hash of the Witnet transaction that solved the queried Data Request.
bytes cborBytes; // Witnet-provided result CBOR-bytes to the queried Data Request.
}
/// Data struct containing the Witnet-provided result to a Data Request.
struct Result {
bool success; // Flag stating whether the request could get solved successfully, or not.
CBOR value; // Resulting value, in CBOR-serialized bytes.
}
/// Data struct following the RFC-7049 standard: Concise Binary Object Representation.
struct CBOR {
Buffer buffer;
uint8 initialByte;
uint8 majorType;
uint8 additionalInformation;
uint64 len;
uint64 tag;
}
/// Iterable bytes buffer.
struct Buffer {
bytes data;
uint32 cursor;
}
/// Witnet error codes table.
enum ErrorCodes {
// 0x00: Unknown error. Something went really bad!
Unknown,
// Script format errors
/// 0x01: At least one of the source scripts is not a valid CBOR-encoded value.
SourceScriptNotCBOR,
/// 0x02: The CBOR value decoded from a source script is not an Array.
SourceScriptNotArray,
/// 0x03: The Array value decoded form a source script is not a valid Data Request.
SourceScriptNotRADON,
/// Unallocated
ScriptFormat0x04,
ScriptFormat0x05,
ScriptFormat0x06,
ScriptFormat0x07,
ScriptFormat0x08,
ScriptFormat0x09,
ScriptFormat0x0A,
ScriptFormat0x0B,
ScriptFormat0x0C,
ScriptFormat0x0D,
ScriptFormat0x0E,
ScriptFormat0x0F,
// Complexity errors
/// 0x10: The request contains too many sources.
RequestTooManySources,
/// 0x11: The script contains too many calls.
ScriptTooManyCalls,
/// Unallocated
Complexity0x12,
Complexity0x13,
Complexity0x14,
Complexity0x15,
Complexity0x16,
Complexity0x17,
Complexity0x18,
Complexity0x19,
Complexity0x1A,
Complexity0x1B,
Complexity0x1C,
Complexity0x1D,
Complexity0x1E,
Complexity0x1F,
// Operator errors
/// 0x20: The operator does not exist.
UnsupportedOperator,
/// Unallocated
Operator0x21,
Operator0x22,
Operator0x23,
Operator0x24,
Operator0x25,
Operator0x26,
Operator0x27,
Operator0x28,
Operator0x29,
Operator0x2A,
Operator0x2B,
Operator0x2C,
Operator0x2D,
Operator0x2E,
Operator0x2F,
// Retrieval-specific errors
/// 0x30: At least one of the sources could not be retrieved, but returned HTTP error.
HTTP,
/// 0x31: Retrieval of at least one of the sources timed out.
RetrievalTimeout,
/// Unallocated
Retrieval0x32,
Retrieval0x33,
Retrieval0x34,
Retrieval0x35,
Retrieval0x36,
Retrieval0x37,
Retrieval0x38,
Retrieval0x39,
Retrieval0x3A,
Retrieval0x3B,
Retrieval0x3C,
Retrieval0x3D,
Retrieval0x3E,
Retrieval0x3F,
// Math errors
/// 0x40: Math operator caused an underflow.
Underflow,
/// 0x41: Math operator caused an overflow.
Overflow,
/// 0x42: Tried to divide by zero.
DivisionByZero,
/// Unallocated
Math0x43,
Math0x44,
Math0x45,
Math0x46,
Math0x47,
Math0x48,
Math0x49,
Math0x4A,
Math0x4B,
Math0x4C,
Math0x4D,
Math0x4E,
Math0x4F,
// Other errors
/// 0x50: Received zero reveals
NoReveals,
/// 0x51: Insufficient consensus in tally precondition clause
InsufficientConsensus,
/// 0x52: Received zero commits
InsufficientCommits,
/// 0x53: Generic error during tally execution
TallyExecution,
/// Unallocated
OtherError0x54,
OtherError0x55,
OtherError0x56,
OtherError0x57,
OtherError0x58,
OtherError0x59,
OtherError0x5A,
OtherError0x5B,
OtherError0x5C,
OtherError0x5D,
OtherError0x5E,
OtherError0x5F,
/// 0x60: Invalid reveal serialization (malformed reveals are converted to this value)
MalformedReveal,
/// Unallocated
OtherError0x61,
OtherError0x62,
OtherError0x63,
OtherError0x64,
OtherError0x65,
OtherError0x66,
OtherError0x67,
OtherError0x68,
OtherError0x69,
OtherError0x6A,
OtherError0x6B,
OtherError0x6C,
OtherError0x6D,
OtherError0x6E,
OtherError0x6F,
// Access errors
/// 0x70: Tried to access a value from an index using an index that is out of bounds
ArrayIndexOutOfBounds,
/// 0x71: Tried to access a value from a map using a key that does not exist
MapKeyNotFound,
/// Unallocated
OtherError0x72,
OtherError0x73,
OtherError0x74,
OtherError0x75,
OtherError0x76,
OtherError0x77,
OtherError0x78,
OtherError0x79,
OtherError0x7A,
OtherError0x7B,
OtherError0x7C,
OtherError0x7D,
OtherError0x7E,
OtherError0x7F,
OtherError0x80,
OtherError0x81,
OtherError0x82,
OtherError0x83,
OtherError0x84,
OtherError0x85,
OtherError0x86,
OtherError0x87,
OtherError0x88,
OtherError0x89,
OtherError0x8A,
OtherError0x8B,
OtherError0x8C,
OtherError0x8D,
OtherError0x8E,
OtherError0x8F,
OtherError0x90,
OtherError0x91,
OtherError0x92,
OtherError0x93,
OtherError0x94,
OtherError0x95,
OtherError0x96,
OtherError0x97,
OtherError0x98,
OtherError0x99,
OtherError0x9A,
OtherError0x9B,
OtherError0x9C,
OtherError0x9D,
OtherError0x9E,
OtherError0x9F,
OtherError0xA0,
OtherError0xA1,
OtherError0xA2,
OtherError0xA3,
OtherError0xA4,
OtherError0xA5,
OtherError0xA6,
OtherError0xA7,
OtherError0xA8,
OtherError0xA9,
OtherError0xAA,
OtherError0xAB,
OtherError0xAC,
OtherError0xAD,
OtherError0xAE,
OtherError0xAF,
OtherError0xB0,
OtherError0xB1,
OtherError0xB2,
OtherError0xB3,
OtherError0xB4,
OtherError0xB5,
OtherError0xB6,
OtherError0xB7,
OtherError0xB8,
OtherError0xB9,
OtherError0xBA,
OtherError0xBB,
OtherError0xBC,
OtherError0xBD,
OtherError0xBE,
OtherError0xBF,
OtherError0xC0,
OtherError0xC1,
OtherError0xC2,
OtherError0xC3,
OtherError0xC4,
OtherError0xC5,
OtherError0xC6,
OtherError0xC7,
OtherError0xC8,
OtherError0xC9,
OtherError0xCA,
OtherError0xCB,
OtherError0xCC,
OtherError0xCD,
OtherError0xCE,
OtherError0xCF,
OtherError0xD0,
OtherError0xD1,
OtherError0xD2,
OtherError0xD3,
OtherError0xD4,
OtherError0xD5,
OtherError0xD6,
OtherError0xD7,
OtherError0xD8,
OtherError0xD9,
OtherError0xDA,
OtherError0xDB,
OtherError0xDC,
OtherError0xDD,
OtherError0xDE,
OtherError0xDF,
// Bridge errors: errors that only belong in inter-client communication
/// 0xE0: Requests that cannot be parsed must always get this error as their result.
/// However, this is not a valid result in a Tally transaction, because invalid requests
/// are never included into blocks and therefore never get a Tally in response.
BridgeMalformedRequest,
/// 0xE1: Witnesses exceeds 100
BridgePoorIncentives,
/// 0xE2: The request is rejected on the grounds that it may cause the submitter to spend or stake an
/// amount of value that is unjustifiably high when compared with the reward they will be getting
BridgeOversizedResult,
/// Unallocated
OtherError0xE3,
OtherError0xE4,
OtherError0xE5,
OtherError0xE6,
OtherError0xE7,
OtherError0xE8,
OtherError0xE9,
OtherError0xEA,
OtherError0xEB,
OtherError0xEC,
OtherError0xED,
OtherError0xEE,
OtherError0xEF,
OtherError0xF0,
OtherError0xF1,
OtherError0xF2,
OtherError0xF3,
OtherError0xF4,
OtherError0xF5,
OtherError0xF6,
OtherError0xF7,
OtherError0xF8,
OtherError0xF9,
OtherError0xFA,
OtherError0xFB,
OtherError0xFC,
OtherError0xFD,
OtherError0xFE,
// This should not exist:
/// 0xFF: Some tally error is not intercepted but should
UnhandledIntercept
}
}
// File: contracts\interfaces\IWitnetRequestBoardRequestor.sol
/// @title Witnet Requestor Interface
/// @notice It defines how to interact with the Witnet Request Board in order to:
/// - request the execution of Witnet Radon scripts (data request);
/// - upgrade the resolution reward of any previously posted request, in case gas price raises in mainnet;
/// - read the result of any previously posted request, eventually reported by the Witnet DON.
/// - remove from storage all data related to past and solved data requests, and results.
/// @author The Witnet Foundation.
interface IWitnetRequestBoardRequestor {
/// Retrieves a copy of all Witnet-provided data related to a previously posted request, removing the whole query from the WRB storage.
/// @dev Fails if the `_queryId` is not in 'Reported' status, or called from an address different to
/// @dev the one that actually posted the given request.
/// @param _queryId The unique query identifier.
function deleteQuery(uint256 _queryId) external returns (Witnet.Response memory);
/// Requests the execution of the given Witnet Data Request in expectation that it will be relayed and solved by the Witnet DON.
/// A reward amount is escrowed by the Witnet Request Board that will be transferred to the reporter who relays back the Witnet-provided
/// result to this request.
/// @dev Fails if:
/// @dev - provided reward is too low.
/// @dev - provided script is zero address.
/// @dev - provided script bytecode is empty.
/// @param _addr The address of the IWitnetRequest contract that can provide the actual Data Request bytecode.
/// @return _queryId An unique query identifier.
function postRequest(IWitnetRequest _addr) external payable returns (uint256 _queryId);
/// Increments the reward of a previously posted request by adding the transaction value to it.
/// @dev Updates request `gasPrice` in case this method is called with a higher
/// @dev gas price value than the one used in previous calls to `postRequest` or
/// @dev `upgradeReward`.
/// @dev Fails if the `_queryId` is not in 'Posted' status.
/// @dev Fails also in case the request `gasPrice` is increased, and the new
/// @dev reward value gets below new recalculated threshold.
/// @param _queryId The unique query identifier.
function upgradeReward(uint256 _queryId) external payable;
}
// File: contracts\interfaces\IWitnetRequestBoardView.sol
/// @title Witnet Request Board info interface.
/// @author The Witnet Foundation.
interface IWitnetRequestBoardView {
/// Estimates the amount of reward we need to insert for a given gas price.
/// @param _gasPrice The gas price for which we need to calculate the rewards.
function estimateReward(uint256 _gasPrice) external view returns (uint256);
/// Returns next query id to be generated by the Witnet Request Board.
function getNextQueryId() external view returns (uint256);
/// Gets the whole Query data contents, if any, no matter its current status.
function getQueryData(uint256 _queryId) external view returns (Witnet.Query memory);
/// Gets current status of given query.
function getQueryStatus(uint256 _queryId) external view returns (Witnet.QueryStatus);
/// Retrieves the whole Request record posted to the Witnet Request Board.
/// @dev Fails if the `_queryId` is not valid or, if it has already been reported
/// @dev or deleted.
/// @param _queryId The unique identifier of a previously posted query.
function readRequest(uint256 _queryId) external view returns (Witnet.Request memory);
/// Retrieves the serialized bytecode of a previously posted Witnet Data Request.
/// @dev Fails if the `_queryId` is not valid, or if the related script bytecode
/// @dev got changed after being posted. Returns empty array once it gets reported,
/// @dev or deleted.
/// @param _queryId The unique query identifier.
function readRequestBytecode(uint256 _queryId) external view returns (bytes memory);
/// Retrieves the gas price that any assigned reporter will have to pay when reporting
/// result to a previously posted Witnet data request.
/// @dev Fails if the `_queryId` is not valid or, if it has already been
/// @dev reported, or deleted.
/// @param _queryId The unique query identifie
function readRequestGasPrice(uint256 _queryId) external view returns (uint256);
/// Retrieves the reward currently set for the referred query.
/// @dev Fails if the `_queryId` is not valid or, if it has already been
/// @dev reported, or deleted.
/// @param _queryId The unique query identifier.
function readRequestReward(uint256 _queryId) external view returns (uint256);
/// Retrieves the whole `Witnet.Response` record referred to a previously posted Witnet Data Request.
/// @dev Fails if the `_queryId` is not in 'Reported' status.
/// @param _queryId The unique query identifier.
function readResponse(uint256 _queryId) external view returns (Witnet.Response memory);
/// Retrieves the hash of the Witnet transaction hash that actually solved the referred query.
/// @dev Fails if the `_queryId` is not in 'Reported' status.
/// @param _queryId The unique query identifier.
function readResponseDrTxHash(uint256 _queryId) external view returns (bytes32);
/// Retrieves the address that reported the result to a previously-posted request.
/// @dev Fails if the `_queryId` is not in 'Reported' status.
/// @param _queryId The unique query identifier.
function readResponseReporter(uint256 _queryId) external view returns (address);
/// Retrieves the Witnet-provided CBOR-bytes result of a previously posted request.
/// @dev Fails if the `_queryId` is not in 'Reported' status.
/// @param _queryId The unique query identifier.
function readResponseResult(uint256 _queryId) external view returns (Witnet.Result memory);
/// Retrieves the timestamp in which the result to the referred query was solved by the Witnet DON.
/// @dev Fails if the `_queryId` is not in 'Reported' status.
/// @param _queryId The unique query identifier.
function readResponseTimestamp(uint256 _queryId) external view returns (uint256);
}
// File: contracts\interfaces\IWitnetRequestParser.sol
/// @title The Witnet interface for decoding Witnet-provided request to Data Requests.
/// This interface exposes functions to check for the success/failure of
/// a Witnet-provided result, as well as to parse and convert result into
/// Solidity types suitable to the application level.
/// @author The Witnet Foundation.
interface IWitnetRequestParser {
/// Decode raw CBOR bytes into a Witnet.Result instance.
/// @param _cborBytes Raw bytes representing a CBOR-encoded value.
/// @return A `Witnet.Result` instance.
function resultFromCborBytes(bytes memory _cborBytes) external pure returns (Witnet.Result memory);
/// Decode a CBOR value into a Witnet.Result instance.
/// @param _cborValue An instance of `Witnet.CBOR`.
/// @return A `Witnet.Result` instance.
function resultFromCborValue(Witnet.CBOR memory _cborValue) external pure returns (Witnet.Result memory);
/// Tell if a Witnet.Result is successful.
/// @param _result An instance of Witnet.Result.
/// @return `true` if successful, `false` if errored.
function isOk(Witnet.Result memory _result) external pure returns (bool);
/// Tell if a Witnet.Result is errored.
/// @param _result An instance of Witnet.Result.
/// @return `true` if errored, `false` if successful.
function isError(Witnet.Result memory _result) external pure returns (bool);
/// Decode a bytes value from a Witnet.Result as a `bytes` value.
/// @param _result An instance of Witnet.Result.
/// @return The `bytes` decoded from the Witnet.Result.
function asBytes(Witnet.Result memory _result) external pure returns (bytes memory);
/// Decode a bytes value from a Witnet.Result as a `bytes32` value.
/// @param _result An instance of Witnet.Result.
/// @return The `bytes32` decoded from the Witnet.Result.
function asBytes32(Witnet.Result memory _result) external pure returns (bytes32);
/// Decode an error code from a Witnet.Result as a member of `Witnet.ErrorCodes`.
/// @param _result An instance of `Witnet.Result`.
/// @return The `CBORValue.Error memory` decoded from the Witnet.Result.
function asErrorCode(Witnet.Result memory _result) external pure returns (Witnet.ErrorCodes);
/// Generate a suitable error message for a member of `Witnet.ErrorCodes` and its corresponding arguments.
/// @dev WARN: Note that client contracts should wrap this function into a try-catch foreseing potential errors generated in this function
/// @param _result An instance of `Witnet.Result`.
/// @return A tuple containing the `CBORValue.Error memory` decoded from the `Witnet.Result`, plus a loggable error message.
function asErrorMessage(Witnet.Result memory _result) external pure returns (Witnet.ErrorCodes, string memory);
/// Decode a raw error from a `Witnet.Result` as a `uint64[]`.
/// @param _result An instance of `Witnet.Result`.
/// @return The `uint64[]` raw error as decoded from the `Witnet.Result`.
function asRawError(Witnet.Result memory _result) external pure returns(uint64[] memory);
/// Decode a boolean value from a Witnet.Result as an `bool` value.
/// @param _result An instance of Witnet.Result.
/// @return The `bool` decoded from the Witnet.Result.
function asBool(Witnet.Result memory _result) external pure returns (bool);
/// Decode a fixed16 (half-precision) numeric value from a Witnet.Result as an `int32` value.
/// @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values.
/// by 5 decimal orders so as to get a fixed precision of 5 decimal positions, which should be OK for most `fixed16`.
/// use cases. In other words, the output of this method is 10,000 times the actual value, encoded into an `int32`.
/// @param _result An instance of Witnet.Result.
/// @return The `int128` decoded from the Witnet.Result.
function asFixed16(Witnet.Result memory _result) external pure returns (int32);
/// Decode an array of fixed16 values from a Witnet.Result as an `int128[]` value.
/// @param _result An instance of Witnet.Result.
/// @return The `int128[]` decoded from the Witnet.Result.
function asFixed16Array(Witnet.Result memory _result) external pure returns (int32[] memory);
/// Decode a integer numeric value from a Witnet.Result as an `int128` value.
/// @param _result An instance of Witnet.Result.
/// @return The `int128` decoded from the Witnet.Result.
function asInt128(Witnet.Result memory _result) external pure returns (int128);
/// Decode an array of integer numeric values from a Witnet.Result as an `int128[]` value.
/// @param _result An instance of Witnet.Result.
/// @return The `int128[]` decoded from the Witnet.Result.
function asInt128Array(Witnet.Result memory _result) external pure returns (int128[] memory);
/// Decode a string value from a Witnet.Result as a `string` value.
/// @param _result An instance of Witnet.Result.
/// @return The `string` decoded from the Witnet.Result.
function asString(Witnet.Result memory _result) external pure returns (string memory);
/// Decode an array of string values from a Witnet.Result as a `string[]` value.
/// @param _result An instance of Witnet.Result.
/// @return The `string[]` decoded from the Witnet.Result.
function asStringArray(Witnet.Result memory _result) external pure returns (string[] memory);
/// Decode a natural numeric value from a Witnet.Result as a `uint64` value.
/// @param _result An instance of Witnet.Result.
/// @return The `uint64` decoded from the Witnet.Result.
function asUint64(Witnet.Result memory _result) external pure returns(uint64);
/// Decode an array of natural numeric values from a Witnet.Result as a `uint64[]` value.
/// @param _result An instance of Witnet.Result.
/// @return The `uint64[]` decoded from the Witnet.Result.
function asUint64Array(Witnet.Result memory _result) external pure returns (uint64[] memory);
}
// File: contracts\WitnetRequestBoard.sol
/// @title Witnet Request Board functionality base contract.
/// @author The Witnet Foundation.
abstract contract WitnetRequestBoard is
IWitnetRequestBoardEvents,
IWitnetRequestBoardReporter,
IWitnetRequestBoardRequestor,
IWitnetRequestBoardView,
IWitnetRequestParser
{
receive() external payable {
revert("WitnetRequestBoard: no transfers accepted");
}
}
// File: contracts\patterns\Proxiable.sol
interface Proxiable {
/// @dev Complying with EIP-1822: Universal Upgradable Proxy Standard (UUPS)
/// @dev See https://eips.ethereum.org/EIPS/eip-1822.
function proxiableUUID() external pure returns (bytes32);
}
// File: contracts\patterns\Initializable.sol
interface Initializable {
/// @dev Initialize contract's storage context.
function initialize(bytes calldata) external;
}
// File: contracts\patterns\Upgradable.sol
/* solhint-disable var-name-mixedcase */
abstract contract Upgradable is Initializable, Proxiable {
address internal immutable _BASE;
bytes32 internal immutable _CODEHASH;
bool internal immutable _UPGRADABLE;
/// Emitted every time the contract gets upgraded.
/// @param from The address who ordered the upgrading. Namely, the WRB operator in "trustable" implementations.
/// @param baseAddr The address of the new implementation contract.
/// @param baseCodehash The EVM-codehash of the new implementation contract.
/// @param versionTag Ascii-encoded version literal with which the implementation deployer decided to tag it.
event Upgraded(
address indexed from,
address indexed baseAddr,
bytes32 indexed baseCodehash,
bytes32 versionTag
);
constructor (bool _isUpgradable) {
address _base = address(this);
bytes32 _codehash;
assembly {
_codehash := extcodehash(_base)
}
_BASE = _base;
_CODEHASH = _codehash;
_UPGRADABLE = _isUpgradable;
}
/// @dev Tells whether provided address could eventually upgrade the contract.
function isUpgradableFrom(address from) virtual external view returns (bool);
/// TODO: the following methods should be all declared as pure
/// whenever this Solidity's PR gets merged and released:
/// https://github.com/ethereum/solidity/pull/10240
/// @dev Retrieves base contract. Differs from address(this) when via delegate-proxy pattern.
function base() public view returns (address) {
return _BASE;
}
/// @dev Retrieves the immutable codehash of this contract, even if invoked as delegatecall.
/// @return _codehash This contracts immutable codehash.
function codehash() public view returns (bytes32 _codehash) {
return _CODEHASH;
}
/// @dev Determines whether current instance allows being upgraded.
/// @dev Returned value should be invariant from whoever is calling.
function isUpgradable() public view returns (bool) {
return _UPGRADABLE;
}
/// @dev Retrieves human-redable named version of current implementation.
function version() virtual public view returns (bytes32);
}
// File: contracts\impls\WitnetProxy.sol
/// @title WitnetProxy: upgradable delegate-proxy contract that routes Witnet data requests coming from a
/// `UsingWitnet`-inheriting contract to a currently active `WitnetRequestBoard` implementation.
/// @author The Witnet Foundation.
contract WitnetProxy {
struct WitnetProxySlot {
address implementation;
}
/// Event emitted every time the implementation gets updated.
event Upgraded(address indexed implementation);
/// Constructor with no params as to ease eventual support of Singleton pattern (i.e. ERC-2470).
constructor () {}
/// WitnetProxies will never accept direct transfer of ETHs.
receive() external payable {
revert("WitnetProxy: no transfers accepted");
}
/// Payable fallback accepts delegating calls to payable functions.
fallback() external payable { /* solhint-disable no-complex-fallback */
address _implementation = implementation();
assembly { /* solhint-disable avoid-low-level-calls */
// Gas optimized delegate call to 'implementation' contract.
// Note: `msg.data`, `msg.sender` and `msg.value` will be passed over
// to actual implementation of `msg.sig` within `implementation` contract.
let ptr := mload(0x40)
calldatacopy(ptr, 0, calldatasize())
let result := delegatecall(gas(), _implementation, ptr, calldatasize(), 0, 0)
let size := returndatasize()
returndatacopy(ptr, 0, size)
switch result
case 0 {
// pass back revert message:
revert(ptr, size)
}
default {
// pass back same data as returned by 'implementation' contract:
return(ptr, size)
}
}
}
/// Returns proxy's current implementation address.
function implementation() public view returns (address) {
return _proxySlot().implementation;
}
/// Upgrades the `implementation` address.
/// @param _newImplementation New implementation address.
/// @param _initData Raw data with which new implementation will be initialized.
/// @return Returns whether new implementation would be further upgradable, or not.
function upgradeTo(address _newImplementation, bytes memory _initData)
public returns (bool)
{
// New implementation cannot be null:
require(_newImplementation != address(0), "WitnetProxy: null implementation");
address _oldImplementation = implementation();
if (_oldImplementation != address(0)) {
// New implementation address must differ from current one:
require(_newImplementation != _oldImplementation, "WitnetProxy: nothing to upgrade");
// Assert whether current implementation is intrinsically upgradable:
try Upgradable(_oldImplementation).isUpgradable() returns (bool _isUpgradable) {
require(_isUpgradable, "WitnetProxy: not upgradable");
} catch {
revert("WitnetProxy: unable to check upgradability");
}
// Assert whether current implementation allows `msg.sender` to upgrade the proxy:
(bool _wasCalled, bytes memory _result) = _oldImplementation.delegatecall(
abi.encodeWithSignature(
"isUpgradableFrom(address)",
msg.sender
)
);
require(_wasCalled, "WitnetProxy: not compliant");
require(abi.decode(_result, (bool)), "WitnetProxy: not authorized");
require(
Upgradable(_oldImplementation).proxiableUUID() == Upgradable(_newImplementation).proxiableUUID(),
"WitnetProxy: proxiableUUIDs mismatch"
);
}
// Initialize new implementation within proxy-context storage:
(bool _wasInitialized,) = _newImplementation.delegatecall(
abi.encodeWithSignature(
"initialize(bytes)",
_initData
)
);
require(_wasInitialized, "WitnetProxy: unable to initialize");
// If all checks and initialization pass, update implementation address:
_proxySlot().implementation = _newImplementation;
emit Upgraded(_newImplementation);
// Asserts new implementation complies w/ minimal implementation of Upgradable interface:
try Upgradable(_newImplementation).isUpgradable() returns (bool _isUpgradable) {
return _isUpgradable;
}
catch {
revert ("WitnetProxy: not compliant");
}
}
/// @dev Complying with EIP-1967, retrieves storage struct containing proxy's current implementation address.
function _proxySlot() private pure returns (WitnetProxySlot storage _slot) {
assembly {
// bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)
_slot.slot := 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc
}
}
}
// File: contracts\impls\WitnetRequestBoardUpgradableBase.sol
/* solhint-disable var-name-mixedcase */
// Inherits from:
// Eventual deployment dependencies:
/// @title Witnet Request Board base contract, with an Upgradable (and Destructible) touch.
/// @author The Witnet Foundation.
abstract contract WitnetRequestBoardUpgradableBase
is
Proxiable,
Upgradable,
WitnetRequestBoard
{
bytes32 internal immutable _VERSION;
constructor(
bool _upgradable,
bytes32 _versionTag
)
Upgradable(_upgradable)
{
_VERSION = _versionTag;
}
/// @dev Reverts if proxy delegatecalls to unexistent method.
fallback() external payable {
revert("WitnetRequestBoardUpgradableBase: not implemented");
}
// ================================================================================================================
// --- Overrides 'Proxiable' --------------------------------------------------------------------------------------
/// @dev Gets immutable "heritage blood line" (ie. genotype) as a Proxiable, and eventually Upgradable, contract.
/// If implemented as an Upgradable touch, upgrading this contract to another one with a different
/// `proxiableUUID()` value should fail.
function proxiableUUID() external pure override returns (bytes32) {
return (
/* keccak256("io.witnet.proxiable.board") */
0x9969c6aff411c5e5f0807500693e8f819ce88529615cfa6cab569b24788a1018
);
}
// ================================================================================================================
// --- Overrides 'Upgradable' --------------------------------------------------------------------------------------
/// Retrieves human-readable version tag of current implementation.
function version() public view override returns (bytes32) {
return _VERSION;
}
}
// File: contracts\data\WitnetBoardData.sol
/// @title Witnet Request Board base data model.
/// @author The Witnet Foundation.
abstract contract WitnetBoardData {
bytes32 internal constant _WITNET_BOARD_DATA_SLOTHASH =
/* keccak256("io.witnet.boards.data") */
0xf595240b351bc8f951c2f53b26f4e78c32cb62122cf76c19b7fdda7d4968e183;
struct WitnetBoardState {
address base;
address owner;
uint256 numQueries;
mapping (uint => Witnet.Query) queries;
}
constructor() {
_state().owner = msg.sender;
}
/// Asserts the given query is currently in the given status.
modifier inStatus(uint256 _queryId, Witnet.QueryStatus _status) {
require(
_getQueryStatus(_queryId) == _status,
_getQueryStatusRevertMessage(_status)
);
_;
}
/// Asserts the given query was previously posted and that it was not yet deleted.
modifier notDeleted(uint256 _queryId) {
require(_queryId > 0 && _queryId <= _state().numQueries, "WitnetBoardData: not yet posted");
require(_getRequester(_queryId) != address(0), "WitnetBoardData: deleted");
_;
}
/// Asserts caller corresponds to the current owner.
modifier onlyOwner {
require(msg.sender == _state().owner, "WitnetBoardData: only owner");
_;
}
/// Asserts the give query was actually posted before calling this method.
modifier wasPosted(uint256 _queryId) {
require(_queryId > 0 && _queryId <= _state().numQueries, "WitnetBoardData: not yet posted");
_;
}
// ================================================================================================================
// --- Internal functions -----------------------------------------------------------------------------------------
/// Gets current status of given query.
function _getQueryStatus(uint256 _queryId)
internal view
returns (Witnet.QueryStatus)
{
if (_queryId == 0 || _queryId > _state().numQueries) {
// "Unknown" status if queryId is out of range:
return Witnet.QueryStatus.Unknown;
}
else {
Witnet.Query storage _query = _state().queries[_queryId];
if (_query.response.drTxHash != 0) {
// Query is in "Reported" status as soon as the hash of the
// Witnet transaction that solved the query is reported
// back from a Witnet bridge:
return Witnet.QueryStatus.Reported;
}
else if (_query.from != address(0)) {
// Otherwise, while address from which the query was posted
// is kept in storage, the query remains in "Posted" status:
return Witnet.QueryStatus.Posted;
}
else {
// Requester's address is removed from storage only if
// the query gets "Deleted" by its requester.
return Witnet.QueryStatus.Deleted;
}
}
}
function _getQueryStatusRevertMessage(Witnet.QueryStatus _status)
internal pure
returns (string memory)
{
if (_status == Witnet.QueryStatus.Posted) {
return "WitnetBoardData: not in Posted status";
} else if (_status == Witnet.QueryStatus.Reported) {
return "WitnetBoardData: not in Reported status";
} else if (_status == Witnet.QueryStatus.Deleted) {
return "WitnetBoardData: not in Deleted status";
} else {
return "WitnetBoardData: bad mood";
}
}
/// Gets from of a given query.
function _getRequester(uint256 _queryId)
internal view
returns (address)
{
return _state().queries[_queryId].from;
}
/// Gets the Witnet.Request part of a given query.
function _getRequestData(uint256 _queryId)
internal view
returns (Witnet.Request storage)
{
return _state().queries[_queryId].request;
}
/// Gets the Witnet.Result part of a given query.
function _getResponseData(uint256 _queryId)
internal view
returns (Witnet.Response storage)
{
return _state().queries[_queryId].response;
}
/// Returns storage pointer to contents of 'WitnetBoardState' struct.
function _state()
internal pure
returns (WitnetBoardState storage _ptr)
{
assembly {
_ptr.slot := _WITNET_BOARD_DATA_SLOTHASH
}
}
}
// File: contracts\data\WitnetBoardDataACLs.sol
/// @title Witnet Access Control Lists storage layout, for Witnet-trusted request boards.
/// @author The Witnet Foundation.
abstract contract WitnetBoardDataACLs
is
WitnetBoardData
{
bytes32 internal constant _WITNET_BOARD_ACLS_SLOTHASH =
/* keccak256("io.witnet.boards.data.acls") */
0xa6db7263983f337bae2c9fb315730227961d1c1153ae1e10a56b5791465dd6fd;
struct WitnetBoardACLs {
mapping (address => bool) isReporter_;
}
constructor() {
_acls().isReporter_[msg.sender] = true;
}
modifier onlyReporters {
require(
_acls().isReporter_[msg.sender],
"WitnetBoardDataACLs: unauthorized reporter"
);
_;
}
// ================================================================================================================
// --- Internal functions -----------------------------------------------------------------------------------------
function _acls() internal pure returns (WitnetBoardACLs storage _struct) {
assembly {
_struct.slot := _WITNET_BOARD_ACLS_SLOTHASH
}
}
}
// File: contracts\interfaces\IWitnetRequestBoardAdmin.sol
/// @title Witnet Request Board basic administration interface.
/// @author The Witnet Foundation.
interface IWitnetRequestBoardAdmin {
event OwnershipTransferred(address indexed from, address indexed to);
/// Gets admin/owner address.
function owner() external view returns (address);
/// Transfers ownership.
function transferOwnership(address) external;
}
// File: contracts\interfaces\IWitnetRequestBoardAdminACLs.sol
/// @title Witnet Request Board ACLs administration interface.
/// @author The Witnet Foundation.
interface IWitnetRequestBoardAdminACLs {
event ReportersSet(address[] reporters);
event ReportersUnset(address[] reporters);
/// Tells whether given address is included in the active reporters control list.
function isReporter(address) external view returns (bool);
/// Adds given addresses to the active reporters control list.
/// @dev Can only be called from the owner address.
/// @dev Emits the `ReportersSet` event.
function setReporters(address[] calldata reporters) external;
/// Removes given addresses from the active reporters control list.
/// @dev Can only be called from the owner address.
/// @dev Emits the `ReportersUnset` event.
function unsetReporters(address[] calldata reporters) external;
}
// File: contracts\libs\WitnetBuffer.sol
/// @title A convenient wrapper around the `bytes memory` type that exposes a buffer-like interface
/// @notice The buffer has an inner cursor that tracks the final offset of every read, i.e. any subsequent read will
/// start with the byte that goes right after the last one in the previous read.
/// @dev `uint32` is used here for `cursor` because `uint16` would only enable seeking up to 8KB, which could in some
/// theoretical use cases be exceeded. Conversely, `uint32` supports up to 512MB, which cannot credibly be exceeded.
/// @author The Witnet Foundation.
library WitnetBuffer {
// Ensures we access an existing index in an array
modifier notOutOfBounds(uint32 index, uint256 length) {
require(index < length, "WitnetBuffer: Tried to read from a consumed Buffer (must rewind it first)");
_;
}
/// @notice Read and consume a certain amount of bytes from the buffer.
/// @param _buffer An instance of `Witnet.Buffer`.
/// @param _length How many bytes to read and consume from the buffer.
/// @return A `bytes memory` containing the first `_length` bytes from the buffer, counting from the cursor position.
function read(Witnet.Buffer memory _buffer, uint32 _length) internal pure returns (bytes memory) {
// Make sure not to read out of the bounds of the original bytes
require(_buffer.cursor + _length <= _buffer.data.length, "WitnetBuffer: Not enough bytes in buffer when reading");
// Create a new `bytes memory destination` value
bytes memory destination = new bytes(_length);
// Early return in case that bytes length is 0
if (_length != 0) {
bytes memory source = _buffer.data;
uint32 offset = _buffer.cursor;
// Get raw pointers for source and destination
uint sourcePointer;
uint destinationPointer;
assembly {
sourcePointer := add(add(source, 32), offset)
destinationPointer := add(destination, 32)
}
// Copy `_length` bytes from source to destination
memcpy(destinationPointer, sourcePointer, uint(_length));
// Move the cursor forward by `_length` bytes
seek(_buffer, _length, true);
}
return destination;
}
/// @notice Read and consume the next byte from the buffer.
/// @param _buffer An instance of `Witnet.Buffer`.
/// @return The next byte in the buffer counting from the cursor position.
function next(Witnet.Buffer memory _buffer) internal pure notOutOfBounds(_buffer.cursor, _buffer.data.length) returns (bytes1) {
// Return the byte at the position marked by the cursor and advance the cursor all at once
return _buffer.data[_buffer.cursor++];
}
/// @notice Move the inner cursor of the buffer to a relative or absolute position.
/// @param _buffer An instance of `Witnet.Buffer`.
/// @param _offset How many bytes to move the cursor forward.
/// @param _relative Whether to count `_offset` from the last position of the cursor (`true`) or the beginning of the
/// buffer (`true`).
/// @return The final position of the cursor (will equal `_offset` if `_relative` is `false`).
// solium-disable-next-line security/no-assign-params
function seek(Witnet.Buffer memory _buffer, uint32 _offset, bool _relative) internal pure returns (uint32) {
// Deal with relative offsets
if (_relative) {
require(_offset + _buffer.cursor > _offset, "WitnetBuffer: Integer overflow when seeking");
_offset += _buffer.cursor;
}
// Make sure not to read out of the bounds of the original bytes
require(_offset <= _buffer.data.length, "WitnetBuffer: Not enough bytes in buffer when seeking");
_buffer.cursor = _offset;
return _buffer.cursor;
}
/// @notice Move the inner cursor a number of bytes forward.
/// @dev This is a simple wrapper around the relative offset case of `seek()`.
/// @param _buffer An instance of `Witnet.Buffer`.
/// @param _relativeOffset How many bytes to move the cursor forward.
/// @return The final position of the cursor.
function seek(Witnet.Buffer memory _buffer, uint32 _relativeOffset) internal pure returns (uint32) {
return seek(_buffer, _relativeOffset, true);
}
/// @notice Move the inner cursor back to the first byte in the buffer.
/// @param _buffer An instance of `Witnet.Buffer`.
function rewind(Witnet.Buffer memory _buffer) internal pure {
_buffer.cursor = 0;
}
/// @notice Read and consume the next byte from the buffer as an `uint8`.
/// @param _buffer An instance of `Witnet.Buffer`.
/// @return The `uint8` value of the next byte in the buffer counting from the cursor position.
function readUint8(Witnet.Buffer memory _buffer) internal pure notOutOfBounds(_buffer.cursor, _buffer.data.length) returns (uint8) {
bytes memory bytesValue = _buffer.data;
uint32 offset = _buffer.cursor;
uint8 value;
assembly {
value := mload(add(add(bytesValue, 1), offset))
}
_buffer.cursor++;
return value;
}
/// @notice Read and consume the next 2 bytes from the buffer as an `uint16`.
/// @param _buffer An instance of `Witnet.Buffer`.
/// @return The `uint16` value of the next 2 bytes in the buffer counting from the cursor position.
function readUint16(Witnet.Buffer memory _buffer) internal pure notOutOfBounds(_buffer.cursor + 1, _buffer.data.length) returns (uint16) {
bytes memory bytesValue = _buffer.data;
uint32 offset = _buffer.cursor;
uint16 value;
assembly {
value := mload(add(add(bytesValue, 2), offset))
}
_buffer.cursor += 2;
return value;
}
/// @notice Read and consume the next 4 bytes from the buffer as an `uint32`.
/// @param _buffer An instance of `Witnet.Buffer`.
/// @return The `uint32` value of the next 4 bytes in the buffer counting from the cursor position.
function readUint32(Witnet.Buffer memory _buffer) internal pure notOutOfBounds(_buffer.cursor + 3, _buffer.data.length) returns (uint32) {
bytes memory bytesValue = _buffer.data;
uint32 offset = _buffer.cursor;
uint32 value;
assembly {
value := mload(add(add(bytesValue, 4), offset))
}
_buffer.cursor += 4;
return value;
}
/// @notice Read and consume the next 8 bytes from the buffer as an `uint64`.
/// @param _buffer An instance of `Witnet.Buffer`.
/// @return The `uint64` value of the next 8 bytes in the buffer counting from the cursor position.
function readUint64(Witnet.Buffer memory _buffer) internal pure notOutOfBounds(_buffer.cursor + 7, _buffer.data.length) returns (uint64) {
bytes memory bytesValue = _buffer.data;
uint32 offset = _buffer.cursor;
uint64 value;
assembly {
value := mload(add(add(bytesValue, 8), offset))
}
_buffer.cursor += 8;
return value;
}
/// @notice Read and consume the next 16 bytes from the buffer as an `uint128`.
/// @param _buffer An instance of `Witnet.Buffer`.
/// @return The `uint128` value of the next 16 bytes in the buffer counting from the cursor position.
function readUint128(Witnet.Buffer memory _buffer) internal pure notOutOfBounds(_buffer.cursor + 15, _buffer.data.length) returns (uint128) {
bytes memory bytesValue = _buffer.data;
uint32 offset = _buffer.cursor;
uint128 value;
assembly {
value := mload(add(add(bytesValue, 16), offset))
}
_buffer.cursor += 16;
return value;
}
/// @notice Read and consume the next 32 bytes from the buffer as an `uint256`.
/// @return The `uint256` value of the next 32 bytes in the buffer counting from the cursor position.
/// @param _buffer An instance of `Witnet.Buffer`.
function readUint256(Witnet.Buffer memory _buffer) internal pure notOutOfBounds(_buffer.cursor + 31, _buffer.data.length) returns (uint256) {
bytes memory bytesValue = _buffer.data;
uint32 offset = _buffer.cursor;
uint256 value;
assembly {
value := mload(add(add(bytesValue, 32), offset))
}
_buffer.cursor += 32;
return value;
}
/// @notice Read and consume the next 2 bytes from the buffer as an IEEE 754-2008 floating point number enclosed in an
/// `int32`.
/// @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values
/// by 5 decimal orders so as to get a fixed precision of 5 decimal positions, which should be OK for most `float16`
/// use cases. In other words, the integer output of this method is 10,000 times the actual value. The input bytes are
/// expected to follow the 16-bit base-2 format (a.k.a. `binary16`) in the IEEE 754-2008 standard.
/// @param _buffer An instance of `Witnet.Buffer`.
/// @return The `uint32` value of the next 4 bytes in the buffer counting from the cursor position.
function readFloat16(Witnet.Buffer memory _buffer) internal pure returns (int32) {
uint32 bytesValue = readUint16(_buffer);
// Get bit at position 0
uint32 sign = bytesValue & 0x8000;
// Get bits 1 to 5, then normalize to the [-14, 15] range so as to counterweight the IEEE 754 exponent bias
int32 exponent = (int32(bytesValue & 0x7c00) >> 10) - 15;
// Get bits 6 to 15
int32 significand = int32(bytesValue & 0x03ff);
// Add 1024 to the fraction if the exponent is 0
if (exponent == 15) {
significand |= 0x400;
}
// Compute `2 ^ exponent · (1 + fraction / 1024)`
int32 result = 0;
if (exponent >= 0) {
result = int32((int256(1 << uint256(int256(exponent))) * 10000 * int256(uint256(int256(significand)) | 0x400)) >> 10);
} else {
result = int32(((int256(uint256(int256(significand)) | 0x400) * 10000) / int256(1 << uint256(int256(- exponent)))) >> 10);
}
// Make the result negative if the sign bit is not 0
if (sign != 0) {
result *= - 1;
}
return result;
}
/// @notice Copy bytes from one memory address into another.
/// @dev This function was borrowed from Nick Johnson's `solidity-stringutils` lib, and reproduced here under the terms
/// of [Apache License 2.0](https://github.com/Arachnid/solidity-stringutils/blob/master/LICENSE).
/// @param _dest Address of the destination memory.
/// @param _src Address to the source memory.
/// @param _len How many bytes to copy.
// solium-disable-next-line security/no-assign-params
function memcpy(uint _dest, uint _src, uint _len) private pure {
require(_len > 0, "WitnetBuffer: Cannot copy 0 bytes");
// Copy word-length chunks while possible
for (; _len >= 32; _len -= 32) {
assembly {
mstore(_dest, mload(_src))
}
_dest += 32;
_src += 32;
}
if (_len > 0) {
// Copy remaining bytes
uint mask = 256 ** (32 - _len) - 1;
assembly {
let srcpart := and(mload(_src), not(mask))
let destpart := and(mload(_dest), mask)
mstore(_dest, or(destpart, srcpart))
}
}
}
}
// File: contracts\libs\WitnetDecoderLib.sol
/// @title A minimalistic implementation of “RFC 7049 Concise Binary Object Representation”
/// @notice This library leverages a buffer-like structure for step-by-step decoding of bytes so as to minimize
/// the gas cost of decoding them into a useful native type.
/// @dev Most of the logic has been borrowed from Patrick Gansterer’s cbor.js library: https://github.com/paroga/cbor-js
/// @author The Witnet Foundation.
///
/// TODO: add support for Array (majorType = 4)
/// TODO: add support for Map (majorType = 5)
/// TODO: add support for Float32 (majorType = 7, additionalInformation = 26)
/// TODO: add support for Float64 (majorType = 7, additionalInformation = 27)
library WitnetDecoderLib {
using WitnetBuffer for Witnet.Buffer;
uint32 constant internal _UINT32_MAX = type(uint32).max;
uint64 constant internal _UINT64_MAX = type(uint64).max;
/// @notice Decode a `Witnet.CBOR` structure into a native `bool` value.
/// @param _cborValue An instance of `Witnet.CBOR`.
/// @return The value represented by the input, as a `bool` value.
function decodeBool(Witnet.CBOR memory _cborValue) public pure returns(bool) {
_cborValue.len = readLength(_cborValue.buffer, _cborValue.additionalInformation);
require(_cborValue.majorType == 7, "WitnetDecoderLib: Tried to read a `bool` value from a `Witnet.CBOR` with majorType != 7");
if (_cborValue.len == 20) {
return false;
} else if (_cborValue.len == 21) {
return true;
} else {
revert("WitnetDecoderLib: Tried to read `bool` from a `Witnet.CBOR` with len different than 20 or 21");
}
}
/// @notice Decode a `Witnet.CBOR` structure into a native `bytes` value.
/// @param _cborValue An instance of `Witnet.CBOR`.
/// @return The value represented by the input, as a `bytes` value.
function decodeBytes(Witnet.CBOR memory _cborValue) public pure returns(bytes memory) {
_cborValue.len = readLength(_cborValue.buffer, _cborValue.additionalInformation);
if (_cborValue.len == _UINT32_MAX) {
bytes memory bytesData;
// These checks look repetitive but the equivalent loop would be more expensive.
uint32 itemLength = uint32(readIndefiniteStringLength(_cborValue.buffer, _cborValue.majorType));
if (itemLength < _UINT32_MAX) {
bytesData = abi.encodePacked(bytesData, _cborValue.buffer.read(itemLength));
itemLength = uint32(readIndefiniteStringLength(_cborValue.buffer, _cborValue.majorType));
if (itemLength < _UINT32_MAX) {
bytesData = abi.encodePacked(bytesData, _cborValue.buffer.read(itemLength));
}
}
return bytesData;
} else {
return _cborValue.buffer.read(uint32(_cborValue.len));
}
}
/// @notice Decode a `Witnet.CBOR` structure into a native `bytes32` value.
/// @param _cborValue An instance of `Witnet.CBOR`.
/// @return _bytes32 The value represented by the input, as a `bytes32` value.
function decodeBytes32(Witnet.CBOR memory _cborValue) public pure returns(bytes32 _bytes32) {
bytes memory _bb = decodeBytes(_cborValue);
uint _len = _bb.length > 32 ? 32 : _bb.length;
for (uint _i = 0; _i < _len; _i ++) {
_bytes32 |= bytes32(_bb[_i] & 0xff) >> (_i * 8);
}
}
/// @notice Decode a `Witnet.CBOR` structure into a `fixed16` value.
/// @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values
/// by 5 decimal orders so as to get a fixed precision of 5 decimal positions, which should be OK for most `fixed16`
/// use cases. In other words, the output of this method is 10,000 times the actual value, encoded into an `int32`.
/// @param _cborValue An instance of `Witnet.CBOR`.
/// @return The value represented by the input, as an `int128` value.
function decodeFixed16(Witnet.CBOR memory _cborValue) public pure returns(int32) {
require(_cborValue.majorType == 7, "WitnetDecoderLib: Tried to read a `fixed` value from a `WT.CBOR` with majorType != 7");
require(_cborValue.additionalInformation == 25, "WitnetDecoderLib: Tried to read `fixed16` from a `WT.CBOR` with additionalInformation != 25");
return _cborValue.buffer.readFloat16();
}
/// @notice Decode a `Witnet.CBOR` structure into a native `int128[]` value whose inner values follow the same convention.
/// as explained in `decodeFixed16`.
/// @param _cborValue An instance of `Witnet.CBOR`.
/// @return The value represented by the input, as an `int128[]` value.
function decodeFixed16Array(Witnet.CBOR memory _cborValue) external pure returns(int32[] memory) {
require(_cborValue.majorType == 4, "WitnetDecoderLib: Tried to read `int128[]` from a `Witnet.CBOR` with majorType != 4");
uint64 length = readLength(_cborValue.buffer, _cborValue.additionalInformation);
require(length < _UINT64_MAX, "WitnetDecoderLib: Indefinite-length CBOR arrays are not supported");
int32[] memory array = new int32[](length);
for (uint64 i = 0; i < length; i++) {
Witnet.CBOR memory item = valueFromBuffer(_cborValue.buffer);
array[i] = decodeFixed16(item);
}
return array;
}
/// @notice Decode a `Witnet.CBOR` structure into a native `int128` value.
/// @param _cborValue An instance of `Witnet.CBOR`.
/// @return The value represented by the input, as an `int128` value.
function decodeInt128(Witnet.CBOR memory _cborValue) public pure returns(int128) {
if (_cborValue.majorType == 1) {
uint64 length = readLength(_cborValue.buffer, _cborValue.additionalInformation);
return int128(-1) - int128(uint128(length));
} else if (_cborValue.majorType == 0) {
// Any `uint64` can be safely casted to `int128`, so this method supports majorType 1 as well so as to have offer
// a uniform API for positive and negative numbers
return int128(uint128(decodeUint64(_cborValue)));
}
revert("WitnetDecoderLib: Tried to read `int128` from a `Witnet.CBOR` with majorType not 0 or 1");
}
/// @notice Decode a `Witnet.CBOR` structure into a native `int128[]` value.
/// @param _cborValue An instance of `Witnet.CBOR`.
/// @return The value represented by the input, as an `int128[]` value.
function decodeInt128Array(Witnet.CBOR memory _cborValue) external pure returns(int128[] memory) {
require(_cborValue.majorType == 4, "WitnetDecoderLib: Tried to read `int128[]` from a `Witnet.CBOR` with majorType != 4");
uint64 length = readLength(_cborValue.buffer, _cborValue.additionalInformation);
require(length < _UINT64_MAX, "WitnetDecoderLib: Indefinite-length CBOR arrays are not supported");
int128[] memory array = new int128[](length);
for (uint64 i = 0; i < length; i++) {
Witnet.CBOR memory item = valueFromBuffer(_cborValue.buffer);
array[i] = decodeInt128(item);
}
return array;
}
/// @notice Decode a `Witnet.CBOR` structure into a native `string` value.
/// @param _cborValue An instance of `Witnet.CBOR`.
/// @return The value represented by the input, as a `string` value.
function decodeString(Witnet.CBOR memory _cborValue) public pure returns(string memory) {
_cborValue.len = readLength(_cborValue.buffer, _cborValue.additionalInformation);
if (_cborValue.len == _UINT64_MAX) {
bytes memory textData;
bool done;
while (!done) {
uint64 itemLength = readIndefiniteStringLength(_cborValue.buffer, _cborValue.majorType);
if (itemLength < _UINT64_MAX) {
textData = abi.encodePacked(textData, readText(_cborValue.buffer, itemLength / 4));
} else {
done = true;
}
}
return string(textData);
} else {
return string(readText(_cborValue.buffer, _cborValue.len));
}
}
/// @notice Decode a `Witnet.CBOR` structure into a native `string[]` value.
/// @param _cborValue An instance of `Witnet.CBOR`.
/// @return The value represented by the input, as an `string[]` value.
function decodeStringArray(Witnet.CBOR memory _cborValue) external pure returns(string[] memory) {
require(_cborValue.majorType == 4, "WitnetDecoderLib: Tried to read `string[]` from a `Witnet.CBOR` with majorType != 4");
uint64 length = readLength(_cborValue.buffer, _cborValue.additionalInformation);
require(length < _UINT64_MAX, "WitnetDecoderLib: Indefinite-length CBOR arrays are not supported");
string[] memory array = new string[](length);
for (uint64 i = 0; i < length; i++) {
Witnet.CBOR memory item = valueFromBuffer(_cborValue.buffer);
array[i] = decodeString(item);
}
return array;
}
/// @notice Decode a `Witnet.CBOR` structure into a native `uint64` value.
/// @param _cborValue An instance of `Witnet.CBOR`.
/// @return The value represented by the input, as an `uint64` value.
function decodeUint64(Witnet.CBOR memory _cborValue) public pure returns(uint64) {
require(_cborValue.majorType == 0, "WitnetDecoderLib: Tried to read `uint64` from a `Witnet.CBOR` with majorType != 0");
return readLength(_cborValue.buffer, _cborValue.additionalInformation);
}
/// @notice Decode a `Witnet.CBOR` structure into a native `uint64[]` value.
/// @param _cborValue An instance of `Witnet.CBOR`.
/// @return The value represented by the input, as an `uint64[]` value.
function decodeUint64Array(Witnet.CBOR memory _cborValue) external pure returns(uint64[] memory) {
require(_cborValue.majorType == 4, "WitnetDecoderLib: Tried to read `uint64[]` from a `Witnet.CBOR` with majorType != 4");
uint64 length = readLength(_cborValue.buffer, _cborValue.additionalInformation);
require(length < _UINT64_MAX, "WitnetDecoderLib: Indefinite-length CBOR arrays are not supported");
uint64[] memory array = new uint64[](length);
for (uint64 i = 0; i < length; i++) {
Witnet.CBOR memory item = valueFromBuffer(_cborValue.buffer);
array[i] = decodeUint64(item);
}
return array;
}
/// @notice Decode a Witnet.CBOR structure from raw bytes.
/// @dev This is the main factory for Witnet.CBOR instances, which can be later decoded into native EVM types.
/// @param _cborBytes Raw bytes representing a CBOR-encoded value.
/// @return A `Witnet.CBOR` instance containing a partially decoded value.
function valueFromBytes(bytes memory _cborBytes) external pure returns(Witnet.CBOR memory) {
Witnet.Buffer memory buffer = Witnet.Buffer(_cborBytes, 0);
return valueFromBuffer(buffer);
}
/// @notice Decode a Witnet.CBOR structure from raw bytes.
/// @dev This is an alternate factory for Witnet.CBOR instances, which can be later decoded into native EVM types.
/// @param _buffer A Buffer structure representing a CBOR-encoded value.
/// @return A `Witnet.CBOR` instance containing a partially decoded value.
function valueFromBuffer(Witnet.Buffer memory _buffer) public pure returns(Witnet.CBOR memory) {
require(_buffer.data.length > 0, "WitnetDecoderLib: Found empty buffer when parsing CBOR value");
uint8 initialByte;
uint8 majorType = 255;
uint8 additionalInformation;
uint64 tag = _UINT64_MAX;
bool isTagged = true;
while (isTagged) {
// Extract basic CBOR properties from input bytes
initialByte = _buffer.readUint8();
majorType = initialByte >> 5;
additionalInformation = initialByte & 0x1f;
// Early CBOR tag parsing.
if (majorType == 6) {
tag = readLength(_buffer, additionalInformation);
} else {
isTagged = false;
}
}
require(majorType <= 7, "WitnetDecoderLib: Invalid CBOR major type");
return Witnet.CBOR(
_buffer,
initialByte,
majorType,
additionalInformation,
0,
tag);
}
/// Reads the length of the next CBOR item from a buffer, consuming a different number of bytes depending on the
/// value of the `additionalInformation` argument.
function readLength(Witnet.Buffer memory _buffer, uint8 additionalInformation) private pure returns(uint64) {
if (additionalInformation < 24) {
return additionalInformation;
}
if (additionalInformation == 24) {
return _buffer.readUint8();
}
if (additionalInformation == 25) {
return _buffer.readUint16();
}
if (additionalInformation == 26) {
return _buffer.readUint32();
}
if (additionalInformation == 27) {
return _buffer.readUint64();
}
if (additionalInformation == 31) {
return _UINT64_MAX;
}
revert("WitnetDecoderLib: Invalid length encoding (non-existent additionalInformation value)");
}
/// Read the length of a CBOR indifinite-length item (arrays, maps, byte strings and text) from a buffer, consuming
/// as many bytes as specified by the first byte.
function readIndefiniteStringLength(Witnet.Buffer memory _buffer, uint8 majorType) private pure returns(uint64) {
uint8 initialByte = _buffer.readUint8();
if (initialByte == 0xff) {
return _UINT64_MAX;
}
uint64 length = readLength(_buffer, initialByte & 0x1f);
require(length < _UINT64_MAX && (initialByte >> 5) == majorType, "WitnetDecoderLib: Invalid indefinite length");
return length;
}
/// Read a text string of a given length from a buffer. Returns a `bytes memory` value for the sake of genericness,
/// but it can be easily casted into a string with `string(result)`.
// solium-disable-next-line security/no-assign-params
function readText(Witnet.Buffer memory _buffer, uint64 _length) private pure returns(bytes memory) {
bytes memory result;
for (uint64 index = 0; index < _length; index++) {
uint8 value = _buffer.readUint8();
if (value & 0x80 != 0) {
if (value < 0xe0) {
value = (value & 0x1f) << 6 |
(_buffer.readUint8() & 0x3f);
_length -= 1;
} else if (value < 0xf0) {
value = (value & 0x0f) << 12 |
(_buffer.readUint8() & 0x3f) << 6 |
(_buffer.readUint8() & 0x3f);
_length -= 2;
} else {
value = (value & 0x0f) << 18 |
(_buffer.readUint8() & 0x3f) << 12 |
(_buffer.readUint8() & 0x3f) << 6 |
(_buffer.readUint8() & 0x3f);
_length -= 3;
}
}
result = abi.encodePacked(result, value);
}
return result;
}
}
// File: contracts\libs\WitnetParserLib.sol
/// @title A library for decoding Witnet request results
/// @notice The library exposes functions to check the Witnet request success.
/// and retrieve Witnet results from CBOR values into solidity types.
/// @author The Witnet Foundation.
library WitnetParserLib {
using WitnetDecoderLib for bytes;
using WitnetDecoderLib for Witnet.CBOR;
/// @notice Decode raw CBOR bytes into a Witnet.Result instance.
/// @param _cborBytes Raw bytes representing a CBOR-encoded value.
/// @return A `Witnet.Result` instance.
function resultFromCborBytes(bytes calldata _cborBytes)
external pure
returns (Witnet.Result memory)
{
Witnet.CBOR memory cborValue = _cborBytes.valueFromBytes();
return resultFromCborValue(cborValue);
}
/// @notice Decode a CBOR value into a Witnet.Result instance.
/// @param _cborValue An instance of `Witnet.Value`.
/// @return A `Witnet.Result` instance.
function resultFromCborValue(Witnet.CBOR memory _cborValue)
public pure
returns (Witnet.Result memory)
{
// Witnet uses CBOR tag 39 to represent RADON error code identifiers.
// [CBOR tag 39] Identifiers for CBOR: https://github.com/lucas-clemente/cbor-specs/blob/master/id.md
bool success = _cborValue.tag != 39;
return Witnet.Result(success, _cborValue);
}
/// @notice Tell if a Witnet.Result is successful.
/// @param _result An instance of Witnet.Result.
/// @return `true` if successful, `false` if errored.
function isOk(Witnet.Result memory _result)
external pure
returns (bool)
{
return _result.success;
}
/// @notice Tell if a Witnet.Result is errored.
/// @param _result An instance of Witnet.Result.
/// @return `true` if errored, `false` if successful.
function isError(Witnet.Result memory _result)
external pure
returns (bool)
{
return !_result.success;
}
/// @notice Decode a bytes value from a Witnet.Result as a `bytes` value.
/// @param _result An instance of Witnet.Result.
/// @return The `bytes` decoded from the Witnet.Result.
function asBytes(Witnet.Result memory _result)
external pure
returns(bytes memory)
{
require(_result.success, "WitnetParserLib: Tried to read bytes value from errored Witnet.Result");
return _result.value.decodeBytes();
}
/// @notice Decode a bytes value from a Witnet.Result as a `bytes32` value.
/// @param _result An instance of Witnet.Result.
/// @return The `bytes32` decoded from the Witnet.Result.
function asBytes32(Witnet.Result memory _result)
external pure
returns(bytes32)
{
require(_result.success, "WitnetParserLib: tried to read bytes32 value from errored Witnet.Result");
return _result.value.decodeBytes32();
}
/// @notice Decode an error code from a Witnet.Result as a member of `Witnet.ErrorCodes`.
/// @param _result An instance of `Witnet.Result`.
/// @return The `CBORValue.Error memory` decoded from the Witnet.Result.
function asErrorCode(Witnet.Result memory _result)
external pure
returns (Witnet.ErrorCodes)
{
uint64[] memory error = asRawError(_result);
if (error.length == 0) {
return Witnet.ErrorCodes.Unknown;
}
return _supportedErrorOrElseUnknown(error[0]);
}
/// @notice Generate a suitable error message for a member of `Witnet.ErrorCodes` and its corresponding arguments.
/// @dev WARN: Note that client contracts should wrap this function into a try-catch foreseing potential errors generated in this function
/// @param _result An instance of `Witnet.Result`.
/// @return A tuple containing the `CBORValue.Error memory` decoded from the `Witnet.Result`, plus a loggable error message.
function asErrorMessage(Witnet.Result memory _result)
public pure
returns (Witnet.ErrorCodes, string memory)
{
uint64[] memory error = asRawError(_result);
if (error.length == 0) {
return (Witnet.ErrorCodes.Unknown, "Unknown error (no error code)");
}
Witnet.ErrorCodes errorCode = _supportedErrorOrElseUnknown(error[0]);
bytes memory errorMessage;
if (errorCode == Witnet.ErrorCodes.SourceScriptNotCBOR && error.length >= 2) {
errorMessage = abi.encodePacked(
"Source script #",
_utoa(error[1]),
" was not a valid CBOR value"
);
} else if (errorCode == Witnet.ErrorCodes.SourceScriptNotArray && error.length >= 2) {
errorMessage = abi.encodePacked(
"The CBOR value in script #",
_utoa(error[1]),
" was not an Array of calls"
);
} else if (errorCode == Witnet.ErrorCodes.SourceScriptNotRADON && error.length >= 2) {
errorMessage = abi.encodePacked(
"The CBOR value in script #",
_utoa(error[1]),
" was not a valid Data Request"
);
} else if (errorCode == Witnet.ErrorCodes.RequestTooManySources && error.length >= 2) {
errorMessage = abi.encodePacked(
"The request contained too many sources (",
_utoa(error[1]),
")"
);
} else if (errorCode == Witnet.ErrorCodes.ScriptTooManyCalls && error.length >= 4) {
errorMessage = abi.encodePacked(
"Script #",
_utoa(error[2]),
" from the ",
stageName(error[1]),
" stage contained too many calls (",
_utoa(error[3]),
")"
);
} else if (errorCode == Witnet.ErrorCodes.UnsupportedOperator && error.length >= 5) {
errorMessage = abi.encodePacked(
"Operator code 0x",
_utohex(error[4]),
" found at call #",
_utoa(error[3]),
" in script #",
_utoa(error[2]),
" from ",
stageName(error[1]),
" stage is not supported"
);
} else if (errorCode == Witnet.ErrorCodes.HTTP && error.length >= 3) {
errorMessage = abi.encodePacked(
"Source #",
_utoa(error[1]),
" could not be retrieved. Failed with HTTP error code: ",
_utoa(error[2] / 100),
_utoa(error[2] % 100 / 10),
_utoa(error[2] % 10)
);
} else if (errorCode == Witnet.ErrorCodes.RetrievalTimeout && error.length >= 2) {
errorMessage = abi.encodePacked(
"Source #",
_utoa(error[1]),
" could not be retrieved because of a timeout"
);
} else if (errorCode == Witnet.ErrorCodes.Underflow && error.length >= 5) {
errorMessage = abi.encodePacked(
"Underflow at operator code 0x",
_utohex(error[4]),
" found at call #",
_utoa(error[3]),
" in script #",
_utoa(error[2]),
" from ",
stageName(error[1]),
" stage"
);
} else if (errorCode == Witnet.ErrorCodes.Overflow && error.length >= 5) {
errorMessage = abi.encodePacked(
"Overflow at operator code 0x",
_utohex(error[4]),
" found at call #",
_utoa(error[3]),
" in script #",
_utoa(error[2]),
" from ",
stageName(error[1]),
" stage"
);
} else if (errorCode == Witnet.ErrorCodes.DivisionByZero && error.length >= 5) {
errorMessage = abi.encodePacked(
"Division by zero at operator code 0x",
_utohex(error[4]),
" found at call #",
_utoa(error[3]),
" in script #",
_utoa(error[2]),
" from ",
stageName(error[1]),
" stage"
);
} else if (errorCode == Witnet.ErrorCodes.BridgeMalformedRequest) {
errorMessage = "The structure of the request is invalid and it cannot be parsed";
} else if (errorCode == Witnet.ErrorCodes.BridgePoorIncentives) {
errorMessage = "The request has been rejected by the bridge node due to poor incentives";
} else if (errorCode == Witnet.ErrorCodes.BridgeOversizedResult) {
errorMessage = "The request result length exceeds a bridge contract defined limit";
} else {
errorMessage = abi.encodePacked("Unknown error (0x", _utohex(error[0]), ")");
}
return (errorCode, string(errorMessage));
}
/// @notice Decode a raw error from a `Witnet.Result` as a `uint64[]`.
/// @param _result An instance of `Witnet.Result`.
/// @return The `uint64[]` raw error as decoded from the `Witnet.Result`.
function asRawError(Witnet.Result memory _result)
public pure
returns(uint64[] memory)
{
require(
!_result.success,
"WitnetParserLib: Tried to read error code from successful Witnet.Result"
);
return _result.value.decodeUint64Array();
}
/// @notice Decode a boolean value from a Witnet.Result as an `bool` value.
/// @param _result An instance of Witnet.Result.
/// @return The `bool` decoded from the Witnet.Result.
function asBool(Witnet.Result memory _result)
external pure
returns (bool)
{
require(_result.success, "WitnetParserLib: Tried to read `bool` value from errored Witnet.Result");
return _result.value.decodeBool();
}
/// @notice Decode a fixed16 (half-precision) numeric value from a Witnet.Result as an `int32` value.
/// @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values.
/// by 5 decimal orders so as to get a fixed precision of 5 decimal positions, which should be OK for most `fixed16`.
/// use cases. In other words, the output of this method is 10,000 times the actual value, encoded into an `int32`.
/// @param _result An instance of Witnet.Result.
/// @return The `int128` decoded from the Witnet.Result.
function asFixed16(Witnet.Result memory _result)
external pure
returns (int32)
{
require(_result.success, "WitnetParserLib: Tried to read `fixed16` value from errored Witnet.Result");
return _result.value.decodeFixed16();
}
/// @notice Decode an array of fixed16 values from a Witnet.Result as an `int128[]` value.
/// @param _result An instance of Witnet.Result.
/// @return The `int128[]` decoded from the Witnet.Result.
function asFixed16Array(Witnet.Result memory _result)
external pure
returns (int32[] memory)
{
require(_result.success, "WitnetParserLib: Tried to read `fixed16[]` value from errored Witnet.Result");
return _result.value.decodeFixed16Array();
}
/// @notice Decode a integer numeric value from a Witnet.Result as an `int128` value.
/// @param _result An instance of Witnet.Result.
/// @return The `int128` decoded from the Witnet.Result.
function asInt128(Witnet.Result memory _result)
external pure
returns (int128)
{
require(_result.success, "WitnetParserLib: Tried to read `int128` value from errored Witnet.Result");
return _result.value.decodeInt128();
}
/// @notice Decode an array of integer numeric values from a Witnet.Result as an `int128[]` value.
/// @param _result An instance of Witnet.Result.
/// @return The `int128[]` decoded from the Witnet.Result.
function asInt128Array(Witnet.Result memory _result)
external pure
returns (int128[] memory)
{
require(_result.success, "WitnetParserLib: Tried to read `int128[]` value from errored Witnet.Result");
return _result.value.decodeInt128Array();
}
/// @notice Decode a string value from a Witnet.Result as a `string` value.
/// @param _result An instance of Witnet.Result.
/// @return The `string` decoded from the Witnet.Result.
function asString(Witnet.Result memory _result)
external pure
returns(string memory)
{
require(_result.success, "WitnetParserLib: Tried to read `string` value from errored Witnet.Result");
return _result.value.decodeString();
}
/// @notice Decode an array of string values from a Witnet.Result as a `string[]` value.
/// @param _result An instance of Witnet.Result.
/// @return The `string[]` decoded from the Witnet.Result.
function asStringArray(Witnet.Result memory _result)
external pure
returns (string[] memory)
{
require(_result.success, "WitnetParserLib: Tried to read `string[]` value from errored Witnet.Result");
return _result.value.decodeStringArray();
}
/// @notice Decode a natural numeric value from a Witnet.Result as a `uint64` value.
/// @param _result An instance of Witnet.Result.
/// @return The `uint64` decoded from the Witnet.Result.
function asUint64(Witnet.Result memory _result)
external pure
returns(uint64)
{
require(_result.success, "WitnetParserLib: Tried to read `uint64` value from errored Witnet.Result");
return _result.value.decodeUint64();
}
/// @notice Decode an array of natural numeric values from a Witnet.Result as a `uint64[]` value.
/// @param _result An instance of Witnet.Result.
/// @return The `uint64[]` decoded from the Witnet.Result.
function asUint64Array(Witnet.Result memory _result)
external pure
returns (uint64[] memory)
{
require(_result.success, "WitnetParserLib: Tried to read `uint64[]` value from errored Witnet.Result");
return _result.value.decodeUint64Array();
}
/// @notice Convert a stage index number into the name of the matching Witnet request stage.
/// @param _stageIndex A `uint64` identifying the index of one of the Witnet request stages.
/// @return The name of the matching stage.
function stageName(uint64 _stageIndex)
public pure
returns (string memory)
{
if (_stageIndex == 0) {
return "retrieval";
} else if (_stageIndex == 1) {
return "aggregation";
} else if (_stageIndex == 2) {
return "tally";
} else {
return "unknown";
}
}
/// @notice Get an `Witnet.ErrorCodes` item from its `uint64` discriminant.
/// @param _discriminant The numeric identifier of an error.
/// @return A member of `Witnet.ErrorCodes`.
function _supportedErrorOrElseUnknown(uint64 _discriminant)
private pure
returns (Witnet.ErrorCodes)
{
return Witnet.ErrorCodes(_discriminant);
}
/// @notice Convert a `uint64` into a 1, 2 or 3 characters long `string` representing its.
/// three less significant decimal values.
/// @param _u A `uint64` value.
/// @return The `string` representing its decimal value.
function _utoa(uint64 _u)
private pure
returns (string memory)
{
if (_u < 10) {
bytes memory b1 = new bytes(1);
b1[0] = bytes1(uint8(_u) + 48);
return string(b1);
} else if (_u < 100) {
bytes memory b2 = new bytes(2);
b2[0] = bytes1(uint8(_u / 10) + 48);
b2[1] = bytes1(uint8(_u % 10) + 48);
return string(b2);
} else {
bytes memory b3 = new bytes(3);
b3[0] = bytes1(uint8(_u / 100) + 48);
b3[1] = bytes1(uint8(_u % 100 / 10) + 48);
b3[2] = bytes1(uint8(_u % 10) + 48);
return string(b3);
}
}
/// @notice Convert a `uint64` into a 2 characters long `string` representing its two less significant hexadecimal values.
/// @param _u A `uint64` value.
/// @return The `string` representing its hexadecimal value.
function _utohex(uint64 _u)
private pure
returns (string memory)
{
bytes memory b2 = new bytes(2);
uint8 d0 = uint8(_u / 16) + 48;
uint8 d1 = uint8(_u % 16) + 48;
if (d0 > 57)
d0 += 7;
if (d1 > 57)
d1 += 7;
b2[0] = bytes1(d0);
b2[1] = bytes1(d1);
return string(b2);
}
}
// File: contracts\interfaces\IERC20.sol
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/// Returns the amount of tokens in existence.
function totalSupply() external view returns (uint256);
/// Returns the amount of tokens owned by `_account`.
function balanceOf(address _account) external view returns (uint256);
/// Moves `_amount` tokens from the caller's account to `_recipient`.
/// Returns a boolean value indicating whether the operation succeeded.
/// Emits a {Transfer} event.
function transfer(address _recipient, uint256 _amount) external returns (bool);
/// Returns the remaining number of tokens that `_spender` will be
/// allowed to spend on behalf of `_owner` through {transferFrom}. This is
/// zero by default.
/// This value changes when {approve} or {transferFrom} are called.
function allowance(address _owner, address _spender) external view returns (uint256);
/// Sets `_amount` as the allowance of `_spender` over the caller's tokens.
/// Returns a boolean value indicating whether the operation succeeded.
///
/// IMPORTANT: Beware that changing an allowance with this method brings the risk
/// that someone may use both the old and the new allowance by unfortunate
/// transaction ordering. One possible solution to mitigate this race
/// condition is to first reduce the spender's allowance to 0 and set the
/// desired value afterwards:
/// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
///
/// Emits an {Approval} event.
function approve(address _spender, uint256 _amount) external returns (bool);
/// Moves `amount` tokens from `_sender` to `_recipient` using the
/// allowance mechanism. `amount` is then deducted from the caller's
/// allowance.
/// Returns a boolean value indicating whether the operation succeeded.
/// Emits a {Transfer} event.
function transferFrom(
address _sender,
address _recipient,
uint256 _amount
) external returns (bool);
/// Emitted when `value` tokens are moved from one account (`from`) to
/// another (`to`).
/// Note that `:value` may be zero.
event Transfer(address indexed from, address indexed to, uint256 value);
/// Emitted when the allowance of a `spender` for an `owner` is set by
/// a call to {approve}. `value` is the new allowance.
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: contracts\patterns\Payable.sol
abstract contract Payable {
IERC20 public immutable currency;
event Received(address from, uint256 amount);
event Transfer(address to, uint256 amount);
constructor(address _currency) {
currency = IERC20(_currency);
}
/// Gets current transaction price.
function _getGasPrice() internal view virtual returns (uint256);
/// Gets current payment value.
function _getMsgValue() internal view virtual returns (uint256);
/// Perform safe transfer or whatever token is used for paying rewards.
function _safeTransferTo(address payable, uint256) internal virtual;
}
// File: contracts\impls\trustable\WitnetRequestBoardTrustableBase.sol
/// @title Witnet Request Board "trustable" base implementation contract.
/// @notice Contract to bridge requests to Witnet Decentralized Oracle Network.
/// @dev This contract enables posting requests that Witnet bridges will insert into the Witnet network.
/// The result of the requests will be posted back to this contract by the bridge nodes too.
/// @author The Witnet Foundation
abstract contract WitnetRequestBoardTrustableBase
is
Payable,
IWitnetRequestBoardAdmin,
IWitnetRequestBoardAdminACLs,
WitnetBoardDataACLs,
WitnetRequestBoardUpgradableBase
{
using Witnet for bytes;
using WitnetParserLib for Witnet.Result;
constructor(bool _upgradable, bytes32 _versionTag, address _currency)
Payable(_currency)
WitnetRequestBoardUpgradableBase(_upgradable, _versionTag)
{}
// ================================================================================================================
// --- Overrides 'Upgradable' -------------------------------------------------------------------------------------
/// Initialize storage-context when invoked as delegatecall.
/// @dev Must fail when trying to initialize same instance more than once.
function initialize(bytes memory _initData) virtual external override {
address _owner = _state().owner;
if (_owner == address(0)) {
// set owner if none set yet
_owner = msg.sender;
_state().owner = _owner;
} else {
// only owner can initialize:
require(msg.sender == _owner, "WitnetRequestBoardTrustableBase: only owner");
}
if (_state().base != address(0)) {
// current implementation cannot be initialized more than once:
require(_state().base != base(), "WitnetRequestBoardTrustableBase: already initialized");
}
_state().base = base();
emit Upgraded(msg.sender, base(), codehash(), version());
// Do actual base initialization:
setReporters(abi.decode(_initData, (address[])));
}
/// Tells whether provided address could eventually upgrade the contract.
function isUpgradableFrom(address _from) external view override returns (bool) {
address _owner = _state().owner;
return (
// false if the WRB is intrinsically not upgradable, or `_from` is no owner
isUpgradable()
&& _owner == _from
);
}
// ================================================================================================================
// --- Full implementation of 'IWitnetRequestBoardAdmin' ----------------------------------------------------------
/// Gets admin/owner address.
function owner()
public view
override
returns (address)
{
return _state().owner;
}
/// Transfers ownership.
function transferOwnership(address _newOwner)
external
virtual override
onlyOwner
{
address _owner = _state().owner;
if (_newOwner != _owner) {
_state().owner = _newOwner;
emit OwnershipTransferred(_owner, _newOwner);
}
}
// ================================================================================================================
// --- Full implementation of 'IWitnetRequestBoardAdminACLs' ------------------------------------------------------
/// Tells whether given address is included in the active reporters control list.
/// @param _reporter The address to be checked.
function isReporter(address _reporter) public view override returns (bool) {
return _acls().isReporter_[_reporter];
}
/// Adds given addresses to the active reporters control list.
/// @dev Can only be called from the owner address.
/// @dev Emits the `ReportersSet` event.
/// @param _reporters List of addresses to be added to the active reporters control list.
function setReporters(address[] memory _reporters)
public
override
onlyOwner
{
for (uint ix = 0; ix < _reporters.length; ix ++) {
address _reporter = _reporters[ix];
_acls().isReporter_[_reporter] = true;
}
emit ReportersSet(_reporters);
}
/// Removes given addresses from the active reporters control list.
/// @dev Can only be called from the owner address.
/// @dev Emits the `ReportersUnset` event.
/// @param _exReporters List of addresses to be added to the active reporters control list.
function unsetReporters(address[] memory _exReporters)
public
override
onlyOwner
{
for (uint ix = 0; ix < _exReporters.length; ix ++) {
address _reporter = _exReporters[ix];
_acls().isReporter_[_reporter] = false;
}
emit ReportersUnset(_exReporters);
}
// ================================================================================================================
// --- Full implementation of 'IWitnetRequestBoardReporter' -------------------------------------------------------
/// Reports the Witnet-provided result to a previously posted request.
/// @dev Will assume `block.timestamp` as the timestamp at which the request was solved.
/// @dev Fails if:
/// @dev - the `_queryId` is not in 'Posted' status.
/// @dev - provided `_drTxHash` is zero;
/// @dev - length of provided `_result` is zero.
/// @param _queryId The unique identifier of the data request.
/// @param _drTxHash The hash of the solving tally transaction in Witnet.
/// @param _cborBytes The result itself as bytes.
function reportResult(
uint256 _queryId,
bytes32 _drTxHash,
bytes calldata _cborBytes
)
external
override
onlyReporters
inStatus(_queryId, Witnet.QueryStatus.Posted)
{
require(_drTxHash != 0, "WitnetRequestBoardTrustableDefault: Witnet drTxHash cannot be zero");
// Ensures the result bytes do not have zero length
// This would not be a valid encoding with CBOR and could trigger a reentrancy attack
require(_cborBytes.length != 0, "WitnetRequestBoardTrustableDefault: result cannot be empty");
// solhint-disable not-rely-on-time
_safeTransferTo(
payable(msg.sender),
__reportResult(
_queryId,
block.timestamp,
_drTxHash,
_cborBytes
)
);
emit PostedResult(_queryId, msg.sender);
}
/// Reports the Witnet-provided result to a previously posted request.
/// @dev Fails if:
/// @dev - called from unauthorized address;
/// @dev - the `_queryId` is not in 'Posted' status.
/// @dev - provided `_drTxHash` is zero;
/// @dev - length of provided `_result` is zero.
/// @param _queryId The unique query identifier
/// @param _timestamp The timestamp of the solving tally transaction in Witnet.
/// @param _drTxHash The hash of the solving tally transaction in Witnet.
/// @param _cborBytes The result itself as bytes.
function reportResult(
uint256 _queryId,
uint256 _timestamp,
bytes32 _drTxHash,
bytes calldata _cborBytes
)
external
override
onlyReporters
inStatus(_queryId, Witnet.QueryStatus.Posted)
{
require(_timestamp <= block.timestamp, "WitnetRequestBoardTrustableDefault: bad timestamp");
require(_drTxHash != 0, "WitnetRequestBoardTrustableDefault: Witnet drTxHash cannot be zero");
// Ensures the result bytes do not have zero length
// This would not be a valid encoding with CBOR and could trigger a reentrancy attack
require(_cborBytes.length != 0, "WitnetRequestBoardTrustableDefault: result cannot be empty");
_safeTransferTo(
payable(msg.sender),
__reportResult(
_queryId,
_timestamp,
_drTxHash,
_cborBytes
)
);
emit PostedResult(_queryId, msg.sender);
}
/// Reports Witnet-provided results to multiple requests within a single EVM tx.
/// @dev Fails if called from unauthorized address.
/// @dev Emits a PostedResult event for every succesfully reported result, if any.
/// @param _batchResults Array of BatchedResult structs, every one containing:
/// - unique query identifier;
/// - timestamp of the solving tally txs in Witnet. If zero is provided, EVM-timestamp will be used instead;
/// - hash of the corresponding data request tx at the Witnet side-chain level;
/// - data request result in raw bytes.
/// @param _verbose If true, emits a BatchReportError event for every failing report, if any.
function reportResultBatch(
BatchResult[] memory _batchResults,
bool _verbose
)
external
override
onlyReporters
{
uint _batchReward;
uint _batchSize = _batchResults.length;
for ( uint _i = 0; _i < _batchSize; _i ++) {
BatchResult memory _result = _batchResults[_i];
if (_getQueryStatus(_result.queryId) != Witnet.QueryStatus.Posted) {
if (_verbose) {
emit BatchReportError(
_result.queryId,
"WitnetRequestBoardTrustableBase: bad queryId"
);
}
} else if (_result.drTxHash == 0) {
if (_verbose) {
emit BatchReportError(
_result.queryId,
"WitnetRequestBoardTrustableBase: bad drTxHash"
);
}
} else if (_result.cborBytes.length == 0) {
if (_verbose) {
emit BatchReportError(
_result.queryId,
"WitnetRequestBoardTrustableBase: bad cborBytes"
);
}
} else if (_result.timestamp > 0 && _result.timestamp > block.timestamp) {
if (_verbose) {
emit BatchReportError(
_result.queryId,
"WitnetRequestBoardTrustableBase: bad timestamp"
);
}
} else {
_batchReward += __reportResult(
_result.queryId,
_result.timestamp == 0 ? block.timestamp : _result.timestamp,
_result.drTxHash,
_result.cborBytes
);
emit PostedResult(
_result.queryId,
msg.sender
);
}
}
// Transfer all successful rewards in one single shot to the authorized reporter, if any:
if (_batchReward > 0) {
_safeTransferTo(
payable(msg.sender),
_batchReward
);
}
}
// ================================================================================================================
// --- Full implementation of 'IWitnetRequestBoardRequestor' ------------------------------------------------------
/// Retrieves copy of all response data related to a previously posted request, removing the whole query from storage.
/// @dev Fails if the `_queryId` is not in 'Reported' status, or called from an address different to
/// @dev the one that actually posted the given request.
/// @param _queryId The unique query identifier.
function deleteQuery(uint256 _queryId)
public
virtual override
inStatus(_queryId, Witnet.QueryStatus.Reported)
returns (Witnet.Response memory _response)
{
Witnet.Query storage __query = _state().queries[_queryId];
require(
msg.sender == __query.from,
"WitnetRequestBoardTrustableBase: only requester"
);
_response = __query.response;
delete _state().queries[_queryId];
emit DeletedQuery(_queryId, msg.sender);
}
/// Requests the execution of the given Witnet Data Request in expectation that it will be relayed and solved by the Witnet DON.
/// A reward amount is escrowed by the Witnet Request Board that will be transferred to the reporter who relays back the Witnet-provided
/// result to this request.
/// @dev Fails if:
/// @dev - provided reward is too low.
/// @dev - provided script is zero address.
/// @dev - provided script bytecode is empty.
/// @param _addr The address of a IWitnetRequest contract, containing the actual Data Request seralized bytecode.
/// @return _queryId An unique query identifier.
function postRequest(IWitnetRequest _addr)
public payable
virtual override
returns (uint256 _queryId)
{
uint256 _value = _getMsgValue();
uint256 _gasPrice = _getGasPrice();
// Checks the tally reward is covering gas cost
uint256 minResultReward = estimateReward(_gasPrice);
require(_value >= minResultReward, "WitnetRequestBoardTrustableBase: reward too low");
// Validates provided script:
require(address(_addr) != address(0), "WitnetRequestBoardTrustableBase: null script");
bytes memory _bytecode = _addr.bytecode();
require(_bytecode.length > 0, "WitnetRequestBoardTrustableBase: empty script");
_queryId = ++ _state().numQueries;
_state().queries[_queryId].from = msg.sender;
Witnet.Request storage _request = _getRequestData(_queryId);
_request.addr = _addr;
_request.hash = _bytecode.hash();
_request.gasprice = _gasPrice;
_request.reward = _value;
// Let observers know that a new request has been posted
emit PostedRequest(_queryId, msg.sender);
}
/// Increments the reward of a previously posted request by adding the transaction value to it.
/// @dev Updates request `gasPrice` in case this method is called with a higher
/// @dev gas price value than the one used in previous calls to `postRequest` or
/// @dev `upgradeReward`.
/// @dev Fails if the `_queryId` is not in 'Posted' status.
/// @dev Fails also in case the request `gasPrice` is increased, and the new
/// @dev reward value gets below new recalculated threshold.
/// @param _queryId The unique query identifier.
function upgradeReward(uint256 _queryId)
public payable
virtual override
inStatus(_queryId, Witnet.QueryStatus.Posted)
{
Witnet.Request storage _request = _getRequestData(_queryId);
uint256 _newReward = _request.reward + _getMsgValue();
uint256 _newGasPrice = _getGasPrice();
// If gas price is increased, then check if new rewards cover gas costs
if (_newGasPrice > _request.gasprice) {
// Checks the reward is covering gas cost
uint256 _minResultReward = estimateReward(_newGasPrice);
require(
_newReward >= _minResultReward,
"WitnetRequestBoardTrustableBase: reward too low"
);
_request.gasprice = _newGasPrice;
}
_request.reward = _newReward;
}
// ================================================================================================================
// --- Full implementation of 'IWitnetRequestBoardView' -----------------------------------------------------------
/// Estimates the amount of reward we need to insert for a given gas price.
/// @param _gasPrice The gas price for which we need to calculate the rewards.
function estimateReward(uint256 _gasPrice)
public view
virtual override
returns (uint256);
/// Returns next request id to be generated by the Witnet Request Board.
function getNextQueryId()
external view
override
returns (uint256)
{
return _state().numQueries + 1;
}
/// Gets the whole Query data contents, if any, no matter its current status.
function getQueryData(uint256 _queryId)
external view
override
returns (Witnet.Query memory)
{
return _state().queries[_queryId];
}
/// Gets current status of given query.
function getQueryStatus(uint256 _queryId)
external view
override
returns (Witnet.QueryStatus)
{
return _getQueryStatus(_queryId);
}
/// Retrieves the whole Request record posted to the Witnet Request Board.
/// @dev Fails if the `_queryId` is not valid or, if it has already been reported
/// @dev or deleted.
/// @param _queryId The unique identifier of a previously posted query.
function readRequest(uint256 _queryId)
external view
override
inStatus(_queryId, Witnet.QueryStatus.Posted)
returns (Witnet.Request memory _request)
{
Witnet.Query storage __query = _state().queries[_queryId];
_request = __query.request;
if (__query.from != address(0)) {
_request.requester = __query.from;
}
}
/// Retrieves the serialized bytecode of a previously posted Witnet Data Request.
/// @dev Fails if the `_queryId` is not valid, or if the related script bytecode
/// @dev got changed after being posted. Returns empty array once it gets reported,
/// @dev or deleted.
/// @param _queryId The unique query identifier.
function readRequestBytecode(uint256 _queryId)
external view
override
returns (bytes memory _bytecode)
{
require(
_getQueryStatus(_queryId) != Witnet.QueryStatus.Unknown,
"WitnetRequestBoardTrustableBase: not yet posted"
);
Witnet.Request storage _request = _getRequestData(_queryId);
if (address(_request.addr) != address(0)) {
// if DR's request contract address is not zero,
// we assume the DR has not been deleted, so
// DR's bytecode can still be fetched:
_bytecode = _request.addr.bytecode();
require(
_bytecode.hash() == _request.hash,
"WitnetRequestBoardTrustableBase: bytecode changed after posting"
);
}
}
/// Retrieves the gas price that any assigned reporter will have to pay when reporting
/// result to a previously posted Witnet data request.
/// @dev Fails if the `_queryId` is not valid or, if it has already been
/// @dev reported, or deleted.
/// @param _queryId The unique query identifier
function readRequestGasPrice(uint256 _queryId)
external view
override
inStatus(_queryId, Witnet.QueryStatus.Posted)
returns (uint256)
{
return _state().queries[_queryId].request.gasprice;
}
/// Retrieves the reward currently set for a previously posted request.
/// @dev Fails if the `_queryId` is not valid or, if it has already been
/// @dev reported, or deleted.
/// @param _queryId The unique query identifier
function readRequestReward(uint256 _queryId)
external view
override
inStatus(_queryId, Witnet.QueryStatus.Posted)
returns (uint256)
{
return _state().queries[_queryId].request.reward;
}
/// Retrieves the Witnet-provided result, and metadata, to a previously posted request.
/// @dev Fails if the `_queryId` is not in 'Reported' status.
/// @param _queryId The unique query identifier
function readResponse(uint256 _queryId)
external view
override
inStatus(_queryId, Witnet.QueryStatus.Reported)
returns (Witnet.Response memory _response)
{
return _getResponseData(_queryId);
}
/// Retrieves the hash of the Witnet transaction that actually solved the referred query.
/// @dev Fails if the `_queryId` is not in 'Reported' status.
/// @param _queryId The unique query identifier.
function readResponseDrTxHash(uint256 _queryId)
external view
override
inStatus(_queryId, Witnet.QueryStatus.Reported)
returns (bytes32)
{
return _getResponseData(_queryId).drTxHash;
}
/// Retrieves the address that reported the result to a previously-posted request.
/// @dev Fails if the `_queryId` is not in 'Reported' status.
/// @param _queryId The unique query identifier
function readResponseReporter(uint256 _queryId)
external view
override
inStatus(_queryId, Witnet.QueryStatus.Reported)
returns (address)
{
return _getResponseData(_queryId).reporter;
}
/// Retrieves the Witnet-provided CBOR-bytes result of a previously posted request.
/// @dev Fails if the `_queryId` is not in 'Reported' status.
/// @param _queryId The unique query identifier
function readResponseResult(uint256 _queryId)
external view
override
inStatus(_queryId, Witnet.QueryStatus.Reported)
returns (Witnet.Result memory)
{
Witnet.Response storage _response = _getResponseData(_queryId);
return WitnetParserLib.resultFromCborBytes(_response.cborBytes);
}
/// Retrieves the timestamp in which the result to the referred query was solved by the Witnet DON.
/// @dev Fails if the `_queryId` is not in 'Reported' status.
/// @param _queryId The unique query identifier.
function readResponseTimestamp(uint256 _queryId)
external view
override
inStatus(_queryId, Witnet.QueryStatus.Reported)
returns (uint256)
{
return _getResponseData(_queryId).timestamp;
}
// ================================================================================================================
// --- Full implementation of 'IWitnetRequestParser' interface ----------------------------------------------------
/// Decode raw CBOR bytes into a Witnet.Result instance.
/// @param _cborBytes Raw bytes representing a CBOR-encoded value.
/// @return A `Witnet.Result` instance.
function resultFromCborBytes(bytes memory _cborBytes)
external pure
override
returns (Witnet.Result memory)
{
return WitnetParserLib.resultFromCborBytes(_cborBytes);
}
/// Decode a CBOR value into a Witnet.Result instance.
/// @param _cborValue An instance of `Witnet.CBOR`.
/// @return A `Witnet.Result` instance.
function resultFromCborValue(Witnet.CBOR memory _cborValue)
external pure
override
returns (Witnet.Result memory)
{
return WitnetParserLib.resultFromCborValue(_cborValue);
}
/// Tell if a Witnet.Result is successful.
/// @param _result An instance of Witnet.Result.
/// @return `true` if successful, `false` if errored.
function isOk(Witnet.Result memory _result)
external pure
override
returns (bool)
{
return _result.isOk();
}
/// Tell if a Witnet.Result is errored.
/// @param _result An instance of Witnet.Result.
/// @return `true` if errored, `false` if successful.
function isError(Witnet.Result memory _result)
external pure
override
returns (bool)
{
return _result.isError();
}
/// Decode a bytes value from a Witnet.Result as a `bytes` value.
/// @param _result An instance of Witnet.Result.
/// @return The `bytes` decoded from the Witnet.Result.
function asBytes(Witnet.Result memory _result)
external pure
override
returns (bytes memory)
{
return _result.asBytes();
}
/// Decode a bytes value from a Witnet.Result as a `bytes32` value.
/// @param _result An instance of Witnet.Result.
/// @return The `bytes32` decoded from the Witnet.Result.
function asBytes32(Witnet.Result memory _result)
external pure
override
returns (bytes32)
{
return _result.asBytes32();
}
/// Decode an error code from a Witnet.Result as a member of `Witnet.ErrorCodes`.
/// @param _result An instance of `Witnet.Result`.
/// @return The `CBORValue.Error memory` decoded from the Witnet.Result.
function asErrorCode(Witnet.Result memory _result)
external pure
override
returns (Witnet.ErrorCodes)
{
return _result.asErrorCode();
}
/// Generate a suitable error message for a member of `Witnet.ErrorCodes` and its corresponding arguments.
/// @dev WARN: Note that client contracts should wrap this function into a try-catch foreseing potential errors generated in this function
/// @param _result An instance of `Witnet.Result`.
/// @return A tuple containing the `CBORValue.Error memory` decoded from the `Witnet.Result`, plus a loggable error message.
function asErrorMessage(Witnet.Result memory _result)
external pure
override
returns (Witnet.ErrorCodes, string memory)
{
try _result.asErrorMessage() returns (Witnet.ErrorCodes _code, string memory _message) {
return (_code, _message);
}
catch Error(string memory _reason) {
return (Witnet.ErrorCodes.Unknown, _reason);
}
catch (bytes memory) {
return (Witnet.ErrorCodes.UnhandledIntercept, "WitnetRequestBoardTrustableBase: failing assert");
}
}
/// Decode a raw error from a `Witnet.Result` as a `uint64[]`.
/// @param _result An instance of `Witnet.Result`.
/// @return The `uint64[]` raw error as decoded from the `Witnet.Result`.
function asRawError(Witnet.Result memory _result)
external pure
override
returns(uint64[] memory)
{
return _result.asRawError();
}
/// Decode a boolean value from a Witnet.Result as an `bool` value.
/// @param _result An instance of Witnet.Result.
/// @return The `bool` decoded from the Witnet.Result.
function asBool(Witnet.Result memory _result)
external pure
override
returns (bool)
{
return _result.asBool();
}
/// Decode a fixed16 (half-precision) numeric value from a Witnet.Result as an `int32` value.
/// @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values.
/// by 5 decimal orders so as to get a fixed precision of 5 decimal positions, which should be OK for most `fixed16`.
/// use cases. In other words, the output of this method is 10,000 times the actual value, encoded into an `int32`.
/// @param _result An instance of Witnet.Result.
/// @return The `int128` decoded from the Witnet.Result.
function asFixed16(Witnet.Result memory _result)
external pure
override
returns (int32)
{
return _result.asFixed16();
}
/// Decode an array of fixed16 values from a Witnet.Result as an `int128[]` value.
/// @param _result An instance of Witnet.Result.
/// @return The `int128[]` decoded from the Witnet.Result.
function asFixed16Array(Witnet.Result memory _result)
external pure
override
returns (int32[] memory)
{
return _result.asFixed16Array();
}
/// Decode a integer numeric value from a Witnet.Result as an `int128` value.
/// @param _result An instance of Witnet.Result.
/// @return The `int128` decoded from the Witnet.Result.
function asInt128(Witnet.Result memory _result)
external pure
override
returns (int128)
{
return _result.asInt128();
}
/// Decode an array of integer numeric values from a Witnet.Result as an `int128[]` value.
/// @param _result An instance of Witnet.Result.
/// @return The `int128[]` decoded from the Witnet.Result.
function asInt128Array(Witnet.Result memory _result)
external pure
override
returns (int128[] memory)
{
return _result.asInt128Array();
}
/// Decode a string value from a Witnet.Result as a `string` value.
/// @param _result An instance of Witnet.Result.
/// @return The `string` decoded from the Witnet.Result.
function asString(Witnet.Result memory _result)
external pure
override
returns (string memory)
{
return _result.asString();
}
/// Decode an array of string values from a Witnet.Result as a `string[]` value.
/// @param _result An instance of Witnet.Result.
/// @return The `string[]` decoded from the Witnet.Result.
function asStringArray(Witnet.Result memory _result)
external pure
override
returns (string[] memory)
{
return _result.asStringArray();
}
/// Decode a natural numeric value from a Witnet.Result as a `uint64` value.
/// @param _result An instance of Witnet.Result.
/// @return The `uint64` decoded from the Witnet.Result.
function asUint64(Witnet.Result memory _result)
external pure
override
returns(uint64)
{
return _result.asUint64();
}
/// Decode an array of natural numeric values from a Witnet.Result as a `uint64[]` value.
/// @param _result An instance of Witnet.Result.
/// @return The `uint64[]` decoded from the Witnet.Result.
function asUint64Array(Witnet.Result memory _result)
external pure
override
returns (uint64[] memory)
{
return _result.asUint64Array();
}
// ================================================================================================================
// --- Internal functions -----------------------------------------------------------------------------------------
function __reportResult(
uint256 _queryId,
uint256 _timestamp,
bytes32 _drTxHash,
bytes memory _cborBytes
)
internal
returns (uint256 _reward)
{
Witnet.Query storage __query = _state().queries[_queryId];
Witnet.Request storage __request = __query.request;
Witnet.Response storage __response = __query.response;
// solhint-disable not-rely-on-time
__response.timestamp = _timestamp;
__response.drTxHash = _drTxHash;
__response.reporter = msg.sender;
__response.cborBytes = _cborBytes;
// return request latest reward
_reward = __request.reward;
// Request data won't be needed anymore, so it can just get deleted right now:
delete __query.request;
}
}
// File: contracts\patterns\Destructible.sol
interface Destructible {
/// @dev Self-destruct the whole contract.
function destruct() external;
}
// File: contracts\impls\trustable\WitnetRequestBoardTrustableDefault.sol
/* solhint-disable var-name-mixedcase */
/// @title Witnet Request Board "trustable" implementation contract.
/// @notice Contract to bridge requests to Witnet Decentralized Oracle Network.
/// @dev This contract enables posting requests that Witnet bridges will insert into the Witnet network.
/// The result of the requests will be posted back to this contract by the bridge nodes too.
/// @author The Witnet Foundation
contract WitnetRequestBoardTrustableDefault
is
Destructible,
WitnetRequestBoardTrustableBase
{
uint256 internal immutable _ESTIMATED_REPORT_RESULT_GAS;
constructor(
bool _upgradable,
bytes32 _versionTag,
uint256 _reportResultGasLimit
)
WitnetRequestBoardTrustableBase(_upgradable, _versionTag, address(0))
{
_ESTIMATED_REPORT_RESULT_GAS = _reportResultGasLimit;
}
// ================================================================================================================
// --- Overrides implementation of 'IWitnetRequestBoardView' ------------------------------------------------------
/// Estimates the amount of reward we need to insert for a given gas price.
/// @param _gasPrice The gas price for which we need to calculate the rewards.
function estimateReward(uint256 _gasPrice)
public view
virtual override
returns (uint256)
{
return _gasPrice * _ESTIMATED_REPORT_RESULT_GAS;
}
// ================================================================================================================
// --- Overrides 'Destructible' -----------------------------------------------------------------------------------
/// Destroys current instance. Only callable by the owner.
function destruct() external override onlyOwner {
selfdestruct(payable(msg.sender));
}
// ================================================================================================================
// --- Overrides 'Payable' ----------------------------------------------------------------------------------------
/// Gets current transaction price.
function _getGasPrice()
internal view
override
returns (uint256)
{
return tx.gasprice;
}
/// Gets current payment value.
function _getMsgValue()
internal view
override
returns (uint256)
{
return msg.value;
}
/// Transfers ETHs to given address.
/// @param _to Recipient address.
/// @param _amount Amount of ETHs to transfer.
function _safeTransferTo(address payable _to, uint256 _amount)
internal
override
{
payable(_to).transfer(_amount);
}
}

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"bool","name":"_upgradable","internalType":"bool"},{"type":"bytes32","name":"_versionTag","internalType":"bytes32"},{"type":"uint256","name":"_reportResultGasLimit","internalType":"uint256"}]},{"type":"event","name":"BatchReportError","inputs":[{"type":"uint256","name":"queryId","internalType":"uint256","indexed":false},{"type":"string","name":"reason","internalType":"string","indexed":false}],"anonymous":false},{"type":"event","name":"DeletedQuery","inputs":[{"type":"uint256","name":"queryId","internalType":"uint256","indexed":false},{"type":"address","name":"from","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"PostedRequest","inputs":[{"type":"uint256","name":"queryId","internalType":"uint256","indexed":false},{"type":"address","name":"from","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"PostedResult","inputs":[{"type":"uint256","name":"queryId","internalType":"uint256","indexed":false},{"type":"address","name":"from","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Received","inputs":[{"type":"address","name":"from","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ReportersSet","inputs":[{"type":"address[]","name":"reporters","internalType":"address[]","indexed":false}],"anonymous":false},{"type":"event","name":"ReportersUnset","inputs":[{"type":"address[]","name":"reporters","internalType":"address[]","indexed":false}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"to","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"baseAddr","internalType":"address","indexed":true},{"type":"bytes32","name":"baseCodehash","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"versionTag","internalType":"bytes32","indexed":false}],"anonymous":false},{"type":"fallback","stateMutability":"payable"},{"type":"function","stateMutability":"pure","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"asBool","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes","name":"","internalType":"bytes"}],"name":"asBytes","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"asBytes32","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint8","name":"","internalType":"enum Witnet.ErrorCodes"}],"name":"asErrorCode","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint8","name":"","internalType":"enum Witnet.ErrorCodes"},{"type":"string","name":"","internalType":"string"}],"name":"asErrorMessage","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"int32","name":"","internalType":"int32"}],"name":"asFixed16","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"int32[]","name":"","internalType":"int32[]"}],"name":"asFixed16Array","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"int128","name":"","internalType":"int128"}],"name":"asInt128","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"int128[]","name":"","internalType":"int128[]"}],"name":"asInt128Array","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint64[]","name":"","internalType":"uint64[]"}],"name":"asRawError","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"asString","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"string[]","name":"","internalType":"string[]"}],"name":"asStringArray","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint64","name":"","internalType":"uint64"}],"name":"asUint64","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint64[]","name":"","internalType":"uint64[]"}],"name":"asUint64Array","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"base","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"_codehash","internalType":"bytes32"}],"name":"codehash","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"currency","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"tuple","name":"_response","internalType":"struct Witnet.Response","components":[{"type":"address","name":"reporter","internalType":"address"},{"type":"uint256","name":"timestamp","internalType":"uint256"},{"type":"bytes32","name":"drTxHash","internalType":"bytes32"},{"type":"bytes","name":"cborBytes","internalType":"bytes"}]}],"name":"deleteQuery","inputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"destruct","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"estimateReward","inputs":[{"type":"uint256","name":"_gasPrice","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getNextQueryId","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct Witnet.Query","components":[{"type":"tuple","name":"request","internalType":"struct Witnet.Request","components":[{"type":"address","name":"addr","internalType":"contract IWitnetRequest"},{"type":"address","name":"requester","internalType":"address"},{"type":"bytes32","name":"hash","internalType":"bytes32"},{"type":"uint256","name":"gasprice","internalType":"uint256"},{"type":"uint256","name":"reward","internalType":"uint256"}]},{"type":"tuple","name":"response","internalType":"struct Witnet.Response","components":[{"type":"address","name":"reporter","internalType":"address"},{"type":"uint256","name":"timestamp","internalType":"uint256"},{"type":"bytes32","name":"drTxHash","internalType":"bytes32"},{"type":"bytes","name":"cborBytes","internalType":"bytes"}]},{"type":"address","name":"from","internalType":"address"}]}],"name":"getQueryData","inputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"enum Witnet.QueryStatus"}],"name":"getQueryStatus","inputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"bytes","name":"_initData","internalType":"bytes"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isError","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isOk","inputs":[{"type":"tuple","name":"_result","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isReporter","inputs":[{"type":"address","name":"_reporter","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isUpgradable","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isUpgradableFrom","inputs":[{"type":"address","name":"_from","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"}],"name":"postRequest","inputs":[{"type":"address","name":"_addr","internalType":"contract IWitnetRequest"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"proxiableUUID","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"_request","internalType":"struct Witnet.Request","components":[{"type":"address","name":"addr","internalType":"contract IWitnetRequest"},{"type":"address","name":"requester","internalType":"address"},{"type":"bytes32","name":"hash","internalType":"bytes32"},{"type":"uint256","name":"gasprice","internalType":"uint256"},{"type":"uint256","name":"reward","internalType":"uint256"}]}],"name":"readRequest","inputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"_bytecode","internalType":"bytes"}],"name":"readRequestBytecode","inputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"readRequestGasPrice","inputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"readRequestReward","inputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"_response","internalType":"struct Witnet.Response","components":[{"type":"address","name":"reporter","internalType":"address"},{"type":"uint256","name":"timestamp","internalType":"uint256"},{"type":"bytes32","name":"drTxHash","internalType":"bytes32"},{"type":"bytes","name":"cborBytes","internalType":"bytes"}]}],"name":"readResponse","inputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"readResponseDrTxHash","inputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"readResponseReporter","inputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}],"name":"readResponseResult","inputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"readResponseTimestamp","inputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"reportResult","inputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"},{"type":"bytes32","name":"_drTxHash","internalType":"bytes32"},{"type":"bytes","name":"_cborBytes","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"reportResult","inputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"},{"type":"uint256","name":"_timestamp","internalType":"uint256"},{"type":"bytes32","name":"_drTxHash","internalType":"bytes32"},{"type":"bytes","name":"_cborBytes","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"reportResultBatch","inputs":[{"type":"tuple[]","name":"_batchResults","internalType":"struct IWitnetRequestBoardReporter.BatchResult[]","components":[{"type":"uint256","name":"queryId","internalType":"uint256"},{"type":"uint256","name":"timestamp","internalType":"uint256"},{"type":"bytes32","name":"drTxHash","internalType":"bytes32"},{"type":"bytes","name":"cborBytes","internalType":"bytes"}]},{"type":"bool","name":"_verbose","internalType":"bool"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"tuple","name":"","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}],"name":"resultFromCborBytes","inputs":[{"type":"bytes","name":"_cborBytes","internalType":"bytes"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"tuple","name":"","internalType":"struct Witnet.Result","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"tuple","name":"value","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]}],"name":"resultFromCborValue","inputs":[{"type":"tuple","name":"_cborValue","internalType":"struct Witnet.CBOR","components":[{"type":"tuple","name":"buffer","internalType":"struct Witnet.Buffer","components":[{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint32","name":"cursor","internalType":"uint32"}]},{"type":"uint8","name":"initialByte","internalType":"uint8"},{"type":"uint8","name":"majorType","internalType":"uint8"},{"type":"uint8","name":"additionalInformation","internalType":"uint8"},{"type":"uint64","name":"len","internalType":"uint64"},{"type":"uint64","name":"tag","internalType":"uint64"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setReporters","inputs":[{"type":"address[]","name":"_reporters","internalType":"address[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"_newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unsetReporters","inputs":[{"type":"address[]","name":"_exReporters","internalType":"address[]"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeReward","inputs":[{"type":"uint256","name":"_queryId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"version","inputs":[]},{"type":"receive","stateMutability":"payable"}]
            

Deployed ByteCode

0x6080604052600436106102e85760003560e01c80637780cde111610190578063c805dd0f116100dc578063d4da69ac11610095578063dc3c71cd1161006f578063dc3c71cd14610aec578063e5a6b10f14610b0c578063e99e47f314610b40578063f2fde38b14610b605761034c565b8063d4da69ac14610a71578063d74803be14610a91578063db04f16d14610abf5761034c565b8063c805dd0f146109af578063c87d969e146109c4578063c8f5cdd5146109f1578063cf62d11514610a11578063d2e8756114610a31578063d4ced13214610a515761034c565b8063a8604c1a11610149578063b281a7bd11610123578063b281a7bd14610917578063bc7e25ff1461092a578063c2485ebd14610962578063c683b4651461098f5761034c565b8063a8604c1a146108a4578063a9e954b9146108c4578063b0768328146108f75761034c565b80637780cde1146107e25780637c1fbda31461080257806381a398b5146108225780638da5cb5b1461084257806399f65804146108575780639d96fced146108845761034c565b80633b885f2a1161024f5780635479d9401161020857806366bfdc75116101e257806366bfdc75146107555780636b58960a146107685780636f07abcc14610788578063754e5bea146107b55761034c565b80635479d940146106cf57806354fd4d50146107025780636280bce8146107355761034c565b80633b885f2a146105c8578063439fab91146105e85780634c9f72e3146106085780634dcffaf3146106285780635001f3b51461065557806352d1902d1461069c5761034c565b80632241f2db116102a15780632241f2db146104de5780632565082b1461051157806328a78d9b1461053e5780632b68b9c6146105605780632b905fbb146105755780633ae97295146105a85761034c565b8063044ad7be146103ae57806307e66852146104095780630f572d2c14610436578063109a0e3c146104635780631dd27daf1461049057806320f9241e146104be5761034c565b3661034c5760405162461bcd60e51b815260206004820152602960248201527f5769746e657452657175657374426f6172643a206e6f207472616e7366657273604482015268081858d8d95c1d195960ba1b60648201526084015b60405180910390fd5b60405162461bcd60e51b815260206004820152603160248201527f5769746e657452657175657374426f61726455706772616461626c65426173656044820152700e881b9bdd081a5b5c1b195b595b9d1959607a1b6064820152608401610343565b3480156103ba57600080fd5b506103f46103c9366004613150565b6001600160a01b031660009081526000805160206146e2833981519152602052604090205460ff1690565b60405190151581526020015b60405180910390f35b34801561041557600080fd5b506104296104243660046133e8565b610b80565b604051610400919061346b565b34801561044257600080fd5b506104566104513660046133e8565b610c05565b60405161040091906134b2565b34801561046f57600080fd5b5061048361047e3660046133e8565b610c84565b6040516104009190613545565b34801561049c57600080fd5b506104b06104ab366004613558565b610d03565b604051908152602001610400565b3480156104ca57600080fd5b506104b06104d9366004613558565b610d6f565b3480156104ea57600080fd5b506104fe6104f93660046133e8565b610dcd565b60405160039190910b8152602001610400565b34801561051d57600080fd5b5061053161052c366004613571565b610e48565b60405161040091906135ad565b34801561054a57600080fd5b5061055e610559366004613680565b610ecc565b005b34801561056c57600080fd5b5061055e610fb8565b34801561058157600080fd5b506105956105903660046133e8565b610fee565b604051600f9190910b8152602001610400565b3480156105b457600080fd5b506104b06105c3366004613558565b611069565b3480156105d457600080fd5b506104836105e3366004613558565b6110d6565b3480156105f457600080fd5b5061055e610603366004613724565b61124d565b34801561061457600080fd5b5061055e610623366004613680565b6114a4565b34801561063457600080fd5b506106486106433660046133e8565b611585565b6040516104009190613758565b34801561066157600080fd5b507f0000000000000000000000001975a649740ddd6e9f1d08d1a7b0105bfbe7eea45b6040516001600160a01b039091168152602001610400565b3480156106a857600080fd5b507f9969c6aff411c5e5f0807500693e8f819ce88529615cfa6cab569b24788a10186104b0565b3480156106db57600080fd5b507f00000000000000000000000000000000000000000000000000000000000000016103f4565b34801561070e57600080fd5b507f302e352e362d747275737461626c6500000000000000000000000000000000006104b0565b34801561074157600080fd5b5061055e6107503660046137e1565b611604565b61055e610763366004613558565b611753565b34801561077457600080fd5b506103f4610783366004613150565b61180c565b34801561079457600080fd5b506107a86107a3366004613558565b61186b565b6040516104009190613849565b3480156107c157600080fd5b506107d56107d0366004613558565b611876565b604051610400919061389e565b3480156107ee57600080fd5b506103f46107fd3660046133e8565b6119b9565b34801561080e57600080fd5b506107d561081d366004613558565b611a34565b34801561082e57600080fd5b5061055e61083d3660046138b1565b611caf565b34801561084e57600080fd5b50610684611fa1565b34801561086357600080fd5b50610877610872366004613558565b611fbd565b6040516104009190613a0a565b34801561089057600080fd5b5061068461089f366004613558565b6120bf565b3480156108b057600080fd5b506103f46108bf3660046133e8565b612123565b3480156108d057600080fd5b507fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4706104b0565b34801561090357600080fd5b506106486109123660046133e8565b61215d565b6104b0610925366004613150565b612197565b34801561093657600080fd5b5061094a6109453660046133e8565b6123bd565b6040516001600160401b039091168152602001610400565b34801561096e57600080fd5b5061098261097d366004613558565b612438565b6040516104009190613a18565b34801561099b57600080fd5b506104836109aa3660046133e8565b6125f2565b3480156109bb57600080fd5b506104b061262c565b3480156109d057600080fd5b506109e46109df3660046133e8565b61264a565b6040516104009190613a67565b3480156109fd57600080fd5b5061055e610a0c366004613ac9565b6126c9565b348015610a1d57600080fd5b506104b0610a2c3660046133e8565b61287e565b348015610a3d57600080fd5b506104b0610a4c366004613558565b6128f9565b348015610a5d57600080fd5b506103f4610a6c3660046133e8565b612925565b348015610a7d57600080fd5b50610531610a8c366004613558565b61295f565b348015610a9d57600080fd5b50610ab1610aac3660046133e8565b612a44565b604051610400929190613b3e565b348015610acb57600080fd5b50610adf610ada3660046133e8565b612b56565b6040516104009190613b5e565b348015610af857600080fd5b506104b0610b07366004613558565b612bd1565b348015610b1857600080fd5b506106847f000000000000000000000000000000000000000000000000000000000000000081565b348015610b4c57600080fd5b50610531610b5b366004613724565b612c2f565b348015610b6c57600080fd5b5061055e610b7b366004613150565b612c6e565b60405163fc853c3760e01b8152606090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff0799063fc853c3790610bba908590600401613bf3565b600060405180830381865af4158015610bd7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610bff9190810190613c2c565b92915050565b6040516308efc09760e01b8152606090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff079906308efc09790610c3f908590600401613bf3565b600060405180830381865af4158015610c5c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610bff9190810190613cd5565b60405163f417daf560e01b8152606090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff0799063f417daf590610cbe908590600401613bf3565b600060405180830381865af4158015610cdb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610bff9190810190613dbb565b600081600180610d1283612d1e565b6003811115610d2357610d23613833565b14610d2d82612da0565b90610d4b5760405162461bcd60e51b81526004016103439190613545565b50610d54612e83565b60009485526003016020525050604090912060040154919050565b600081600280610d7e83612d1e565b6003811115610d8f57610d8f613833565b14610d9982612da0565b90610db75760405162461bcd60e51b81526004016103439190613545565b50610dc184612ea7565b60010154949350505050565b604051636c4346db60e11b8152600090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff0799063d8868db690610e07908590600401613bf3565b602060405180830381865af4158015610e24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bff9190613def565b610e50613012565b60405163098141f760e11b8152731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff0799063130283ee90610e87908590600401613e0a565b600060405180830381865af4158015610ea4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610bff9190810190613e33565b610ed4612e83565b600101546001600160a01b03163314610eff5760405162461bcd60e51b815260040161034390613f80565b60005b8151811015610f7d576000828281518110610f1f57610f1f613fb7565b602002602001015190506000610f406000805160206146e283398151915290565b6001600160a01b039290921660009081526020929092526040909120805460ff191691151591909117905580610f7581613fe3565b915050610f02565b507f646436560d9757cb3c0f01da0f62642c6040b00c9a80685f94ef1a7725cad5f181604051610fad9190613ffc565b60405180910390a150565b610fc0612e83565b600101546001600160a01b03163314610feb5760405162461bcd60e51b815260040161034390613f80565b33ff5b60405163c71db52160e01b8152600090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff0799063c71db52190611028908590600401613bf3565b602060405180830381865af4158015611045573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bff919061403d565b60008160018061107883612d1e565b600381111561108957611089613833565b1461109382612da0565b906110b15760405162461bcd60e51b81526004016103439190613545565b506110ba612e83565b6000858152600391820160205260409020015492505050919050565b606060006110e383612d1e565b60038111156110f4576110f4613833565b036111475760405162461bcd60e51b815260206004820152602f60248201526000805160206146c283398151915260448201526e081b9bdd081e595d081c1bdcdd1959608a1b6064820152608401610343565b600061115283612ec7565b80549091506001600160a01b0316156112475780546040805163784a000160e11b815290516001600160a01b039092169163f0940002916004808201926000929091908290030181865afa1580156111ae573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526111d69190810190613dbb565b915080600201546111e683612ee4565b146112475760405162461bcd60e51b815260206004820152603f60248201526000805160206146c283398151915260448201527f2062797465636f6465206368616e67656420616674657220706f7374696e67006064820152608401610343565b50919050565b6000611257612e83565b600101546001600160a01b031690508061129c57503380611276612e83565b60010180546001600160a01b0319166001600160a01b03929092169190911790556112f6565b336001600160a01b038216146112f65760405162461bcd60e51b815260206004820152602b60248201526000805160206146c283398151915260448201526a1037b7363c9037bbb732b960a91b6064820152608401610343565b6000611300612e83565b546001600160a01b0316146113a3577f0000000000000000000000001975a649740ddd6e9f1d08d1a7b0105bfbe7eea46001600160a01b0316611341612e83565b546001600160a01b0316036113a35760405162461bcd60e51b815260206004820152603460248201526000805160206146c283398151915260448201527308185b1c9958591e481a5b9a5d1a585b1a5e995960621b6064820152608401610343565b7f0000000000000000000000001975a649740ddd6e9f1d08d1a7b0105bfbe7eea46113cc612e83565b80546001600160a01b0319166001600160a01b03929092169190911790557fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4707f0000000000000000000000001975a649740ddd6e9f1d08d1a7b0105bfbe7eea46001600160a01b0316337f72d4b00d8e35b3717e384aef5f900256a106d6a423d88935a11579981333ba207f302e352e362d747275737461626c65000000000000000000000000000000000060405190815260200160405180910390a46114a0828060200190518101906106239190614058565b5050565b6114ac612e83565b600101546001600160a01b031633146114d75760405162461bcd60e51b815260040161034390613f80565b60005b81518110156115555760008282815181106114f7576114f7613fb7565b6020026020010151905060016115186000805160206146e283398151915290565b6001600160a01b039290921660009081526020929092526040909120805460ff19169115159190911790558061154d81613fe3565b9150506114da565b507f4d570ee36dec878006609360d34ac8d6a0b68d521871ae15a407b6340877ca0181604051610fad9190613ffc565b60405163147e5c8f60e01b8152606090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff0799063147e5c8f906115bf908590600401613bf3565b600060405180830381865af41580156115dc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610bff91908101906140f1565b3360009081526000805160206146e2833981519152602052604090205460ff166116405760405162461bcd60e51b81526004016103439061418a565b8360018061164d83612d1e565b600381111561165e5761165e613833565b1461166882612da0565b906116865760405162461bcd60e51b81526004016103439190613545565b5060008590036116a85760405162461bcd60e51b8152600401610343906141d4565b60008390036116c95760405162461bcd60e51b81526004016103439061423c565b6117143361170f88428989898080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612f3692505050565b612fd7565b604080518781523360208201527ee9413c6321ec446a267b7ebf5bb108663f2ef58b35c4f6e18905ac8f205cb2910160405180910390a1505050505050565b8060018061176083612d1e565b600381111561177157611771613833565b1461177b82612da0565b906117995760405162461bcd60e51b81526004016103439190613545565b5060006117a584612ec7565b905060003482600401546117b99190614299565b60038301549091503a908111156118005760006117d5826128f9565b9050808310156117f75760405162461bcd60e51b8152600401610343906142b1565b50600383018190555b50600490910155505050565b600080611817612e83565b600101546001600160a01b031690507f000000000000000000000000000000000000000000000000000000000000000180156118645750826001600160a01b0316816001600160a01b0316145b9392505050565b6000610bff82612d1e565b6040805160808101825260008082526020820181905291810191909152606080820152816002806118a683612d1e565b60038111156118b7576118b7613833565b146118c182612da0565b906118df5760405162461bcd60e51b81526004016103439190613545565b506118e984612ea7565b6040805160808101825282546001600160a01b031681526001830154602082015260028301549181019190915260038201805491929160608401919061192e906142ee565b80601f016020809104026020016040519081016040528092919081815260200182805461195a906142ee565b80156119a75780601f1061197c576101008083540402835291602001916119a7565b820191906000526020600020905b81548152906001019060200180831161198a57829003601f168201915b50505050508152505092505050919050565b6040516350ea2eab60e11b8152600090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff0799063a1d45d56906119f3908590600401613bf3565b602060405180830381865af4158015611a10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bff9190614322565b604080516080810182526000808252602082018190529181019190915260608082015281600280611a6483612d1e565b6003811115611a7557611a75613833565b14611a7f82612da0565b90611a9d5760405162461bcd60e51b81526004016103439190613545565b506000611aa8612e83565b60008681526003919091016020526040902060098101549091506001600160a01b03163314611b1f5760405162461bcd60e51b815260206004820152602f60248201526000805160206146c283398151915260448201526e1037b7363c903932b8bab2b9ba32b960891b6064820152608401610343565b604080516080810182526005830180546001600160a01b0316825260068401546020830152600784015492820192909252600883018054919291606084019190611b68906142ee565b80601f0160208091040260200160405190810160405280929190818152602001828054611b94906142ee565b8015611be15780601f10611bb657610100808354040283529160200191611be1565b820191906000526020600020905b815481529060010190602001808311611bc457829003601f168201915b5050505050815250509350611bf4612e83565b600086815260039182016020526040812080546001600160a01b03199081168255600182018054821690556002820183905592810182905560048101829055600581018054909316835560068101829055600781018290559181611c5b6008850182613065565b50505060090180546001600160a01b0319169055604080518681523360208201527fdec847db058c9c012e0f3dbe2b99e05cfa4c693f61a7d8bc64652a68913cbfff910160405180910390a1505050919050565b3360009081526000805160206146e2833981519152602052604090205460ff16611ceb5760405162461bcd60e51b81526004016103439061418a565b8151600090815b81811015611f8a576000858281518110611d0e57611d0e613fb7565b6020026020010151905060016003811115611d2b57611d2b613833565b8151611d3690612d1e565b6003811115611d4757611d47613833565b14611db3578415611dae5780516040805191825260208201819052602c908201526000805160206146c283398151915260608201526b08189859081c5d595c9e525960a21b60808201526000805160206146568339815191529060a0015b60405180910390a15b611f77565b6040810151600003611e1d578415611dae5780516040805191825260208201819052602d908201526000805160206146c283398151915260608201526c040c4c2c840c8e4a8f090c2e6d609b1b60808201526000805160206146568339815191529060a001611da5565b806060015151600003611e89578415611dae5780516040805191825260208201819052602e908201526000805160206146c283398151915260608201526d206261642063626f72427974657360901b60808201526000805160206146568339815191529060a001611da5565b60008160200151118015611ea05750428160200151115b15611f04578415611dae5780516040805191825260208201819052602e908201526000805160206146c283398151915260608201526d0206261642074696d657374616d760941b60808201526000805160206146568339815191529060a001611da5565b80516020820151611f30919015611f1f578260200151611f21565b425b83604001518460600151612f36565b611f3a9085614299565b8151604080519182523360208301529195507ee9413c6321ec446a267b7ebf5bb108663f2ef58b35c4f6e18905ac8f205cb2910160405180910390a15b5080611f8281613fe3565b915050611cf2565b508115611f9b57611f9b3383612fd7565b50505050565b6000611fab612e83565b600101546001600160a01b0316919050565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915281600180611ff583612d1e565b600381111561200657612006613833565b1461201082612da0565b9061202e5760405162461bcd60e51b81526004016103439190613545565b506000612039612e83565b600086815260039182016020908152604091829020825160a08101845281546001600160a01b039081168252600183015481169382019390935260028201549381019390935292830154606083015260048301546080830152600983015491965091925016156120b75760098101546001600160a01b031660208501525b505050919050565b6000816002806120ce83612d1e565b60038111156120df576120df613833565b146120e982612da0565b906121075760405162461bcd60e51b81526004016103439190613545565b5061211184612ea7565b546001600160a01b0316949350505050565b604051636646c11960e01b8152600090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff07990636646c119906119f3908590600401613bf3565b604051630879730d60e01b8152606090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff07990630879730d906115bf908590600401613bf3565b6000343a826121a5826128f9565b9050808310156121c75760405162461bcd60e51b8152600401610343906142b1565b6001600160a01b0385166122205760405162461bcd60e51b815260206004820152602c60248201526000805160206146c283398151915260448201526b081b9d5b1b081cd8dc9a5c1d60a21b6064820152608401610343565b6000856001600160a01b031663f09400026040518163ffffffff1660e01b8152600401600060405180830381865afa158015612260573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526122889190810190613dbb565b905060008151116122df5760405162461bcd60e51b815260206004820152602d60248201526000805160206146c283398151915260448201526c08195b5c1d1e481cd8dc9a5c1d609a1b6064820152608401610343565b6122e7612e83565b600201600081546122f790613fe3565b9182905550945033612307612e83565b60008781526003919091016020526040812060090180546001600160a01b0319166001600160a01b03939093169290921790915561234486612ec7565b80546001600160a01b0319166001600160a01b038916178155905061236882612ee4565b60028201556003810184905560048101859055604080518781523360208201527fcabaf9c102f83746b27ae932f638eebfaf5ea7d014edd20ab14dec3768a8f55c910160405180910390a15050505050919050565b604051638233f9b360e01b8152600090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff07990638233f9b3906123f7908590600401613bf3565b602060405180830381865af4158015612414573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bff919061433f565b6124a26040805161010081019091526000606082018181526080830182905260a0830182905260c0830182905260e0830191909152819081526040805160808101825260008082526020828101829052928201526060808201529101908152600060209091015290565b6124aa612e83565b60008381526003918201602090815260409182902082516101008101845281546001600160a01b03908116606080840191825260018501548316608080860191909152600286015460a08601529785015460c0850152600485015460e08501529083528551968701865260058401805490921687526006840154878601526007840154958701959095526008830180549296939594870194919291840191612551906142ee565b80601f016020809104026020016040519081016040528092919081815260200182805461257d906142ee565b80156125ca5780601f1061259f576101008083540402835291602001916125ca565b820191906000526020600020905b8154815290600101906020018083116125ad57829003601f168201915b505050919092525050508152600991909101546001600160a01b031660209091015292915050565b60405163a1b9089160e01b8152606090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff0799063a1b9089190610cbe908590600401613bf3565b6000612636612e83565b60020154612645906001614299565b905090565b6040516316935cf160e11b8152606090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff07990632d26b9e290612684908590600401613bf3565b600060405180830381865af41580156126a1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610bff919081019061435c565b3360009081526000805160206146e2833981519152602052604090205460ff166127055760405162461bcd60e51b81526004016103439061418a565b8460018061271283612d1e565b600381111561272357612723613833565b1461272d82612da0565b9061274b5760405162461bcd60e51b81526004016103439190613545565b50428611156127b65760405162461bcd60e51b815260206004820152603160248201527f5769746e657452657175657374426f617264547275737461626c65446566617560448201527006c743a206261642074696d657374616d7607c1b6064820152608401610343565b60008590036127d75760405162461bcd60e51b8152600401610343906141d4565b60008390036127f85760405162461bcd60e51b81526004016103439061423c565b61283e3361170f89898989898080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612f3692505050565b604080518881523360208201527ee9413c6321ec446a267b7ebf5bb108663f2ef58b35c4f6e18905ac8f205cb2910160405180910390a150505050505050565b60405163a2e8765560e01b8152600090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff0799063a2e87655906128b8908590600401613bf3565b602060405180830381865af41580156128d5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bff9190614417565b6000610bff7f0000000000000000000000000000000000000000000000000000000000020e9083614430565b604051632afe0bd360e21b8152600090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff0799063abf82f4c906119f3908590600401613bf3565b612967613012565b8160028061297483612d1e565b600381111561298557612985613833565b1461298f82612da0565b906129ad5760405162461bcd60e51b81526004016103439190613545565b5060006129b985612ea7565b60405163e99e47f360e01b8152909150731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff0799063e99e47f3906129f690600385019060040161444f565b600060405180830381865af4158015612a13573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612a3b9190810190613e33565b95945050505050565b6040516323317ad560e21b8152600090606090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff07990638cc5eb5490612a81908690600401613bf3565b600060405180830381865af4925050508015612abf57506040513d6000823e601f3d908101601f19168201604052612abc9190810190614506565b60015b612b4c57612acb614553565b806308c379a003612af55750612adf61456f565b80612aea5750612af7565b600094909350915050565b505b3d808015612b21576040519150601f19603f3d011682016040523d82523d6000602084013e612b26565b606091505b5060ff6040518060600160405280602f8152602001614702602f91399250925050915091565b9094909350915050565b60405163d45d097d60e01b8152600090731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff0799063d45d097d90612b90908590600401613bf3565b602060405180830381865af4158015612bad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bff91906145f8565b600081600280612be083612d1e565b6003811115612bf157612bf1613833565b14612bfb82612da0565b90612c195760405162461bcd60e51b81526004016103439190613545565b50612c2384612ea7565b60020154949350505050565b612c37613012565b60405163e99e47f360e01b8152731d9c4a8f8b7b5f9b8e2641d81927f8f8cc7ff0799063e99e47f390610e87908590600401613545565b612c76612e83565b600101546001600160a01b03163314612ca15760405162461bcd60e51b815260040161034390613f80565b6000612cab612e83565b600101546001600160a01b039081169150821681146114a05781612ccd612e83565b60010180546001600160a01b0319166001600160a01b03928316179055604051838216918316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000811580612d375750612d30612e83565b6002015482115b15612d4457506000919050565b6000612d4e612e83565b600084815260039190910160205260409020600781015490915015612d765750600292915050565b60098101546001600160a01b031615612d925750600192915050565b50600392915050565b919050565b60606001826003811115612db657612db6613833565b03612dda576040518060600160405280602581526020016146766025913992915050565b6002826003811115612dee57612dee613833565b03612e125760405180606001604052806027815260200161469b6027913992915050565b6003826003811115612e2657612e26613833565b03612e4a576040518060600160405280602681526020016146306026913992915050565b505060408051808201909152601981527f5769746e6574426f617264446174613a20626164206d6f6f6400000000000000602082015290565b7ff595240b351bc8f951c2f53b26f4e78c32cb62122cf76c19b7fdda7d4968e18390565b6000612eb1612e83565b6000928352600301602052506040902060050190565b6000612ed1612e83565b6000928352600301602052506040902090565b6000600282604051612ef69190614613565b602060405180830381855afa158015612f13573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250810190610bff9190614417565b600080612f41612e83565b60008781526003919091016020908152604090912060068101879055600781018690556005810180546001600160a01b03191633178155855191935083929091612f93916008850191908801906130a2565b505060049081015482546001600160a01b03199081168455600184018054909116905560006002840181905560038401819055929091019190915595945050505050565b6040516001600160a01b0383169082156108fc029083906000818181858888f1935050505015801561300d573d6000803e3d6000fd5b505050565b6040805180820182526000808252825161010081018452606060c0820181815260e083018490528252602082810184905294820183905281018290526080810182905260a0810191909152909182015290565b508054613071906142ee565b6000825580601f10613081575050565b601f01602090049060005260206000209081019061309f9190613126565b50565b8280546130ae906142ee565b90600052602060002090601f0160209004810192826130d05760008555613116565b82601f106130e957805160ff1916838001178555613116565b82800160010185558215613116579182015b828111156131165782518255916020019190600101906130fb565b50613122929150613126565b5090565b5b808211156131225760008155600101613127565b6001600160a01b038116811461309f57600080fd5b60006020828403121561316257600080fd5b81356118648161313b565b634e487b7160e01b600052604160045260246000fd5b60c081018181106001600160401b03821117156131a2576131a261316d565b60405250565b604081018181106001600160401b03821117156131a2576131a261316d565b608081018181106001600160401b03821117156131a2576131a261316d565b601f8201601f191681016001600160401b038111828210171561320b5761320b61316d565b6040525050565b801515811461309f57600080fd5b8035612d9b81613212565b60006001600160401b038211156132445761324461316d565b50601f01601f191660200190565b600082601f83011261326357600080fd5b813561326e8161322b565b60405161327b82826131e6565b82815285602084870101111561329057600080fd5b82602086016020830137600092810160200192909252509392505050565b63ffffffff8116811461309f57600080fd5b60ff8116811461309f57600080fd5b8035612d9b816132c0565b6001600160401b038116811461309f57600080fd5b8035612d9b816132da565b600060c0828403121561330c57600080fd5b60405161331881613183565b80915082356001600160401b038082111561333257600080fd5b908401906040828703121561334657600080fd5b604051613352816131a8565b82358281111561336157600080fd5b61336d88828601613252565b82525060208301359250613380836132ae565b826020820152808452505050613398602084016132cf565b60208201526133a9604084016132cf565b60408201526133ba606084016132cf565b60608201526133cb608084016132ef565b60808201526133dc60a084016132ef565b60a08201525092915050565b6000602082840312156133fa57600080fd5b81356001600160401b038082111561341157600080fd5b908301906040828603121561342557600080fd5b604051613431816131a8565b823561343c81613212565b815260208301358281111561345057600080fd5b61345c878286016132fa565b60208301525095945050505050565b6020808252825182820181905260009190848201906040850190845b818110156134a6578351600f0b83529284019291840191600101613487565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156134a657835160030b835292840192918401916001016134ce565b60005b838110156135085781810151838201526020016134f0565b83811115611f9b5750506000910152565b600081518084526135318160208601602086016134ed565b601f01601f19169290920160200192915050565b6020815260006118646020830184613519565b60006020828403121561356a57600080fd5b5035919050565b60006020828403121561358357600080fd5b81356001600160401b0381111561359957600080fd5b6135a5848285016132fa565b949350505050565b6020815281511515602082015260006020830151604080840152805160c06060850152805160406101208601526135e8610160860182613519565b60209283015163ffffffff166101408701529183015160ff81166080870152919050604083015160ff811660a08701529150606083015160ff811660c0870152915060808301516001600160401b03811660e0870152915060a08301519250612a3b6101008601846001600160401b03169052565b60006001600160401b038211156136765761367661316d565b5060051b60200190565b6000602080838503121561369357600080fd5b82356001600160401b038111156136a957600080fd5b8301601f810185136136ba57600080fd5b80356136c58161365d565b6040516136d282826131e6565b82815260059290921b83018401918481019150878311156136f257600080fd5b928401925b8284101561371957833561370a8161313b565b825292840192908401906136f7565b979650505050505050565b60006020828403121561373657600080fd5b81356001600160401b0381111561374c57600080fd5b6135a584828501613252565b6020808252825182820181905260009190848201906040850190845b818110156134a65783516001600160401b031683529284019291840191600101613774565b60008083601f8401126137ab57600080fd5b5081356001600160401b038111156137c257600080fd5b6020830191508360208285010111156137da57600080fd5b9250929050565b600080600080606085870312156137f757600080fd5b843593506020850135925060408501356001600160401b0381111561381b57600080fd5b61382787828801613799565b95989497509550505050565b634e487b7160e01b600052602160045260246000fd5b602081016004831061385d5761385d613833565b91905290565b60018060a01b038151168252602081015160208301526040810151604083015260006060820151608060608501526135a56080850182613519565b6020815260006118646020830184613863565b60008060408084860312156138c557600080fd5b83356001600160401b03808211156138dc57600080fd5b818601915086601f8301126138f057600080fd5b813560206138fd8261365d565b855161390982826131e6565b83815260059390931b850182019282810191508a84111561392957600080fd5b8286015b848110156139b15780358681111561394457600080fd5b87016080818e03601f1901121561395a57600080fd5b8851613965816131c7565b858201358152898201358682015260608201358a82015260808201358881111561398f5760008081fd5b61399d8f8883860101613252565b60608301525084525091830191830161392d565b5097506139c19050888201613220565b955050505050509250929050565b80516001600160a01b039081168352602080830151909116908301526040808201519083015260608082015190830152608090810151910152565b60a08101610bff82846139cf565b60208152613a2a6020820183516139cf565b6000602083015160e060c0840152613a46610100840182613863565b604094909401516001600160a01b031660e093909301929092525090919050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015613abc57603f19888603018452613aaa858351613519565b94509285019290850190600101613a8e565b5092979650505050505050565b600080600080600060808688031215613ae157600080fd5b85359450602086013593506040860135925060608601356001600160401b03811115613b0c57600080fd5b613b1888828901613799565b969995985093965092949392505050565b6101008110613b3a57613b3a613833565b9052565b613b488184613b29565b6040602082015260006135a56040830184613519565b60208101610bff8284613b29565b6000815160c084528051604060c0860152613b8b610100860182613519565b905063ffffffff60208301511660e086015260ff602085015116602086015260ff604085015116604086015260ff60608501511660608601526001600160401b03608085015116608086015260a084015191506135a560a08601836001600160401b03169052565b60208152815115156020820152600060208301516040808401526135a56060840182613b6c565b8051600f81900b8114612d9b57600080fd5b60006020808385031215613c3f57600080fd5b82516001600160401b03811115613c5557600080fd5b8301601f81018513613c6657600080fd5b8051613c718161365d565b604051613c7e82826131e6565b82815260059290921b8301840191848101915087831115613c9e57600080fd5b928401925b8284101561371957613cb484613c1a565b82529284019290840190613ca3565b8051600381900b8114612d9b57600080fd5b60006020808385031215613ce857600080fd5b82516001600160401b03811115613cfe57600080fd5b8301601f81018513613d0f57600080fd5b8051613d1a8161365d565b604051613d2782826131e6565b82815260059290921b8301840191848101915087831115613d4757600080fd5b928401925b8284101561371957613d5d84613cc3565b82529284019290840190613d4c565b600082601f830112613d7d57600080fd5b8151613d888161322b565b604051613d9582826131e6565b828152856020848701011115613daa57600080fd5b612a3b8360208301602088016134ed565b600060208284031215613dcd57600080fd5b81516001600160401b03811115613de357600080fd5b6135a584828501613d6c565b600060208284031215613e0157600080fd5b61186482613cc3565b6020815260006118646020830184613b6c565b8051612d9b816132c0565b8051612d9b816132da565b60006020808385031215613e4657600080fd5b82516001600160401b0380821115613e5d57600080fd5b81850191506040808388031215613e7357600080fd5b8051613e7e816131a8565b8351613e8981613212565b81528385015183811115613e9c57600080fd5b939093019260c08489031215613eb157600080fd5b8151613ebc81613183565b845184811115613ecb57600080fd5b8501808a03841315613edc57600080fd5b8351613ee7816131a8565b815186811115613ef657600080fd5b613f028c828501613d6c565b825250878201519550613f14866132ae565b808801869052825250613f28858701613e1d565b86820152613f37838601613e1d565b83820152613f4760608601613e1d565b6060820152613f5860808601613e28565b6080820152613f6960a08601613e28565b60a082015294810194909452509195945050505050565b6020808252601b908201527f5769746e6574426f617264446174613a206f6e6c79206f776e65720000000000604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201613ff557613ff5613fcd565b5060010190565b6020808252825182820181905260009190848201906040850190845b818110156134a65783516001600160a01b031683529284019291840191600101614018565b60006020828403121561404f57600080fd5b61186482613c1a565b6000602080838503121561406b57600080fd5b82516001600160401b0381111561408157600080fd5b8301601f8101851361409257600080fd5b805161409d8161365d565b6040516140aa82826131e6565b82815260059290921b83018401918481019150878311156140ca57600080fd5b928401925b828410156137195783516140e28161313b565b825292840192908401906140cf565b6000602080838503121561410457600080fd5b82516001600160401b0381111561411a57600080fd5b8301601f8101851361412b57600080fd5b80516141368161365d565b60405161414382826131e6565b82815260059290921b830184019184810191508783111561416357600080fd5b928401925b8284101561371957835161417b816132da565b82529284019290840190614168565b6020808252602a908201527f5769746e6574426f6172644461746141434c733a20756e617574686f72697a6560408201526932103932b837b93a32b960b11b606082015260800190565b60208082526042908201527f5769746e657452657175657374426f617264547275737461626c65446566617560408201527f6c743a205769746e65742064725478486173682063616e6e6f74206265207a65606082015261726f60f01b608082015260a00190565b6020808252603a908201527f5769746e657452657175657374426f617264547275737461626c65446566617560408201527f6c743a20726573756c742063616e6e6f7420626520656d707479000000000000606082015260800190565b600082198211156142ac576142ac613fcd565b500190565b6020808252602f908201526000805160206146c283398151915260408201526e2072657761726420746f6f206c6f7760881b606082015260800190565b600181811c9082168061430257607f821691505b60208210810361124757634e487b7160e01b600052602260045260246000fd5b60006020828403121561433457600080fd5b815161186481613212565b60006020828403121561435157600080fd5b8151611864816132da565b6000602080838503121561436f57600080fd5b82516001600160401b038082111561438657600080fd5b818501915085601f83011261439a57600080fd5b81516143a58161365d565b6040516143b282826131e6565b82815260059290921b84018501918581019150888311156143d257600080fd5b8585015b8381101561440a578051858111156143ee5760008081fd5b6143fc8b89838a0101613d6c565b8452509186019186016143d6565b5098975050505050505050565b60006020828403121561442957600080fd5b5051919050565b600081600019048311821515161561444a5761444a613fcd565b500290565b600060208083526000845481600182811c91508083168061447157607f831692505b858310810361448e57634e487b7160e01b85526022600452602485fd5b8786018381526020018180156144ab57600181146144bc576144e7565b60ff198616825287820196506144e7565b60008b81526020902060005b868110156144e1578154848201529085019089016144c8565b83019750505b50949998505050505050505050565b80516101008110612d9b57600080fd5b6000806040838503121561451957600080fd5b614522836144f6565b915060208301516001600160401b0381111561453d57600080fd5b61454985828601613d6c565b9150509250929050565b600060033d111561456c5760046000803e5060005160e01c5b90565b600060443d101561457d5790565b6040516003193d81016004833e81513d6001600160401b0381602484011181841117156145ac57505050505090565b82850191508151818111156145c45750505050505090565b843d87010160208285010111156145de5750505050505090565b6145ed602082860101876131e6565b509095945050505050565b60006020828403121561460a57600080fd5b611864826144f6565b600082516146258184602087016134ed565b919091019291505056fe5769746e6574426f617264446174613a206e6f7420696e2044656c65746564207374617475734df64445edc775fba59db44b8001852fb1b777eea88fd54f04572dd114e3ff7f5769746e6574426f617264446174613a206e6f7420696e20506f73746564207374617475735769746e6574426f617264446174613a206e6f7420696e205265706f72746564207374617475735769746e657452657175657374426f617264547275737461626c65426173653aa6db7263983f337bae2c9fb315730227961d1c1153ae1e10a56b5791465dd6fd5769746e657452657175657374426f617264547275737461626c65426173653a206661696c696e6720617373657274a264697066735822122025a490715b9bb6b91f55a5f5009e7eda6da6f62e71d3ad6aafaae8ecdaa4a74b64736f6c634300080d0033

External libraries