Skip to content

Commit

Permalink
add oracle permissions to contract
Browse files Browse the repository at this point in the history
  • Loading branch information
noot committed Dec 12, 2024
1 parent 0401aa1 commit e9a404e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/AstriaOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ pragma solidity ^0.8.21;
// Core oracle contract for Astria's native oracle.
// This contract stores the price data for every currency pair supported by the oracle.
contract AstriaOracle {
// the `astriaOracleSenderAddress` built into the astria-geth node
address public immutable ORACLE;

// mapping of block number to mapping of hash of the currency pair string to its price data
mapping(uint256 => mapping(bytes32 => PriceData)) public priceData;

Expand All @@ -13,16 +16,21 @@ contract AstriaOracle {
// block number of the latest price data update
uint256 public latestBlockNumber;

modifier onlyOracle() {
require(msg.sender == ORACLE, "AstriaOracle: only oracle can update");
_;
}

struct PriceData {
uint128 price;
uint256 timestamp;
}

function setDecimals(bytes32 _currencyPair, uint8 _decimals) public {
function setDecimals(bytes32 _currencyPair, uint8 _decimals) external onlyOracle {
decimals[_currencyPair] = _decimals;
}

function updatePriceData(bytes32[] memory _currencyPairs, uint128[] memory _prices) public {
function updatePriceData(bytes32[] memory _currencyPairs, uint128[] memory _prices) external onlyOracle {
require(_currencyPairs.length == _prices.length, "currency pair and price length mismatch");
latestBlockNumber = block.number;
for (uint256 i = 0; i < _currencyPairs.length; i++) {
Expand Down

0 comments on commit e9a404e

Please sign in to comment.