| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- // contracts/Getters.sol
- // SPDX-License-Identifier: Apache 2
- pragma solidity ^0.8.0;
- import "../wormhole/interfaces/IWormhole.sol";
- import "./PythInternalStructs.sol";
- import "./PythState.sol";
- contract PythGetters is PythState {
- function wormhole() public view returns (IWormhole) {
- return IWormhole(_state.wormhole);
- }
- /// Deprecated, use `validDataSources` instead
- function pyth2WormholeChainId() public view returns (uint16) {
- return _state._deprecatedPyth2WormholeChainId;
- }
- /// Deprecated, use `validDataSources` instead
- function pyth2WormholeEmitter() public view returns (bytes32) {
- return _state._deprecatedPyth2WormholeEmitter;
- }
- function latestPriceInfo(
- bytes32 priceId
- ) internal view returns (PythInternalStructs.PriceInfo memory info) {
- return _state.latestPriceInfo[priceId];
- }
- function latestPriceInfoPublishTime(
- bytes32 priceId
- ) public view returns (uint64) {
- return _state.latestPriceInfo[priceId].publishTime;
- }
- function hashDataSource(
- PythInternalStructs.DataSource memory ds
- ) public pure returns (bytes32) {
- return keccak256(abi.encodePacked(ds.chainId, ds.emitterAddress));
- }
- function isValidDataSource(
- uint16 dataSourceChainId,
- bytes32 dataSourceEmitterAddress
- ) public view returns (bool) {
- return
- _state.isValidDataSource[
- keccak256(
- abi.encodePacked(
- dataSourceChainId,
- dataSourceEmitterAddress
- )
- )
- ];
- }
- function isValidGovernanceDataSource(
- uint16 governanceChainId,
- bytes32 governanceEmitterAddress
- ) public view returns (bool) {
- return
- _state.governanceDataSource.chainId == governanceChainId &&
- _state.governanceDataSource.emitterAddress ==
- governanceEmitterAddress;
- }
- function chainId() public view returns (uint16) {
- return wormhole().chainId();
- }
- function lastExecutedGovernanceSequence() public view returns (uint64) {
- return _state.lastExecutedGovernanceSequence;
- }
- function validDataSources()
- public
- view
- returns (PythInternalStructs.DataSource[] memory)
- {
- return _state.validDataSources;
- }
- function governanceDataSource()
- public
- view
- returns (PythInternalStructs.DataSource memory)
- {
- return _state.governanceDataSource;
- }
- function singleUpdateFeeInWei() public view returns (uint) {
- return _state.singleUpdateFeeInWei;
- }
- function validTimePeriodSeconds() public view returns (uint) {
- return _state.validTimePeriodSeconds;
- }
- function governanceDataSourceIndex() public view returns (uint32) {
- return _state.governanceDataSourceIndex;
- }
- }
|