Skip to content

Commit 0275f03

Browse files
authored
Upgrade solc to 0.5.x (#70)
1 parent 905abc7 commit 0275f03

17 files changed

+75
-75
lines changed

.circleci/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
key: protocol-{{ .Environment.CIRCLE_SHA1 }}
3131
- run:
3232
name: Compile contracts
33-
command: $(npm bin)/truffle compile
33+
command: npm install && $(npm bin)/truffle compile
3434
- save_cache:
3535
key: protocol-completed-build-{{ .Environment.CIRCLE_SHA1 }}
3636
paths:
@@ -75,7 +75,7 @@ jobs:
7575
- checkout
7676
- run:
7777
name: Install Dependencies
78-
command: apk add make git python g++ && npm install --quiet
78+
command: apk add make git python g++ curl && npm install --quiet
7979
- run:
8080
name: Run coverage
8181
command: npm run coverage

contracts/ContractCreator.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity >=0.4.24;
1+
pragma solidity ^0.5.0;
22

33
import "./Registry.sol";
44

contracts/Derivative.sol

+10-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
TODO: Implement tax function
77
*/
8-
pragma solidity >=0.4.24;
8+
pragma solidity ^0.5.0;
99

1010
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
1111
import "./OracleInterface.sol";
@@ -52,7 +52,7 @@ contract Derivative {
5252
}
5353

5454
struct ContractParty {
55-
address accountAddress;
55+
address payable accountAddress;
5656
int256 balance;
5757
bool hasConfirmedPrice;
5858
}
@@ -76,13 +76,13 @@ contract Derivative {
7676
int256 public npv; // Net present value is measured in Wei
7777

7878
constructor(
79-
address _makerAddress,
80-
address _takerAddress,
79+
address payable _makerAddress,
80+
address payable _takerAddress,
8181
address _oracleAddress,
8282
int256 _defaultPenalty,
8383
int256 _requiredMargin,
8484
uint expiry,
85-
string _product,
85+
string memory _product,
8686
uint _notional
8787
) public payable {
8888
// Address information
@@ -361,13 +361,13 @@ contract Derivative {
361361
contract SimpleDerivative is Derivative {
362362

363363
constructor(
364-
address _ownerAddress,
365-
address _counterpartyAddress,
364+
address payable _ownerAddress,
365+
address payable _counterpartyAddress,
366366
address _oracleAddress,
367367
int256 _defaultPenalty,
368368
int256 _requiredMargin,
369369
uint expiry,
370-
string product,
370+
string memory product,
371371
uint notional
372372
) public payable Derivative(
373373
_ownerAddress,
@@ -397,11 +397,11 @@ contract DerivativeCreator is ContractCreator {
397397
ContractCreator(registryAddress, _oracleAddress) {} // solhint-disable-line no-empty-blocks
398398

399399
function createDerivative(
400-
address counterparty,
400+
address payable counterparty,
401401
int256 defaultPenalty,
402402
int256 requiredMargin,
403403
uint expiry,
404-
string product,
404+
string calldata product,
405405
uint notional
406406
)
407407
external

contracts/Migrations.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity >=0.4.24;
1+
pragma solidity ^0.5.0;
22

33

44
contract Migrations {

contracts/OracleInterface.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
OracleInterface contract.
33
The interface that contracts use to query verified and unverified price feeds.
44
*/
5-
pragma solidity >=0.4.24;
5+
pragma solidity ^0.5.0;
66

77

88
// This interface allows contracts to query verified and unverified prices from the VoteToken.

contracts/OracleMock.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
Simple mock implementation of a Vote Token to be used by a derivative for querying price feeds.
55
*/
6-
pragma solidity >=0.4.24;
6+
pragma solidity ^0.5.0;
77

88
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
99
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";

contracts/PriceTime.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
PriceTime Library
33
*/
4-
pragma solidity >=0.4.24;
4+
pragma solidity ^0.5.0;
55

66
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
77

contracts/Registry.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity >=0.4.24;
1+
pragma solidity ^0.5.0;
22

33
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
44

contracts/Testable.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Base class that provides time overrides, but only if being run in test mode.
55
*/
66

7-
pragma solidity >=0.4.24;
7+
pragma solidity ^0.5.0;
88

99
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
1010

contracts/TokenizedDerivative.sol

+18-18
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
Implements a simplified version of tokenized Product/ETH Products.
55
*/
6-
pragma solidity >=0.4.24;
6+
pragma solidity ^0.5.0;
77

88
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
99
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
@@ -71,7 +71,7 @@ contract TokenizedDerivative is ERC20 {
7171
}
7272

7373
struct ContractParty {
74-
address accountAddress;
74+
address payable accountAddress;
7575
int256 balance;
7676
bool hasConfirmedPrice;
7777
uint marginRequirement; // Percentage of nav*10^18
@@ -118,7 +118,7 @@ contract TokenizedDerivative is ERC20 {
118118
uint deposit;
119119
}
120120

121-
Dispute public dispute;
121+
Dispute public disputeInfo;
122122

123123
// The information in the following struct is only valid if in the midst of a Default or Termination.
124124
struct Termination {
@@ -148,13 +148,13 @@ contract TokenizedDerivative is ERC20 {
148148
}
149149

150150
constructor(
151-
address _providerAddress,
152-
address _investorAddress,
151+
address payable _providerAddress,
152+
address payable _investorAddress,
153153
address _oracleAddress,
154154
uint _defaultPenalty, // Percentage of nav*10^18
155155
uint _terminationFee, // Percentage of nav*10^18
156156
uint _providerRequiredMargin, // Percentage of nav*10^18
157-
string _product,
157+
string memory _product,
158158
uint _fixedYearlyFee, // Percentage of nav * 10^18
159159
uint _disputeDeposit, // Percentage of nav * 10^18
160160
address _returnCalculator,
@@ -249,8 +249,8 @@ contract TokenizedDerivative is ERC20 {
249249

250250
uint initialSupply = totalSupply();
251251

252-
require(this.transferFrom(msg.sender, this, numTokens));
253-
_burn(this, numTokens);
252+
require(this.transferFrom(msg.sender, address(this), numTokens));
253+
_burn(address(this), numTokens);
254254

255255

256256
int256 investorBalance = investor.balance;
@@ -312,9 +312,9 @@ contract TokenizedDerivative is ERC20 {
312312

313313
state = State.Disputed;
314314
endTime = lastRemarginTime;
315-
dispute.disputedNav = nav;
316-
dispute.disputer = msg.sender;
317-
dispute.deposit = requiredDeposit;
315+
disputeInfo.disputedNav = nav;
316+
disputeInfo.disputer = msg.sender;
317+
disputeInfo.deposit = requiredDeposit;
318318

319319
msg.sender.transfer(refund);
320320
}
@@ -343,9 +343,9 @@ contract TokenizedDerivative is ERC20 {
343343
require(startingState == State.Disputed || startingState == State.Expired || startingState == State.Defaulted);
344344
_settleVerifiedPrice();
345345
if (startingState == State.Disputed) {
346-
(ContractParty storage disputer, ContractParty storage notDisputer) = _whoAmI(dispute.disputer);
347-
int256 depositValue = int256(dispute.deposit);
348-
if (nav == dispute.disputedNav) {
346+
(ContractParty storage disputer, ContractParty storage notDisputer) = _whoAmI(disputeInfo.disputer);
347+
int256 depositValue = int256(disputeInfo.deposit);
348+
if (nav == disputeInfo.disputedNav) {
349349
disputer.balance += depositValue;
350350
} else {
351351
notDisputer.balance += depositValue;
@@ -539,7 +539,7 @@ contract TokenizedDerivative is ERC20 {
539539
if (state != State.Live) {
540540
didReduce = additionalAuthorizedNav != 0;
541541
additionalAuthorizedNav = 0;
542-
return;
542+
return didReduce;
543543
}
544544

545545
int256 totalAuthorizedNav = currentNav + int256(additionalAuthorizedNav);
@@ -630,12 +630,12 @@ contract TokenizedDerivativeCreator is ContractCreator {
630630
ContractCreator(registryAddress, _oracleAddress) {} // solhint-disable-line no-empty-blocks
631631

632632
function createTokenizedDerivative(
633-
address provider,
634-
address investor,
633+
address payable provider,
634+
address payable investor,
635635
uint defaultPenalty,
636636
uint terminationFee,
637637
uint providerRequiredMargin,
638-
string product,
638+
string calldata product,
639639
uint fixedYearlyFee,
640640
uint disputeDeposit,
641641
address returnCalculator,

contracts/Vote.sol

+17-13
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Allows users to vote yes/no on whether a price is accurate
99
1010
*/
11-
pragma solidity >=0.4.24;
11+
pragma solidity ^0.5.0;
1212

1313
pragma experimental ABIEncoderV2;
1414

@@ -72,7 +72,7 @@ library Poll {
7272
}
7373
}
7474

75-
function _addProposal(Data storage self, string ipfsHash) internal {
75+
function _addProposal(Data storage self, string memory ipfsHash) internal {
7676
uint idx = self.proposals.length++;
7777
self.proposals[idx].ipfsHash = ipfsHash;
7878
}
@@ -107,7 +107,7 @@ library VotePeriod {
107107
mapping(string => bool) ipfsHashSet;
108108
}
109109

110-
function _proposeFeed(Data storage self, string ipfsHash) internal {
110+
function _proposeFeed(Data storage self, string memory ipfsHash) internal {
111111
require(!self.ipfsHashSet[ipfsHash]);
112112
self.ipfsHashSet[ipfsHash] = true;
113113
self.runoffPoll._addProposal(ipfsHash);
@@ -210,7 +210,7 @@ contract VoteCoin is ERC20, VoteInterface, OracleInterface, Testable {
210210

211211
PeriodTiming[5] private periodTimings;
212212

213-
constructor(string _product, uint _priceInterval, bool isTest) public Testable(isTest) {
213+
constructor(string memory _product, uint _priceInterval, bool isTest) public Testable(isTest) {
214214
_mint(msg.sender, 10000);
215215
product = _product;
216216
priceInterval = _priceInterval;
@@ -269,20 +269,20 @@ contract VoteCoin is ERC20, VoteInterface, OracleInterface, Testable {
269269
_getCurrentVotePeriod()._revealVote(voteOption, salt, balanceOf(msg.sender), period);
270270
}
271271

272-
function proposeFeed(string ipfsHash) public {
272+
function proposeFeed(string memory ipfsHash) public {
273273
checkTimeAndUpdateState();
274274
require(period == VotePeriod.PeriodType.Commit || period == VotePeriod.PeriodType.Reveal);
275275

276276
_getCurrentVotePeriod()._proposeFeed(ipfsHash);
277277
}
278278

279-
function addUnverifiedPrice(PriceTime.Data priceTime) public {
279+
function addUnverifiedPrice(PriceTime.Data memory priceTime) public {
280280
PriceTime.Data[] memory priceTimes = new PriceTime.Data[](1);
281281
priceTimes[0] = priceTime;
282282
addUnverifiedPrices(priceTimes);
283283
}
284284

285-
function getProposals() public view returns (Proposal.Data[] proposals) {
285+
function getProposals() public view returns (Proposal.Data[] memory proposals) {
286286
uint time = getCurrentTime();
287287
uint computedStartTime = _getStartOfPeriod(time);
288288

@@ -307,23 +307,23 @@ contract VoteCoin is ERC20, VoteInterface, OracleInterface, Testable {
307307
}
308308
}
309309

310-
function getCurrentPeriodType() public view returns (string periodType) {
310+
function getCurrentPeriodType() public view returns (string memory periodType) {
311311
uint currentTime = getCurrentTime();
312312
return _getStringPeriodType(_getPeriodType(_getStartOfPeriod(currentTime), currentTime));
313313
}
314314

315-
function getProduct() public view returns (string _product) {
315+
function getProduct() public view returns (string memory _product) {
316316
return product;
317317
}
318318

319-
function getDefaultProposalPrices() public view returns (PriceTime.Data[] prices) {
319+
function getDefaultProposalPrices() public view returns (PriceTime.Data[] memory prices) {
320320
// TODO(mrice32): we may want to subtract some time offset to ensure all unverifiedPrices being voted on are
321321
// in before the voting period starts.
322322
// Note: this will fail if the entire voting period of prices previous do not exist.
323323
VotePeriod.Data storage votePeriod = _getCurrentVotePeriod();
324324
(uint startTime, uint endTime) = votePeriod._getPricePeriod(totalVotingDuration);
325325
if (unverifiedPrices.length == 0 || startTime < unverifiedPrices[0].time) {
326-
return;
326+
return prices;
327327
}
328328
uint startIndex = unverifiedPrices._getIndex(startTime, priceInterval);
329329

@@ -469,7 +469,11 @@ contract VoteCoin is ERC20, VoteInterface, OracleInterface, Testable {
469469
return timestamp.sub(epochOffset).div(totalVotingDuration).mul(totalVotingDuration).add(epochOffset);
470470
}
471471

472-
function _getStringPeriodType(VotePeriod.PeriodType periodType) private pure returns (string stringPeriodType) {
472+
function _getStringPeriodType(VotePeriod.PeriodType periodType)
473+
private
474+
pure
475+
returns (string memory stringPeriodType)
476+
{
473477
if (periodType == VotePeriod.PeriodType.Commit) {
474478
return "commit";
475479
} else if (periodType == VotePeriod.PeriodType.Reveal) {
@@ -488,7 +492,7 @@ contract VoteCoin is ERC20, VoteInterface, OracleInterface, Testable {
488492
function _initPeriodTiming(uint startOffset, uint duration, VotePeriod.PeriodType periodType)
489493
private
490494
view
491-
returns (PeriodTiming periodTiming, uint nextStartOffset)
495+
returns (PeriodTiming memory periodTiming, uint nextStartOffset)
492496
{
493497
periodTiming.startOffset = startOffset;
494498
periodTiming.endOffset = startOffset.add(duration);

contracts/VoteInterface.sol

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ contract VoteInterface {
3939
function getCurrentCommitRevealPeriods() public view returns (Period[] memory periods);
4040

4141
// Returns the current period type ("commit", "reveal", or "none").
42-
function getCurrentPeriodType() public view returns (string periodType);
42+
function getCurrentPeriodType() public view returns (string memory periodType);
4343

4444
// Gets the product that the price votes apply to.
45-
function getProduct() public view returns (string product);
45+
function getProduct() public view returns (string memory product);
4646

4747
// Gets the runoff/alternative proposals for the current period.
48-
function getProposals() public view returns (Proposal.Data[] proposals);
48+
function getProposals() public view returns (Proposal.Data[] memory proposals);
4949

5050
// Gets the default proposal (option 1 during the primary vote period) for the current period.
51-
function getDefaultProposalPrices() public view returns (PriceTime.Data[] defaultProposal);
51+
function getDefaultProposalPrices() public view returns (PriceTime.Data[] memory defaultProposal);
5252

5353
// Gets the default proposal (option 1 during the primary vote period) price for a particular time during the
5454
// current period.

0 commit comments

Comments
 (0)