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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 10 additions & 10 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 18 additions & 18 deletions
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,

0 commit comments

Comments
 (0)