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

Commit f9c9a22

Browse files
justinkchenfelix2feng
authored andcommitted
Upgrade solidity version to 0.5.4 (#393)
* 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
1 parent 2c01c4e commit f9c9a22

File tree

117 files changed

+796
-752
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+796
-752
lines changed

.circleci/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
docker_layer_caching: true
3131
- run:
3232
name: Fetch solc version
33-
command: docker pull ethereum/solc:0.4.25
33+
command: docker pull ethereum/solc:0.5.4
3434
- restore_cache:
3535
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
3636
- run:
@@ -60,7 +60,7 @@ jobs:
6060
docker_layer_caching: true
6161
- run:
6262
name: Fetch solc version
63-
command: docker pull ethereum/solc:0.4.25
63+
command: docker pull ethereum/solc:0.5.4
6464
- restore_cache:
6565
key: compiled-env-{{ .Environment.CIRCLE_SHA1 }}
6666
- run:

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/types/generated/*
99
coverage.json
1010
coverage/
11+
.env
1112

1213
### Coverage artifacts (yarn coverage-setup) ###
1314
test/*.js*
@@ -31,4 +32,4 @@ yarn-error.log*
3132
blockchain/
3233

3334
# Ouputs
34-
deployments/outputs.ts
35+
deployments/outputs.ts

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Firstly, you need to install Docker. The easiest way is to follow the Instructio
3838
You need to pull the docker image that you want to use by using the following command:
3939

4040
```
41-
docker pull ethereum/solc:0.4.25
41+
docker pull ethereum/solc:0.5.4
4242
```
4343

4444
If you wish not to set up docker, you can turn off the `docker: true` flag in truffle.js

contracts/Migrations.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity 0.4.25;
1+
pragma solidity 0.5.4;
22

33

44
contract Migrations {

contracts/core/Core.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
pragma solidity 0.4.25;
17+
pragma solidity 0.5.4;
1818

1919
import { CoreAccounting } from "./extensions/CoreAccounting.sol";
2020
import { CoreFactory } from "./extensions/CoreFactory.sol";

contracts/core/TransferProxy.sol

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
pragma solidity 0.4.25;
17+
pragma solidity 0.5.4;
1818

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

@@ -92,8 +92,8 @@ contract TransferProxy is
9292
* @param _to The address to transfer to
9393
*/
9494
function batchTransfer(
95-
address[] _tokens,
96-
uint256[] _quantities,
95+
address[] calldata _tokens,
96+
uint256[] calldata _quantities,
9797
address _from,
9898
address _to
9999
)
@@ -102,7 +102,7 @@ contract TransferProxy is
102102
{
103103
// Storing token count to local variable to save on invocation
104104
uint256 tokenCount = _tokens.length;
105-
105+
106106
// Confirm and empty _tokens array is not passed
107107
require(
108108
tokenCount > 0,

contracts/core/Vault.sol

+14-14
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
pragma solidity 0.4.25;
17+
pragma solidity 0.5.4;
1818

1919

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

8080
// Call specified ERC20 token contract to transfer tokens from Vault to user
@@ -87,7 +87,7 @@ contract Vault is
8787
// Verify transfer quantity is reflected in balance
8888
uint256 newVaultBalance = ERC20Wrapper.balanceOf(
8989
_token,
90-
this
90+
address(this)
9191
);
9292
// Check to make sure current balances are as expected
9393
require(
@@ -139,7 +139,7 @@ contract Vault is
139139
);
140140

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

145145
/**
@@ -182,16 +182,16 @@ contract Vault is
182182
* @param _quantities The numbers of tokens to attribute to owner
183183
*/
184184
function batchWithdrawTo(
185-
address[] _tokens,
185+
address[] calldata _tokens,
186186
address _owner,
187-
uint256[] _quantities
187+
uint256[] calldata _quantities
188188
)
189189
external
190190
onlyAuthorized
191191
{
192192
// Storing token count to local variable to save on invocation
193193
uint256 tokenCount = _tokens.length;
194-
194+
195195
// Confirm and empty _tokens array is not passed
196196
require(
197197
tokenCount > 0,
@@ -224,9 +224,9 @@ contract Vault is
224224
* @param _quantities The numbers of tokens to attribute to owner
225225
*/
226226
function batchIncrementTokenOwner(
227-
address[] _tokens,
227+
address[] calldata _tokens,
228228
address _owner,
229-
uint256[] _quantities
229+
uint256[] calldata _quantities
230230
)
231231
external
232232
onlyAuthorized
@@ -252,7 +252,7 @@ contract Vault is
252252
_tokens[i],
253253
_owner,
254254
_quantities[i]
255-
);
255+
);
256256
}
257257
}
258258
}
@@ -266,9 +266,9 @@ contract Vault is
266266
* @param _quantities The numbers of tokens to attribute to owner
267267
*/
268268
function batchDecrementTokenOwner(
269-
address[] _tokens,
269+
address[] calldata _tokens,
270270
address _owner,
271-
uint256[] _quantities
271+
uint256[] calldata _quantities
272272
)
273273
external
274274
onlyAuthorized
@@ -308,10 +308,10 @@ contract Vault is
308308
* @param _quantities Amounts of tokens being transferred
309309
*/
310310
function batchTransferBalance(
311-
address[] _tokens,
311+
address[] calldata _tokens,
312312
address _from,
313313
address _to,
314-
uint256[] _quantities
314+
uint256[] calldata _quantities
315315
)
316316
external
317317
onlyAuthorized

contracts/core/exchange-wrappers/KyberNetworkWrapper.sol

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
pragma solidity 0.4.25;
17+
pragma solidity 0.5.4;
1818
pragma experimental "ABIEncoderV2";
1919

2020
import { SafeMath } from "openzeppelin-solidity/contracts/math/SafeMath.sol";
@@ -119,11 +119,11 @@ contract KyberNetworkWrapper {
119119
* @return ExchangeWrapperLibrary.ExchangeResults Struct containing component acquisition results
120120
*/
121121
function exchange(
122-
ExchangeWrapperLibrary.ExchangeData _exchangeData,
123-
bytes _tradesData
122+
ExchangeWrapperLibrary.ExchangeData memory _exchangeData,
123+
bytes memory _tradesData
124124
)
125125
public
126-
returns (ExchangeWrapperLibrary.ExchangeResults)
126+
returns (ExchangeWrapperLibrary.ExchangeResults memory)
127127
{
128128
require(
129129
ICore(core).validModules(msg.sender),
@@ -175,7 +175,7 @@ contract KyberNetworkWrapper {
175175
*/
176176
function tradeOnKyberReserve(
177177
address _sourceToken,
178-
bytes _tradesData,
178+
bytes memory _tradesData,
179179
uint256 _offset
180180
)
181181
private
@@ -199,7 +199,7 @@ contract KyberNetworkWrapper {
199199
address(this),
200200
destinationQuantityToTradeFor,
201201
trade.minimumConversionRate,
202-
0
202+
address(0)
203203
);
204204

205205
// Ensure the destination token is allowed to be transferred by Set TransferProxy
@@ -231,7 +231,7 @@ contract KyberNetworkWrapper {
231231
* @return KyberTrade KyberTrade struct
232232
*/
233233
function parseKyberTrade(
234-
bytes _tradesData,
234+
bytes memory _tradesData,
235235
uint256 _offset
236236
)
237237
private
@@ -265,13 +265,13 @@ contract KyberNetworkWrapper {
265265
private
266266
{
267267
// Transfer any unused or remainder maker token back to the issuance order user
268-
uint256 remainderMakerToken = ERC20.balanceOf(_makerToken, this);
268+
uint256 remainderMakerToken = ERC20.balanceOf(_makerToken, address(this));
269269
if (remainderMakerToken > 0) {
270270
ERC20.transfer(
271271
_makerToken,
272272
_maker,
273273
remainderMakerToken
274274
);
275-
}
275+
}
276276
}
277277
}

contracts/core/exchange-wrappers/ZeroExExchangeWrapper.sol

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
pragma solidity 0.4.25;
17+
pragma solidity 0.5.4;
1818
pragma experimental "ABIEncoderV2";
1919

2020
import { SafeMath } from "openzeppelin-solidity/contracts/math/SafeMath.sol";
@@ -93,11 +93,11 @@ contract ZeroExExchangeWrapper {
9393
* @return ExchangeWrapperLibrary.ExchangeResults Struct containing component acquisition results
9494
*/
9595
function exchange(
96-
ExchangeWrapperLibrary.ExchangeData _exchangeData,
97-
bytes _ordersData
96+
ExchangeWrapperLibrary.ExchangeData memory _exchangeData,
97+
bytes memory _ordersData
9898
)
9999
public
100-
returns (ExchangeWrapperLibrary.ExchangeResults)
100+
returns (ExchangeWrapperLibrary.ExchangeResults memory)
101101
{
102102
require(
103103
ICore(core).validModules(msg.sender),
@@ -164,8 +164,8 @@ contract ZeroExExchangeWrapper {
164164
*/
165165
function fillZeroExOrder(
166166
address _issuanceOrderFiller,
167-
OrderHandler.OrderHeader _header,
168-
ZeroExOrder.Order _order )
167+
OrderHandler.OrderHeader memory _header,
168+
ZeroExOrder.Order memory _order )
169169
private
170170
returns (address, uint256)
171171
{
@@ -237,13 +237,13 @@ contract ZeroExExchangeWrapper {
237237
* @return uint256 Tracks how many bytes in _ordersData have been parsed
238238
*/
239239
function parseOrderInformation(
240-
bytes _ordersData,
240+
bytes memory _ordersData,
241241
uint256 _offset,
242242
address _takerToken
243243
)
244244
private
245245
pure
246-
returns (OrderHandler.ZeroExOrderInformation, uint256)
246+
returns (OrderHandler.ZeroExOrderInformation memory, uint256)
247247
{
248248
// Parse header of current wrapper order
249249
OrderHandler.OrderHeader memory header = OrderHandler.parseOrderHeader(
@@ -273,6 +273,6 @@ contract ZeroExExchangeWrapper {
273273
order: order
274274
});
275275

276-
return (orderInformation, orderBodyStart);
276+
return (orderInformation, orderBodyStart);
277277
}
278278
}

contracts/core/exchange-wrappers/lib/ZeroExOrderDataHandler.sol

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
pragma solidity 0.4.25;
17+
pragma solidity 0.5.4;
1818
pragma experimental "ABIEncoderV2";
1919

2020
import { SafeMath } from "openzeppelin-solidity/contracts/math/SafeMath.sol";
@@ -71,12 +71,12 @@ library ZeroExOrderDataHandler {
7171
* @return OrderHeader Struct containing wrapper order header data
7272
*/
7373
function parseOrderHeader(
74-
bytes _ordersData,
74+
bytes memory _ordersData,
7575
uint256 _offset
7676
)
7777
internal
7878
pure
79-
returns (OrderHeader)
79+
returns (OrderHeader memory)
8080
{
8181
OrderHeader memory header;
8282

@@ -114,7 +114,7 @@ library ZeroExOrderDataHandler {
114114
* @return LibOrder.Order 0x order struct
115115
*/
116116
function parseZeroExOrder(
117-
bytes _ordersData,
117+
bytes memory _ordersData,
118118
address _makerTokenAddress,
119119
address _takerTokenAddress,
120120
uint256 _offset
@@ -157,7 +157,7 @@ library ZeroExOrderDataHandler {
157157
)
158158
private
159159
pure
160-
returns (bytes)
160+
returns (bytes memory)
161161
{
162162
bytes memory result = new bytes(36);
163163

0 commit comments

Comments
 (0)