Skip to content

Commit

Permalink
Merge pull request #4 from gnosis/sol-0.5
Browse files Browse the repository at this point in the history
Solidity 0.5 support
  • Loading branch information
V1rtuousCycle committed Dec 11, 2018
2 parents 2cd63ee + 3baf89b commit 83796fa
Show file tree
Hide file tree
Showing 10 changed files with 510 additions and 5,999 deletions.
14 changes: 0 additions & 14 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,3 @@ else
echo "✘ ESLint failed!" 1>&2
exit ${eslint_exit}
fi

# Solhint staged changes only
git diff --diff-filter=d --cached --name-only -z -- '*.sol' \
| xargs -0 -I % sh -c 'git show ":%" | ./node_modules/.bin/solhint stdin;'

# Solhint currently doesn't report a useful exit code
# solhint_exit=$?

# if [ ${solhint_exit} -eq 0 ]; then
# echo "✓ Solhint passed"
# else
# echo "✘ Solhint failed!" 1>&2
# exit ${solhint_exit}
# fi
6 changes: 1 addition & 5 deletions contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
pragma solidity ^0.4.24;

// HACK: should be removed along with the hack-ey migration
// when https://github.com/trufflesuite/truffle/pull/1085 hits
import "canonical-weth/contracts/WETH9.sol";
pragma solidity ^0.5.1;


contract Migrations {
Expand Down
4 changes: 2 additions & 2 deletions contracts/OracleConsumer.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.1;


interface OracleConsumer {
function receiveResult(bytes32 id, bytes result) external;
function receiveResult(bytes32 id, bytes calldata result) external;
}
12 changes: 6 additions & 6 deletions contracts/PredictionMarketSystem.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.1;
import { IERC20 } from "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
import { ERC1155 } from "erc-1155/contracts/ERC1155.sol";
import "./OracleConsumer.sol";
Expand Down Expand Up @@ -40,7 +40,7 @@ contract PredictionMarketSystem is OracleConsumer, ERC1155 {
/// @dev Called by the oracle for reporting results of conditions. Will set the payout vector for the condition with the ID ``keccak256(abi.encodePacked(oracle, questionId, outcomeSlotCount))``, where oracle is the message sender, questionId is one of the parameters of this function, and outcomeSlotCount is derived from result, which is the result of serializing 32-byte EVM words representing payoutNumerators for each outcome slot of the condition.
/// @param questionId The question ID the oracle is answering for
/// @param result The oracle's answer
function receiveResult(bytes32 questionId, bytes result) external {
function receiveResult(bytes32 questionId, bytes calldata result) external {
require(result.length > 0, "results empty");
require(result.length % 32 == 0, "results not 32-byte aligned");
uint outcomeSlotCount = result.length / 32;
Expand Down Expand Up @@ -69,7 +69,7 @@ contract PredictionMarketSystem is OracleConsumer, ERC1155 {
/// @param conditionId The ID of the condition to split on.
/// @param partition An array of disjoint index sets representing a nontrivial partition of the outcome slots of the given condition.
/// @param amount The amount of collateral or stake to split.
function splitPosition(IERC20 collateralToken, bytes32 parentCollectionId, bytes32 conditionId, uint[] partition, uint amount) external {
function splitPosition(IERC20 collateralToken, bytes32 parentCollectionId, bytes32 conditionId, uint[] calldata partition, uint amount) external {
uint outcomeSlotCount = payoutNumerators[conditionId].length;
require(outcomeSlotCount > 0, "condition not prepared yet");

Expand All @@ -88,7 +88,7 @@ contract PredictionMarketSystem is OracleConsumer, ERC1155 {

if (freeIndexSet == 0) {
if (parentCollectionId == bytes32(0)) {
require(collateralToken.transferFrom(msg.sender, this, amount), "could not receive collateral tokens");
require(collateralToken.transferFrom(msg.sender, address(this), amount), "could not receive collateral tokens");
} else {
key = keccak256(abi.encodePacked(collateralToken, parentCollectionId));
balances[uint(key)][msg.sender] = balances[uint(key)][msg.sender].sub(amount);
Expand All @@ -101,7 +101,7 @@ contract PredictionMarketSystem is OracleConsumer, ERC1155 {
emit PositionSplit(msg.sender, collateralToken, parentCollectionId, conditionId, partition, amount);
}

function mergePositions(IERC20 collateralToken, bytes32 parentCollectionId, bytes32 conditionId, uint[] partition, uint amount) external {
function mergePositions(IERC20 collateralToken, bytes32 parentCollectionId, bytes32 conditionId, uint[] calldata partition, uint amount) external {
uint outcomeSlotCount = payoutNumerators[conditionId].length;
require(outcomeSlotCount > 0, "condition not prepared yet");

Expand Down Expand Up @@ -133,7 +133,7 @@ contract PredictionMarketSystem is OracleConsumer, ERC1155 {
emit PositionsMerge(msg.sender, collateralToken, parentCollectionId, conditionId, partition, amount);
}

function redeemPositions(IERC20 collateralToken, bytes32 parentCollectionId, bytes32 conditionId, uint[] indexSets) external {
function redeemPositions(IERC20 collateralToken, bytes32 parentCollectionId, bytes32 conditionId, uint[] calldata indexSets) external {
require(payoutDenominator[conditionId] > 0, "result for condition not received yet");
uint outcomeSlotCount = payoutNumerators[conditionId].length;
require(outcomeSlotCount > 0, "condition not prepared yet");
Expand Down
3 changes: 0 additions & 3 deletions migrations/03_deploy_ether_token.js

This file was deleted.

0 comments on commit 83796fa

Please sign in to comment.