Skip to content

Commit

Permalink
[Fix] Oracle update permissioning
Browse files Browse the repository at this point in the history
  • Loading branch information
arjun-io committed Aug 25, 2023
1 parent 0421a66 commit 35b188d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/perennial-oracle/contracts/Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ contract Oracle is IOracle, Instance {

/// @notice Updates the current oracle provider
/// @param newProvider The new oracle provider
function update(IOracleProvider newProvider) external onlyOwner {
function update(IOracleProvider newProvider) external {
if (msg.sender != address(factory())) revert OracleNotFactoryError();
_updateCurrent(newProvider);
_updateLatest(newProvider.latest());
}
Expand Down
1 change: 1 addition & 0 deletions packages/perennial-oracle/contracts/interfaces/IOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "@equilibria/root/attribute/interfaces/IInstance.sol";
import "@equilibria/perennial-v2/contracts/interfaces/IOracleProvider.sol";

interface IOracle is IOracleProvider, IInstance {
error OracleNotFactoryError();
error OracleOutOfSyncError();
error OracleOutOfOrderCommitError();

Expand Down
2 changes: 1 addition & 1 deletion packages/perennial-oracle/test/unit/oracle/Oracle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe('Oracle', () => {

context('updates the oracle w/o sync', async () => {
beforeEach(async () => {
await expect(oracle.connect(owner).update(underlying1.address))
await expect(oracle.connect(oracleFactorySigner).update(underlying1.address))
.to.emit(oracle, 'OracleUpdated')
.withArgs(underlying1.address)
})
Expand Down

0 comments on commit 35b188d

Please sign in to comment.