Skip to content

Instantly share code, notes, and snippets.

@Ashar2shahid
Last active February 24, 2023 02:16
Show Gist options
  • Save Ashar2shahid/c2f32da1c95c2826ec337faa3a2fb933 to your computer and use it in GitHub Desktop.
Save Ashar2shahid/c2f32da1c95c2826ec337faa3a2fb933 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "@api3/airnode-protocol-v1/contracts/dapis/DapiReader.sol";
contract DataFeedReaderExample is DapiReader {
constructor(address _dapiServer) DapiReader(_dapiServer) {}
function readDataFeedWithDapiName(bytes32 dapiName)
external
view
returns (int224 value, uint256 timestamp)
{
(value, timestamp) = IDapiServer(dapiServer).readDataFeedWithDapiName(
dapiName
);
}
function readDataFeedValueWithDapiName(bytes32 dapiName)
external
view
returns (int224 value)
{
value = IDapiServer(dapiServer).readDataFeedValueWithDapiName(dapiName);
}
function dapiNameToReaderToWhitelistStatus(bytes32 dapiName, address reader)
external
view
returns (uint64 expirationTimestamp, uint192 indefiniteWhitelistCount)
{
bytes32 dapiNameHash = keccak256(abi.encodePacked(dapiName));
return
IDapiServer(dapiServer).dataFeedIdToReaderToWhitelistStatus(
dapiNameHash,
reader
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment