WitnetERC20Lib

Description:

Proxy contract enabling upgradeable smart contract patterns. Delegates calls to an implementation contract.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "settings": {
    "evmVersion": "prague",
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "remappings": [
      "project/:witnet-solidity-bridge/=npm/witnet-solidity-bridge@2.2.8/",
      "project/:witnet-solidity-bridge/=npm/witnet-solidity-bridge@2.2.8/"
    ]
  },
  "sources": {
    "npm/witnet-solidity-bridge@2.2.8/contracts/interfaces/IWitAppliance.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
\r
pragma solidity ^0.8.0;\r
\r
abstract contract IWitAppliance {\r
\r
    /// @notice Returns the name of the actual contract implementing the logic of this Witnet appliance.\r
    function class() virtual public view returns (string memory);\r
\r
    /// @notice Returns the ERC-165 id of the minimal functionality expected for this appliance.\r
    function specs() virtual external view returns (bytes4);\r
\r
    function _require(bool _condition, string memory _message) virtual internal view {\r
        if (!_condition) {\r
            _revert(_message);\r
        }\r
    }\r
\r
    function _revert(string memory _message) virtual internal view {\r
        revert(\r
            string(abi.encodePacked(\r
                class(),\r
                ": ",\r
                _message\r
            ))\r
        );\r
    }\r
\r
}\r
"
    },
    "npm/witnet-solidity-bridge@2.2.8/contracts/interfaces/IWitOracle.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
\r
pragma solidity >=0.8.0 <0.9.0;\r
\r
import "./IWitOracleRadonRegistry.sol";\r
\r
interface IWitOracle {\r
\r
    error InvalidDataReport();\r
    \r
    event WitOracleReport(\r
            address indexed evmOrigin, \r
            address indexed evmConsumer, \r
            address evmReporter,\r
            Witnet.TransactionHash witDrTxHash,\r
            Witnet.RadonHash queryRadHash,\r
            Witnet.QuerySLA  queryParams,\r
            Witnet.Timestamp resultTimestamp,\r
            bytes resultCborBytes\r
        );\r
\r
    /// @notice Uniquely identifies the WitOracle instance and the chain on which it's deployed.\r
    function channel() external view returns (bytes4);\r
\r
    /// @notice Verify the data report (as provided by Wit/Kermit API) is well-formed and authentic,\r
    /// returning the parsed Witnet.DataResult if so, or reverting otherwise.\r
    function parseDataReport(Witnet.DataPushReport calldata report, bytes calldata proof) external view returns (Witnet.DataResult memory);\r
\r
    /// @notice Same as `parseDataReport` but on certain implementations it may store roll-up information \r
    /// that will contribute to reduce the cost of verifying and/or rolling-up future data reports.\r
    /// Emits `DataReport` if report is authentic. \r
    function pushDataReport(Witnet.DataPushReport calldata report, bytes calldata proof) external returns (Witnet.DataResult memory);\r
\r
    /// @notice Returns the WitOracleRadonRegistry in which Witnet-compliant Radon requests\r
    /// @notice can be formally verified and forever registered as a away to let smart contracts\r
    /// and users to track actual data sources and offchain computations applied on data updates\r
    /// safely reported from the Wit/Oracle blockchain. \r
    function registry() external view returns (IWitOracleRadonRegistry);\r
}\r
"
    },
    "npm/witnet-solidity-bridge@2.2.8/contracts/interfaces/IWitOracleAppliance.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
\r
pragma solidity ^0.8.0;\r
\r
import "./IWitAppliance.sol";\r
\r
abstract contract IWitOracleAppliance\r
    is\r
        IWitAppliance\r
{\r
    /// @notice Returns the WitOracle address that this appliance is bound to.\r
    function witOracle() virtual external view returns (address);\r
}\r
"
    },
    "npm/witnet-solidity-bridge@2.2.8/contracts/interfaces/IWitOracleQueriable.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
\r
pragma solidity >=0.8.0 <0.9.0;\r
\r
import "../libs/Witnet.sol";\r
\r
interface IWitOracleQueriable {\r
    \r
    /// @notice Removes all query data from storage. Pays back reward on expired queries.\r
    /// @dev Fails if the query is not in a final status, or not called from the actual requester.\r
    /// @param queryId The unique query identifier.\r
    function deleteQuery(uint256 queryId) external returns (Witnet.QueryEvmReward);\r
\r
    /// @notice Estimate the minimum reward required for posting a data request.\r
    /// @param evmGasPrice Expected gas price to pay upon posting the data request.\r
    function estimateBaseFee(uint256 evmGasPrice) external view returns (uint256);\r
    \r
    /// @notice Estimate the minimum reward required for posting a data request with a callback.\r
    /// @param evmGasPrice Expected gas price to pay upon posting the data request.\r
    /// @param callbackGas Maximum gas to be spent when reporting the data request result.\r
    function estimateBaseFeeWithCallback(uint256 evmGasPrice, uint24 callbackGas) external view returns (uint256);\r
\r
    /// @notice Estimate the extra reward (i.e. over the base fee) to be paid when posting a new\r
    /// @notice data query in order to avoid getting provable "too low incentives" results from\r
    /// @notice the Wit/Oracle blockchain. \r
    /// @dev The extra fee gets calculated in proportion to:\r
    /// @param evmGasPrice Tentative EVM gas price at the moment the query result is ready.\r
    /// @param evmWitPrice  Tentative nanoWit price in Wei at the moment the query is solved on the Wit/Oracle blockchain.\r
    /// @param querySLA The query SLA data security parameters as required for the Wit/Oracle blockchain. \r
    function estimateExtraFee(uint256 evmGasPrice, uint256 evmWitPrice, Witnet.QuerySLA calldata querySLA) external view returns (uint256);\r
\r
    /// @notice Returns next query id to be generated by the Witnet Request Board.\r
    function getNextQueryId() external view returns (Witnet.QueryId);\r
\r
    /// @notice Gets the whole Query data contents, if any, no matter its current status.\r
    function getQuery(Witnet.QueryId queryId) external view returns (Witnet.Query memory);\r
\r
    /// @notice Gets the current EVM reward the reporter can claim, if not done yet.\r
    function getQueryEvmReward(uint256) external view returns (Witnet.QueryEvmReward);\r
\r
    /// @notice Retrieves the RAD hash and SLA parameters of the given query.\r
    function getQueryRequest(Witnet.QueryId) external view returns (Witnet.QueryRequest memory);\r
\r
    /// @notice Retrieves the whole `Witnet.QueryResponse` record referred to a previously posted Witnet Data Request.\r
    function getQueryResponse(Witnet.QueryId) external view returns (Witnet.QueryResponse memory);\r
\r
    function getQueryResult(uint256) external view returns (Witnet.DataResult memory);\r
    function getQueryResultStatus(uint256) external view returns (Witnet.ResultStatus);\r
    function getQueryResultStatusDescription(uint256) external view returns (string memory);\r
    \r
    /// @notice Gets query's result back tracing trails\r
    function getQueryResultTrails(uint256) \r
        external view returns (\r
            bytes32 queryUUID,\r
            Witnet.TransactionHash resultDrTxHash,\r
            Witnet.Timestamp resultTimestamp,\r
            uint256 resultFinalityBlock\r
        );\r
\r
    /// @notice Gets current status of given query.\r
    function getQueryStatus(uint256) external view returns (Witnet.QueryStatus);\r
    function getQueryStatusString(uint256) external view returns (string memory);\r
    \r
    /// @notice Get current status of all given query ids.\r
    function getQueryStatusBatch(uint256[] calldata) external view returns (Witnet.QueryStatus[] memory);\r
\r
    /// @notice Request real world data from the Wit/Oracle sidechain. \r
    /// @notice The paid fee is escrowed as a reward for the reporter that eventually relays back \r
    /// @notice a valid query result from the Wit/Oracle sidechain.\r
    /// @notice Query results are CBOR-encoded, and can contain either some     data, or an error.\r
    /// @dev Reasons to revert:\r
    /// @dev - the data request's RAD hash was not previously verified into the WitOracleRadonRegistry contract;\r
    /// @dev - invalid query SLA parameters were provided;\r
    /// @dev - insufficient value is paid as reward.\r
    /// @param radonHash The unique hash of the Radon Request to be solved by Wit/Oracle sidechain. \r
    function queryData(\r
            Witnet.RadonHash radonHash,\r
            Witnet.QuerySLA calldata\r
        )\r
        external payable returns (uint256);\r
\r
    /// @notice Request real world data from the Wit/Oracle sidechain. \r
    /// @notice The paid fee is escrowed as a reward for the reporter that eventually relays back \r
    /// @notice a valid query result from the Wit/Oracle sidechain.\r
    /// @notice The Witnet-provable result will be reported directly to the requesting contract. \r
    /// @notice Query results are CBOR-encoded, and can contain either some data, or an error.\r
    /// @dev Reasons to revert:\r
    /// @dev - the data request's RAD hash was not previously verified into the Radon Registry;\r
    /// @dev - invalid query SLA parameters were provided;\r
    /// @dev - insufficient value is paid as reward.\r
    /// @dev - passed `consumer` is not a contract implementing the IWitOracleQueriableConsumer interface;\r
    /// @param radonHash The unique hash of the Radon Request to be solved by Wit/Oracle sidechain. \r
    function queryDataWithCallback(\r
            Witnet.RadonHash radonHash, \r
            Witnet.QuerySLA calldata, \r
            Witnet.QueryCallback calldata\r
        )\r
        external payable returns (uint256);\r
\r
    /// @notice Increments the reward of a previously posted request by adding the transaction value to it.\r
    function upgradeQueryEvmReward(uint256) external payable;\r
}"
    },
    "npm/witnet-solidity-bridge@2.2.8/contracts/interfaces/IWitOracleQueriableEvents.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
\r
pragma solidity >=0.8.0 <0.9.0;\r
\r
import "../libs/Witnet.sol";\r
\r
interface IWitOracleQueriableEvents {\r
\r
    /// Emitted every time a new query containing some verified data request is posted to the WitOracle.\r
    event WitOracleQuery(\r
        address indexed evmRequester,\r
        uint256 evmGasPrice,\r
        uint256 evmReward,\r
        Witnet.QueryId queryId, \r
        Witnet.RadonHash radonHash,\r
        Witnet.QuerySLA radonParams\r
    );\r
\r
    /// Emitted when the reward of some not-yet reported query gets upgraded.\r
    event WitOracleQueryUpgrade(\r
        Witnet.QueryId queryId,\r
        address evmSender,\r
        uint256 evmGasPrice,\r
        uint256 evmReward\r
    );\r
\r
\r
    /// Emitted when a query with no callback gets reported into the WRB.\r
    event WitOracleQueryReport(\r
        Witnet.QueryId queryId, \r
        uint256 evmGasPrice\r
    );\r
\r
    event WitOracleQueryReportDispute(\r
        Witnet.QueryId queryId,\r
        address evmDisputer\r
    );\r
\r
    /// Emitted when a query with a callback gets successfully reported into the WRB.\r
    event WitOracleQueryReportDelivery(\r
        Witnet.QueryId queryId, \r
        address evmConsumer,\r
        uint256 evmGasPrice, \r
        uint256 evmCallbackGas\r
    );\r
\r
    /// Emitted when a query with a callback cannot get reported into the WRB.\r
    event WitOracleResportDeliveryFailed(\r
        Witnet.QueryId queryId, \r
        address evmConsumer,\r
        uint256 evmGasPrice, \r
        uint256 evmCallbackActualGas, \r
        string  evmCallbackRevertReason,\r
        bytes   resultCborBytes\r
    );\r
}\r
"
    },
    "npm/witnet-solidity-bridge@2.2.8/contracts/interfaces/IWitOracleRadonRegistry.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
\r
pragma solidity >=0.8.0 <0.9.0;\r
\r
import "../libs/Witnet.sol";\r
\r
interface IWitOracleRadonRegistry {\r
\r
    /// @notice Returns the Witnet-compliant DRO bytecode for some data request object \r
    /// made out of the given Radon Request and Radon SLA security parameters. \r
    function bytecodeOf(\r
            Witnet.RadonHash radonRequestHash, \r
            Witnet.QuerySLA calldata queryParams\r
        ) external view returns (bytes memory);\r
    \r
    /// @notice Returns the Witnet-compliant DRO bytecode for some data request object \r
    /// made out of the given RAD bytecode and Radon SLA security parameters. \r
    function bytecodeOf(\r
            bytes calldata radonRequestBytecode, \r
            Witnet.QuerySLA calldata queryParams\r
        ) external view returns (bytes memory);\r
\r
    /// @notice Returns the hash of the given Witnet-compliant bytecode. Returned value\r
    /// can be used to trace back in the Witnet blockchain all past resolutions \r
    /// of the given data request payload.\r
    function hashOf(bytes calldata) external view returns (Witnet.RadonHash);\r
\r
    /// @notice Tells whether the specified Radon Reducer has been formally verified into the registry.\r
    function isVerifiedRadonReducer(bytes32) external view returns (bool);\r
    \r
    /// @notice Tells whether the given Radon Hash has been formally verified into the registry.\r
    function isVerifiedRadonRequest(Witnet.RadonHash) external view returns (bool);\r
    \r
    /// @notice Tells whether the specified Radon Retrieval has been formally verified into the registry.\r
    function isVerifiedRadonRetrieval(bytes32) external view returns (bool);\r
    \r
    /// @notice Returns the whole Witnet.RadonReducer metadata struct for the given hash.\r
    /// @dev Reverts if unknown.\r
    function lookupRadonReducer(bytes32 hash) external view returns (Witnet.RadonReducer memory);\r
\r
    // /// @notice Returns the whole Witnet.RadonRequest metadata struct for the given RAD hash value. \r
    // /// @dev Reverts if unknown.\r
    // function lookupRadonRequest(Witnet.RadonHash radonRequestHash) external view returns (Witnet.RadonRequest memory);\r
\r
    /// @notice Returns the Witnet-compliant RAD bytecode for some Radon Request \r
    /// identified by its unique RAD hash. \r
    function lookupRadonRequestBytecode(Witnet.RadonHash radonRequestHash) external view returns (bytes memory);\r
\r
    /// @notice Returns the Tally reducer that is applied to aggregated values revealed by the witnessing nodes on the \r
    /// Witnet blockchain. \r
    /// @dev Reverts if unknown.\r
    function lookupRadonRequestCrowdAttestationTally(Witnet.RadonHash radonRequestHash) external view returns (Witnet.RadonReducer memory);\r
    \r
    /// @notice Returns the deterministic data type returned by successful resolutions of the given Radon Request. \r
    /// @dev Reverts if unknown.\r
    function lookupRadonRequestResultDataType(Witnet.RadonHash radonRequestHash) external view returns (Witnet.RadonDataTypes);\r
\r
    /// @notice Returns introspective metadata for the index-th data source of some pre-verified Radon Request. \r
    /// @dev Reverts if out of range.\r
    // function lookupRadonRequestRetrievalByIndex(Witnet.RadonHash radonRequestHash, uint256 index) external view returns (Witnet.RadonRetrieval memory);\r
\r
    /// @notice Returns an array (one or more items) containing the introspective metadata of the given Radon Request's \r
    /// data sources (i.e. Radon Retrievals). \r
    /// @dev Reverts if unknown.\r
    function lookupRadonRequestRetrievals(Witnet.RadonHash radonRequestHash) external view returns (Witnet.RadonRetrieval[] memory);\r
\r
    /// @notice Returns the Aggregate reducer that is applied to the data extracted from the data sources \r
    /// (i.e. Radon Retrievals) whenever the given Radon Request gets solved on the Witnet blockchain. \r
    /// @dev Reverts if unknown.\r
    function lookupRadonRequestRetrievalsAggregator(Witnet.RadonHash radonRequestHash) external view returns (Witnet.RadonReducer memory);\r
\r
    function lookupRadonRequestRetrievalsCount(Witnet.RadonHash radonRequestHash) external view returns (uint8);\r
\r
    /// @notice Returns introspective metadata of some previously verified Radon Retrieval (i.e. public data source). \r
    ///@dev Reverts if unknown.\r
    function lookupRadonRetrieval(bytes32 hash) external view returns (Witnet.RadonRetrieval memory);\r
    \r
    /// @notice Returns the number of indexed parameters required to be fulfilled when \r
    /// eventually using the given Radon Retrieval. \r
    /// @dev Reverts if unknown.\r
    function lookupRadonRetrievalArgsCount(bytes32 hash) external view returns (uint8);\r
\r
    /// @notice Returns the type of the data that would be retrieved by the given Radon Retrieval \r
    /// (i.e. public data source). \r
    /// @dev Reverts if unknown.\r
    function lookupRadonRetrievalResultDataType(bytes32 hash) external view returns (Witnet.RadonDataTypes);\r
\r
    /// @notice Verifies and registers the given sequence of dataset filters and reducing function to be \r
    /// potentially used as either Aggregate or Tally reducers within the resolution workflow\r
    /// of Radon Requests in the Wit/Oracle blockchain. Returns a unique hash that identifies the \r
    /// given Radon Reducer in the registry. \r
    /// @dev Reverts if unsupported reducing or filtering methods are specified.\r
    function verifyRadonReducer(Witnet.RadonReducer calldata reducer) external returns (bytes32 hash);\r
    \r
    /// @notice Verifies and registers the specified Radon Request out of the given data sources (i.e. retrievals)\r
    /// and the aggregate and tally Radon Reducers. Returns a unique RAD hash that identifies the \r
    /// verified Radon Request. \r
    /// @dev Reverts if:\r
    /// - unverified retrievals are passed;\r
    /// - retrievals return different data types;\r
    /// - any of passed retrievals is parameterized;\r
    /// - unsupported reducers are passed.\r
    function verifyRadonRequest(\r
            bytes32[] calldata radonRetrieveHashes,\r
            Witnet.RadonReducer calldata dataSourcesAggregator,\r
            Witnet.RadonReducer calldata crowsAttestationTally\r
        ) external returns (Witnet.RadonHash radonRequestHash);\r
\r
    /// @notice Verifies and registers the specified Radon Request out of the given data sources (i.e. retrievals), \r
    /// data sources parameters (if required), and some pre-verified aggregate and tally Radon Reducers. \r
    /// Returns a unique RAD hash that identifies the verified Radon Request.\r
    /// @dev Reverts if:\r
    /// - unverified retrievals are passed;\r
    /// - retrievals return different data types;\r
    /// - ranks of passed args don't match with those required by each given retrieval;\r
    /// - unverified reducers are passed.\r
    function verifyRadonRequest(\r
            bytes32[] calldata retrieveHashes,\r
            bytes32 aggregateReducerHash,\r
            bytes32 tallyReducerHash\r
        ) external returns (Witnet.RadonHash radonRequestHash);\r
\r
    /// @notice Verifies and registers the specified Radon Request out of the given data sources (i.e. retrievals), \r
    /// data sources parameters (if required), and the aggregate and tally Radon Reducers. Returns a unique \r
    /// RAD hash that identifies the verified Radon Request.\r
    /// @dev Reverts if:\r
    /// - unverified retrievals are passed;\r
    /// - retrievals return different data types;\r
    /// - ranks of passed args don't match with those required by each given retrieval;\r
    /// - unsupported reducers are passed.\r
    function verifyRadonRequest(\r
            bytes32[] calldata radonRetrieveHashes,\r
            string[][] calldata radonRetrieveArgs,\r
            Witnet.RadonReducer calldata dataSourcesAggregator,\r
            Witnet.RadonReducer calldata crowdAttestationTally\r
        ) external returns (Witnet.RadonHash radonRequestHash);\r
\r
    /// @notice Verifies and registers the specified Radon Request out of a single modal retrieval where first \r
    /// parameter corresponds to data provider's URL, an array of data providers (i.e. URLs), and an array\r
    /// of parmeter values common to all data providers. Some pre-verified aggregate and tally Radon Reducers\r
    /// must also be provided. Returns a unique RAD hash that identifies the verified Radon Request.\r
    /// @dev Reverts if:\r
    /// - unverified retrieval is passed;\r
    /// - ranks of passed args don't match with those expected by given retrieval, after replacing the data provider URL.\r
    /// - unverified reducers are passed.\r
    function verifyRadonRequest(\r
            bytes32[] calldata radonRetrieveHashes,\r
            string[][] calldata radonRetrieveArgs,\r
            bytes32 dataSourcesAggregatorHash,\r
            bytes32 crowdAttestationTallyHash\r
        ) external returns (Witnet.RadonHash radonRequestHash);\r
\r
    function verifyRadonRequest(\r
            bytes32 commonRetrieveHash,\r
            string[] calldata commonRetrieveArgs,\r
            string[] calldata dataProviders,\r
            bytes32 dataSourcesAggregatorHash,\r
            bytes32 crowdAttestationTallyHash\r
        ) external returns (Witnet.RadonHash radonRequestHash);\r
\r
    /// @notice Verifies and registers the specified Radon Retrieval (i.e. public data source) into this registry contract. \r
    /// Returns a unique retrieval hash that identifies the verified Radon Retrieval.\r
    /// All parameters but the retrieval method are parameterizable by using embedded wildcard \x\ substrings (with x='0'..'9').\r
    /// @dev Reverts if:\r
    /// - unsupported retrieval method is given;\r
    /// - no URL is provided Http/* requests;\r
    /// - non-empty strings given on RNG reqs.\r
    function verifyRadonRetrieval(\r
            Witnet.RadonRetrievalMethods requestMethod,\r
            string calldata requestURL,\r
            string calldata requestBody,\r
            string[2][] calldata requestHeaders,\r
            bytes calldata requestRadonScript\r
        ) external returns (bytes32 hash);\r
\r
//     /// Verifies a new Radon Retrieval by specifying the value to the highest indexed parameter of an already existing one.\r
//     /// Returns the unique hash that identifies the resulting Radon Retrieval.\r
//     /// Reverts if an unverified retrieval hash is passed.\r
//     function verifyRadonRetrieval(\r
//             bytes32 retrieveHash,\r
//             string calldata lastArgValue\r
//         ) external returns (bytes32 hash);\r
// }\r
}"
    },
    "npm/witnet-solidity-bridge@2.2.8/contracts/interfaces/IWitOracleRadonRegistryEvents.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
\r
pragma solidity >=0.8.0 <0.9.0;\r
\r
import "../libs/Witnet.sol";\r
\r
interface IWitOracleRadonRegistryEvents {\r
\r
    /// Emitted every time a new Radon Reducer gets successfully verified and\r
    /// stored into the WitOracleRadonRegistry.\r
    event NewRadonReducer(bytes32 hash);\r
\r
    /// Emitted every time a new Radon Retrieval gets successfully verified and\r
    /// stored into the WitOracleRadonRegistry.\r
    event NewRadonRetrieval(bytes32 hash);\r
\r
    /// Emitted every time a new Radon Request gets successfully verified and\r
    /// stored into the WitOracleRadonRegistry.\r
    event NewRadonRequest(Witnet.RadonHash radonHash);\r
}\r
"
    },
    "npm/witnet-solidity-bridge@2.2.8/contracts/interfaces/IWitOracleRadonRequestFactory.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
\r
pragma solidity >=0.8.0 <0.9.0;\r
\r
import "./IWitOracleRadonRequestModal.sol";\r
import "./IWitOracleRadonRequestTemplate.sol";\r
\r
interface IWitOracleRadonRequestFactory {\r
\r
    event NewRadonRequestModal(address witOracleRadonRequestModal);\r
    event NewRadonRequestTemplate(address witOracleRadonRequestTemplate);\r
\r
    struct DataSource {\r
        string url;\r
        DataSourceRequest request;\r
    }\r
\r
    struct DataSourceRequest {\r
        Witnet.RadonRetrievalMethods method;\r
        string body;\r
        string[2][] headers;\r
        bytes script;\r
    }\r
\r
    function buildRadonRequestModal(\r
            DataSourceRequest calldata commonDataRequest,\r
            Witnet.RadonReducer calldata crowdAttestationTally\r
        )\r
        external returns (IWitOracleRadonRequestModal);\r
\r
    function buildRadonRequestTemplate(\r
            bytes32[] calldata dataRetrieveHashes,\r
            Witnet.RadonReducer calldata dataSourcesAggregator,\r
            Witnet.RadonReducer calldata crowdAttestationTally\r
        ) external returns (IWitOracleRadonRequestTemplate);\r
        \r
    function buildRadonRequestTemplate(\r
            DataSource[] calldata dataSources,\r
            Witnet.RadonReducer calldata dataSourcesAggregator,\r
            Witnet.RadonReducer calldata crowdAttestationTally\r
        )\r
        external returns (IWitOracleRadonRequestTemplate);\r
}\r
"
    },
    "npm/witnet-solidity-bridge@2.2.8/contracts/interfaces/IWitOracleRadonRequestModal.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
\r
pragma solidity >=0.8.0 <0.9.0;\r
\r
import "../libs/Witnet.sol";\r
\r
interface IWitOracleRadonRequestModal {\r
\r
    function getCrowdAttestationTally() external view returns (Witnet.RadonReducer memory);\r
    function getDataResultType() external view returns (Witnet.RadonDataTypes); \r
    function getDataSourceArgsCount(string calldata url) external view returns (uint8);\r
    function getDataSourcesAggregator() external view returns (Witnet.RadonReducer memory);\r
    \r
    function getRadonModalRetrieval() external view returns (Witnet.RadonRetrieval memory);\r
\r
    function verifyRadonRequest(string[] calldata commonRetrievalArgs, string[] calldata dataProviders) external returns (Witnet.RadonHash);\r
    function witOracle() external view returns (address);\r
}\r
"
    },
    "npm/witnet-solidity-bridge@2.2.8/contracts/interfaces/IWitOracleRadonRequestTemplate.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
\r
pragma solidity >=0.8.0 <0.9.0;\r
\r
import "../libs/Witnet.sol";\r
\r
interface IWitOracleRadonRequestTemplate {\r
\r
    function getArgsCount() external view returns (uint8[] memory);\r
    function getCrowdAttestationTally() external view returns (Witnet.RadonReducer memory);\r
    function getDataResultType() external view returns (Witnet.RadonDataTypes); \r
    function getDataSources() external view returns (Witnet.RadonRetrieval[] memory);\r
    function getDataSourcesAggregator() external view returns (Witnet.RadonReducer memory);\r
    \r
    /// Verifies into the bounded WitOracle's registry the actual bytecode \r
    /// and RAD hash of the Witnet-compliant Radon Request that gets provably \r
    /// made out of the data sources, aggregate and tally Radon Reducers that \r
    /// compose this WitOracleRequestTemplate. While no WitOracleRequest instance is \r
    /// actually constructed, the returned value will be accepted as a valid\r
    /// RAD hash on the witOracle() contract from now on. \r
    /// Reverts if:\r
    /// - the ranks of passed array don't match either the number of this \r
    ///   template's data sources, or the number of required parameters by \r
    ///   each one of those.\r
    /// @dev This method requires less gas than buildWitOracleRequest(string[][]), and \r
    /// @dev it's usually preferred when data requests built out of this template\r
    /// @dev are intended to be used just once in lifetime.    \r
    function verifyRadonRequest(string[][] calldata args) external returns (Witnet.RadonHash);\r
\r
    function witOracle() external view returns (address);\r
}\r
"
    },
    "npm/witnet-solidity-bridge@2.2.8/contracts/libs/Bech32.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
// Stratonet Contracts (last updated v1.0.0) (utils/Bech32.sol)\r
\r
pragma solidity ^0.8.0;\r
\r
/**\r
 * @dev Collection of functions related to the Bech32 address generation\r
 */\r
library Bech32 {\r
    bytes constant ALPHABET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";\r
    bytes constant ALPHABET_REV = hex"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0fff0a1115141a1e0705ffffffffffffff1dff180d19090817ff12161f1b13ff010003100b1c0c0e060402ffffffffffff1dff180d19090817ff12161f1b13ff010003100b1c0c0e060402ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";\r
    bytes constant ALPHABET_REV_LOWER_ONLY = hex"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0fff0a1115141a1e0705ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1dff180d19090817ff12161f1b13ff010003100b1c0c0e060402ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";\r
\r
    // 0f <= 0: 48      | 30\r
    // 0a <= 2: 50      | 32\r
    // 11 <= 3: 51      | 33\r
    // 15 <= 4: 52      | 34\r
    // 14 <= 5: 53      | 35\r
    // 1a <= 6: 54      | 36\r
    // 1e <= 7: 55      | 37\r
    // 07 <= 8: 56      | 38\r
    // 05 <= 9: 57      | 39\r
    \r
    // 1d <= a: 97, 65  | 61, 41\r
    // 18 <= c: 99, 67  | 63, 43\r
    // 0d <= d: 100, 68 | 64, 44\r
    // 19 <= e: 101, 69 | 65, 45\r
    // 09 <= f: 102, 70 | 66, 46\r
    // 08 <= g: 103, 71 | 67, 47\r
    // 17 <= h: 104, 72 | 68, 48\r
    // 12 <= j: 106, 74 | 6A, 4A\r
    // 16 <= k: 107, 75 | 6B, 4B\r
    // 1f <= l: 108, 76 | 6C, 4C\r
    // 1b <= m: 109, 77 | 6D, 4D\r
    // 13 <= n: 110, 78 | 6E, 4E\r
    \r
    // 01 <= p: 112, 80 | 70, 50\r
    // 00 <= q: 113, 81 | 71, 51\r
    // 03 <= r: 114, 82 | 72, 52\r
    // 10 <= s: 115, 83 | 73, 53\r
    // 0b <= t: 116, 84 | 74, 54\r
    // 1c <= u: 117, 85 | 75, 55\r
    // 0c <= v: 118, 86 | 76, 56\r
    // 0e <= w: 119, 87 | 77, 57\r
    // 06 <= x: 120, 88 | 78, 58\r
    // 04 <= y: 121, 89 | 79, 59\r
    // 02 <= z: 122, 90 | 7A, 5A\r
    \r
    uint32 constant ENC_BECH32 = 1;\r
    uint32 constant ENC_BECH32M = 0x2bc830a3;\r
\r
\r
    function toBech32(\r
        address addr,\r
        string memory prefix\r
    ) internal pure returns (string memory) {\r
        return toBech32(abi.encodePacked(addr), prefix);\r
    }\r
\r
    function toBech32(\r
        bytes memory data,\r
        string memory prefix\r
    ) internal pure returns (string memory) {\r
        bytes memory hrp = abi.encodePacked(prefix);\r
        bytes memory input = convertBits(data, 8, 5, true);\r
        return encode(hrp, input, ENC_BECH32);\r
    }\r
\r
    function toBech32(\r
        address addr,\r
        string memory prefix,\r
        uint8 version\r
    ) internal pure returns (string memory) {\r
        return toBech32(abi.encodePacked(addr), prefix, version);\r
    }\r
\r
    function toBech32(\r
        bytes memory data,\r
        string memory prefix,\r
        uint8 version\r
    ) internal pure returns (string memory) {\r
        bytes memory hrp = abi.encodePacked(prefix);\r
        bytes memory input = convertBits(data, 8, 5, true);\r
        uint32 enc = ENC_BECH32;\r
        if (version > 0) {\r
            enc = ENC_BECH32M;\r
        }\r
        bytes memory inputWithV = abi.encodePacked(bytes1(version), input);\r
        return encode(hrp, inputWithV, enc);\r
    }\r
\r
    function fromBech32(\r
        string memory bechAddr\r
    ) internal pure returns (address) {\r
        (, uint8[] memory data) = decode(\r
            abi.encodePacked(bechAddr),\r
            ENC_BECH32\r
        );\r
        bytes memory input = convertBits(data, 5, 8, false);\r
        return getAddressFromBytes(input);\r
    }\r
\r
    function fromBech32(\r
        string memory bechAddr,\r
        string memory prefix\r
    ) internal pure returns (address) {\r
        (bytes memory dHrp, uint8[] memory data) = decode(\r
            abi.encodePacked(bechAddr),\r
            ENC_BECH32\r
        );\r
        _requireHrpMatch(abi.encodePacked(prefix), dHrp);\r
        bytes memory input = convertBits(data, 5, 8, false);\r
        return getAddressFromBytes(input);\r
    }\r
\r
    function fromBech32WithVersion(\r
        string memory bechAddr,\r
        string memory prefix,\r
        uint32 enc\r
    ) internal pure returns (uint8, bytes memory) {\r
        (bytes memory dHrp, uint8[] memory data) = decode(\r
            abi.encodePacked(bechAddr),\r
            enc\r
        );\r
        _requireHrpMatch(abi.encodePacked(prefix), dHrp);\r
        require(!(data.length < 1 || data[0] > 16), "Bech32: wrong version");\r
        uint8[] memory dataNoV = new uint8[](data.length - 1);\r
        for (uint8 i = 1; i < data.length; ++i) {\r
            dataNoV[i - 1] = data[i];\r
        }\r
        bytes memory input = convertBits(dataNoV, 5, 8, false);\r
        require(\r
            input.length >= 2 && input.length <= 40,\r
            "Bech32: wrong bits length"\r
        );\r
        require(\r
            !(data[0] == 0 && input.length != 20 && input.length != 32),\r
            "Bech32: wrong bits length for version"\r
        );\r
        return (uint8(data[0]), input);\r
    }\r
\r
    function _requireHrpMatch(\r
        bytes memory hrp1,\r
        bytes memory hrp2\r
    ) internal pure {\r
        require(keccak256(hrp1) == keccak256(hrp2), "Bech32: hrp mismatch");\r
    }\r
\r
    function getAddressFromBytes(\r
        bytes memory data\r
    ) internal pure returns (address) {\r
        require(data.length == 20, "Bech32: invalid data length");\r
\r
        address addr;\r
        assembly {\r
            addr := mload(add(data, 20))\r
        }\r
        return addr;\r
    }\r
\r
    function encode(\r
        bytes memory hrp,\r
        bytes memory input,\r
        uint32 enc\r
    ) internal pure returns (string memory) {\r
        unchecked {\r
            uint8[] memory checksum = createChecksum(hrp, input, enc);\r
            bytes memory result = new bytes(hrp.length + input.length + checksum.length + 1);\r
            for (uint i; i < hrp.length; ++ i) {\r
                result[i] = hrp[i];\r
            }\r
            result[hrp.length] = bytes1("1");\r
            uint offset = hrp.length + 1;\r
            for (uint i; i < input.length; ++ i) {\r
                uint8 _data = uint8(input[i]);\r
                if (_data < ALPHABET.length) {\r
                    result[i + offset] = ALPHABET[_data];\r
                }\r
            }\r
            offset += input.length;\r
            for (uint i; i < checksum.length; ++ i) {\r
                uint8 _data = uint8(checksum[i]);\r
                if (_data < ALPHABET.length) {\r
                    result[i + offset] = ALPHABET[_data];\r
                }\r
            }\r
            return string(result);\r
        }\r
    }\r
\r
    function decode(bytes memory bechStr, uint32 enc) \r
        internal pure \r
        returns (bytes memory hrp, uint8[] memory data)\r
    {\r
        unchecked {\r
            uint pos;\r
            require(\r
                bechStr.length <= 90, \r
                "Bech32: invalid string length"\r
            );\r
            for (uint p = 0; p < bechStr.length; ++ p) {\r
                uint8 charAt = uint8(bechStr[p]);\r
                require(\r
                    charAt >= 33 \r
                        && charAt <= 126, \r
                    "Bech32: wrong char"\r
                );\r
                if (charAt == uint8(bytes1("1"))) {\r
                    require(\r
                        pos == 0 \r
                            && p >= 1 \r
                            && p + 7 <= bechStr.length, \r
                        "Bech32: wrong pos of 1"\r
                    );\r
                    pos = p;\r
                }\r
            }\r
            hrp = new bytes(pos);\r
            for (uint i; i < pos; ++ i) {\r
                hrp[i] = bechStr[i]; \r
            }\r
            data = new uint8[](bechStr.length - pos - 1);\r
            for (uint i; i < data.length; ++ i) {\r
                bytes1 charAt = ALPHABET_REV_LOWER_ONLY[uint8(bechStr[i + pos + 1])];\r
                require(charAt != 0xff, "Bech32: byte not in alphabet");\r
                data[i] = uint8(charAt);\r
            }\r
            require(\r
                verifyChecksum(hrp, data, enc), \r
                "Bech32: wrong checksum"\r
            );\r
            uint dataLength = data.length - 6;\r
            assembly {\r
                mstore(data, dataLength)\r
            }\r
        }\r
    }\r
\r
    function hrpExpand(\r
        bytes memory hrp\r
    ) internal pure returns (uint8[] memory ret) {\r
        unchecked {\r
            ret = new uint8[](hrp.length + hrp.length + 1);\r
            for (uint p; p < hrp.length; ++ p) {\r
                ret[p] = uint8(hrp[p]) >> 5;\r
                ret[p + hrp.length + 1] = uint8(hrp[p]) & 31;\r
            }\r
        }\r
    }\r
\r
    function polymod(uint32[] memory values) internal pure returns (uint32) {\r
        uint32 chk = 1;\r
        uint32[5] memory GEN = [\r
            0x3b6a57b2,\r
            0x26508e6d,\r
            0x1ea119fa,\r
            0x3d4233dd,\r
            0x2a1462b3\r
        ];\r
\r
        unchecked {\r
            for (uint32 i = 0; i < values.length; ++i) {\r
                uint32 top = chk >> 25;\r
                chk = (uint32(chk & 0x1ffffff) << 5) ^ uint32(values[i]);\r
                for (uint32 j = 0; j < 5; ++j) {\r
                    if (((top >> j) & 1) == 1) {\r
                        chk ^= GEN[j];\r
                    }\r
                }\r
            }\r
        }\r
\r
        return chk;\r
    }\r
\r
    function createChecksum(\r
        bytes memory hrp,\r
        bytes memory data,\r
        uint32 enc\r
    ) internal pure returns (uint8[] memory res) {\r
        unchecked {\r
            uint8[] memory values = hrpExpand(hrp);\r
            uint32[] memory comb = new uint32[](values.length + data.length + 6);\r
\r
            for (uint i; i < values.length + data.length; ++ i) {\r
                if (i < values.length) {\r
                    comb[i] = uint32(values[i]);\r
                } else {\r
                    comb[i] = uint32(uint8(data[i - values.length]));\r
                }\r
            }\r
            \r
            res = new uint8[](6);\r
            uint32 mod = polymod(comb) ^ enc;\r
            for (uint p = 0; p < 6; ++ p) {\r
                res[p] = uint8((mod >> (5 * (5 - p))) & 31);\r
            }\r
        }\r
    }\r
\r
    function verifyChecksum(\r
        bytes memory hrp,\r
        uint8[] memory data,\r
        uint32 enc\r
    ) internal pure returns (bool) {\r
        unchecked {\r
            uint8[] memory ehrp = hrpExpand(hrp);\r
            uint32[] memory cData = new uint32[](ehrp.length + data.length);\r
            for (uint i; i < ehrp.length; ++ i) {\r
                cData[i] = uint32(ehrp[i]);\r
            }\r
            for (uint i; i < data.length; ++ i) {\r
                cData[i + ehrp.length] = uint32(data[i]);\r
            }\r
            return polymod(cData) == enc;\r
        }\r
    }\r
\r
    function convertBits(\r
        bytes memory data,\r
        uint frombits,\r
        uint tobits,\r
        bool pad\r
    ) internal pure returns (bytes memory) {\r
        uint8[] memory dataBits = new uint8[](data.length);\r
\r
        for (uint32 p = 0; p < dataBits.length; ++p) {\r
            dataBits[p] = uint8(data[p]);\r
        }\r
\r
        return _convertBits(dataBits, frombits, tobits, pad);\r
    }\r
\r
    function convertBits(\r
        uint8[] memory data,\r
        uint frombits,\r
        uint tobits,\r
        bool pad\r
    ) internal pure returns (bytes memory) {\r
        return _convertBits(data, frombits, tobits, pad);\r
    }\r
\r
    function _convertBits(\r
        uint8[] memory dataBits,\r
        uint frombits,\r
        uint tobits,\r
        bool pad\r
    ) internal pure returns (bytes memory ret) {\r
        uint acc = 0;\r
        uint bits = 0;\r
\r
        uint maxv = (1 << tobits) - 1;\r
\r
        unchecked {\r
            for (uint p; p < dataBits.length; ++p) {\r
                uint8 value = dataBits[p];\r
                require(\r
                    value >= 0 && (value >> frombits) == 0,\r
                    "Bech32: value must be non-negative and fit in frombits"\r
                );\r
\r
                acc = (acc << frombits) | value;\r
                bits += frombits;\r
\r
                while (bits >= tobits) {\r
                    bits -= tobits;\r
                    ret = abi.encodePacked(\r
                        ret,\r
                        bytes1(uint8((acc >> bits) & maxv))\r
                    );\r
                }\r
            }\r
        }\r
\r
        if (pad) {\r
            if (bits > 0) {\r
                ret = abi.encodePacked(\r
                    ret,\r
                    bytes1(uint8((acc << (tobits - bits)) & maxv))\r
                );\r
            }\r
        } else {\r
            require(\r
                bits < frombits || ((acc << (tobits - bits)) & maxv) == 0,\r
                "Bech32: invalid padding or value size"\r
            );\r
        }\r
    }\r
}"
    },
    "npm/witnet-solidity-bridge@2.2.8/contracts/libs/Secp256k1.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
\r
pragma solidity >= 0.8.17;\r
\r
/**\r
 * @title Secp256k1 public key recovery Library\r
 * @dev Library providing arithmetic operations over signed `secpk256k1` signed message due to recover the signer public key EC point in `Solidity`.\r
 * @author cyphered.eth\r
 */\r
library Secp256k1 {\r
    // Elliptic curve Constants\r
    uint256 private constant U255_MAX_PLUS_1 =\r
        57896044618658097711785492504343953926634992332820282019728792003956564819968;\r
\r
    // Curve Constants\r
    uint256 private constant A = 0;\r
    uint256 private constant B = 7;\r
    uint256 private constant GX = 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798;\r
    uint256 private constant GY = 0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8;\r
    uint256 private constant P = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F;\r
    uint256 private constant N = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141;\r
\r
    /// @dev recovers signer public key point value.\r
    /// @param digest hashed message\r
    /// @param v recovery\r
    /// @param r first 32 bytes of signature\r
    /// @param v last 32 bytes of signature\r
    /// @return (x, y) EC point\r
    function recover(\r
        uint256 digest,\r
        uint8 v,\r
        uint256 r,\r
        uint256 s\r
    ) internal pure returns (uint256, uint256) {\r
        uint256 x = addmod(r, P * (v >> 1), P);\r
        if (x > P || s > N || r > N || s == 0 || r == 0 || v > 1) {\r
            return (0, 0);\r
        }\r
        uint256 rInv = invMod(r, N);\r
\r
        uint256 y2 = addmod(mulmod(x, mulmod(x, x, P), P), addmod(mulmod(x, A, P), B, P), P);\r
        y2 = expMod(y2, (P + 1) / 4);\r
        uint256 y = ((y2 + v + 2) & 1 == 0) ? y2 : P - y2;\r
\r
        (uint256 qx, uint256 qy, uint256 qz) = jacMul(mulmod(rInv, N - digest, N), GX, GY, 1);\r
        (uint256 qx2, uint256 qy2, uint256 qz2) = jacMul(mulmod(rInv, s, N), x, y, 1);\r
        (uint256 qx3, uint256 qy3) = ecAdd(qx, qy, qz, qx2, qy2, qz2);\r
\r
        return (qx3, qy3);\r
    }\r
\r
    /// @dev Modular exponentiation, b^e % P.\r
    /// Source: https://github.com/witnet/elliptic-curve-solidity/blob/master/contracts/EllipticCurve.sol\r
    /// Source: https://github.com/androlo/standard-contracts/blob/master/contracts/src/crypto/ECCMath.sol\r
    /// @param _base base\r
    /// @param _exp exponent\r
    /// @return r such that r = b**e (mod P)\r
    function expMod(uint256 _base, uint256 _exp) internal pure returns (uint256) {\r
        if (_base == 0) return 0;\r
        if (_exp == 0) return 1;\r
\r
        uint256 r = 1;\r
        uint256 bit = U255_MAX_PLUS_1;\r
        assembly {\r
            for {\r
\r
            } gt(bit, 0) {\r
\r
            } {\r
                r := mulmod(mulmod(r, r, P), exp(_base, iszero(iszero(and(_exp, bit)))), P)\r
                r := mulmod(mulmod(r, r, P), exp(_base, iszero(iszero(and(_exp, div(bit, 2))))), P)\r
                r := mulmod(mulmod(r, r, P), exp(_base, iszero(iszero(and(_exp, div(bit, 4))))), P)\r
                r := mulmod(mulmod(r, r, P), exp(_base, iszero(iszero(and(_exp, div(bit, 8))))), P)\r
                bit := div(bit, 16)\r
            }\r
        }\r
\r
        return r;\r
    }\r
\r
    /// @dev Adds two points (x1, y1, z1) and (x2 y2, z2).\r
    /// Source: https://github.com/witnet/elliptic-curve-solidity/blob/master/contracts/EllipticCurve.sol\r
    /// @param _x1 coordinate x of P1\r
    /// @param _y1 coordinate y of P1\r
    /// @param _z1 coordinate z of P1\r
    /// @param _x2 coordinate x of square\r
    /// @param _y2 coordinate y of square\r
    /// @param _z2 coordinate z of square\r
    /// @return (qx, qy, qz) P1+square in Jacobian\r
    function jacAdd(\r
        uint256 _x1,\r
        uint256 _y1,\r
        uint256 _z1,\r
        uint256 _x2,\r
        uint256 _y2,\r
        uint256 _z2\r
    )\r
        internal\r
        pure\r
        returns (\r
            uint256,\r
            uint256,\r
            uint256\r
        )\r
    {\r
        if (_x1 == 0 && _y1 == 0) return (_x2, _y2, _z2);\r
        if (_x2 == 0 && _y2 == 0) return (_x1, _y1, _z1);\r
\r
        // We follow the equations described in https://pdfs.semanticscholar.org/5c64/29952e08025a9649c2b0ba32518e9a7fb5c2.pdf Section 5\r
        uint256[4] memory zs; // z1^2, z1^3, z2^2, z2^3\r
        zs[0] = mulmod(_z1, _z1, P);\r
        zs[1] = mulmod(_z1, zs[0], P);\r
        zs[2] = mulmod(_z2, _z2, P);\r
        zs[3] = mulmod(_z2, zs[2], P);\r
\r
        // u1, s1, u2, s2\r
        zs = [mulmod(_x1, zs[2], P), mulmod(_y1, zs[3], P), mulmod(_x2, zs[0], P), mulmod(_y2, zs[1], P)];\r
\r
        // In case of zs[0] == zs[2] && zs[1] == zs[3], double function should be used\r
        require(zs[0] != zs[2] || zs[1] != zs[3], 'Use jacDouble function instead');\r
\r
        uint256[4] memory hr;\r
        //h\r
        hr[0] = addmod(zs[2], P - zs[0], P);\r
        //r\r
        hr[1] = addmod(zs[3], P - zs[1], P);\r
        //h^2\r
        hr[2] = mulmod(hr[0], hr[0], P);\r
        // h^3\r
        hr[3] = mulmod(hr[2], hr[0], P);\r
        // qx = -h^3  -2u1h^2+r^2\r
        uint256 qx = addmod(mulmod(hr[1], hr[1], P), P - hr[3], P);\r
        qx = addmod(qx, P - mulmod(2, mulmod(zs[0], hr[2], P), P), P);\r
        // qy = -s1*z1*h^3+r(u1*h^2 -x^3)\r
        uint256 qy = mulmod(hr[1], addmod(mulmod(zs[0], hr[2], P), P - qx, P), P);\r
        qy = addmod(qy, P - mulmod(zs[1], hr[3], P), P);\r
        // qz = h*z1*z2\r
        uint256 qz = mulmod(hr[0], mulmod(_z1, _z2, P), P);\r
        return (qx, qy, qz);\r
    }\r
\r
    /// @dev Multiply point (x, y, z) times d.\r
    /// Source: https://github.com/witnet/elliptic-curve-solidity/blob/master/contracts/EllipticCurve.sol\r
    /// @param _d scalar to multiply\r
    /// @param _x coordinate x of P1\r
    /// @param _y coordinate y of P1\r
    /// @param _z coordinate z of P1\r
    /// @return (qx, qy, qz) d*P1 in Jacobian\r
    function jacMul(\r
        uint256 _d,\r
        uint256 _x,\r
        uint256 _y,\r
        uint256 _z\r
    )\r
        internal\r
        pure\r
        returns (\r
            uint256,\r
            uint256,\r
            uint256\r
        )\r
    {\r
        // Early return in case that `_d == 0`\r
        if (_d == 0) {\r
            return (_x, _y, _z);\r
        }\r
\r
        uint256 remaining = _d;\r
        uint256 qx = 0;\r
        uint256 qy = 0;\r
        uint256 qz = 1;\r
\r
        // Double and add algorithm\r
        while (remaining != 0) {\r
            if ((remaining & 1) != 0) {\r
                (qx, qy, qz) = jacAdd(qx, qy, qz, _x, _y, _z);\r
            }\r
            remaining = remaining / 2;\r
            (_x, _y, _z) = jacDouble(_x, _y, _z);\r
        }\r
        return (qx, qy, qz);\r
    }\r
\r
    /// @dev Doubles a points (x, y, z).\r
    /// Source: https://github.com/witnet/elliptic-curve-solidity/blob/master/contracts/EllipticCurve.sol\r
    /// @param _x coordinate x of P1\r
    /// @param _y coordinate y of P1\r
    /// @param _z coordinate z of P1\r
    /// @return (qx, qy, qz) 2P in Jacobian\r
    function jacDouble(\r
        uint256 _x,\r
        uint256 _y,\r
        uint256 _z\r
    )\r
        internal\r
        pure\r
        returns (\r
            uint256,\r
            uint256,\r
            uint256\r
        )\r
    {\r
        if (_z == 0) return (_x, _y, _z);\r
\r
        // We follow the equations described in https://pdfs.semanticscholar.org/5c64/29952e08025a9649c2b0ba32518e9a7fb5c2.pdf Section 5\r
        // Note: there is a bug in the paper regarding the m parameter, M=3*(x1^2)+a*(z1^4)\r
        // x, y, z at this point represent the squares of _x, _y, _z\r
        uint256 x = mulmod(_x, _x, P); //x1^2\r
        uint256 y = mulmod(_y, _y, P); //y1^2\r
        uint256 z = mulmod(_z, _z, P); //z1^2\r
\r
        // s\r
        uint256 s = mulmod(4, mulmod(_x, y, P), P);\r
        // m\r
        uint256 m = addmod(mulmod(3, x, P), mulmod(A, mulmod(z, z, P), P), P);\r
\r
        // x, y, z at this point will be reassigned and rather represent qx, qy, qz from the paper\r
        // This allows to reduce the gas cost and stack footprint of the algorithm\r
        // qx\r
        x = addmod(mulmod(m, m, P), P - addmod(s, s, P), P);\r
        // qy = -8*y1^4 + M(S-T)\r
        y = addmod(mulmod(m, addmod(s, P - x, P), P), P - mulmod(8, mulmod(y, y, P), P), P);\r
        // qz = 2*y1*z1\r
        z = mulmod(2, mulmod(_y, _z, P), P);\r
\r
        return (x, y, z);\r
    }\r
\r
    /// @dev Add two points (x1, y1) and (x2, y2) in affine coordinates.\r
    /// Source: https://github.com/witnet/elliptic-curve-solidity/blob/master/contracts/EllipticCurve.sol\r
    /// @param _x1 coordinate x of P1\r
    /// @param _y1 coordinate y of P1\r
    /// @param _x2 coordinate x of P2\r
    /// @param _y2 coordinate y of P2\r
    /// @return (qx, qy) = P1+P2 in affine coordinates\r
    function ecAdd(\r
        uint256 _x1,\r
        uint256 _y1,\r
        uint256 _z1,\r
        uint256 _x2,\r
        uint256 _y2,\r
        uint256 _z2\r
    ) internal pure returns (uint256, uint256) {\r
        uint256 x = 0;\r
        uint256 y = 0;\r
        uint256 z = 0;\r
\r
        // Double if x1==x2 else add\r
        if (_x1 == _x2) {\r
            // y1 = -y2 mod p\r
            if (addmod(_y1, _y2, P) == 0) {\r
                return (0, 0);\r
            } else {\r
                // P1 = P2\r
                (x, y, z) = jacDouble(_x1, _y1, _z1);\r
            }\r
        } else {\r
            (x, y, z) = jacAdd(_x1, _y1, _z1, _x2, _y2, _z2);\r
        }\r
        // Get back to affine\r
        return toAffine(x, y, z);\r
    }\r
\r
    /// @dev Converts a point (x, y, z) expressed in Jacobian coordinates to affine coordinates (x', y', 1).\r
    /// Source: https://github.com/witnet/elliptic-curve-solidity/blob/master/contracts/EllipticCurve.sol\r
    /// @param _x coordinate x\r
    /// @param _y coordinate y\r
    /// @param _z coordinate z\r
    /// @return (x', y') affine coordinates\r
    function toAffine(\r
        uint256 _x,\r
        uint256 _y,\r
        uint256 _z\r
    ) internal pure returns (uint256, uint256) {\r
        uint256 zInv = invMod(_z, P);\r
        uint256 zInv2 = mulmod(zInv, zInv, P);\r
        uint256 x2 = mulmod(_x, zInv2, P);\r
        uint256 y2 = mulmod(_y, mulmod(zInv, zInv2, P), P);\r
\r
        return (x2, y2);\r
    }\r
\r
    /// @dev Modular euclidean inverse of a number (mod p).\r
    /// Source: https://github.com/witnet/elliptic-curve-solidity/blob/master/contracts/EllipticCurve.sol\r
    /// @param _x The number\r
    /// @param _pp The modulus\r
    /// @return q such that x*q = 1 (mod _pp)\r
    function invMod(uint256 _x, uint256 _pp) internal pure returns (uint256) {\r
        require(_x != 0 && _x != _pp && _pp != 0, 'Invalid number');\r
        uint256 q = 0;\r
        uint256 newT = 1;\r
        uint256 r = _pp;\r
        uint256 t;\r
        while (_x != 0) {\r
            t = r / _x;\r
            (q, newT) = (newT, addmod(q, (_pp - mulmod(t, newT, _pp)), _pp));\r
            (r, _x) = (_x, r - t * _x);\r
        }\r
\r
        return q;\r
    }\r
}"
    },
    "npm/witnet-solidity-bridge@2.2.8/contracts/libs/Witnet.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
\r
pragma solidity >=0.8.0 <0.9.0;\r
\r
import "./Bech32.sol";\r
import "./Secp256k1.sol";\r
import "./WitnetCBOR.sol";\r
\r
library Witnet {\r
\r
    using Bech32 for Witnet.Address;\r
    using WitnetBuffer for WitnetBuffer.Buffer;\r
    using WitnetCBOR for WitnetCBOR.CBOR;\r
    using WitnetCBOR for WitnetCBOR.CBOR[];\r
\r
    type Address is bytes20;\r
\r
    type BlockNumber is uint64;\r
    \r
    type QueryEvmReward is uint72;\r
    type QueryUUID is bytes15;\r
    type QueryId is uint64;\r
\r
    type RadonHash is bytes32;\r
    type ServiceProvider is bytes20;\r
    \r
    type Timestamp is uint64;\r
    type TransactionHash is bytes32;\r
\r
    uint32  constant internal WIT_1_GENESIS_TIMESTAMP = 0; // TBD    \r
    uint32  constant internal WIT_1_SECS_PER_EPOCH = 45;\r
\r
    uint32  constant internal WIT_2_GENESIS_BEACON_INDEX = 0;       // TBD\r
    uint32  constant internal WIT_2_GENESIS_BEACON_PREV_INDEX = 0;  // TBD\r
    bytes24 constant internal WIT_2_GENESIS_BEACON_PREV_ROOT = 0;   // TBD\r
    bytes16 constant internal WIT_2_GENESIS_BEACON_DDR_TALLIES_MERKLE_ROOT = 0;  // TBD\r
    bytes16 constant internal WIT_2_GENESIS_BEACON_DRO_TALLIES_MERKLE_ROOT = 0;  // TBD\r
    uint256 constant internal WIT_2_GENESIS_BEACON_NEXT_COMMITTEE_AGG_PUBKEY_0 = 0; // TBD\r
    uint256 constant internal WIT_2_GENESIS_BEACON_NEXT_COMMITTEE_AGG_PUBKEY_1 = 0; // TBD\r
    uint256 constant internal WIT_2_GENESIS_BEACON_NEXT_COMMITTEE_AGG_PUBKEY_2 = 0; // TBD\r
    uint256 constant internal WIT_2_GENESIS_BEACON_NEXT_COMMITTEE_AGG_PUBKEY_3 = 0; // TBD\r
    uint32  constant internal WIT_2_GENESIS_EPOCH = 0;      // TBD\r
    uint32  constant internal WIT_2_GENESIS_TIMESTAMP = 0;  // TBD\r
    uint32  constant internal WIT_2_SECS_PER_EPOCH = 20;    // TBD\r
    uint32  constant internal WIT_2_FAST_FORWARD_COMMITTEE_SIZE = 64; // TBD\r
\r
\r
    function channel(address wrb) internal view returns (bytes4) {\r
        return bytes4(keccak256(abi.encode(address(wrb), block.chainid)));\r
    }\r
\r
    struct Beacon {\r
        uint32  index;\r
        uint32  prevIndex;\r
        bytes24 prevRoot;\r
        bytes16 ddrTalliesMerkleRoot;\r
        bytes16 droTalliesMerkleRoot;\r
        uint256[4] nextCommitteeAggPubkey;\r
    }\r
\r
    struct DataPullReport {\r
        QueryId queryId;\r
        QueryUUID queryHash;           // KECCAK256(channel | blockhash(block.number - 1) | ...)\r
        bytes witDrRelayerSignature;   // ECDSA.signature(queryHash)\r
        BlockNumber witDrResultEpoch;\r
        bytes witDrResultCborBytes;\r
        TransactionHash witDrTxHash;\r
    }\r
\r
    struct DataPushReport {\r
        TransactionHash witDrTxHash;\r
        RadonHash queryRadHash;\r
        QuerySLA  queryParams;\r
        Timestamp resultTimestamp;\r
        bytes resultCborBytes;\r
    }\r
\r
    /// Data struct containing the Witnet-provided result to a Data Request.\r
    struct DataResult {\r
        ResultStatus status;\r
        RadonDataTypes dataType;\r
        TransactionHash drTxHash;\r
        uint256 finality;\r
        Timestamp timestamp;\r
        WitnetCBOR.CBOR value;\r
    }\r
\r
    struct FastForward {\r
        Beacon beacon;\r
        uint256[2] committeeAggSignature;\r
        uint256[4][] committeeMissingPubkeys;\r
    }\r
\r
    /// Struct containing both request and response data related to every query posted to the Witnet Request Board\r
    struct Query {\r
        QueryRequest request;\r
        QueryResponse response;\r
        QuerySLA slaParams;      // Minimum Service-Level parameters to be committed by the Witnet blockchain.\r
        QueryUUID uuid;          // Universal unique identifier determined by the payload, WRB instance, chain id and EVM's previous block hash.\r
        QueryEvmReward reward;   // EVM amount in wei eventually to be paid to the legit reporter.\r
        BlockNumber checkpoint;\r
    }\r
\r
    /// Possible status of a Witnet query.\r
    enum QueryStatus {\r
        Unknown,\r
        Posted,\r
        Reported,\r
        Finalized,\r
        Delayed,\r
        Expired,\r
        Disputed\r
    }\r
\r
    struct QueryCallback {\r
        address consumer;               // consumer contract address to which the query result will be reported\r
        uint24  gasLimit;               // expected max amount of gas required by the callback method in the consumer contract\r
    }\r
\r
    /// Data kept in EVM-storage for every Request posted to the Witnet Request Board.\r
    struct QueryRequest {\r
        address   requester;     // EVM address from which the request was posted.\r
        uint24    callbackGas;   // Max callback gas limit upon response, if a callback is required.\r
        bytes     radonBytecode; // Optional: Witnet Data Request bytecode to be solved by the Witnet blockchain.\r
        RadonHash radonHash;     // Optional: Previously verified hash of the Witnet Data Request to be solved.\r
    }\r
\r
    /// QueryResponse metadata and result as resolved by the Witnet blockchain.\r
    struct QueryResponse {\r
        address reporter;               // EVM address from which the Data Request result was reported.\r
        Timestamp resultTimestamp;      // Unix timestamp (seconds) at which the data request was resolved in the Witnet blockchain.\r
        TransactionHash resultDrTxHash; // Unique hash of the commit/reveal act in the Witnet blockchain that resolved the data request.\r
        bytes resultCborBytes;          // CBOR-encode result to the request, as resolved in the Witnet blockchain.\r
        address disputer;\r
    }\r
\r
    /// Structure containing all possible SLA security parameters for Wit/2.1 Data Requests\r
    struct QuerySLA {\r
        uint16  witResultMaxSize; // max size permitted to whatever query result may come from the Wit/Oracle blockchain.\r
        uint16  witCommitteeSize; // max number of eligibile witnesses in the Wit/Oracle blockchain for solving some query.\r
        uint64  witUnitaryReward; // min fees in nanowits to be paid for getting the query solved and reported from the Wit/Oracle.\r
    }\r
\r
    enum ResultStatus {\r
        /// 0x00: No errors.\r
        NoErrors,\r
        \r
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r
        /// Source-specific format error sub-codes ============================================================================\r
        \r
        /// 0x01: At least one of the source scripts is not a valid CBOR-encoded value.\r
        SourceScriptNotCBOR, \r
        \r
        /// 0x02: The CBOR value decoded from a source script is not an Array.\r
        SourceScriptNotArray,\r
        \r
        /// 0x03: The Array value decoded form a source script is not a valid Data Request.\r
        SourceScriptNotRADON,\r
        \r
        /// 0x04: The request body of at least one data source was not properly formated.\r
        SourceRequestBody,\r
        \r
        /// 0x05: The request headers of at least one data source was not properly formated.\r
        SourceRequestHeaders,\r
        \r
        /// 0x06: The request URL of at least one data source was not properly formated.\r
        SourceRequestURL,\r
        \r
        /// Unallocated\r
        SourceFormat0x07, SourceFormat0x08, SourceFormat0x09, SourceFormat0x0A, SourceFormat0x0B, SourceFormat0x0C,\r
        SourceFormat0x0D, SourceFormat0x0E, SourceFormat0x0F, \r
        \r
        \r
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r
        /// Complexity error sub-codes ========================================================================================\r
        \r
        /// 0x10: The request contains too many sources.\r
        RequestTooManySources,\r
        \r
        /// 0x11: The script contains too many calls.\r
        ScriptTooManyCalls,\r
        \r
        /// Unallocated\r
        Complexity0x12, Complexity0x13, Complexity0x14, Complexity0x15, Complexity0x16, Complexity0x17, Complexity0x18,\r
        Complexity0x19, Complexity0x1A, Complexity0x1B, Complexity0x1C, Complexity0x1D, Complexity0x1E, Complexity0x1F,\r
\r
        \r
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r
        /// Lack of support error sub-codes ===================================================================================\r
        \r
        /// 0x20: Some Radon operator code was found that is not supported (1+ args).\r
        UnsupportedOperator,\r
        \r
        /// 0x21: Some Radon filter opcode is not currently supported (1+ args).\r
        UnsupportedFilter,\r
        \r
        /// 0x22: Some Radon request type is not currently supported (1+ args).\r
        UnsupportedHashFunction,\r
        \r
        /// 0x23: Some Radon reducer opcode is not currently supported (1+ args)\r
        UnsupportedReducer,\r
        \r
        /// 0x24: Some Radon hash function is not currently supported (1+ args).\r
        UnsupportedRequestType, \r
        \r
        /// 0x25: Some Radon encoding function is not currently supported (1+ args).\r
        UnsupportedEncodingFunction,\r
        \r
        /// Unallocated\r
        Operator0x26, Operator0x27, \r
        \r
        /// 0x28: Wrong number (or type) of arguments were passed to some Radon operator.\r
        WrongArguments,\r
        \r
        /// Unallocated\r
        Operator0x29, Operator0x2A, Operator0x2B, Operator0x2C, Operator0x2D, Operator0x2E, Operator0x2F,\r
        \r
        \r
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\r
        /// Retrieve-specific circumstantial error sub-codes ================================================================================\r
        /// 0x30: A majority of data sources returned an HTTP status code other than 200 (1+ args):\r
        HttpErrors,\r
        \r
        /// 0x31: A majority of data sources timed out:\r
        RetrievalsTimeout,\r
        \r
        /// Unallocated\r
        RetrieveCircumstance0x32, RetrieveCircumstance0x33, RetrieveCircumstance0x34, RetrieveCircumstance0x35,\r
        RetrieveCircumstance0x36, RetrieveCircumstance0x37, RetrieveCircumstance0x38, RetrieveCircumstance0x39,\r
        RetrieveCircumstance0x3A, RetrieveCircumstance0x3B, RetrieveCircumstance0x3C, RetrieveCircumstance0x3D,\r
        RetrieveCircumstance0x3

Tags:
Proxy, Upgradeable, Factory, Oracle|addr:0xeccc198b53afecb007234d5344e9b965d180c63c|verified:true|block:23576225|tx:0xe20d6746d7129b541e52e34fca3f8e3712b8e48092747a6591a892a91d568ff9|first_check:1760451913

Submitted on: 2025-10-14 16:25:13

Comments

Log in to comment.

No comments yet.