From 8c42e155572b14455ee057a19913acf76a66ecac Mon Sep 17 00:00:00 2001 From: Dmitriy Kostin Date: Mon, 5 Nov 2018 16:39:39 +0200 Subject: [PATCH 01/15] Updated oraclizeAPI to version 0.4.25 --- contracts/external/oraclizeAPI.sol | 33 ++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/contracts/external/oraclizeAPI.sol b/contracts/external/oraclizeAPI.sol index c8d7a8f18..bc8045879 100644 --- a/contracts/external/oraclizeAPI.sol +++ b/contracts/external/oraclizeAPI.sol @@ -1,15 +1,25 @@ // +// Release targetted at solc 0.4.25 to silence compiler warning/error messages, compatible down to 0.4.22 /* Copyright (c) 2015-2016 Oraclize SRL Copyright (c) 2016 Oraclize LTD + + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 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 THE SOFTWARE. */ -// This api is currently targeted at 0.4.18, please import oraclizeAPI_pre0.4.sol or oraclizeAPI_0.4 where necessary +// 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 /* solium-disable */ -pragma solidity >=0.4.18;// Incompatible compiler version... please select one stated within pragma solidity or use different oraclizeAPI version +pragma solidity >=0.4.22;// Incompatible compiler version... please select one stated within pragma solidity or use different oraclizeAPI version contract OraclizeI { address public cbAddress; @@ -44,17 +54,23 @@ contract OraclizeAddrResolverI { /* Begin solidity-cborutils + https://github.com/smartcontractkit/solidity-cborutils + MIT License + Copyright (c) 2018 SmartContract ChainLink, Ltd. + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -346,7 +362,11 @@ contract usingOraclize { } function __callback(bytes32 myid, string result, bytes proof) public { return; + // Following should never be reached with a preceding return, however + // this is just a placeholder function, ideally meant to be defined in + // child contract when proofs are used myid; result; proof; // Silence compiler warnings + oraclize = OraclizeI(0); // Additional compiler silence about making function pure/view. } function oraclize_getPrice(string datasource) oraclizeAPI internal returns (uint){ @@ -744,7 +764,7 @@ contract usingOraclize { return oraclize.randomDS_getSessionPubKeyHash(); } - function getCodeSize(address _addr) constant internal returns(uint _size) { + function getCodeSize(address _addr) view internal returns(uint _size) { assembly { _size := extcodesize(_addr) } @@ -963,7 +983,7 @@ contract usingOraclize { } - oraclize_randomDS_setCommitment(queryId, keccak256(delay_bytes8_left, args[1], sha256(args[0]), args[2])); + oraclize_randomDS_setCommitment(queryId, keccak256(abi.encodePacked(delay_bytes8_left, args[1], sha256(args[0]), args[2]))); return queryId; } @@ -1075,7 +1095,7 @@ contract usingOraclize { uint ledgerProofLength = 3+65+(uint(proof[3+65+1])+2)+32; bytes memory keyhash = new bytes(32); copyBytes(proof, ledgerProofLength, 32, keyhash, 0); - if (!(keccak256(keyhash) == keccak256(sha256(context_name, queryId)))) return false; + if (!(keccak256(keyhash) == keccak256(abi.encodePacked(sha256(abi.encodePacked(context_name, queryId)))))) return false; bytes memory sig1 = new bytes(uint(proof[ledgerProofLength+(32+8+1+32)+1])+2); copyBytes(proof, ledgerProofLength+(32+8+1+32), sig1.length, sig1, 0); @@ -1093,7 +1113,7 @@ contract usingOraclize { copyBytes(proof, sig2offset-64, 64, sessionPubkey, 0); bytes32 sessionPubkeyHash = sha256(sessionPubkey); - if (oraclize_randomDS_args[queryId] == keccak256(commitmentSlice1, sessionPubkeyHash)){ //unonce, nbytes and sessionKeyHash match + if (oraclize_randomDS_args[queryId] == keccak256(abi.encodePacked(commitmentSlice1, sessionPubkeyHash))){ //unonce, nbytes and sessionKeyHash match delete oraclize_randomDS_args[queryId]; } else return false; @@ -1212,3 +1232,4 @@ contract usingOraclize { } } +// From d7181a892c29737713a6d4bbdddcd86105c1f61e Mon Sep 17 00:00:00 2001 From: Dmitriy Kostin Date: Tue, 6 Nov 2018 11:03:57 +0200 Subject: [PATCH 02/15] Updated: imports, use owner() --- contracts/ModuleRegistry.sol | 2 +- contracts/ReclaimTokens.sol | 2 +- contracts/SecurityTokenRegistry.sol | 2 +- contracts/helpers/PolyToken.sol | 2 +- contracts/mocks/MockBurnFactory.sol | 2 +- .../Checkpoint/ERC20DividendCheckpoint.sol | 2 +- .../ERC20DividendCheckpointFactory.sol | 2 +- .../EtherDividendCheckpointFactory.sol | 2 +- .../Mixed/ScheduledCheckpointFactory.sol | 2 +- .../LockupVolumeRestrictionTMFactory.sol | 2 +- .../SingleTradeVolumeRestrictionTMFactory.sol | 2 +- contracts/modules/Module.sol | 2 +- contracts/modules/ModuleFactory.sol | 2 +- .../GeneralPermissionManagerFactory.sol | 2 +- contracts/modules/STO/CappedSTO.sol | 2 +- contracts/modules/STO/CappedSTOFactory.sol | 2 +- contracts/modules/STO/DummySTOFactory.sol | 2 +- contracts/modules/STO/ISTO.sol | 2 +- contracts/modules/STO/PreSaleSTOFactory.sol | 2 +- contracts/modules/STO/USDTieredSTO.sol | 2 +- contracts/modules/STO/USDTieredSTOFactory.sol | 2 +- .../CountTransferManagerFactory.sol | 2 +- .../GeneralTransferManagerFactory.sol | 2 +- .../ManualApprovalTransferManagerFactory.sol | 2 +- .../PercentageTransferManagerFactory.sol | 2 +- contracts/proxy/UpgradeabilityProxy.sol | 4 ++-- contracts/tokens/SecurityToken.sol | 16 ++++++++-------- package.json | 5 +++-- 28 files changed, 38 insertions(+), 37 deletions(-) diff --git a/contracts/ModuleRegistry.sol b/contracts/ModuleRegistry.sol index b2f1fbba5..e376a8301 100644 --- a/contracts/ModuleRegistry.sol +++ b/contracts/ModuleRegistry.sol @@ -1,11 +1,11 @@ pragma solidity ^0.4.24; +import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; import "./interfaces/IModuleRegistry.sol"; import "./interfaces/IModuleFactory.sol"; import "./interfaces/ISecurityTokenRegistry.sol"; import "./interfaces/IPolymathRegistry.sol"; import "./interfaces/IFeatureRegistry.sol"; -import "./interfaces/IERC20.sol"; import "./libraries/VersionUtils.sol"; import "./storage/EternalStorage.sol"; import "./libraries/Encoder.sol"; diff --git a/contracts/ReclaimTokens.sol b/contracts/ReclaimTokens.sol index 767442829..a7e86eba2 100644 --- a/contracts/ReclaimTokens.sol +++ b/contracts/ReclaimTokens.sol @@ -1,7 +1,7 @@ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; -import "./interfaces/IERC20.sol"; +import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; /** * @title Utility contract to allow owner to retreive any ERC20 sent to the contract diff --git a/contracts/SecurityTokenRegistry.sol b/contracts/SecurityTokenRegistry.sol index a9642cc20..74f96de0a 100644 --- a/contracts/SecurityTokenRegistry.sol +++ b/contracts/SecurityTokenRegistry.sol @@ -1,9 +1,9 @@ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; +import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; import "./interfaces/IOwnable.sol"; import "./interfaces/ISTFactory.sol"; -import "./interfaces/IERC20.sol"; import "./interfaces/ISecurityTokenRegistry.sol"; import "./storage/EternalStorage.sol"; import "./libraries/Util.sol"; diff --git a/contracts/helpers/PolyToken.sol b/contracts/helpers/PolyToken.sol index d8f3d48ec..747778713 100644 --- a/contracts/helpers/PolyToken.sol +++ b/contracts/helpers/PolyToken.sol @@ -1,6 +1,6 @@ pragma solidity ^0.4.24; -import "../interfaces/IERC20.sol"; +import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; /* Copyright (c) 2016 Smart Contract Solutions, Inc. diff --git a/contracts/mocks/MockBurnFactory.sol b/contracts/mocks/MockBurnFactory.sol index 6c0e47c3d..31e5edafa 100644 --- a/contracts/mocks/MockBurnFactory.sol +++ b/contracts/mocks/MockBurnFactory.sol @@ -24,7 +24,7 @@ contract MockBurnFactory is TrackedRedemptionFactory { */ function deploy(bytes /*_data*/) external returns(address) { if(setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Unable to pay setup cost"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Unable to pay setup cost"); //Check valid bytes - can only call module init function MockRedemptionManager mockRedemptionManager = new MockRedemptionManager(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ diff --git a/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol b/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol index 1f7f25cd5..3a981ce28 100644 --- a/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol +++ b/contracts/modules/Checkpoint/ERC20DividendCheckpoint.sol @@ -2,7 +2,7 @@ pragma solidity ^0.4.24; import "./DividendCheckpoint.sol"; import "../../interfaces/IOwnable.sol"; -import "../../interfaces/IERC20.sol"; +import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; /** * @title Checkpoint module for issuing ERC20 dividends diff --git a/contracts/modules/Checkpoint/ERC20DividendCheckpointFactory.sol b/contracts/modules/Checkpoint/ERC20DividendCheckpointFactory.sol index 5fd158c26..10a1fc5a0 100644 --- a/contracts/modules/Checkpoint/ERC20DividendCheckpointFactory.sol +++ b/contracts/modules/Checkpoint/ERC20DividendCheckpointFactory.sol @@ -32,7 +32,7 @@ contract ERC20DividendCheckpointFactory is ModuleFactory { */ function deploy(bytes /* _data */) external returns(address) { if (setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner, setupCost), "insufficent allowance"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "insufficent allowance"); address erc20DividendCheckpoint = new ERC20DividendCheckpoint(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ emit GenerateModuleFromFactory(erc20DividendCheckpoint, getName(), address(this), msg.sender, setupCost, now); diff --git a/contracts/modules/Checkpoint/EtherDividendCheckpointFactory.sol b/contracts/modules/Checkpoint/EtherDividendCheckpointFactory.sol index 315760be1..69859c4f0 100644 --- a/contracts/modules/Checkpoint/EtherDividendCheckpointFactory.sol +++ b/contracts/modules/Checkpoint/EtherDividendCheckpointFactory.sol @@ -32,7 +32,7 @@ contract EtherDividendCheckpointFactory is ModuleFactory { */ function deploy(bytes /* _data */) external returns(address) { if(setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Insufficent allowance or balance"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Insufficent allowance or balance"); address ethDividendCheckpoint = new EtherDividendCheckpoint(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ emit GenerateModuleFromFactory(ethDividendCheckpoint, getName(), address(this), msg.sender, setupCost, now); diff --git a/contracts/modules/Experimental/Mixed/ScheduledCheckpointFactory.sol b/contracts/modules/Experimental/Mixed/ScheduledCheckpointFactory.sol index 1b5daac29..c3ec735cc 100644 --- a/contracts/modules/Experimental/Mixed/ScheduledCheckpointFactory.sol +++ b/contracts/modules/Experimental/Mixed/ScheduledCheckpointFactory.sol @@ -32,7 +32,7 @@ contract ScheduledCheckpointFactory is ModuleFactory { */ function deploy(bytes /* _data */) external returns(address) { if(setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); address scheduledCheckpoint = new ScheduledCheckpoint(msg.sender, address(polyToken)); emit GenerateModuleFromFactory(scheduledCheckpoint, getName(), address(this), msg.sender, setupCost, now); return scheduledCheckpoint; diff --git a/contracts/modules/Experimental/TransferManager/LockupVolumeRestrictionTMFactory.sol b/contracts/modules/Experimental/TransferManager/LockupVolumeRestrictionTMFactory.sol index 5be77b6e0..9ad339be3 100644 --- a/contracts/modules/Experimental/TransferManager/LockupVolumeRestrictionTMFactory.sol +++ b/contracts/modules/Experimental/TransferManager/LockupVolumeRestrictionTMFactory.sol @@ -32,7 +32,7 @@ contract LockupVolumeRestrictionTMFactory is ModuleFactory { */ function deploy(bytes /* _data */) external returns(address) { if (setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); LockupVolumeRestrictionTM lockupVolumeRestrictionTransferManager = new LockupVolumeRestrictionTM(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ emit GenerateModuleFromFactory(address(lockupVolumeRestrictionTransferManager), getName(), address(this), msg.sender, now); diff --git a/contracts/modules/Experimental/TransferManager/SingleTradeVolumeRestrictionTMFactory.sol b/contracts/modules/Experimental/TransferManager/SingleTradeVolumeRestrictionTMFactory.sol index e6d8ed2be..346fe9997 100644 --- a/contracts/modules/Experimental/TransferManager/SingleTradeVolumeRestrictionTMFactory.sol +++ b/contracts/modules/Experimental/TransferManager/SingleTradeVolumeRestrictionTMFactory.sol @@ -34,7 +34,7 @@ contract SingleTradeVolumeRestrictionTMFactory is ModuleFactory { */ function deploy(bytes _data) external returns(address) { if (setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); SingleTradeVolumeRestrictionTM singleTradeVolumeRestrictionManager = new SingleTradeVolumeRestrictionTM(msg.sender, address(polyToken)); require(Util.getSig(_data) == singleTradeVolumeRestrictionManager.getInitFunction(), "Provided data is not valid"); diff --git a/contracts/modules/Module.sol b/contracts/modules/Module.sol index aa3e6d865..e48a74614 100644 --- a/contracts/modules/Module.sol +++ b/contracts/modules/Module.sol @@ -2,7 +2,7 @@ pragma solidity ^0.4.24; import "../interfaces/IModule.sol"; import "../interfaces/ISecurityToken.sol"; -import "../interfaces/IERC20.sol"; +import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; /** diff --git a/contracts/modules/ModuleFactory.sol b/contracts/modules/ModuleFactory.sol index aca262621..99e0f2d9d 100644 --- a/contracts/modules/ModuleFactory.sol +++ b/contracts/modules/ModuleFactory.sol @@ -1,6 +1,6 @@ pragma solidity ^0.4.24; -import "../interfaces/IERC20.sol"; +import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; import "../interfaces/IModuleFactory.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; import "../libraries/VersionUtils.sol"; diff --git a/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol b/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol index bfdc73801..900fcef1c 100644 --- a/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol +++ b/contracts/modules/PermissionManager/GeneralPermissionManagerFactory.sol @@ -29,7 +29,7 @@ contract GeneralPermissionManagerFactory is ModuleFactory { */ function deploy(bytes /* _data */) external returns(address) { if(setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Failed transferFrom due to insufficent Allowance provided"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom due to insufficent Allowance provided"); address permissionManager = new GeneralPermissionManager(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ emit GenerateModuleFromFactory(address(permissionManager), getName(), address(this), msg.sender, setupCost, now); diff --git a/contracts/modules/STO/CappedSTO.sol b/contracts/modules/STO/CappedSTO.sol index 60373ae37..a22750bc4 100644 --- a/contracts/modules/STO/CappedSTO.sol +++ b/contracts/modules/STO/CappedSTO.sol @@ -2,7 +2,7 @@ pragma solidity ^0.4.24; import "./ISTO.sol"; import "../../interfaces/ISecurityToken.sol"; -import "openzeppelin-solidity/contracts/ReentrancyGuard.sol"; +import "openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol"; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; /** diff --git a/contracts/modules/STO/CappedSTOFactory.sol b/contracts/modules/STO/CappedSTOFactory.sol index 89f3311d2..37cf37f21 100644 --- a/contracts/modules/STO/CappedSTOFactory.sol +++ b/contracts/modules/STO/CappedSTOFactory.sol @@ -30,7 +30,7 @@ contract CappedSTOFactory is ModuleFactory { */ function deploy(bytes _data) external returns(address) { if(setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Sufficent Allowance is not provided"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Sufficent Allowance is not provided"); //Check valid bytes - can only call module init function CappedSTO cappedSTO = new CappedSTO(msg.sender, address(polyToken)); //Checks that _data is valid (not calling anything it shouldn't) diff --git a/contracts/modules/STO/DummySTOFactory.sol b/contracts/modules/STO/DummySTOFactory.sol index 04640ac58..02b55fe08 100644 --- a/contracts/modules/STO/DummySTOFactory.sol +++ b/contracts/modules/STO/DummySTOFactory.sol @@ -29,7 +29,7 @@ contract DummySTOFactory is ModuleFactory { */ function deploy(bytes _data) external returns(address) { if (setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Sufficent Allowance is not provided"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Sufficent Allowance is not provided"); //Check valid bytes - can only call module init function DummySTO dummySTO = new DummySTO(msg.sender, address(polyToken)); //Checks that _data is valid (not calling anything it shouldn't) diff --git a/contracts/modules/STO/ISTO.sol b/contracts/modules/STO/ISTO.sol index 6ed1d5ba1..111c6fa4c 100644 --- a/contracts/modules/STO/ISTO.sol +++ b/contracts/modules/STO/ISTO.sol @@ -2,7 +2,7 @@ pragma solidity ^0.4.24; import "../../Pausable.sol"; import "../Module.sol"; -import "../../interfaces/IERC20.sol"; +import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; /** diff --git a/contracts/modules/STO/PreSaleSTOFactory.sol b/contracts/modules/STO/PreSaleSTOFactory.sol index 035c4bad5..b78a208ed 100644 --- a/contracts/modules/STO/PreSaleSTOFactory.sol +++ b/contracts/modules/STO/PreSaleSTOFactory.sol @@ -31,7 +31,7 @@ contract PreSaleSTOFactory is ModuleFactory { */ function deploy(bytes _data) external returns(address) { if (setupCost > 0) { - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Sufficent Allowance is not provided"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Sufficent Allowance is not provided"); } //Check valid bytes - can only call module init function PreSaleSTO preSaleSTO = new PreSaleSTO(msg.sender, address(polyToken)); diff --git a/contracts/modules/STO/USDTieredSTO.sol b/contracts/modules/STO/USDTieredSTO.sol index 894744451..df7b290db 100644 --- a/contracts/modules/STO/USDTieredSTO.sol +++ b/contracts/modules/STO/USDTieredSTO.sol @@ -6,7 +6,7 @@ import "../../interfaces/IOracle.sol"; import "../../RegistryUpdater.sol"; import "../../libraries/DecimalMath.sol"; import "openzeppelin-solidity/contracts/math/SafeMath.sol"; -import "openzeppelin-solidity/contracts/ReentrancyGuard.sol"; +import "openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol"; /** * @title STO module for standard capped crowdsale diff --git a/contracts/modules/STO/USDTieredSTOFactory.sol b/contracts/modules/STO/USDTieredSTOFactory.sol index adc3ba628..51dbbc87f 100644 --- a/contracts/modules/STO/USDTieredSTOFactory.sol +++ b/contracts/modules/STO/USDTieredSTOFactory.sol @@ -35,7 +35,7 @@ contract USDTieredSTOFactory is ModuleFactory { */ function deploy(bytes _data) external returns(address) { if(setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Sufficent Allowance is not provided"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Sufficent Allowance is not provided"); require(USDTieredSTOProxyAddress != address(0), "Proxy contract should be pre-set"); //Check valid bytes - can only call module init function address usdTieredSTO = IUSDTieredSTOProxy(USDTieredSTOProxyAddress).deploySTO(msg.sender, address(polyToken), address(this)); diff --git a/contracts/modules/TransferManager/CountTransferManagerFactory.sol b/contracts/modules/TransferManager/CountTransferManagerFactory.sol index d9b1328f7..48c2f3705 100644 --- a/contracts/modules/TransferManager/CountTransferManagerFactory.sol +++ b/contracts/modules/TransferManager/CountTransferManagerFactory.sol @@ -31,7 +31,7 @@ contract CountTransferManagerFactory is ModuleFactory { */ function deploy(bytes _data) external returns(address) { if(setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Failed transferFrom due to insufficent Allowance provided"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom due to insufficent Allowance provided"); CountTransferManager countTransferManager = new CountTransferManager(msg.sender, address(polyToken)); require(Util.getSig(_data) == countTransferManager.getInitFunction(), "Provided data is not valid"); /*solium-disable-next-line security/no-low-level-calls*/ diff --git a/contracts/modules/TransferManager/GeneralTransferManagerFactory.sol b/contracts/modules/TransferManager/GeneralTransferManagerFactory.sol index c15eb52aa..f073dee6f 100644 --- a/contracts/modules/TransferManager/GeneralTransferManagerFactory.sol +++ b/contracts/modules/TransferManager/GeneralTransferManagerFactory.sol @@ -30,7 +30,7 @@ contract GeneralTransferManagerFactory is ModuleFactory { */ function deploy(bytes /* _data */) external returns(address) { if (setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); address generalTransferManager = new GeneralTransferManager(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ emit GenerateModuleFromFactory(address(generalTransferManager), getName(), address(this), msg.sender, setupCost, now); diff --git a/contracts/modules/TransferManager/ManualApprovalTransferManagerFactory.sol b/contracts/modules/TransferManager/ManualApprovalTransferManagerFactory.sol index f634b33e9..f2a3ddd6a 100644 --- a/contracts/modules/TransferManager/ManualApprovalTransferManagerFactory.sol +++ b/contracts/modules/TransferManager/ManualApprovalTransferManagerFactory.sol @@ -32,7 +32,7 @@ contract ManualApprovalTransferManagerFactory is ModuleFactory { */ function deploy(bytes /* _data */) external returns(address) { if (setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); address manualTransferManager = new ManualApprovalTransferManager(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ emit GenerateModuleFromFactory(address(manualTransferManager), getName(), address(this), msg.sender, setupCost, now); diff --git a/contracts/modules/TransferManager/PercentageTransferManagerFactory.sol b/contracts/modules/TransferManager/PercentageTransferManagerFactory.sol index 1702b6f08..81a9a01fd 100644 --- a/contracts/modules/TransferManager/PercentageTransferManagerFactory.sol +++ b/contracts/modules/TransferManager/PercentageTransferManagerFactory.sol @@ -31,7 +31,7 @@ contract PercentageTransferManagerFactory is ModuleFactory { */ function deploy(bytes _data) external returns(address) { if(setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Failed transferFrom because of sufficent Allowance is not provided"); PercentageTransferManager percentageTransferManager = new PercentageTransferManager(msg.sender, address(polyToken)); require(Util.getSig(_data) == percentageTransferManager.getInitFunction(), "Provided data is not valid"); /*solium-disable-next-line security/no-low-level-calls*/ diff --git a/contracts/proxy/UpgradeabilityProxy.sol b/contracts/proxy/UpgradeabilityProxy.sol index 0f7806b71..37b64af3e 100644 --- a/contracts/proxy/UpgradeabilityProxy.sol +++ b/contracts/proxy/UpgradeabilityProxy.sol @@ -1,7 +1,7 @@ pragma solidity ^0.4.24; import "./Proxy.sol"; -import "openzeppelin-solidity/contracts/AddressUtils.sol"; +import "openzeppelin-solidity/contracts/utils/Address.sol"; /** * @title UpgradeabilityProxy @@ -32,7 +32,7 @@ contract UpgradeabilityProxy is Proxy { __implementation != _newImplementation && _newImplementation != address(0), "Old address is not allowed and implementation address should not be 0x" ); - require(AddressUtils.isContract(_newImplementation), "Cannot set a proxy implementation to a non-contract address"); + require(Address.isContract(_newImplementation), "Cannot set a proxy implementation to a non-contract address"); require(bytes(_newVersion).length > 0, "Version should not be empty string"); require(keccak256(abi.encodePacked(__version)) != keccak256(abi.encodePacked(_newVersion)), "New version equals to current"); __version = _newVersion; diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index cfa24baa1..d019e36d2 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -1,7 +1,6 @@ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/math/Math.sol"; -import "../interfaces/IERC20.sol"; import "../interfaces/IModule.sol"; import "../interfaces/IModuleFactory.sol"; import "../interfaces/IModuleRegistry.sol"; @@ -9,9 +8,10 @@ import "../interfaces/IFeatureRegistry.sol"; import "../modules/TransferManager/ITransferManager.sol"; import "../RegistryUpdater.sol"; import "../libraries/Util.sol"; -import "openzeppelin-solidity/contracts/ReentrancyGuard.sol"; -import "openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol"; -import "openzeppelin-solidity/contracts/token/ERC20/DetailedERC20.sol"; +import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; +import "openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol"; +import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; +import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol"; import "../libraries/TokenLib.sol"; /** @@ -24,7 +24,7 @@ import "../libraries/TokenLib.sol"; * @notice - ST does not inherit from ISecurityToken due to: * @notice - https://github.com/ethereum/solidity/issues/4847 */ -contract SecurityToken is StandardToken, DetailedERC20, ReentrancyGuard, RegistryUpdater { +contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater { using SafeMath for uint256; TokenLib.InvestorDataStorage investorData; @@ -153,7 +153,7 @@ contract SecurityToken is StandardToken, DetailedERC20, ReentrancyGuard, Registr // Require msg.sender to be the specified module type or the owner of the token modifier onlyModuleOrOwner(uint8 _type) { - if (msg.sender == owner) { + if (msg.sender == owner()) { _; } else { require(_isModule(msg.sender, _type)); @@ -203,7 +203,7 @@ contract SecurityToken is StandardToken, DetailedERC20, ReentrancyGuard, Registr address _polymathRegistry ) public - DetailedERC20(_name, _symbol, _decimals) + ERC20Detailed(_name, _symbol, _decimals) RegistryUpdater(_polymathRegistry) { //When it is created, the owner is the STR @@ -365,7 +365,7 @@ contract SecurityToken is StandardToken, DetailedERC20, ReentrancyGuard, Registr function withdrawERC20(address _tokenContract, uint256 _value) external onlyOwner { require(_tokenContract != address(0)); IERC20 token = IERC20(_tokenContract); - require(token.transfer(owner, _value)); + require(token.transfer(owner(), _value)); } /** diff --git a/package.json b/package.json index b350b4ac6..3f856fc0b 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "ethereumjs-testrpc": "^6.0.3", "ethers": "^3.0.15", "fs": "0.0.1-security", - "openzeppelin-solidity": "1.10.0", + "openzeppelin-solidity": "2.0.0", "readline-sync": "^1.4.9", "request": "^2.88.0", "request-promise": "^4.2.2", @@ -74,7 +74,8 @@ "solc": "^0.4.24", "truffle-contract": "^3.0.4", "truffle-hdwallet-provider-privkey": "^0.1.0", - "web3": "1.0.0-beta.34" + "web3": "1.0.0-beta.34", + "web3-provider-engine": "^14.1.0" }, "devDependencies": { "@soldoc/soldoc": "^0.4.3", From 8e12007957bb2a68fd8b64fdd0b257314ca65eaa Mon Sep 17 00:00:00 2001 From: Dmitriy Kostin Date: Tue, 6 Nov 2018 17:28:56 +0200 Subject: [PATCH 03/15] Fixed compilation errors (transfer in ReclaimTokens commented) --- contracts/ReclaimTokens.sol | 7 +++-- contracts/helpers/PolyToken.sol | 3 +- .../{IERC20.sol => IERC20Extended.sol} | 2 +- .../modules/Checkpoint/DividendCheckpoint.sol | 2 +- .../Burn/TrackedRedemptionFactory.sol | 2 +- contracts/modules/STO/USDTieredSTO.sol | 5 ++-- contracts/oracles/PolyOracle.sol | 2 +- contracts/tokens/SecurityToken.sol | 30 ++++++++----------- 8 files changed, 25 insertions(+), 28 deletions(-) rename contracts/interfaces/{IERC20.sol => IERC20Extended.sol} (97%) diff --git a/contracts/ReclaimTokens.sol b/contracts/ReclaimTokens.sol index a7e86eba2..a1c2ffd2c 100644 --- a/contracts/ReclaimTokens.sol +++ b/contracts/ReclaimTokens.sol @@ -1,7 +1,7 @@ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; -import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; +import "./interfaces/IERC20Extended.sol"; /** * @title Utility contract to allow owner to retreive any ERC20 sent to the contract @@ -14,8 +14,9 @@ contract ReclaimTokens is Ownable { */ function reclaimERC20(address _tokenContract) external onlyOwner { require(_tokenContract != address(0), "Invalid address"); - IERC20 token = IERC20(_tokenContract); + IERC20Extended token = IERC20Extended(_tokenContract); uint256 balance = token.balanceOf(address(this)); - require(token.transfer(owner, balance), "Transfer failed"); +// TODO oz - ??? +// require(token.transfer(owner, balance), "Transfer failed"); } } diff --git a/contracts/helpers/PolyToken.sol b/contracts/helpers/PolyToken.sol index 747778713..115c75138 100644 --- a/contracts/helpers/PolyToken.sol +++ b/contracts/helpers/PolyToken.sol @@ -1,6 +1,7 @@ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; +import "../interfaces/IERC20Extended.sol"; /* Copyright (c) 2016 Smart Contract Solutions, Inc. @@ -64,7 +65,7 @@ library SafeMath { * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 */ -contract PolyToken is IERC20 { +contract PolyToken is IERC20Extended { using SafeMath for uint256; // Poly Token parameters diff --git a/contracts/interfaces/IERC20.sol b/contracts/interfaces/IERC20Extended.sol similarity index 97% rename from contracts/interfaces/IERC20.sol rename to contracts/interfaces/IERC20Extended.sol index b1d36463f..728ce004b 100644 --- a/contracts/interfaces/IERC20.sol +++ b/contracts/interfaces/IERC20Extended.sol @@ -4,7 +4,7 @@ pragma solidity ^0.4.24; * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ -interface IERC20 { +interface IERC20Extended { function decimals() external view returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address _owner) external view returns (uint256); diff --git a/contracts/modules/Checkpoint/DividendCheckpoint.sol b/contracts/modules/Checkpoint/DividendCheckpoint.sol index 452a48b13..9a804772f 100644 --- a/contracts/modules/Checkpoint/DividendCheckpoint.sol +++ b/contracts/modules/Checkpoint/DividendCheckpoint.sol @@ -176,7 +176,7 @@ contract DividendCheckpoint is ICheckpoint, Module { { Dividend storage dividend = dividends[_dividendIndex]; address[] memory investors = ISecurityToken(securityToken).getInvestors(); - uint256 numberInvestors = Math.min256(investors.length, _start.add(_iterations)); + uint256 numberInvestors = Math.min(investors.length, _start.add(_iterations)); for (uint256 i = _start; i < numberInvestors; i++) { address payee = investors[i]; if ((!dividend.claimed[payee]) && (!dividend.dividendExcluded[payee])) { diff --git a/contracts/modules/Experimental/Burn/TrackedRedemptionFactory.sol b/contracts/modules/Experimental/Burn/TrackedRedemptionFactory.sol index d1fa010b7..87f480e09 100644 --- a/contracts/modules/Experimental/Burn/TrackedRedemptionFactory.sol +++ b/contracts/modules/Experimental/Burn/TrackedRedemptionFactory.sol @@ -32,7 +32,7 @@ contract TrackedRedemptionFactory is ModuleFactory { */ function deploy(bytes /* _data */) external returns(address) { if (setupCost > 0) - require(polyToken.transferFrom(msg.sender, owner, setupCost), "Insufficent allowance or balance"); + require(polyToken.transferFrom(msg.sender, owner(), setupCost), "Insufficent allowance or balance"); address trackedRedemption = new TrackedRedemption(msg.sender, address(polyToken)); /*solium-disable-next-line security/no-block-members*/ emit GenerateModuleFromFactory(address(trackedRedemption), getName(), address(this), msg.sender, setupCost, now); diff --git a/contracts/modules/STO/USDTieredSTO.sol b/contracts/modules/STO/USDTieredSTO.sol index df7b290db..b4e0bc203 100644 --- a/contracts/modules/STO/USDTieredSTO.sol +++ b/contracts/modules/STO/USDTieredSTO.sol @@ -434,7 +434,7 @@ contract USDTieredSTO is ISTO, ReentrancyGuard { require(_investmentValue > 0, "No funds were sent"); uint256 investedUSD = DecimalMath.mul(_rate, _investmentValue); - uint256 originalUSD = investedUSD; + uint256 spentValue = investedUSD; // Check for minimum investment require(investedUSD.add(investorInvestedUSD[_beneficiary]) >= minimumInvestmentUSD, "Total investment < minimumInvestmentUSD"); @@ -469,11 +469,10 @@ contract USDTieredSTO is ISTO, ReentrancyGuard { } // Calculate spent in base currency (ETH, DAI or POLY) - uint256 spentValue; if (spentUSD == 0) { spentValue = 0; } else { - spentValue = DecimalMath.mul(DecimalMath.div(spentUSD, originalUSD), _investmentValue); + spentValue = DecimalMath.mul(DecimalMath.div(spentUSD, spentValue), _investmentValue); } // Return calculated amounts diff --git a/contracts/oracles/PolyOracle.sol b/contracts/oracles/PolyOracle.sol index d46242929..45f068a3e 100644 --- a/contracts/oracles/PolyOracle.sol +++ b/contracts/oracles/PolyOracle.sol @@ -33,7 +33,7 @@ contract PolyOracle is usingOraclize, IOracle, Ownable { event StalePriceUpdate(bytes32 _queryId, uint256 _time, string _result); modifier isAdminOrOwner { - require(admin[msg.sender] || msg.sender == owner, "Address is not admin or owner"); + require(admin[msg.sender] || msg.sender == owner(), "Address is not admin or owner"); _; } diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index d019e36d2..13f98c1fa 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -8,7 +8,7 @@ import "../interfaces/IFeatureRegistry.sol"; import "../modules/TransferManager/ITransferManager.sol"; import "../RegistryUpdater.sol"; import "../libraries/Util.sol"; -import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; +import "../interfaces/IERC20Extended.sol"; import "openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol"; @@ -377,13 +377,13 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater */ function changeModuleBudget(address _module, uint256 _change, bool _increase) external onlyOwner { require(modulesToData[_module].module != address(0), "Module missing"); - uint256 currentAllowance = IERC20(polyToken).allowance(address(this), _module); + uint256 currentAllowance = IERC20Extended(polyToken).allowance(address(this), _module); uint256 newAllowance; if (_increase) { - require(IERC20(polyToken).increaseApproval(_module, _change), "IncreaseApproval fail"); + require(IERC20Extended(polyToken).increaseApproval(_module, _change), "IncreaseApproval fail"); newAllowance = currentAllowance.add(_change); } else { - require(IERC20(polyToken).decreaseApproval(_module, _change), "Insufficient allowance"); + require(IERC20Extended(polyToken).decreaseApproval(_module, _change), "Insufficient allowance"); newAllowance = currentAllowance.sub(_change); } emit ModuleBudgetChanged(modulesToData[_module].moduleTypes, _module, currentAllowance, newAllowance); @@ -681,10 +681,8 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater require(_investor != address(0), "Investor is 0"); require(_updateTransfer(address(0), _investor, _value, _data), "Transfer invalid"); _adjustTotalSupplyCheckpoints(); - totalSupply_ = totalSupply_.add(_value); - balances[_investor] = balances[_investor].add(_value); + _mint(_investor, _value); emit Minted(_investor, _value); - emit Transfer(address(0), _investor, _value); return true; } @@ -721,13 +719,15 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater } function _burn(address _from, uint256 _value, bytes _data) internal returns(bool) { - require(_value <= balances[_from], "Value too high"); + require(_value <= balanceOf(_from), "Value too high"); bool verified = _updateTransfer(_from, address(0), _value, _data); _adjustTotalSupplyCheckpoints(); - balances[_from] = balances[_from].sub(_value); - totalSupply_ = totalSupply_.sub(_value); + if (msg.sender == _from) { + _burn(_from, _value); + } else { + _burnFrom(_from, _value); + } emit Burnt(_from, _value); - emit Transfer(_from, address(0), _value); return verified; } @@ -747,8 +747,6 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater * @param _data data to indicate validation */ function burnFromWithData(address _from, uint256 _value, bytes _data) public onlyModule(BURN_KEY) { - require(_value <= allowed[_from][msg.sender], "Value too high"); - allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); require(_burn(_from, _value, _data), "Burn invalid"); } @@ -826,12 +824,10 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater */ function forceTransfer(address _from, address _to, uint256 _value, bytes _data, bytes _log) public onlyController { require(_to != address(0)); - require(_value <= balances[_from]); + require(_value <= balanceOf(_from)); bool verified = _updateTransfer(_from, _to, _value, _data); - balances[_from] = balances[_from].sub(_value); - balances[_to] = balances[_to].add(_value); + _transfer(_from, _to, _value); emit ForceTransfer(msg.sender, _from, _to, _value, verified, _log); - emit Transfer(_from, _to, _value); } /** From de7092932a779165efe0b1cfc492e5f2bc22dd08 Mon Sep 17 00:00:00 2001 From: Dmitriy Kostin Date: Tue, 6 Nov 2018 22:56:51 +0200 Subject: [PATCH 04/15] IERC20 instead of IERC20Extended --- contracts/ReclaimTokens.sol | 6 +++--- contracts/helpers/PolyToken.sol | 3 +-- contracts/tokens/SecurityToken.sol | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/contracts/ReclaimTokens.sol b/contracts/ReclaimTokens.sol index a1c2ffd2c..6230d6901 100644 --- a/contracts/ReclaimTokens.sol +++ b/contracts/ReclaimTokens.sol @@ -1,7 +1,7 @@ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; -import "./interfaces/IERC20Extended.sol"; +import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; /** * @title Utility contract to allow owner to retreive any ERC20 sent to the contract @@ -14,9 +14,9 @@ contract ReclaimTokens is Ownable { */ function reclaimERC20(address _tokenContract) external onlyOwner { require(_tokenContract != address(0), "Invalid address"); - IERC20Extended token = IERC20Extended(_tokenContract); + IERC20 token = IERC20(_tokenContract); uint256 balance = token.balanceOf(address(this)); -// TODO oz - ??? +// TODO oz ??? // require(token.transfer(owner, balance), "Transfer failed"); } } diff --git a/contracts/helpers/PolyToken.sol b/contracts/helpers/PolyToken.sol index 115c75138..747778713 100644 --- a/contracts/helpers/PolyToken.sol +++ b/contracts/helpers/PolyToken.sol @@ -1,7 +1,6 @@ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; -import "../interfaces/IERC20Extended.sol"; /* Copyright (c) 2016 Smart Contract Solutions, Inc. @@ -65,7 +64,7 @@ library SafeMath { * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 */ -contract PolyToken is IERC20Extended { +contract PolyToken is IERC20 { using SafeMath for uint256; // Poly Token parameters diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index 13f98c1fa..713a2ef5b 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -8,7 +8,7 @@ import "../interfaces/IFeatureRegistry.sol"; import "../modules/TransferManager/ITransferManager.sol"; import "../RegistryUpdater.sol"; import "../libraries/Util.sol"; -import "../interfaces/IERC20Extended.sol"; +import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; import "openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol"; @@ -377,13 +377,13 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater */ function changeModuleBudget(address _module, uint256 _change, bool _increase) external onlyOwner { require(modulesToData[_module].module != address(0), "Module missing"); - uint256 currentAllowance = IERC20Extended(polyToken).allowance(address(this), _module); + uint256 currentAllowance = IERC20(polyToken).allowance(address(this), _module); uint256 newAllowance; if (_increase) { - require(IERC20Extended(polyToken).increaseApproval(_module, _change), "IncreaseApproval fail"); + require(ERC20(polyToken).increaseAllowance(_module, _change), "IncreaseApproval fail"); newAllowance = currentAllowance.add(_change); } else { - require(IERC20Extended(polyToken).decreaseApproval(_module, _change), "Insufficient allowance"); + require(ERC20(polyToken).decreaseAllowance(_module, _change), "Insufficient allowance"); newAllowance = currentAllowance.sub(_change); } emit ModuleBudgetChanged(modulesToData[_module].moduleTypes, _module, currentAllowance, newAllowance); From ff6fd604ddb166b51568c2e9e70a52284c095a58 Mon Sep 17 00:00:00 2001 From: Dmitriy Kostin Date: Tue, 6 Nov 2018 23:52:00 +0200 Subject: [PATCH 05/15] fix for "truffle test" --- contracts/ReclaimTokens.sol | 3 +-- test/helpers/contracts/PolyToken.sol | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/contracts/ReclaimTokens.sol b/contracts/ReclaimTokens.sol index 6230d6901..d1c4516f5 100644 --- a/contracts/ReclaimTokens.sol +++ b/contracts/ReclaimTokens.sol @@ -16,7 +16,6 @@ contract ReclaimTokens is Ownable { require(_tokenContract != address(0), "Invalid address"); IERC20 token = IERC20(_tokenContract); uint256 balance = token.balanceOf(address(this)); -// TODO oz ??? -// require(token.transfer(owner, balance), "Transfer failed"); + require(token.transfer(owner(), balance), "Transfer failed"); } } diff --git a/test/helpers/contracts/PolyToken.sol b/test/helpers/contracts/PolyToken.sol index e14d5d663..6f39af814 100644 --- a/test/helpers/contracts/PolyToken.sol +++ b/test/helpers/contracts/PolyToken.sol @@ -1,9 +1,9 @@ pragma solidity ^0.4.24; -import "openzeppelin-solidity/contracts/token/ERC20/MintableToken.sol"; +import "openzeppelin-solidity/contracts/token/ERC20/ERC20Mintable.sol"; -contract PolyToken is MintableToken { +contract PolyToken is ERC20Mintable { constructor () public { From 6d78c7ef27892b9b8c99f7b53ac8500eb36b00cb Mon Sep 17 00:00:00 2001 From: Dmitriy Kostin Date: Wed, 7 Nov 2018 20:55:24 +0200 Subject: [PATCH 06/15] reverted changes in PolyToken --- contracts/helpers/PolyToken.sol | 2 +- contracts/interfaces/{IERC20Extended.sol => IERC20.sol} | 2 +- contracts/tokens/SecurityToken.sol | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) rename contracts/interfaces/{IERC20Extended.sol => IERC20.sol} (97%) diff --git a/contracts/helpers/PolyToken.sol b/contracts/helpers/PolyToken.sol index 747778713..d8f3d48ec 100644 --- a/contracts/helpers/PolyToken.sol +++ b/contracts/helpers/PolyToken.sol @@ -1,6 +1,6 @@ pragma solidity ^0.4.24; -import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; +import "../interfaces/IERC20.sol"; /* Copyright (c) 2016 Smart Contract Solutions, Inc. diff --git a/contracts/interfaces/IERC20Extended.sol b/contracts/interfaces/IERC20.sol similarity index 97% rename from contracts/interfaces/IERC20Extended.sol rename to contracts/interfaces/IERC20.sol index 728ce004b..b1d36463f 100644 --- a/contracts/interfaces/IERC20Extended.sol +++ b/contracts/interfaces/IERC20.sol @@ -4,7 +4,7 @@ pragma solidity ^0.4.24; * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ -interface IERC20Extended { +interface IERC20 { function decimals() external view returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address _owner) external view returns (uint256); diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index 713a2ef5b..7f8554e17 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -1,6 +1,7 @@ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/math/Math.sol"; +import {IERC20 as IERC20Poly} from "../interfaces/IERC20.sol"; import "../interfaces/IModule.sol"; import "../interfaces/IModuleFactory.sol"; import "../interfaces/IModuleRegistry.sol"; @@ -8,7 +9,6 @@ import "../interfaces/IFeatureRegistry.sol"; import "../modules/TransferManager/ITransferManager.sol"; import "../RegistryUpdater.sol"; import "../libraries/Util.sol"; -import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; import "openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol"; @@ -380,10 +380,10 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater uint256 currentAllowance = IERC20(polyToken).allowance(address(this), _module); uint256 newAllowance; if (_increase) { - require(ERC20(polyToken).increaseAllowance(_module, _change), "IncreaseApproval fail"); + require(IERC20Poly(polyToken).increaseApproval(_module, _change), "IncreaseApproval fail"); newAllowance = currentAllowance.add(_change); } else { - require(ERC20(polyToken).decreaseAllowance(_module, _change), "Insufficient allowance"); + require(IERC20Poly(polyToken).decreaseApproval(_module, _change), "Insufficient allowance"); newAllowance = currentAllowance.sub(_change); } emit ModuleBudgetChanged(modulesToData[_module].moduleTypes, _module, currentAllowance, newAllowance); From e5cb70f293e4465204dfde92109d1652c6aa2050 Mon Sep 17 00:00:00 2001 From: Dmitriy Kostin Date: Wed, 7 Nov 2018 21:01:12 +0200 Subject: [PATCH 07/15] fixed creation of SecurityToken in tests --- test/b_capped_sto.js | 8 ++++---- test/c_checkpoints.js | 4 ++-- test/d_count_transfer_manager.js | 4 ++-- test/e_erc20_dividends.js | 4 ++-- test/f_ether_dividends.js | 4 ++-- test/g_general_permission_manager.js | 4 ++-- test/h_general_transfer_manager.js | 4 ++-- test/i_Issuance.js | 4 ++-- test/j_manual_approval_transfer_manager.js | 4 ++-- test/k_module_registry.js | 4 ++-- test/l_percentage_transfer_manager.js | 4 ++-- test/m_presale_sto.js | 4 ++-- test/n_security_token_registry.js | 4 ++-- test/o_security_token.js | 4 ++-- test/p_usd_tiered_sto.js | 4 ++-- test/q_usd_tiered_sto_sim.js | 4 ++-- test/r_concurrent_STO.js | 4 ++-- test/t_security_token_registry_proxy.js | 4 ++-- test/v_tracked_redemptions.js | 4 ++-- test/w_lockup_volume_restriction_transfer_manager.js | 4 ++-- test/x_single_trade_volume_restriction.js | 4 ++-- test/y_scheduled_checkpoints.js | 4 ++-- 22 files changed, 46 insertions(+), 46 deletions(-) diff --git a/test/b_capped_sto.js b/test/b_capped_sto.js index d89fe6eba..d3b4076ee 100644 --- a/test/b_capped_sto.js +++ b/test/b_capped_sto.js @@ -180,9 +180,9 @@ contract("CappedSTO", accounts => { let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol, "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); - I_SecurityToken_ETH = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken_ETH = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken_ETH.ModuleAdded({ from: _blockNo }), 1); @@ -657,9 +657,9 @@ contract("CappedSTO", accounts => { let tx = await I_STRProxied.generateSecurityToken(P_name, P_symbol, P_tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, P_symbol, "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, P_symbol, "SecurityToken doesn't get deployed"); - I_SecurityToken_POLY = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken_POLY = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken_POLY.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/c_checkpoints.js b/test/c_checkpoints.js index 6a08b6dea..4f2771c45 100644 --- a/test/c_checkpoints.js +++ b/test/c_checkpoints.js @@ -119,9 +119,9 @@ contract("Checkpoints", accounts => { let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/d_count_transfer_manager.js b/test/d_count_transfer_manager.js index 1a1e7717a..f7c1be722 100644 --- a/test/d_count_transfer_manager.js +++ b/test/d_count_transfer_manager.js @@ -134,9 +134,9 @@ contract("CountTransferManager", accounts => { let _blockNo = latestBlock(); let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/e_erc20_dividends.js b/test/e_erc20_dividends.js index b832bcee2..67b88454f 100644 --- a/test/e_erc20_dividends.js +++ b/test/e_erc20_dividends.js @@ -141,9 +141,9 @@ contract("ERC20DividendCheckpoint", accounts => { let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); // Verify that GeneralTransferManager module get added successfully or not diff --git a/test/f_ether_dividends.js b/test/f_ether_dividends.js index b4e5bbf2b..ae1409942 100644 --- a/test/f_ether_dividends.js +++ b/test/f_ether_dividends.js @@ -138,9 +138,9 @@ contract("EtherDividendCheckpoint", accounts => { let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/g_general_permission_manager.js b/test/g_general_permission_manager.js index d554891ee..bc95b925d 100644 --- a/test/g_general_permission_manager.js +++ b/test/g_general_permission_manager.js @@ -138,9 +138,9 @@ contract('GeneralPermissionManager', accounts => { let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/h_general_transfer_manager.js b/test/h_general_transfer_manager.js index 3e060c288..ebabdaa3b 100644 --- a/test/h_general_transfer_manager.js +++ b/test/h_general_transfer_manager.js @@ -152,9 +152,9 @@ contract("GeneralTransferManager", accounts => { let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/i_Issuance.js b/test/i_Issuance.js index ac1fcdd37..61636f4ee 100644 --- a/test/i_Issuance.js +++ b/test/i_Issuance.js @@ -149,9 +149,9 @@ contract("Issuance", accounts => { let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: account_polymath }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol, "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/j_manual_approval_transfer_manager.js b/test/j_manual_approval_transfer_manager.js index 709991b92..4e3b2799f 100644 --- a/test/j_manual_approval_transfer_manager.js +++ b/test/j_manual_approval_transfer_manager.js @@ -145,9 +145,9 @@ contract("ManualApprovalTransferManager", accounts => { let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/k_module_registry.js b/test/k_module_registry.js index 193c53bad..4042a6fea 100644 --- a/test/k_module_registry.js +++ b/test/k_module_registry.js @@ -310,8 +310,8 @@ contract("ModuleRegistry", accounts => { await I_PolyToken.approve(I_STRProxied.address, web3.utils.toWei("500"), { from: account_issuer }); await I_STRProxied.registerTicker(account_issuer, symbol, name, { from: account_issuer }); let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, true, { from: account_issuer }); - assert.equal(tx.logs[1].args._ticker, symbol.toUpperCase()); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase()); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); }); it("Should fail in adding module. Because module is un-verified", async () => { diff --git a/test/l_percentage_transfer_manager.js b/test/l_percentage_transfer_manager.js index b15ee41a0..bc37b4663 100644 --- a/test/l_percentage_transfer_manager.js +++ b/test/l_percentage_transfer_manager.js @@ -154,9 +154,9 @@ contract("PercentageTransferManager", accounts => { let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/m_presale_sto.js b/test/m_presale_sto.js index a89932dc4..b6bdd2928 100644 --- a/test/m_presale_sto.js +++ b/test/m_presale_sto.js @@ -136,9 +136,9 @@ contract("PreSaleSTO", accounts => { let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol, "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/n_security_token_registry.js b/test/n_security_token_registry.js index 9000b87ed..dbb848312 100644 --- a/test/n_security_token_registry.js +++ b/test/n_security_token_registry.js @@ -512,9 +512,9 @@ contract("SecurityTokenRegistry", accounts => { let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol, "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/o_security_token.js b/test/o_security_token.js index 52521181e..272da38e9 100644 --- a/test/o_security_token.js +++ b/test/o_security_token.js @@ -169,9 +169,9 @@ contract("SecurityToken", accounts => { let _blockNo = latestBlock(); let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol, "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/p_usd_tiered_sto.js b/test/p_usd_tiered_sto.js index 5332700b4..96491e795 100644 --- a/test/p_usd_tiered_sto.js +++ b/test/p_usd_tiered_sto.js @@ -269,9 +269,9 @@ contract("USDTieredSTO", accounts => { await I_PolyToken.approve(I_STRProxied.address, REGFEE, { from: ISSUER }); let _blockNo = latestBlock(); let tx = await I_STRProxied.generateSecurityToken(NAME, SYMBOL, TOKENDETAILS, true, { from: ISSUER }); - assert.equal(tx.logs[1].args._ticker, SYMBOL, "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, SYMBOL, "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/q_usd_tiered_sto_sim.js b/test/q_usd_tiered_sto_sim.js index 53a12e74a..04b6a9b66 100644 --- a/test/q_usd_tiered_sto_sim.js +++ b/test/q_usd_tiered_sto_sim.js @@ -241,9 +241,9 @@ contract("USDTieredSTO Sim", accounts => { await I_PolyToken.approve(I_STRProxied.address, REGFEE, { from: ISSUER }); let _blockNo = latestBlock(); let tx = await I_STRProxied.generateSecurityToken(NAME, SYMBOL, TOKENDETAILS, true, { from: ISSUER }); - assert.equal(tx.logs[1].args._ticker, SYMBOL, "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, SYMBOL, "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/r_concurrent_STO.js b/test/r_concurrent_STO.js index 7912658a4..82bd68729 100644 --- a/test/r_concurrent_STO.js +++ b/test/r_concurrent_STO.js @@ -139,9 +139,9 @@ contract("Concurrent STO", accounts => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: account_issuer }); let _blockNo = latestBlock(); let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: account_issuer }); - assert.equal(tx.logs[1].args._ticker, symbol, "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/t_security_token_registry_proxy.js b/test/t_security_token_registry_proxy.js index 40b1cced8..264ab44b0 100644 --- a/test/t_security_token_registry_proxy.js +++ b/test/t_security_token_registry_proxy.js @@ -151,9 +151,9 @@ contract("SecurityTokenRegistryProxy", accounts => { let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol, "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/v_tracked_redemptions.js b/test/v_tracked_redemptions.js index 159564651..197c1d5bf 100644 --- a/test/v_tracked_redemptions.js +++ b/test/v_tracked_redemptions.js @@ -139,9 +139,9 @@ contract("TrackedRedemption", accounts => { let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo }), 1); diff --git a/test/w_lockup_volume_restriction_transfer_manager.js b/test/w_lockup_volume_restriction_transfer_manager.js index fe06f3f5c..71a5f49ec 100644 --- a/test/w_lockup_volume_restriction_transfer_manager.js +++ b/test/w_lockup_volume_restriction_transfer_manager.js @@ -133,9 +133,9 @@ contract('LockupVolumeRestrictionTransferManager', accounts => { let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({from: _blockNo}), 1); diff --git a/test/x_single_trade_volume_restriction.js b/test/x_single_trade_volume_restriction.js index 15c01e68c..aaf51a5f4 100644 --- a/test/x_single_trade_volume_restriction.js +++ b/test/x_single_trade_volume_restriction.js @@ -132,9 +132,9 @@ contract('SingleTradeVolumeRestrictionManager', accounts => { }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({ from: _blockNo diff --git a/test/y_scheduled_checkpoints.js b/test/y_scheduled_checkpoints.js index 5fcc03a74..f5319e474 100644 --- a/test/y_scheduled_checkpoints.js +++ b/test/y_scheduled_checkpoints.js @@ -128,9 +128,9 @@ contract('ScheduledCheckpoint', accounts => { let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); - I_SecurityToken = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken = SecurityToken.at(tx.logs[2].args._securityTokenAddress); const log = await promisifyLogWatch(I_SecurityToken.ModuleAdded({from: _blockNo}), 1); From 29bb4ec31e548654a7aeca52132f9336ca2e2cb9 Mon Sep 17 00:00:00 2001 From: Dmitriy Kostin Date: Thu, 8 Nov 2018 12:07:53 +0200 Subject: [PATCH 08/15] fix tests --- test/k_module_registry.js | 4 ++-- test/n_security_token_registry.js | 6 +++--- test/o_security_token.js | 32 ++++++++++++++++--------------- test/s_v130_to_v140_upgrade.js | 8 ++++---- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/test/k_module_registry.js b/test/k_module_registry.js index 4042a6fea..1756f4cb2 100644 --- a/test/k_module_registry.js +++ b/test/k_module_registry.js @@ -417,8 +417,8 @@ contract("ModuleRegistry", accounts => { await I_PolyToken.approve(I_STRProxied.address, web3.utils.toWei("500"), { from: account_issuer }); await I_STRProxied.registerTicker(account_issuer, newSymbol, name, { from: account_issuer }); let tx = await I_STRProxied.generateSecurityToken(name, newSymbol, tokenDetails, true, { from: account_issuer }); - assert.equal(tx.logs[1].args._ticker, newSymbol.toUpperCase()); - I_SecurityToken2 = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + assert.equal(tx.logs[2].args._ticker, newSymbol.toUpperCase()); + I_SecurityToken2 = SecurityToken.at(tx.logs[2].args._securityTokenAddress); let bytesData = encodeModuleCall( ["uint256", "uint256", "uint256", "string"], diff --git a/test/n_security_token_registry.js b/test/n_security_token_registry.js index dbb848312..0cb1bc131 100644 --- a/test/n_security_token_registry.js +++ b/test/n_security_token_registry.js @@ -583,9 +583,9 @@ contract("SecurityTokenRegistry", accounts => { let tx = await I_STRProxied.generateSecurityToken(name2, symbol2, tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, symbol2, "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, symbol2, "SecurityToken doesn't get deployed"); - I_SecurityToken002 = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + I_SecurityToken002 = SecurityToken.at(tx.logs[2].args._securityTokenAddress); let tokens = await I_STRProxied.getTokensByOwner.call(token_owner); assert.equal(tokens[0], I_SecurityToken.address); assert.equal(tokens[1], I_SecurityToken002.address); @@ -952,7 +952,7 @@ contract("SecurityTokenRegistry", accounts => { let tx = await I_STRProxied.generateSecurityToken("Polymath", "POLY", tokenDetails, false, { from: token_owner }); // Verify the successful generation of the security token - assert.equal(tx.logs[1].args._ticker, "POLY", "SecurityToken doesn't get deployed"); + assert.equal(tx.logs[2].args._ticker, "POLY", "SecurityToken doesn't get deployed"); }); }); diff --git a/test/o_security_token.js b/test/o_security_token.js index 272da38e9..1b89023d6 100644 --- a/test/o_security_token.js +++ b/test/o_security_token.js @@ -850,8 +850,8 @@ contract("SecurityToken", accounts => { let currentBalance = await I_SecurityToken.balanceOf(account_temp); // console.log(currentInvestorCount.toString(), currentBalance.toString()); let tx = await I_SecurityToken.forceBurn(account_temp, currentBalance, "", "", { from: account_controller }); - // console.log(tx.logs[0].args._value.toNumber(), currentBalance.toNumber()); - assert.equal(tx.logs[0].args._value.toNumber(), currentBalance.toNumber()); + // console.log(tx.logs[1].args._value.toNumber(), currentBalance.toNumber()); + assert.equal(tx.logs[1].args._value.toNumber(), currentBalance.toNumber()); let newInvestorCount = await I_SecurityToken.getInvestorCount.call(); // console.log(newInvestorCount.toString()); assert.equal(newInvestorCount.toNumber() + 1, currentInvestorCount.toNumber(), "Investor count drops by one"); @@ -1085,19 +1085,21 @@ contract("SecurityToken", accounts => { end_balInv2.toNumber(), "Investor balance not changed" ); - console.log(tx.logs[0].args); - console.log(tx.logs[1].args); - assert.equal(account_controller, tx.logs[0].args._controller, "Event not emitted as expected"); - assert.equal(account_investor1, tx.logs[0].args._from, "Event not emitted as expected"); - assert.equal(account_investor2, tx.logs[0].args._to, "Event not emitted as expected"); - assert.equal(web3.utils.toWei("10", "ether"), tx.logs[0].args._value, "Event not emitted as expected"); - console.log(tx.logs[0].args._verifyTransfer); - assert.equal(false, tx.logs[0].args._verifyTransfer, "Event not emitted as expected"); - assert.equal("reason", web3.utils.hexToUtf8(tx.logs[0].args._data), "Event not emitted as expected"); - - assert.equal(account_investor1, tx.logs[1].args.from, "Event not emitted as expected"); - assert.equal(account_investor2, tx.logs[1].args.to, "Event not emitted as expected"); - assert.equal(web3.utils.toWei("10", "ether"), tx.logs[1].args.value, "Event not emitted as expected"); + let eventForceTransfer = tx.logs[1]; + let eventTransfer = tx.logs[0]; + console.log(eventForceTransfer.args); + console.log(eventTransfer.args); + assert.equal(account_controller, eventForceTransfer.args._controller, "Event not emitted as expected"); + assert.equal(account_investor1, eventForceTransfer.args._from, "Event not emitted as expected"); + assert.equal(account_investor2, eventForceTransfer.args._to, "Event not emitted as expected"); + assert.equal(web3.utils.toWei("10", "ether"), eventForceTransfer.args._value, "Event not emitted as expected"); + console.log(eventForceTransfer.args._verifyTransfer); + assert.equal(false, eventForceTransfer.args._verifyTransfer, "Event not emitted as expected"); + assert.equal("reason", web3.utils.hexToUtf8(eventForceTransfer.args._data), "Event not emitted as expected"); + + assert.equal(account_investor1, eventTransfer.args.from, "Event not emitted as expected"); + assert.equal(account_investor2, eventTransfer.args.to, "Event not emitted as expected"); + assert.equal(web3.utils.toWei("10", "ether"), eventTransfer.args.value, "Event not emitted as expected"); }); it("Should fail to freeze controller functionality because not owner", async () => { diff --git a/test/s_v130_to_v140_upgrade.js b/test/s_v130_to_v140_upgrade.js index 3fb3092aa..1cfa0eb67 100644 --- a/test/s_v130_to_v140_upgrade.js +++ b/test/s_v130_to_v140_upgrade.js @@ -151,14 +151,14 @@ contract("Upgrade from v1.3.0 to v1.4.0", accounts => { // (A) : TOK1 await I_PolyToken.approve(I_STRProxied.address, REGFEE, { from: ISSUER1 }); let tx = await I_STRProxied.generateSecurityToken(name1, symbol1, tokenDetails1, false, { from: ISSUER1 }); - assert.equal(tx.logs[1].args._ticker, symbol1, "SecurityToken doesn't get deployed"); - I_SecurityToken1 = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + assert.equal(tx.logs[2].args._ticker, symbol1, "SecurityToken doesn't get deployed"); + I_SecurityToken1 = SecurityToken.at(tx.logs[2].args._securityTokenAddress); // (B) : TOK2 await I_PolyToken.approve(I_STRProxied.address, REGFEE, { from: ISSUER2 }); tx = await I_STRProxied.generateSecurityToken(name2, symbol2, tokenDetails2, false, { from: ISSUER2 }); - assert.equal(tx.logs[1].args._ticker, symbol2, "SecurityToken doesn't get deployed"); - I_SecurityToken2 = SecurityToken.at(tx.logs[1].args._securityTokenAddress); + assert.equal(tx.logs[2].args._ticker, symbol2, "SecurityToken doesn't get deployed"); + I_SecurityToken2 = SecurityToken.at(tx.logs[2].args._securityTokenAddress); // Printing all the contract addresses console.log(` From 6c978304ddb0f639196a26a92ee77cb1b1126091 Mon Sep 17 00:00:00 2001 From: Dmitriy Kostin Date: Thu, 8 Nov 2018 15:01:17 +0200 Subject: [PATCH 09/15] fixed SecurityToken._burn --- contracts/tokens/SecurityToken.sol | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index 7f8554e17..3949d4539 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -722,11 +722,7 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater require(_value <= balanceOf(_from), "Value too high"); bool verified = _updateTransfer(_from, address(0), _value, _data); _adjustTotalSupplyCheckpoints(); - if (msg.sender == _from) { - _burn(_from, _value); - } else { - _burnFrom(_from, _value); - } + _burn(_from, _value); emit Burnt(_from, _value); return verified; } @@ -740,6 +736,15 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater require(_burn(msg.sender, _value, _data), "Burn invalid"); } + function _burnFrom(address _from, uint256 _value, bytes _data) internal returns(bool) { + require(_value <= balanceOf(_from), "Value too high"); + bool verified = _updateTransfer(_from, address(0), _value, _data); + _adjustTotalSupplyCheckpoints(); + _burnFrom(_from, _value); + emit Burnt(_from, _value); + return verified; + } + /** * @notice Burn function used to burn the securityToken on behalf of someone else * @param _from Address for whom to burn tokens @@ -747,7 +752,8 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater * @param _data data to indicate validation */ function burnFromWithData(address _from, uint256 _value, bytes _data) public onlyModule(BURN_KEY) { - require(_burn(_from, _value, _data), "Burn invalid"); + require(_value <= allowance(_from, msg.sender), "Value too high"); + require(_burnFrom(_from, _value, _data), "Burn invalid"); } /** From bdaa8150bfb9b2cc54973f2b05221a32025ff3e1 Mon Sep 17 00:00:00 2001 From: Dmitriy Kostin Date: Fri, 9 Nov 2018 10:08:54 +0200 Subject: [PATCH 10/15] Removed redundant checking. --- contracts/tokens/SecurityToken.sol | 4 ---- 1 file changed, 4 deletions(-) diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index 3949d4539..e4a8f1218 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -678,7 +678,6 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater uint256 _value, bytes _data ) public onlyModuleOrOwner(MINT_KEY) isMintingAllowed() returns (bool success) { - require(_investor != address(0), "Investor is 0"); require(_updateTransfer(address(0), _investor, _value, _data), "Transfer invalid"); _adjustTotalSupplyCheckpoints(); _mint(_investor, _value); @@ -719,7 +718,6 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater } function _burn(address _from, uint256 _value, bytes _data) internal returns(bool) { - require(_value <= balanceOf(_from), "Value too high"); bool verified = _updateTransfer(_from, address(0), _value, _data); _adjustTotalSupplyCheckpoints(); _burn(_from, _value); @@ -752,7 +750,6 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater * @param _data data to indicate validation */ function burnFromWithData(address _from, uint256 _value, bytes _data) public onlyModule(BURN_KEY) { - require(_value <= allowance(_from, msg.sender), "Value too high"); require(_burnFrom(_from, _value, _data), "Burn invalid"); } @@ -830,7 +827,6 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater */ function forceTransfer(address _from, address _to, uint256 _value, bytes _data, bytes _log) public onlyController { require(_to != address(0)); - require(_value <= balanceOf(_from)); bool verified = _updateTransfer(_from, _to, _value, _data); _transfer(_from, _to, _value); emit ForceTransfer(msg.sender, _from, _to, _value, verified, _log); From f1e1512d769efb1ff32bc45d418d602804311beb Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Fri, 9 Nov 2018 16:02:07 +0530 Subject: [PATCH 11/15] fix merge --- package.json | 2 +- yarn.lock | 227 ++++++++++++++++++++++++++------------------------- 2 files changed, 115 insertions(+), 114 deletions(-) diff --git a/package.json b/package.json index 744c3bc39..c4517ae4f 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "ethereumjs-testrpc": "^6.0.3", "ethers": "^4.0.7", "fs": "0.0.2", - "openzeppelin-solidity": "1.10.0", + "openzeppelin-solidity": "2.0.0", "readline-sync": "^1.4.9", "request": "^2.88.0", "request-promise": "^4.2.2", diff --git a/yarn.lock b/yarn.lock index aba68e85b..899a36f02 100644 --- a/yarn.lock +++ b/yarn.lock @@ -73,15 +73,10 @@ acorn-dynamic-import@^2.0.0: dependencies: acorn "^4.0.3" -acorn-jsx@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b" - dependencies: - acorn "^3.0.4" - -acorn@^3.0.4: - version "3.3.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" +acorn-jsx@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.0.0.tgz#958584ddb60990c02c97c1bd9d521fce433bb101" + integrity sha512-XkB50fn0MURDyww9+UYL3c1yLbOBz0ZFvrdYlGB8l+Ije1oSC75qAqrzSPjYQbdnQUzhlUGNKuesryAv0gxZOg== acorn@^4.0.3: version "4.0.13" @@ -104,10 +99,6 @@ aes-js@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.1.1.tgz#89fd1f94ae51b4c72d62466adc1a7323ff52f072" -ajv-keywords@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762" - ajv-keywords@^3.1.0: version "3.2.0" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.2.0.tgz#e86b819c602cf8821ad637413698f1dec021847a" @@ -130,6 +121,16 @@ ajv@^6.1.0: json-schema-traverse "^0.4.1" uri-js "^4.2.2" +ajv@^6.5.3: + version "6.5.5" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.5.5.tgz#cf97cdade71c6399a92c6d6c4177381291b781a1" + integrity sha512-7q7gtRQDJSyuEHjuVgHoUa2VuemFiCMrfQc9Tc08XTAc4Zj/5U1buQJ0HU6i7fKjXU09SVgSmxa4sLvuvS8Iyg== + dependencies: + fast-deep-equal "^2.0.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + align-text@^0.1.1, align-text@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" @@ -984,13 +985,10 @@ bignumber.js@^4.0.2: version "4.1.0" resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-4.1.0.tgz#db6f14067c140bd46624815a7916c92d9b6c24b1" -bignumber.js@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-5.0.0.tgz#fbce63f09776b3000a83185badcde525daf34833" - -bignumber.js@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-6.0.0.tgz#bbfa047644609a5af093e9cbd83b0461fa3f6002" +bignumber.js@^7.2.1: + version "7.2.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-7.2.1.tgz#80c048759d826800807c4bfd521e50edbba57a5f" + integrity sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ== "bignumber.js@git+https://github.com/debris/bignumber.js#master": version "2.0.7" @@ -1088,7 +1086,7 @@ borc@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/borc/-/borc-2.0.3.tgz#08845ea73a6d3211120928ee3929f8dc2de9f52e" dependencies: - bignumber.js "^7.2.1" + bignumber.js "^6.0.0" commander "^2.15.0" ieee754 "^1.1.8" json-text-sequence "^0.1" @@ -1369,9 +1367,10 @@ chalk@^2.0.0, chalk@^2.1.0, chalk@^2.3.1, chalk@^2.4.1: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chardet@^0.4.0: - version "0.4.2" - resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" +chardet@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" + integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== checkpoint-store@^1.1.0: version "1.1.0" @@ -1526,13 +1525,7 @@ colors@^1.1.2: version "1.3.2" resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.2.tgz#2df8ff573dfbf255af562f8ce7181d6b971a359b" -combined-stream@1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" - dependencies: - delayed-stream "~1.0.0" - -combined-stream@~1.0.6: +combined-stream@^1.0.6, combined-stream@~1.0.6: version "1.0.7" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.7.tgz#2d1d24317afb8abe95d6d2c0b07b57813539d828" dependencies: @@ -1572,15 +1565,6 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -concat-stream@^1.6.0: - version "1.6.2" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" - dependencies: - buffer-from "^1.0.0" - inherits "^2.0.3" - readable-stream "^2.2.2" - typedarray "^0.0.6" - console-browserify@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10" @@ -2238,9 +2222,10 @@ escope@^3.6.0: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint-config-standard@^11.0.0: - version "11.0.0" - resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-11.0.0.tgz#87ee0d3c9d95382dc761958cbb23da9eea31e0ba" +eslint-config-standard@^12.0.0: + version "12.0.0" + resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-12.0.0.tgz#638b4c65db0bd5a41319f96bba1f15ddad2107d9" + integrity sha512-COUz8FnXhqFitYj4DTqHzidjIL/t4mumGZto5c7DrBpvWoie+Sn3P4sLEzUGeYhRElWuFEf8K1S1EfvD1vixCQ== eslint-import-resolver-node@^0.3.1: version "0.3.2" @@ -2279,9 +2264,10 @@ eslint-plugin-import@^2.10.0: read-pkg-up "^2.0.0" resolve "^1.6.0" -eslint-plugin-node@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-6.0.1.tgz#bf19642298064379315d7a4b2a75937376fa05e4" +eslint-plugin-node@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-8.0.0.tgz#fb9e8911f4543514f154bb6a5924b599aa645568" + integrity sha512-Y+ln8iQ52scz9+rSPnSWRaAxeWaoJZ4wIveDR0vLHkuSZGe44Vk1J4HX7WvEP5Cm+iXPE8ixo7OM7gAO3/OKpQ== dependencies: eslint-plugin-es "^1.3.1" eslint-utils "^1.3.1" @@ -2290,17 +2276,20 @@ eslint-plugin-node@^6.0.1: resolve "^1.8.1" semver "^5.5.0" -eslint-plugin-promise@^3.7.0: - version "3.8.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.8.0.tgz#65ebf27a845e3c1e9d6f6a5622ddd3801694b621" +eslint-plugin-promise@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-4.0.1.tgz#2d074b653f35a23d1ba89d8e976a985117d1c6a2" + integrity sha512-Si16O0+Hqz1gDHsys6RtFRrW7cCTB6P7p3OJmKp3Y3dxpQE2qwOA7d3xnV+0mBmrPoi0RBnxlCKvqu70te6wjg== -eslint-plugin-standard@^3.0.1: - version "3.1.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-3.1.0.tgz#2a9e21259ba4c47c02d53b2d0c9135d4b1022d47" +eslint-plugin-standard@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-4.0.0.tgz#f845b45109c99cd90e77796940a344546c8f6b5c" + integrity sha512-OwxJkR6TQiYMmt1EsNRMe5qG3GsbjlcOhbGUBY4LtavF9DsLaTcoR+j2Tdjqi23oUwKNUqX7qcn5fPStafMdlA== -eslint-scope@^3.7.1: - version "3.7.3" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.3.tgz#bb507200d3d17f60247636160b4826284b108535" +eslint-scope@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.0.tgz#50bf3071e9338bcdc43331794a0cb533f0136172" + integrity sha512-1G6UTDi7Jc1ELFwnR58HV4fK9OQK4S6N985f166xqXxpjU6plxFISJa2Ba9KCQuFa8RCnj/lSFJbHo7UFDBnUA== dependencies: esrecurse "^4.1.0" estraverse "^4.1.1" @@ -2314,9 +2303,10 @@ eslint-visitor-keys@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" -eslint@^4.19.1: - version "4.19.1" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.19.1.tgz#32d1d653e1d90408854bfb296f076ec7e186a300" +eslint@^5.8.0: + version "5.8.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.8.0.tgz#91fbf24f6e0471e8fdf681a4d9dd1b2c9f28309b" + integrity sha512-Zok6Bru3y2JprqTNm14mgQ15YQu/SMDkWdnmHfFg770DIUlmMFd/gqqzCHekxzjHZJxXv3tmTpH0C1icaYJsRQ== dependencies: "@babel/code-frame" "^7.0.0" ajv "^6.5.3" @@ -2357,9 +2347,10 @@ eslint@^4.19.1: table "^5.0.2" text-table "^0.2.0" -espree@^3.5.4: - version "3.5.4" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.4.tgz#b0f447187c8a8bed944b815a660bddf5deb5d1a7" +espree@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-4.1.0.tgz#728d5451e0fd156c04384a7ad89ed51ff54eb25f" + integrity sha512-I5BycZW6FCVIub93TeVY1s7vjhP9CY6cXCznIRfiig7nRviKZYdRnj/sHEWC6A7WE9RDWOFq9+7OsWSYz8qv2w== dependencies: acorn "^6.0.2" acorn-jsx "^5.0.0" @@ -2608,9 +2599,10 @@ ethereumjs-wallet@^0.6.0: utf8 "^3.0.0" uuid "^3.3.2" -ethers@^3.0.15: - version "3.0.29" - resolved "https://registry.yarnpkg.com/ethers/-/ethers-3.0.29.tgz#ce8139955b4ed44456eb6764b089bb117c86775d" +ethers@^4.0.7: + version "4.0.9" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-4.0.9.tgz#82bb075b1b3da847d672426cb24685371389155d" + integrity sha512-GcPAI8yRCx/Sihk9OCBobERCvjnrLtvCIqJRJUuNUDlR81z9vyRS7siJ3gimPi1JUKMscrFBDOul4ZA9NM0jHA== dependencies: "@types/node" "^10.3.2" aes-js "3.0.0" @@ -2777,9 +2769,10 @@ extendr@^2.1.0: dependencies: typechecker "~2.0.1" -external-editor@^2.0.4: - version "2.2.0" - resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.2.0.tgz#045511cfd8d133f3846673d1047c154e214ad3d5" +external-editor@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.0.3.tgz#5866db29a97826dbe4bf3afd24070ead9ea43a27" + integrity sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA== dependencies: chardet "^0.7.0" iconv-lite "^0.4.24" @@ -2972,7 +2965,7 @@ form-data@~2.3.2: resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.2.tgz#4970498be604c20c005d4f5c23aecd21d6b49099" dependencies: asynckit "^0.4.0" - combined-stream "^1.0.6" + combined-stream "1.0.6" mime-types "^2.1.12" forwarded@~0.1.2: @@ -3045,9 +3038,10 @@ fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" -fs@0.0.1-security: - version "0.0.1-security" - resolved "https://registry.yarnpkg.com/fs/-/fs-0.0.1-security.tgz#8a7bd37186b6dddf3813f23858b57ecaaf5e41d4" +fs@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/fs/-/fs-0.0.2.tgz#e1f244ef3933c1b2a64bd4799136060d0f5914f8" + integrity sha1-4fJE7zkzwbKmS9R5kTYGDQ9ZFPg= fsevents@^1.0.0, fsevents@^1.2.2: version "1.2.4" @@ -3441,9 +3435,15 @@ ignore-walk@^3.0.1: dependencies: minimatch "^3.0.4" -ignore@^3.3.3, ignore@^3.3.6: - version "3.3.10" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043" +ignore@^4.0.6: + version "4.0.6" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" + integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== + +ignore@^5.0.2: + version "5.0.4" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.0.4.tgz#33168af4a21e99b00c5d41cbadb6a6cb49903a45" + integrity sha512-WLsTMEhsQuXpCiG173+f3aymI43SXa+fB1rSfbzyP4GkPP+ZFVuO0/3sFUGNBtifisPeDcl/uD/Y2NxZ7xFq4g== ignorefs@^1.0.0: version "1.2.0" @@ -3487,9 +3487,10 @@ ini@~1.3.0: version "1.3.5" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" -inquirer@^3.0.6: - version "3.3.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9" +inquirer@^6.1.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.2.0.tgz#51adcd776f661369dc1e894859c2560a224abdd8" + integrity sha512-QIEQG4YyQ2UYZGDC4srMZ7BjHOmNk1lR2JQj5UknBapklm6WHA+VVH7N+sUdX3A7NeCfGF8o4X1S3Ao7nAcIeg== dependencies: ansi-escapes "^3.0.0" chalk "^2.0.0" @@ -4326,15 +4327,16 @@ miller-rabin@^4.0.0: bn.js "^4.0.0" brorand "^1.0.1" -mime-db@~1.36.0: - version "1.36.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.36.0.tgz#5020478db3c7fe93aad7bbcc4dcf869c43363397" +mime-db@~1.37.0: + version "1.37.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.37.0.tgz#0b6a0ce6fdbe9576e25f1f2d2fde8830dc0ad0d8" + integrity sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg== mime-types@^2.1.12, mime-types@^2.1.16, mime-types@~2.1.18, mime-types@~2.1.19: version "2.1.20" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.20.tgz#930cb719d571e903738520f8470911548ca2cc19" dependencies: - mime-db "~1.37.0" + mime-db "~1.36.0" mime@1.4.1: version "1.4.1" @@ -4766,9 +4768,10 @@ onetime@^2.0.0: dependencies: mimic-fn "^1.0.0" -openzeppelin-solidity@1.10.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/openzeppelin-solidity/-/openzeppelin-solidity-1.10.0.tgz#d77eee6653f5958d051318a61ba0b436f92216c0" +openzeppelin-solidity@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/openzeppelin-solidity/-/openzeppelin-solidity-2.0.0.tgz#b45dddbdae090f89577598c1a7e7518df61b7ba2" + integrity sha512-SolpxQFArtiYnlSNg3dZ9sz0WVlKtPqSOcJkXRllaZp4+Lpfqz3vxF0yoh7g75TszKPyadqoJmU7+GM/vwh9SA== optimist@^0.6.1: version "0.6.1" @@ -5175,7 +5178,7 @@ react-dom@^16.2.0: loose-envify "^1.1.0" object-assign "^4.1.1" prop-types "^15.6.2" - scheduler "^0.10.0" + schedule "^0.5.0" react@^16.2.0: version "16.5.2" @@ -5184,7 +5187,7 @@ react@^16.2.0: loose-envify "^1.1.0" object-assign "^4.1.1" prop-types "^15.6.2" - scheduler "^0.10.0" + schedule "^0.5.0" read-pkg-up@^1.0.1: version "1.0.1" @@ -5297,9 +5300,10 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" -regexpp@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-1.1.0.tgz#0e3516dd0b7904f413d2d4193dce4618c3a689ab" +regexpp@^2.0.0, regexpp@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" + integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== regexpu-core@^2.0.0: version "2.0.0" @@ -5488,15 +5492,12 @@ rustbn.js@~0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/rustbn.js/-/rustbn.js-0.2.0.tgz#8082cb886e707155fd1cb6f23bd591ab8d55d0ca" -rx-lite-aggregates@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be" +rxjs@^6.1.0: + version "6.3.3" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.3.3.tgz#3c6a7fa420e844a81390fb1158a9ec614f4bad55" + integrity sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw== dependencies: - rx-lite "*" - -rx-lite@*, rx-lite@^4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" + tslib "^1.9.0" safe-buffer@5.1.2, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" @@ -5540,9 +5541,10 @@ scandirectory@^2.5.0: safefs "^3.1.2" taskgroup "^4.0.5" -schedule@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/schedule/-/schedule-0.5.0.tgz#c128fffa0b402488b08b55ae74bb9df55cc29cc8" +scheduler@^0.10.0: + version "0.10.0" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.10.0.tgz#7988de90fe7edccc774ea175a783e69c40c521e1" + integrity sha512-+TSTVTCBAA3h8Anei3haDc1IRwMeDmtI/y/o3iBe3Mjl2vwYF9DtPDt929HyRmV/e7au7CLu8sc4C4W0VOs29w== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" @@ -5551,9 +5553,10 @@ scrypt-async@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/scrypt-async/-/scrypt-async-1.3.1.tgz#a11fd6fac981b4b823ee01dee0221169500ddae9" -scrypt-js@2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-2.0.3.tgz#bb0040be03043da9a012a2cea9fc9f852cfc87d4" +scrypt-js@2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-2.0.4.tgz#32f8c5149f0797672e551c07e230f834b6af5f16" + integrity sha512-4KsaGcPnuhtCZQCxFxN3GVYIhKFPTdLd8PLC552XwbMndtD0cjRFAhDuuydXQ0h08ZfPgzqe6EKHozpuH74iDw== scrypt.js@0.2.0, scrypt.js@^0.2.0: version "0.2.0" @@ -6162,9 +6165,10 @@ swarm-js@0.1.37: tar.gz "^1.0.5" xhr-request-promise "^0.1.2" -table@4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/table/-/table-4.0.2.tgz#a33447375391e766ad34d3486e6e2aedc84d2e36" +table@^5.0.2: + version "5.1.0" + resolved "https://registry.yarnpkg.com/table/-/table-5.1.0.tgz#69a54644f6f01ad1628f8178715b408dc6bf11f7" + integrity sha512-e542in22ZLhD/fOIuXs/8yDZ9W61ltF8daM88rkRNtgTIct+vI2fTnAyu/Db2TCfEcI8i7mjZz6meLq0nW7TYg== dependencies: ajv "^6.5.3" lodash "^4.17.10" @@ -6374,9 +6378,10 @@ truffle-error@^0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/truffle-error/-/truffle-error-0.0.3.tgz#4bf55242e14deee1c7194932709182deff2c97ca" -truffle-hdwallet-provider-privkey@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/truffle-hdwallet-provider-privkey/-/truffle-hdwallet-provider-privkey-0.1.0.tgz#9417047a74ad37d923df926154b6486ffb57f6c9" +truffle-hdwallet-provider-privkey@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/truffle-hdwallet-provider-privkey/-/truffle-hdwallet-provider-privkey-0.2.0.tgz#91e9e8a6a5005970a5b442fa89fc198ecd1f71ef" + integrity sha512-p4dCmB/roQaHaRMe7Ihej4/Cdmq7Usi6aZsPv/cc2x7S5bYLSwwpgQBdjz4PjPSgNh8zqLte6ZhWkkW1CEq1iQ== dependencies: ethereumjs-tx "^1.3.4" ethereumjs-wallet "^0.6.0" @@ -6455,10 +6460,6 @@ typedarray-to-buffer@^3.1.2: dependencies: is-typedarray "^1.0.0" -typedarray@^0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" - uglify-js@^2.8.29: version "2.8.29" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd" From 407e8928bfb31581513d145cf969dcb87cccb696 Mon Sep 17 00:00:00 2001 From: Dmitriy Kostin Date: Fri, 9 Nov 2018 13:03:07 +0200 Subject: [PATCH 12/15] Removed redundant checking. --- contracts/tokens/SecurityToken.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index 9c09343c6..dd78d011c 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -826,7 +826,6 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater * @param _log data attached to the transfer by controller to emit in event */ function forceTransfer(address _from, address _to, uint256 _value, bytes _data, bytes _log) public onlyController { - require(_to != address(0)); bool verified = _updateTransfer(_from, _to, _value, _data); _transfer(_from, _to, _value); emit ForceTransfer(msg.sender, _from, _to, _value, verified, _log); From 2ad42a03c4a3740ad7d0db17ac32c7c97ab86edf Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Mon, 12 Nov 2018 21:49:24 +0530 Subject: [PATCH 13/15] Coverage Fixed --- contracts/helpers/PolyToken.sol | 4 ++-- contracts/interfaces/{IERC20.sol => IPoly.sol} | 2 +- contracts/tokens/SecurityToken.sol | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) rename contracts/interfaces/{IERC20.sol => IPoly.sol} (98%) diff --git a/contracts/helpers/PolyToken.sol b/contracts/helpers/PolyToken.sol index d8f3d48ec..ab71ecfda 100644 --- a/contracts/helpers/PolyToken.sol +++ b/contracts/helpers/PolyToken.sol @@ -1,6 +1,6 @@ pragma solidity ^0.4.24; -import "../interfaces/IERC20.sol"; +import "../interfaces/IPoly.sol"; /* Copyright (c) 2016 Smart Contract Solutions, Inc. @@ -64,7 +64,7 @@ library SafeMath { * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 */ -contract PolyToken is IERC20 { +contract PolyToken is IPoly { using SafeMath for uint256; // Poly Token parameters diff --git a/contracts/interfaces/IERC20.sol b/contracts/interfaces/IPoly.sol similarity index 98% rename from contracts/interfaces/IERC20.sol rename to contracts/interfaces/IPoly.sol index b1d36463f..3d84a468b 100644 --- a/contracts/interfaces/IERC20.sol +++ b/contracts/interfaces/IPoly.sol @@ -4,7 +4,7 @@ pragma solidity ^0.4.24; * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ -interface IERC20 { +interface IPoly { function decimals() external view returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address _owner) external view returns (uint256); diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index dd78d011c..d59780465 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -1,7 +1,7 @@ pragma solidity ^0.4.24; import "openzeppelin-solidity/contracts/math/Math.sol"; -import {IERC20 as IERC20Poly} from "../interfaces/IERC20.sol"; +import "../interfaces/IPoly.sol"; import "../interfaces/IModule.sol"; import "../interfaces/IModuleFactory.sol"; import "../interfaces/IModuleRegistry.sol"; @@ -377,13 +377,13 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater */ function changeModuleBudget(address _module, uint256 _change, bool _increase) external onlyOwner { require(modulesToData[_module].module != address(0), "Module missing"); - uint256 currentAllowance = IERC20(polyToken).allowance(address(this), _module); + uint256 currentAllowance = IPoly(polyToken).allowance(address(this), _module); uint256 newAllowance; if (_increase) { - require(IERC20Poly(polyToken).increaseApproval(_module, _change), "IncreaseApproval fail"); + require(IPoly(polyToken).increaseApproval(_module, _change), "IncreaseApproval fail"); newAllowance = currentAllowance.add(_change); } else { - require(IERC20Poly(polyToken).decreaseApproval(_module, _change), "Insufficient allowance"); + require(IPoly(polyToken).decreaseApproval(_module, _change), "Insufficient allowance"); newAllowance = currentAllowance.sub(_change); } emit ModuleBudgetChanged(modulesToData[_module].moduleTypes, _module, currentAllowance, newAllowance); From 451e5713b836210a829668c35dd28552eff16e72 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Mon, 12 Nov 2018 21:51:17 +0530 Subject: [PATCH 14/15] Updated yarn.lock --- yarn.lock | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/yarn.lock b/yarn.lock index 899a36f02..33dc876ee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -985,10 +985,10 @@ bignumber.js@^4.0.2: version "4.1.0" resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-4.1.0.tgz#db6f14067c140bd46624815a7916c92d9b6c24b1" -bignumber.js@^7.2.1: - version "7.2.1" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-7.2.1.tgz#80c048759d826800807c4bfd521e50edbba57a5f" - integrity sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ== +bignumber.js@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-6.0.0.tgz#bbfa047644609a5af093e9cbd83b0461fa3f6002" + integrity sha512-x247jIuy60/+FtMRvscqfxtVHQf8AGx2hm9c6btkgC0x/hp9yt+teISNhvF8WlwRkCc5yF2fDECH8SIMe8j+GA== "bignumber.js@git+https://github.com/debris/bignumber.js#master": version "2.0.7" @@ -1525,7 +1525,14 @@ colors@^1.1.2: version "1.3.2" resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.2.tgz#2df8ff573dfbf255af562f8ce7181d6b971a359b" -combined-stream@^1.0.6, combined-stream@~1.0.6: +combined-stream@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" + integrity sha1-cj599ugBrFYTETp+RFqbactjKBg= + dependencies: + delayed-stream "~1.0.0" + +combined-stream@~1.0.6: version "1.0.7" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.7.tgz#2d1d24317afb8abe95d6d2c0b07b57813539d828" dependencies: @@ -4327,10 +4334,10 @@ miller-rabin@^4.0.0: bn.js "^4.0.0" brorand "^1.0.1" -mime-db@~1.37.0: - version "1.37.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.37.0.tgz#0b6a0ce6fdbe9576e25f1f2d2fde8830dc0ad0d8" - integrity sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg== +mime-db@~1.36.0: + version "1.36.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.36.0.tgz#5020478db3c7fe93aad7bbcc4dcf869c43363397" + integrity sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw== mime-types@^2.1.12, mime-types@^2.1.16, mime-types@~2.1.18, mime-types@~2.1.19: version "2.1.20" @@ -5541,12 +5548,11 @@ scandirectory@^2.5.0: safefs "^3.1.2" taskgroup "^4.0.5" -scheduler@^0.10.0: - version "0.10.0" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.10.0.tgz#7988de90fe7edccc774ea175a783e69c40c521e1" - integrity sha512-+TSTVTCBAA3h8Anei3haDc1IRwMeDmtI/y/o3iBe3Mjl2vwYF9DtPDt929HyRmV/e7au7CLu8sc4C4W0VOs29w== +schedule@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/schedule/-/schedule-0.5.0.tgz#c128fffa0b402488b08b55ae74bb9df55cc29cc8" + integrity sha512-HUcJicG5Ou8xfR//c2rPT0lPIRR09vVvN81T9fqfVgBmhERUbDEQoYKjpBxbueJnCPpSu2ujXzOnRQt6x9o/jw== dependencies: - loose-envify "^1.1.0" object-assign "^4.1.1" scrypt-async@^1.2.0: From 1af4a2e7c2a249b8b3cc85e9d8545757518d71a6 Mon Sep 17 00:00:00 2001 From: Adam Dossa Date: Wed, 14 Nov 2018 15:27:28 +0000 Subject: [PATCH 15/15] Some function name changes to avoid namespace clashes with OZ --- contracts/tokens/SecurityToken.sol | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index d59780465..9cb54865c 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -717,7 +717,7 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater return false; } - function _burn(address _from, uint256 _value, bytes _data) internal returns(bool) { + function _checkAndBurn(address _from, uint256 _value, bytes _data) internal returns(bool) { bool verified = _updateTransfer(_from, address(0), _value, _data); _adjustTotalSupplyCheckpoints(); _burn(_from, _value); @@ -731,11 +731,10 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater * @param _data data to indicate validation */ function burnWithData(uint256 _value, bytes _data) public onlyModule(BURN_KEY) { - require(_burn(msg.sender, _value, _data), "Burn invalid"); + require(_checkAndBurn(msg.sender, _value, _data), "Burn invalid"); } - function _burnFrom(address _from, uint256 _value, bytes _data) internal returns(bool) { - require(_value <= balanceOf(_from), "Value too high"); + function _checkAndBurnFrom(address _from, uint256 _value, bytes _data) internal returns(bool) { bool verified = _updateTransfer(_from, address(0), _value, _data); _adjustTotalSupplyCheckpoints(); _burnFrom(_from, _value); @@ -750,7 +749,7 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater * @param _data data to indicate validation */ function burnFromWithData(address _from, uint256 _value, bytes _data) public onlyModule(BURN_KEY) { - require(_burnFrom(_from, _value, _data), "Burn invalid"); + require(_checkAndBurnFrom(_from, _value, _data), "Burn invalid"); } /** @@ -839,7 +838,7 @@ contract SecurityToken is ERC20, ERC20Detailed, ReentrancyGuard, RegistryUpdater * @param _log data attached to the transfer by controller to emit in event */ function forceBurn(address _from, uint256 _value, bytes _data, bytes _log) public onlyController { - bool verified = _burn(_from, _value, _data); + bool verified = _checkAndBurn(_from, _value, _data); emit ForceBurn(msg.sender, _from, _value, verified, _log); }