Skip to content

Commit

Permalink
Merge branch 'development-1.5.0' into CLI-minor-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloruiz55 authored Oct 2, 2018
2 parents 96399a7 + 8667113 commit d391ea1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
12 changes: 6 additions & 6 deletions contracts/oracles/MakerDAOOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ contract MakerDAOOracle is IOracle, Ownable {
bool public manualOverride;
uint256 public manualPrice;

event LogChangeMedianizer(address _newMedianizer, address _oldMedianizer, uint256 _now);
event LogSetManualPrice(uint256 _oldPrice, uint256 _newPrice, uint256 _time);
event LogSetManualOverride(bool _override, uint256 _time);
event ChangeMedianizer(address _newMedianizer, address _oldMedianizer, uint256 _now);
event SetManualPrice(uint256 _oldPrice, uint256 _newPrice, uint256 _time);
event SetManualOverride(bool _override, uint256 _time);

/**
* @notice Creates a new Maker based oracle
Expand All @@ -35,7 +35,7 @@ contract MakerDAOOracle is IOracle, Ownable {
*/
function changeMedianier(address _medianizer) public onlyOwner {
require(_medianizer != address(0), "0x not allowed");
emit LogChangeMedianizer(_medianizer, medianizer, now);
emit ChangeMedianizer(_medianizer, medianizer, now);
medianizer = _medianizer;
}

Expand Down Expand Up @@ -78,7 +78,7 @@ contract MakerDAOOracle is IOracle, Ownable {
* @param _price Price to set
*/
function setManualPrice(uint256 _price) public onlyOwner {
emit LogSetManualPrice(manualPrice, _price, now);
emit SetManualPrice(manualPrice, _price, now);
manualPrice = _price;
}

Expand All @@ -88,7 +88,7 @@ contract MakerDAOOracle is IOracle, Ownable {
*/
function setManualOverride(bool _override) public onlyOwner {
manualOverride = _override;
emit LogSetManualOverride(_override, now);
emit SetManualOverride(_override, now);
}

}
22 changes: 11 additions & 11 deletions contracts/oracles/PolyOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ contract PolyOracle is usingOraclize, IOracle, Ownable {

bool public freezeOracle;

event LogPriceUpdated(uint256 _price, uint256 _oldPrice, bytes32 _queryId, uint256 _time);
event LogNewOraclizeQuery(uint256 _time, bytes32 _queryId, string _query);
event LogAdminSet(address _admin, bool _valid, uint256 _time);
event LogStalePriceUpdate(bytes32 _queryId, uint256 _time, string _result);
event PriceUpdated(uint256 _price, uint256 _oldPrice, bytes32 _queryId, uint256 _time);
event NewOraclizeQuery(uint256 _time, bytes32 _queryId, string _query);
event AdminSet(address _admin, bool _valid, uint256 _time);
event StalePriceUpdate(bytes32 _queryId, uint256 _time, string _result);

modifier isAdminOrOwner {
require(admin[msg.sender] || msg.sender == owner, "Address is not admin or owner");
Expand All @@ -55,7 +55,7 @@ contract PolyOracle is usingOraclize, IOracle, Ownable {
require(!ignoreRequestIds[_requestId], "Ignoring requestId");
if (requestIds[_requestId] < latestUpdate) {
// Result is stale, probably because it was received out of order
emit LogStalePriceUpdate(_requestId, requestIds[_requestId], _result);
emit StalePriceUpdate(_requestId, requestIds[_requestId], _result);
return;
}
require(requestIds[_requestId] >= latestUpdate, "Result is stale");
Expand All @@ -67,7 +67,7 @@ contract PolyOracle is usingOraclize, IOracle, Ownable {
require(newPOLYUSD >= POLYUSD.sub(bound), "Result is too small");
}
latestUpdate = requestIds[_requestId];
emit LogPriceUpdated(newPOLYUSD, POLYUSD, _requestId, latestUpdate);
emit PriceUpdated(newPOLYUSD, POLYUSD, _requestId, latestUpdate);
POLYUSD = newPOLYUSD;
}

Expand All @@ -83,7 +83,7 @@ contract PolyOracle is usingOraclize, IOracle, Ownable {
requestId = oraclize_query(oracleQueryType, oracleURL, gasLimit);
requestIds[requestId] = now;
maximumScheduledUpdated = now;
emit LogNewOraclizeQuery(now, requestId, oracleURL);
emit NewOraclizeQuery(now, requestId, oracleURL);
} else {
require(oraclize_getPrice(oracleQueryType, gasLimit) * _times.length <= address(this).balance, "Insufficient Funds");
for (uint256 i = 0; i < _times.length; i++) {
Expand All @@ -93,7 +93,7 @@ contract PolyOracle is usingOraclize, IOracle, Ownable {
if (maximumScheduledUpdated < requestIds[requestId]) {
maximumScheduledUpdated = requestIds[requestId];
}
emit LogNewOraclizeQuery(_times[i], requestId, oracleURL);
emit NewOraclizeQuery(_times[i], requestId, oracleURL);
}
}
if (latestScheduledUpdate < maximumScheduledUpdated) {
Expand All @@ -117,7 +117,7 @@ contract PolyOracle is usingOraclize, IOracle, Ownable {
uint256 scheduledTime = _startTime + (i * _interval);
requestId = oraclize_query(scheduledTime, oracleQueryType, oracleURL, gasLimit);
requestIds[requestId] = scheduledTime;
emit LogNewOraclizeQuery(scheduledTime, requestId, oracleURL);
emit NewOraclizeQuery(scheduledTime, requestId, oracleURL);
}
if (latestScheduledUpdate < requestIds[requestId]) {
latestScheduledUpdate = requestIds[requestId];
Expand All @@ -129,7 +129,7 @@ contract PolyOracle is usingOraclize, IOracle, Ownable {
* @param _price POLYUSD price
*/
function setPOLYUSD(uint256 _price) onlyOwner public {
emit LogPriceUpdated(_price, POLYUSD, 0, now);
emit PriceUpdated(_price, POLYUSD, 0, now);
POLYUSD = _price;
latestUpdate = now;
}
Expand Down Expand Up @@ -220,7 +220,7 @@ contract PolyOracle is usingOraclize, IOracle, Ownable {
*/
function setAdmin(address _admin, bool _valid) onlyOwner public {
admin[_admin] = _valid;
emit LogAdminSet(_admin, _valid, now);
emit AdminSet(_admin, _valid, now);
}

/**
Expand Down
20 changes: 10 additions & 10 deletions test/a_poly_oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ let requestIds = new Array();
let tx = await I_PolyOracle.schedulePriceUpdatesFixed([],{from: owner, value:web3.utils.toWei("1")});
assert.isAtMost(tx.logs[0].args._time.toNumber(), latestTime());
// await increaseTime(50);
const logNewPriceWatcher = await promisifyLogWatch(I_PolyOracle.LogPriceUpdated({ fromBlock: blockNo }), 1);
const logNewPriceWatcher = await promisifyLogWatch(I_PolyOracle.PriceUpdated({ fromBlock: blockNo }), 1);
// const log = await logNewPriceWatcher;
assert.equal(logNewPriceWatcher.event, 'LogPriceUpdated', 'LogPriceUpdated not emitted.')
assert.equal(logNewPriceWatcher.event, 'PriceUpdated', 'PriceUpdated not emitted.')
assert.isNotNull(logNewPriceWatcher.args._price, 'Price returned was null.')
assert.equal(logNewPriceWatcher.args._oldPrice.toNumber(), 0);
console.log('Success! Current price is: ' + logNewPriceWatcher.args._price.dividedBy(new BigNumber(10).pow(18)).toNumber() + ' USD/POLY')
Expand All @@ -107,9 +107,9 @@ let requestIds = new Array();
}

// Wait for the callback to be invoked by oraclize and the event to be emitted
const logNewPriceWatcher = promisifyLogWatch(I_PolyOracle.LogPriceUpdated({ fromBlock: blockNo }), 2);
const logNewPriceWatcher = promisifyLogWatch(I_PolyOracle.PriceUpdated({ fromBlock: blockNo }), 2);
const log = await logNewPriceWatcher;
assert.equal(log.event, 'LogPriceUpdated', 'LogPriceUpdated not emitted.')
assert.equal(log.event, 'PriceUpdated', 'PriceUpdated not emitted.')
assert.isNotNull(log.args._price, 'Price returned was null.');
console.log('Success! Current price is: ' + log.args._price.dividedBy(new BigNumber(10).pow(18)).toNumber() + ' USD/POLY')
});
Expand Down Expand Up @@ -137,9 +137,9 @@ let requestIds = new Array();
assert.isAtMost(time.toNumber(), latestTime() + ((i + 1) * 30));
}
// Wait for the callback to be invoked by oraclize and the event to be emitted
const logNewPriceWatcher = promisifyLogWatch(I_PolyOracle.LogPriceUpdated({ fromBlock: blockNo }), 2);
const logNewPriceWatcher = promisifyLogWatch(I_PolyOracle.PriceUpdated({ fromBlock: blockNo }), 2);
const log = await logNewPriceWatcher;
assert.equal(log.event, 'LogPriceUpdated', 'LogPriceUpdated not emitted.')
assert.equal(log.event, 'PriceUpdated', 'PriceUpdated not emitted.')
assert.isNotNull(log.args._price, 'Price returned was null.')
console.log('Success! Current price is: ' + log.args._price.dividedBy(new BigNumber(10).pow(18)).toNumber() + ' USD/POLY');
latestPrice = log.args._price;
Expand Down Expand Up @@ -229,9 +229,9 @@ let requestIds = new Array();
assert.isAtMost(time.toNumber(), timeScheduling[i]);
}

const logNewPriceWatcher = await promisifyLogWatch(I_PolyOracle.LogPriceUpdated({ fromBlock: blockNo }), 2);
const logNewPriceWatcher = await promisifyLogWatch(I_PolyOracle.PriceUpdated({ fromBlock: blockNo }), 2);

assert.equal(logNewPriceWatcher.event, 'LogPriceUpdated', 'LogPriceUpdated not emitted.')
assert.equal(logNewPriceWatcher.event, 'PriceUpdated', 'PriceUpdated not emitted.')
assert.isNotNull(logNewPriceWatcher.args._price, 'Price returned was null.')
console.log('Success! Current price is: ' + logNewPriceWatcher.args._price.dividedBy(new BigNumber(10).pow(18)).toNumber() + ' USD/POLY');
// assert.isTrue(false);
Expand Down Expand Up @@ -319,8 +319,8 @@ let requestIds = new Array();
let blockNo = latestBlock();
let tx = await I_PolyOracle.schedulePriceUpdatesFixed([],{from: owner, value:web3.utils.toWei("1")});
assert.isAtMost(tx.logs[0].args._time.toNumber(), latestTime());
const logNewPriceWatcher = await promisifyLogWatch(I_PolyOracle.LogPriceUpdated({ fromBlock: blockNo }), 1);
assert.equal(logNewPriceWatcher.event, 'LogPriceUpdated', 'LogPriceUpdated not emitted.')
const logNewPriceWatcher = await promisifyLogWatch(I_PolyOracle.PriceUpdated({ fromBlock: blockNo }), 1);
assert.equal(logNewPriceWatcher.event, 'PriceUpdated', 'PriceUpdated not emitted.')
assert.isNotNull(logNewPriceWatcher.args._price, 'Price returned was null.')
console.log('Success! Current price is: ' + logNewPriceWatcher.args._price.dividedBy(new BigNumber(10).pow(18)).toNumber() + ' USD/POLY');
// assert.isTrue(false);
Expand Down

0 comments on commit d391ea1

Please sign in to comment.