|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | +pragma solidity >=0.7.6 <0.9; |
| 3 | + |
| 4 | +/** |
| 5 | + * @custom:name IJsonApi |
| 6 | + * @custom:supported WEB2 |
| 7 | + * @author Flare |
| 8 | + * @notice An attestation request that fetches data from the given url and then edits the information with a |
| 9 | + * jq transformation. |
| 10 | + * @custom:verification Data is fetched from an url `url`. The received data is then processed with jq as |
| 11 | + * the `postprocessJq` states. The structure of the final json is written in the `abi_signature`. |
| 12 | + * |
| 13 | + * The response contains an abi encoding of the final data. |
| 14 | + * @custom:lut `0xffffffffffffffff` |
| 15 | + * @custom:lut-limit `0xffffffffffffffff` |
| 16 | + */ |
| 17 | +interface IJsonApi { |
| 18 | + /** |
| 19 | + * @notice Toplevel request |
| 20 | + * @param attestationType ID of the attestation type. |
| 21 | + * @param sourceId ID of the data source. |
| 22 | + * @param messageIntegrityCode `MessageIntegrityCode` that is derived from the expected response. |
| 23 | + * @param requestBody Data defining the request. Type (struct) and interpretation is determined |
| 24 | + * by the `attestationType`. |
| 25 | + */ |
| 26 | + struct Request { |
| 27 | + bytes32 attestationType; |
| 28 | + bytes32 sourceId; |
| 29 | + bytes32 messageIntegrityCode; |
| 30 | + RequestBody requestBody; |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * @notice Toplevel response |
| 35 | + * @param attestationType Extracted from the request. |
| 36 | + * @param sourceId Extracted from the request. |
| 37 | + * @param votingRound The ID of the State Connector round in which the request was considered. |
| 38 | + * @param lowestUsedTimestamp The lowest timestamp used to generate the response. |
| 39 | + * @param requestBody Extracted from the request. |
| 40 | + * @param responseBody Data defining the response. The verification rules for the construction |
| 41 | + * of the response body and the type are defined per specific `attestationType`. |
| 42 | + */ |
| 43 | + struct Response { |
| 44 | + bytes32 attestationType; |
| 45 | + bytes32 sourceId; |
| 46 | + uint64 votingRound; |
| 47 | + uint64 lowestUsedTimestamp; |
| 48 | + RequestBody requestBody; |
| 49 | + ResponseBody responseBody; |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * @notice Toplevel proof |
| 54 | + * @param merkleProof Merkle proof corresponding to the attestation response. |
| 55 | + * @param data Attestation response. |
| 56 | + */ |
| 57 | + struct Proof { |
| 58 | + bytes32[] merkleProof; |
| 59 | + Response data; |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * @notice Request body for Payment attestation type |
| 64 | + * @param url URL of the data source |
| 65 | + * @param postprocessJq jq filter to postprocess the data |
| 66 | + * @param abi_signature ABI signature of the data |
| 67 | + */ |
| 68 | + struct RequestBody { |
| 69 | + string url; |
| 70 | + string postprocessJq; |
| 71 | + string abi_signature; |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * @notice Response body for Payment attestation type |
| 76 | + * @param abi_encoded_data ABI encoded data |
| 77 | + */ |
| 78 | + struct ResponseBody { |
| 79 | + bytes abi_encoded_data; |
| 80 | + } |
| 81 | +} |
0 commit comments