Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
Upgrade solidity version to 0.5.4 (#393)
Browse files Browse the repository at this point in the history
* Bump solidity version to 0.5.4

* Upgrade openzeppelin and canonical-weth and move declarations of variables of multi-return functions to work with new solc compiler

* Update compile script

* Add .env to gitignore

* Add explicit modifiers for calldata and memory for parameters

* Handle other compile errors like explicit conversions between uint and byte, contract to address, and cleaning up DappHub code

* Fix explicit data locations for IssuanceLibrary

* Add more call data location parameters

* Fix typo in comment

* Allow for unlimited contract size in development

* Use leapdao solidity coverage for 0.5 solidity support

* Fix specs using deep include

* Remove unused variables from parameters

* Refactor coreissuance to take up less bytecode and remove allowUnlimitedContractSize

* modify create to creatSet

* REorder checks

* Add back check
  • Loading branch information
justinkchen authored and felix2feng committed Feb 26, 2019
1 parent 2c01c4e commit f9c9a22
Show file tree
Hide file tree
Showing 117 changed files with 796 additions and 752 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
docker_layer_caching: true
- run:
name: Fetch solc version
command: docker pull ethereum/solc:0.4.25
command: docker pull ethereum/solc:0.5.4
- restore_cache:
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
- run:
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
docker_layer_caching: true
- run:
name: Fetch solc version
command: docker pull ethereum/solc:0.4.25
command: docker pull ethereum/solc:0.5.4
- restore_cache:
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
- run:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/types/generated/*
coverage.json
coverage/
.env

### Coverage artifacts (yarn coverage-setup) ###
test/*.js*
Expand All @@ -31,4 +32,4 @@ yarn-error.log*
blockchain/

# Ouputs
deployments/outputs.ts
deployments/outputs.ts
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Firstly, you need to install Docker. The easiest way is to follow the Instructio
You need to pull the docker image that you want to use by using the following command:

```
docker pull ethereum/solc:0.4.25
docker pull ethereum/solc:0.5.4
```

If you wish not to set up docker, you can turn off the `docker: true` flag in truffle.js
Expand Down
2 changes: 1 addition & 1 deletion contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.25;
pragma solidity 0.5.4;


contract Migrations {
Expand Down
2 changes: 1 addition & 1 deletion contracts/core/Core.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

pragma solidity 0.4.25;
pragma solidity 0.5.4;

import { CoreAccounting } from "./extensions/CoreAccounting.sol";
import { CoreFactory } from "./extensions/CoreFactory.sol";
Expand Down
8 changes: 4 additions & 4 deletions contracts/core/TransferProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

pragma solidity 0.4.25;
pragma solidity 0.5.4;

import { SafeMath } from "openzeppelin-solidity/contracts/math/SafeMath.sol";

Expand Down Expand Up @@ -92,8 +92,8 @@ contract TransferProxy is
* @param _to The address to transfer to
*/
function batchTransfer(
address[] _tokens,
uint256[] _quantities,
address[] calldata _tokens,
uint256[] calldata _quantities,
address _from,
address _to
)
Expand All @@ -102,7 +102,7 @@ contract TransferProxy is
{
// Storing token count to local variable to save on invocation
uint256 tokenCount = _tokens.length;

// Confirm and empty _tokens array is not passed
require(
tokenCount > 0,
Expand Down
28 changes: 14 additions & 14 deletions contracts/core/Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

pragma solidity 0.4.25;
pragma solidity 0.5.4;


import { SafeMath } from "openzeppelin-solidity/contracts/math/SafeMath.sol";
Expand Down Expand Up @@ -74,7 +74,7 @@ contract Vault is
// Retrieve current balance of token for the vault
uint256 existingVaultBalance = ERC20Wrapper.balanceOf(
_token,
this
address(this)
);

// Call specified ERC20 token contract to transfer tokens from Vault to user
Expand All @@ -87,7 +87,7 @@ contract Vault is
// Verify transfer quantity is reflected in balance
uint256 newVaultBalance = ERC20Wrapper.balanceOf(
_token,
this
address(this)
);
// Check to make sure current balances are as expected
require(
Expand Down Expand Up @@ -139,7 +139,7 @@ contract Vault is
);

// Decrement balances state variable subtracting _quantity to user's token amount
balances[_token][_owner] = balances[_token][_owner].sub(_quantity);
balances[_token][_owner] = balances[_token][_owner].sub(_quantity);
}

/**
Expand Down Expand Up @@ -182,16 +182,16 @@ contract Vault is
* @param _quantities The numbers of tokens to attribute to owner
*/
function batchWithdrawTo(
address[] _tokens,
address[] calldata _tokens,
address _owner,
uint256[] _quantities
uint256[] calldata _quantities
)
external
onlyAuthorized
{
// Storing token count to local variable to save on invocation
uint256 tokenCount = _tokens.length;

// Confirm and empty _tokens array is not passed
require(
tokenCount > 0,
Expand Down Expand Up @@ -224,9 +224,9 @@ contract Vault is
* @param _quantities The numbers of tokens to attribute to owner
*/
function batchIncrementTokenOwner(
address[] _tokens,
address[] calldata _tokens,
address _owner,
uint256[] _quantities
uint256[] calldata _quantities
)
external
onlyAuthorized
Expand All @@ -252,7 +252,7 @@ contract Vault is
_tokens[i],
_owner,
_quantities[i]
);
);
}
}
}
Expand All @@ -266,9 +266,9 @@ contract Vault is
* @param _quantities The numbers of tokens to attribute to owner
*/
function batchDecrementTokenOwner(
address[] _tokens,
address[] calldata _tokens,
address _owner,
uint256[] _quantities
uint256[] calldata _quantities
)
external
onlyAuthorized
Expand Down Expand Up @@ -308,10 +308,10 @@ contract Vault is
* @param _quantities Amounts of tokens being transferred
*/
function batchTransferBalance(
address[] _tokens,
address[] calldata _tokens,
address _from,
address _to,
uint256[] _quantities
uint256[] calldata _quantities
)
external
onlyAuthorized
Expand Down
18 changes: 9 additions & 9 deletions contracts/core/exchange-wrappers/KyberNetworkWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

pragma solidity 0.4.25;
pragma solidity 0.5.4;
pragma experimental "ABIEncoderV2";

import { SafeMath } from "openzeppelin-solidity/contracts/math/SafeMath.sol";
Expand Down Expand Up @@ -119,11 +119,11 @@ contract KyberNetworkWrapper {
* @return ExchangeWrapperLibrary.ExchangeResults Struct containing component acquisition results
*/
function exchange(
ExchangeWrapperLibrary.ExchangeData _exchangeData,
bytes _tradesData
ExchangeWrapperLibrary.ExchangeData memory _exchangeData,
bytes memory _tradesData
)
public
returns (ExchangeWrapperLibrary.ExchangeResults)
returns (ExchangeWrapperLibrary.ExchangeResults memory)
{
require(
ICore(core).validModules(msg.sender),
Expand Down Expand Up @@ -175,7 +175,7 @@ contract KyberNetworkWrapper {
*/
function tradeOnKyberReserve(
address _sourceToken,
bytes _tradesData,
bytes memory _tradesData,
uint256 _offset
)
private
Expand All @@ -199,7 +199,7 @@ contract KyberNetworkWrapper {
address(this),
destinationQuantityToTradeFor,
trade.minimumConversionRate,
0
address(0)
);

// Ensure the destination token is allowed to be transferred by Set TransferProxy
Expand Down Expand Up @@ -231,7 +231,7 @@ contract KyberNetworkWrapper {
* @return KyberTrade KyberTrade struct
*/
function parseKyberTrade(
bytes _tradesData,
bytes memory _tradesData,
uint256 _offset
)
private
Expand Down Expand Up @@ -265,13 +265,13 @@ contract KyberNetworkWrapper {
private
{
// Transfer any unused or remainder maker token back to the issuance order user
uint256 remainderMakerToken = ERC20.balanceOf(_makerToken, this);
uint256 remainderMakerToken = ERC20.balanceOf(_makerToken, address(this));
if (remainderMakerToken > 0) {
ERC20.transfer(
_makerToken,
_maker,
remainderMakerToken
);
}
}
}
}
18 changes: 9 additions & 9 deletions contracts/core/exchange-wrappers/ZeroExExchangeWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

pragma solidity 0.4.25;
pragma solidity 0.5.4;
pragma experimental "ABIEncoderV2";

import { SafeMath } from "openzeppelin-solidity/contracts/math/SafeMath.sol";
Expand Down Expand Up @@ -93,11 +93,11 @@ contract ZeroExExchangeWrapper {
* @return ExchangeWrapperLibrary.ExchangeResults Struct containing component acquisition results
*/
function exchange(
ExchangeWrapperLibrary.ExchangeData _exchangeData,
bytes _ordersData
ExchangeWrapperLibrary.ExchangeData memory _exchangeData,
bytes memory _ordersData
)
public
returns (ExchangeWrapperLibrary.ExchangeResults)
returns (ExchangeWrapperLibrary.ExchangeResults memory)
{
require(
ICore(core).validModules(msg.sender),
Expand Down Expand Up @@ -164,8 +164,8 @@ contract ZeroExExchangeWrapper {
*/
function fillZeroExOrder(
address _issuanceOrderFiller,
OrderHandler.OrderHeader _header,
ZeroExOrder.Order _order )
OrderHandler.OrderHeader memory _header,
ZeroExOrder.Order memory _order )
private
returns (address, uint256)
{
Expand Down Expand Up @@ -237,13 +237,13 @@ contract ZeroExExchangeWrapper {
* @return uint256 Tracks how many bytes in _ordersData have been parsed
*/
function parseOrderInformation(
bytes _ordersData,
bytes memory _ordersData,
uint256 _offset,
address _takerToken
)
private
pure
returns (OrderHandler.ZeroExOrderInformation, uint256)
returns (OrderHandler.ZeroExOrderInformation memory, uint256)
{
// Parse header of current wrapper order
OrderHandler.OrderHeader memory header = OrderHandler.parseOrderHeader(
Expand Down Expand Up @@ -273,6 +273,6 @@ contract ZeroExExchangeWrapper {
order: order
});

return (orderInformation, orderBodyStart);
return (orderInformation, orderBodyStart);
}
}
10 changes: 5 additions & 5 deletions contracts/core/exchange-wrappers/lib/ZeroExOrderDataHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

pragma solidity 0.4.25;
pragma solidity 0.5.4;
pragma experimental "ABIEncoderV2";

import { SafeMath } from "openzeppelin-solidity/contracts/math/SafeMath.sol";
Expand Down Expand Up @@ -71,12 +71,12 @@ library ZeroExOrderDataHandler {
* @return OrderHeader Struct containing wrapper order header data
*/
function parseOrderHeader(
bytes _ordersData,
bytes memory _ordersData,
uint256 _offset
)
internal
pure
returns (OrderHeader)
returns (OrderHeader memory)
{
OrderHeader memory header;

Expand Down Expand Up @@ -114,7 +114,7 @@ library ZeroExOrderDataHandler {
* @return LibOrder.Order 0x order struct
*/
function parseZeroExOrder(
bytes _ordersData,
bytes memory _ordersData,
address _makerTokenAddress,
address _takerTokenAddress,
uint256 _offset
Expand Down Expand Up @@ -157,7 +157,7 @@ library ZeroExOrderDataHandler {
)
private
pure
returns (bytes)
returns (bytes memory)
{
bytes memory result = new bytes(36);

Expand Down
Loading

0 comments on commit f9c9a22

Please sign in to comment.