Skip to content

Commit e4dc5f3

Browse files
kostindadamdossa
authored andcommitted
Update open zeppelin and oraclize (#398)
* Updated oraclizeAPI to version 0.4.25 * Updated: imports, use owner() * Fixed compilation errors (transfer in ReclaimTokens commented) * IERC20 instead of IERC20Extended * fix for "truffle test" * reverted changes in PolyToken * fixed creation of SecurityToken in tests * fix tests * fixed SecurityToken._burn * Removed redundant checking. * fix merge * Removed redundant checking. * Coverage Fixed * Updated yarn.lock * Some function name changes to avoid namespace clashes with OZ
1 parent abe3ed4 commit e4dc5f3

File tree

58 files changed

+268
-243
lines changed

Some content is hidden

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

58 files changed

+268
-243
lines changed

contracts/ModuleRegistry.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
pragma solidity ^0.4.24;
22

3+
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
34
import "./interfaces/IModuleRegistry.sol";
45
import "./interfaces/IModuleFactory.sol";
56
import "./interfaces/ISecurityTokenRegistry.sol";
67
import "./interfaces/IPolymathRegistry.sol";
78
import "./interfaces/IFeatureRegistry.sol";
8-
import "./interfaces/IERC20.sol";
99
import "./libraries/VersionUtils.sol";
1010
import "./storage/EternalStorage.sol";
1111
import "./libraries/Encoder.sol";

contracts/ReclaimTokens.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pragma solidity ^0.4.24;
22

33
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
4-
import "./interfaces/IERC20.sol";
4+
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
55

66
/**
77
* @title Utility contract to allow owner to retreive any ERC20 sent to the contract
@@ -16,6 +16,6 @@ contract ReclaimTokens is Ownable {
1616
require(_tokenContract != address(0), "Invalid address");
1717
IERC20 token = IERC20(_tokenContract);
1818
uint256 balance = token.balanceOf(address(this));
19-
require(token.transfer(owner, balance), "Transfer failed");
19+
require(token.transfer(owner(), balance), "Transfer failed");
2020
}
2121
}

contracts/SecurityTokenRegistry.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
pragma solidity ^0.4.24;
22

33
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
4+
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
45
import "./interfaces/IOwnable.sol";
56
import "./interfaces/ISTFactory.sol";
6-
import "./interfaces/IERC20.sol";
77
import "./interfaces/ISecurityTokenRegistry.sol";
88
import "./storage/EternalStorage.sol";
99
import "./libraries/Util.sol";

contracts/external/oraclizeAPI.sol

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
// <ORACLIZE_API>
2+
// Release targetted at solc 0.4.25 to silence compiler warning/error messages, compatible down to 0.4.22
23
/*
34
Copyright (c) 2015-2016 Oraclize SRL
45
Copyright (c) 2016 Oraclize LTD
6+
7+
8+
59
Permission is hereby granted, free of charge, to any person obtaining a copy
610
of this software and associated documentation files (the "Software"), to deal
711
in the Software without restriction, including without limitation the rights
812
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
913
copies of the Software, and to permit persons to whom the Software is
1014
furnished to do so, subject to the following conditions:
15+
16+
17+
1118
The above copyright notice and this permission notice shall be included in
1219
all copies or substantial portions of the Software.
20+
21+
22+
1323
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1424
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1525
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -19,9 +29,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1929
THE SOFTWARE.
2030
*/
2131

22-
// This api is currently targeted at 0.4.18, please import oraclizeAPI_pre0.4.sol or oraclizeAPI_0.4 where necessary
32+
// This api is currently targeted at 0.4.22 to 0.4.25 (stable builds), please import oraclizeAPI_pre0.4.sol or oraclizeAPI_0.4 where necessary
2333
/* solium-disable */
24-
pragma solidity >=0.4.18;// Incompatible compiler version... please select one stated within pragma solidity or use different oraclizeAPI version
34+
pragma solidity >=0.4.22;// Incompatible compiler version... please select one stated within pragma solidity or use different oraclizeAPI version
2535

2636
contract OraclizeI {
2737
address public cbAddress;
@@ -44,17 +54,23 @@ contract OraclizeAddrResolverI {
4454

4555
/*
4656
Begin solidity-cborutils
57+
4758
https://github.com/smartcontractkit/solidity-cborutils
59+
4860
MIT License
61+
4962
Copyright (c) 2018 SmartContract ChainLink, Ltd.
63+
5064
Permission is hereby granted, free of charge, to any person obtaining a copy
5165
of this software and associated documentation files (the "Software"), to deal
5266
in the Software without restriction, including without limitation the rights
5367
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5468
copies of the Software, and to permit persons to whom the Software is
5569
furnished to do so, subject to the following conditions:
70+
5671
The above copyright notice and this permission notice shall be included in all
5772
copies or substantial portions of the Software.
73+
5874
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5975
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6076
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -346,7 +362,11 @@ contract usingOraclize {
346362
}
347363
function __callback(bytes32 myid, string result, bytes proof) public {
348364
return;
365+
// Following should never be reached with a preceding return, however
366+
// this is just a placeholder function, ideally meant to be defined in
367+
// child contract when proofs are used
349368
myid; result; proof; // Silence compiler warnings
369+
oraclize = OraclizeI(0); // Additional compiler silence about making function pure/view.
350370
}
351371

352372
function oraclize_getPrice(string datasource) oraclizeAPI internal returns (uint){
@@ -744,7 +764,7 @@ contract usingOraclize {
744764
return oraclize.randomDS_getSessionPubKeyHash();
745765
}
746766

747-
function getCodeSize(address _addr) constant internal returns(uint _size) {
767+
function getCodeSize(address _addr) view internal returns(uint _size) {
748768
assembly {
749769
_size := extcodesize(_addr)
750770
}
@@ -963,7 +983,7 @@ contract usingOraclize {
963983

964984
}
965985

966-
oraclize_randomDS_setCommitment(queryId, keccak256(delay_bytes8_left, args[1], sha256(args[0]), args[2]));
986+
oraclize_randomDS_setCommitment(queryId, keccak256(abi.encodePacked(delay_bytes8_left, args[1], sha256(args[0]), args[2])));
967987
return queryId;
968988
}
969989

@@ -1075,7 +1095,7 @@ contract usingOraclize {
10751095
uint ledgerProofLength = 3+65+(uint(proof[3+65+1])+2)+32;
10761096
bytes memory keyhash = new bytes(32);
10771097
copyBytes(proof, ledgerProofLength, 32, keyhash, 0);
1078-
if (!(keccak256(keyhash) == keccak256(sha256(context_name, queryId)))) return false;
1098+
if (!(keccak256(keyhash) == keccak256(abi.encodePacked(sha256(abi.encodePacked(context_name, queryId)))))) return false;
10791099

10801100
bytes memory sig1 = new bytes(uint(proof[ledgerProofLength+(32+8+1+32)+1])+2);
10811101
copyBytes(proof, ledgerProofLength+(32+8+1+32), sig1.length, sig1, 0);
@@ -1093,7 +1113,7 @@ contract usingOraclize {
10931113
copyBytes(proof, sig2offset-64, 64, sessionPubkey, 0);
10941114

10951115
bytes32 sessionPubkeyHash = sha256(sessionPubkey);
1096-
if (oraclize_randomDS_args[queryId] == keccak256(commitmentSlice1, sessionPubkeyHash)){ //unonce, nbytes and sessionKeyHash match
1116+
if (oraclize_randomDS_args[queryId] == keccak256(abi.encodePacked(commitmentSlice1, sessionPubkeyHash))){ //unonce, nbytes and sessionKeyHash match
10971117
delete oraclize_randomDS_args[queryId];
10981118
} else return false;
10991119

@@ -1212,3 +1232,4 @@ contract usingOraclize {
12121232
}
12131233

12141234
}
1235+
// </ORACLIZE_API>

contracts/helpers/PolyToken.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma solidity ^0.4.24;
22

3-
import "../interfaces/IERC20.sol";
3+
import "../interfaces/IPoly.sol";
44

55
/*
66
Copyright (c) 2016 Smart Contract Solutions, Inc.
@@ -64,7 +64,7 @@ library SafeMath {
6464
* @dev Implementation of the basic standard token.
6565
* @dev https://github.com/ethereum/EIPs/issues/20
6666
*/
67-
contract PolyToken is IERC20 {
67+
contract PolyToken is IPoly {
6868
using SafeMath for uint256;
6969

7070
// Poly Token parameters

contracts/interfaces/IERC20.sol renamed to contracts/interfaces/IPoly.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pragma solidity ^0.4.24;
44
* @title ERC20 interface
55
* @dev see https://github.com/ethereum/EIPs/issues/20
66
*/
7-
interface IERC20 {
7+
interface IPoly {
88
function decimals() external view returns (uint8);
99
function totalSupply() external view returns (uint256);
1010
function balanceOf(address _owner) external view returns (uint256);

contracts/mocks/MockBurnFactory.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ contract MockBurnFactory is TrackedRedemptionFactory {
2424
*/
2525
function deploy(bytes /*_data*/) external returns(address) {
2626
if(setupCost > 0)
27-
require(polyToken.transferFrom(msg.sender, owner, setupCost), "Unable to pay setup cost");
27+
require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Unable to pay setup cost");
2828
//Check valid bytes - can only call module init function
2929
MockRedemptionManager mockRedemptionManager = new MockRedemptionManager(msg.sender, address(polyToken));
3030
/*solium-disable-next-line security/no-block-members*/

contracts/modules/Checkpoint/DividendCheckpoint.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ contract DividendCheckpoint is ICheckpoint, Module {
176176
{
177177
Dividend storage dividend = dividends[_dividendIndex];
178178
address[] memory investors = ISecurityToken(securityToken).getInvestors();
179-
uint256 numberInvestors = Math.min256(investors.length, _start.add(_iterations));
179+
uint256 numberInvestors = Math.min(investors.length, _start.add(_iterations));
180180
for (uint256 i = _start; i < numberInvestors; i++) {
181181
address payee = investors[i];
182182
if ((!dividend.claimed[payee]) && (!dividend.dividendExcluded[payee])) {

contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pragma solidity ^0.4.24;
22

33
import "./DividendCheckpoint.sol";
44
import "../../interfaces/IOwnable.sol";
5-
import "../../interfaces/IERC20.sol";
5+
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
66

77
/**
88
* @title Checkpoint module for issuing ERC20 dividends

contracts/modules/Checkpoint/ERC20DividendCheckpointFactory.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ contract ERC20DividendCheckpointFactory is ModuleFactory {
3232
*/
3333
function deploy(bytes /* _data */) external returns(address) {
3434
if (setupCost > 0)
35-
require(polyToken.transferFrom(msg.sender, owner, setupCost), "insufficent allowance");
35+
require(polyToken.transferFrom(msg.sender, owner(), setupCost), "insufficent allowance");
3636
address erc20DividendCheckpoint = new ERC20DividendCheckpoint(msg.sender, address(polyToken));
3737
/*solium-disable-next-line security/no-block-members*/
3838
emit GenerateModuleFromFactory(erc20DividendCheckpoint, getName(), address(this), msg.sender, setupCost, now);

0 commit comments

Comments
 (0)