diff options
Diffstat (limited to 'test')
97 files changed, 1832 insertions, 873 deletions
diff --git a/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol b/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol index 16219aa2..8d0c1a3f 100644 --- a/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol +++ b/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol @@ -15,7 +15,7 @@ contract MultiSigWalletFactory is Factory { public returns (address wallet) { - wallet = new MultiSigWallet(_owners, _required); + wallet = address(new MultiSigWallet(_owners, _required)); register(wallet); } } diff --git a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol index e4cfc031..f897d938 100644 --- a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol +++ b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol @@ -16,7 +16,7 @@ contract MultiSigWalletWithDailyLimitFactory is Factory { public returns (address wallet) { - wallet = new MultiSigWalletWithDailyLimit(_owners, _required, _dailyLimit); + wallet = address(new MultiSigWalletWithDailyLimit(_owners, _required, _dailyLimit)); register(wallet); } } diff --git a/test/compilationTests/corion/announcementTypes.sol b/test/compilationTests/corion/announcementTypes.sol index f31d580e..94f4a9dc 100644 --- a/test/compilationTests/corion/announcementTypes.sol +++ b/test/compilationTests/corion/announcementTypes.sol @@ -1,35 +1,35 @@ -pragma solidity ^0.4.11;
-
-contract announcementTypes {
-
- enum announcementType {
- /*
- type of announcements
- */
- newModule,
- dropModule,
- replaceModule,
- replaceModuleHandler,
- question,
- transactionFeeRate,
- transactionFeeMin,
- transactionFeeMax,
- transactionFeeBurn,
- providerPublicFunds,
- providerPrivateFunds,
- providerPrivateClientLimit,
- providerPublicMinRate,
- providerPublicMaxRate,
- providerPrivateMinRate,
- providerPrivateMaxRate,
- providerGasProtect,
- providerInterestMinFunds,
- providerRentRate,
- schellingRoundBlockDelay,
- schellingCheckRounds,
- schellingCheckAboves,
- schellingRate,
- publisherMinAnnouncementDelay,
- publisherOppositeRate
- }
+pragma solidity ^0.4.11; + +contract announcementTypes { + + enum announcementType { + /* + type of announcements + */ + newModule, + dropModule, + replaceModule, + replaceModuleHandler, + question, + transactionFeeRate, + transactionFeeMin, + transactionFeeMax, + transactionFeeBurn, + providerPublicFunds, + providerPrivateFunds, + providerPrivateClientLimit, + providerPublicMinRate, + providerPublicMaxRate, + providerPrivateMinRate, + providerPrivateMaxRate, + providerGasProtect, + providerInterestMinFunds, + providerRentRate, + schellingRoundBlockDelay, + schellingCheckRounds, + schellingCheckAboves, + schellingRate, + publisherMinAnnouncementDelay, + publisherOppositeRate + } }
\ No newline at end of file diff --git a/test/compilationTests/corion/ico.sol b/test/compilationTests/corion/ico.sol index 2f60e0fe..b1e0bf75 100644 --- a/test/compilationTests/corion/ico.sol +++ b/test/compilationTests/corion/ico.sol @@ -6,7 +6,7 @@ import "./premium.sol"; import "./moduleHandler.sol"; contract ico is safeMath { - + struct icoLevels_s { uint256 block; uint8 rate; @@ -24,9 +24,9 @@ contract ico is safeMath { uint256 cor; uint256 corp; } - + uint256 constant oneSegment = 40320; - + address public owner; address public tokenAddr; address public premiumAddr; @@ -53,7 +53,7 @@ contract ico is safeMath { constructor(address foundation, address priceSet, uint256 exchangeRate, uint256 startBlockNum, address[] memory genesisAddr, uint256[] memory genesisValue) public { /* Installation function. - + @foundation The ETC address of the foundation @priceSet The address which will be able to make changes on the rate later on. @exchangeRate The current ETC/USD rate multiplied by 1e4. For example: 2.5 USD/ETC = 25000 @@ -80,11 +80,11 @@ contract ico is safeMath { interestDB[genesisAddr[a]][0].amount = genesisValue[a]; } } - + function ICObonus() public view returns(uint256 bonus) { /* Query of current bonus - + @bonus Bonus % */ for ( uint8 a=0 ; a<icoLevels.length ; a++ ) { @@ -93,32 +93,32 @@ contract ico is safeMath { } } } - + function setInterestDB(address addr, uint256 balance) external returns(bool success) { /* Setting interest database. It can be requested by Token contract only. - A database has to be built in order that after ICO closed everybody can get their compound interest on their capital accumulated - + A database has to be built in order that after ICO closed everybody can get their compound interest on their capital accumulated + @addr Sender @balance Quantity - + @success Was the process successful or not */ require( msg.sender == tokenAddr ); uint256 _num = (block.number - startBlock) / interestBlockDelay; interestDB[addr][_num].amount = balance; - if ( balance == 0 ) { + if ( balance == 0 ) { interestDB[addr][_num].empty = true; } return true; } - + function checkInterest(address addr) public view returns(uint256 amount) { /* Query of compound interest - + @addr Address - + @amount Amount of compound interest */ uint256 _lastBal; @@ -126,9 +126,9 @@ contract ico is safeMath { bool _empty; interest_s memory _idb; uint256 _to = (block.number - startBlock) / interestBlockDelay; - + if ( _to == 0 || aborted ) { return 0; } - + for ( uint256 r=0 ; r < _to ; r++ ) { if ( r*interestBlockDelay+startBlock >= icoDelay ) { break; } _idb = interestDB[addr][r]; @@ -148,11 +148,11 @@ contract ico is safeMath { amount += _tamount; } } - + function getInterest(address beneficiary) external { /* Request of compound interest. This is deleted from the database after the ICO closed and following the query of the compound interest. - + @beneficiary Beneficiary who will receive the interest */ uint256 _lastBal; @@ -163,10 +163,10 @@ contract ico is safeMath { address _addr = beneficiary; uint256 _to = (block.number - startBlock) / interestBlockDelay; if ( _addr == address(0x00) ) { _addr = msg.sender; } - + require( block.number > icoDelay ); require( ! aborted ); - + for ( uint256 r=0 ; r < _to ; r++ ) { if ( r*interestBlockDelay+startBlock >= icoDelay ) { break; } _idb = interestDB[msg.sender][r]; @@ -186,17 +186,17 @@ contract ico is safeMath { _amount += _tamount; delete interestDB[msg.sender][r]; } - + require( _amount > 0 ); token(tokenAddr).mint(_addr, _amount); } - + function setICOEthPrice(uint256 value) external { /* - Setting of the ICO ETC USD rates which can only be calle by a pre-defined address. + Setting of the ICO ETC USD rates which can only be calle by a pre-defined address. After this function is completed till the call of the next function (which is at least an exchangeRateDelay array) this rate counts. With this process avoiding the sudden rate changes. - + @value The ETC/USD rate multiplied by 1e4. For example: 2.5 USD/ETC = 25000 */ require( isICO() ); @@ -205,18 +205,18 @@ contract ico is safeMath { icoExchangeRateSetBlock = block.number + exchangeRateDelay; icoExchangeRate = value; } - + function extendICO() external { /* Extend the period of the ICO with one segment. - + It is only possible during the ICO and only callable by the owner. */ require( isICO() ); require( msg.sender == owner ); icoDelay += oneSegment; } - + function closeICO() external { /* Closing the ICO. @@ -235,10 +235,10 @@ contract ico is safeMath { require( token(tokenAddr).closeIco() ); require( premium(premiumAddr).closeIco() ); } - + function abortICO() external { /* - Withdrawal of the ICO. + Withdrawal of the ICO. It is only possible during the ICO period. Only callable by the owner. After this process only the receiveFunds function will be available for the customers. @@ -247,12 +247,12 @@ contract ico is safeMath { require( msg.sender == owner ); aborted = true; } - + function connectTokens(address tokenContractAddr, address premiumContractAddr) external { /* Installation function which joins the two token contracts with this contract. Only callable by the owner - + @tokenContractAddr Address of the corion token contract. @premiumContractAddr Address of the corion premium token contract */ @@ -261,7 +261,7 @@ contract ico is safeMath { tokenAddr = tokenContractAddr; premiumAddr = premiumContractAddr; } - + function receiveFunds() external { /* Refund the amount which was purchased during the ICO period. @@ -274,7 +274,7 @@ contract ico is safeMath { delete brought[msg.sender]; require( msg.sender.send(_val) ); } - + function () external payable { /* Callback function. Simply calls the buy function as a beneficiary and there is no affiliate address. @@ -287,7 +287,7 @@ contract ico is safeMath { function buy(address beneficiaryAddress, address affilateAddress) public payable returns (bool success) { /* Buying a token - + If there is not at least 0.2 ether balance on the beneficiaryAddress then the amount of the ether which was intended for the purchase will be reduced by 0.2 and that will be sent to the address of the beneficiary. From the remaining amount calculate the reward with the help of the getIcoReward function. Only that affiliate address is valid which has some token on it’s account. @@ -327,7 +327,7 @@ contract ico is safeMath { rate = 4; } else if (extra >= 1e10) { rate = 3; - } else if (extra >= 1e9) { + } else if (extra >= 1e9) { rate = 2; } else { rate = 1; @@ -344,7 +344,7 @@ contract ico is safeMath { function checkPremium(address owner) internal { /* Crediting the premium token - + @owner The corion token balance of this address will be set based on the calculation which shows that how many times can be the amount of the purchased tokens divided by 5000. So after each 5000 token we give 1 premium token. */ uint256 _reward = (brought[owner].cor / 5e9) - brought[owner].corp; @@ -354,11 +354,11 @@ contract ico is safeMath { totalPremiumMint = safeAdd(totalPremiumMint, _reward); } } - + function getIcoReward(uint256 value) public view returns (uint256 reward) { /* Expected token volume at token purchase - + @value The amount of ether for the purchase @reward Amount of the token x = (value * 1e6 * USD_ETC_exchange rate / 1e4 / 1e18) * bonus percentage @@ -367,10 +367,10 @@ contract ico is safeMath { reward = (value * 1e6 * icoExchangeRate / icoExchangeRateM / 1 ether) * (ICObonus() + 100) / 100; if ( reward < 5e6) { return 0; } } - + function isICO() public view returns (bool success) { return startBlock <= block.number && block.number <= icoDelay && ( ! aborted ) && ( ! closed ); } - + event EICO(address indexed Address, uint256 indexed value, address Affiliate, uint256 AffilateValue); } diff --git a/test/compilationTests/corion/module.sol b/test/compilationTests/corion/module.sol index e0084ea5..da4dd344 100644 --- a/test/compilationTests/corion/module.sol +++ b/test/compilationTests/corion/module.sol @@ -9,18 +9,18 @@ contract module { /* Module */ - + enum status { New, Connected, Disconnected, Disabled } - + status public moduleStatus; uint256 public disabledUntil; address public moduleHandlerAddress; - + function disableModule(bool forever) external onlyForModuleHandler returns (bool success) { _disableModule(forever); return true; @@ -29,13 +29,13 @@ contract module { /* Disable the module for one week, if the forever true then for forever. This function calls the Publisher module. - + @forever For forever or not */ if ( forever ) { moduleStatus = status.Disabled; } else { disabledUntil = block.number + 5760; } } - + function replaceModuleHandler(address newModuleHandlerAddress) external onlyForModuleHandler returns (bool success) { _replaceModuleHandler(newModuleHandlerAddress); return true; @@ -44,13 +44,13 @@ contract module { /* Replace the ModuleHandler address. This function calls the Publisher module. - + @newModuleHandlerAddress New module handler address */ require( moduleStatus == status.Connected ); moduleHandlerAddress = newModuleHandlerAddress; } - + function connectModule() external onlyForModuleHandler returns (bool success) { _connectModule(); return true; @@ -63,7 +63,7 @@ contract module { require( moduleStatus == status.New ); moduleStatus = status.Connected; } - + function disconnectModule() external onlyForModuleHandler returns (bool success) { _disconnectModule(); return true; @@ -76,7 +76,7 @@ contract module { require( moduleStatus != status.New && moduleStatus != status.Disconnected ); moduleStatus = status.Disconnected; } - + function replaceModule(address newModuleAddress) external onlyForModuleHandler returns (bool success) { _replaceModule(newModuleAddress); return true; @@ -86,7 +86,7 @@ contract module { Replace the module for an another new module. This function calls the Publisher module. We send every Token and ether to the new module. - + @newModuleAddress New module handler address */ require( moduleStatus != status.New && moduleStatus != status.Disconnected); @@ -100,14 +100,14 @@ contract module { } moduleStatus = status.Disconnected; } - + function transferEvent(address from, address to, uint256 value) external onlyForModuleHandler returns (bool success) { return true; } function newSchellingRoundEvent(uint256 roundID, uint256 reward) external onlyForModuleHandler returns (bool success) { return true; } - + function registerModuleHandler(address _moduleHandlerAddress) internal { /* Module constructor function for registering ModuleHandler address. @@ -118,9 +118,9 @@ contract module { /* Test for ModuleHandler address. If the module is not connected then returns always false. - + @addr Address to check - + @ret This is the module handler address or not */ if ( moduleHandlerAddress == address(0x00) ) { return true; } @@ -130,7 +130,7 @@ contract module { function isActive() public view returns (bool success, bool active) { /* Check self for ready for functions or not. - + @success Function call was successful or not @active Ready for functions or not */ diff --git a/test/compilationTests/corion/moduleHandler.sol b/test/compilationTests/corion/moduleHandler.sol index ce53114b..5628f657 100644 --- a/test/compilationTests/corion/moduleHandler.sol +++ b/test/compilationTests/corion/moduleHandler.sol @@ -23,14 +23,14 @@ contract abstractModule { } contract moduleHandler is multiOwner, announcementTypes { - + struct modules_s { address addr; bytes32 name; bool schellingEvent; bool transferEvent; } - + modules_s[] public modules; address public foundationAddress; uint256 debugModeUntil = block.number + 1000000; @@ -40,10 +40,10 @@ contract moduleHandler is multiOwner, announcementTypes { function load(address foundation, bool forReplace, address Token, address Premium, address Publisher, address Schelling, address Provider) public { /* Loading modulest to ModuleHandler. - + This module can be called only once and only by the owner, if every single module and its database are already put on the blockchain. If forReaplace is true, than the ModuleHandler will be replaced. Before the publishing of its replace, the new contract must be already on the blockchain. - + @foundation Address of foundation. @forReplace Is it for replace or not. If not, it will be connected to the module. @Token address of token. @@ -64,7 +64,7 @@ contract moduleHandler is multiOwner, announcementTypes { /* Inside function for registration of the modules in the database. If the call is false, won't happen any direct call. - + @input _Structure of module. @call Is connect to the module or not. */ @@ -84,7 +84,7 @@ contract moduleHandler is multiOwner, announcementTypes { function getModuleAddressByName(string memory name) public view returns( bool success, bool found, address addr ) { /* Search by name for module. The result is an Ethereum address. - + @name Name of module. @addr Address of module. @found Is there any result. @@ -97,7 +97,7 @@ contract moduleHandler is multiOwner, announcementTypes { function getModuleIDByHash(bytes32 hashOfName) public view returns( bool success, bool found, uint256 id ) { /* Search by hash of name in the module array. The result is an index array. - + @name Name of module. @id Index of module. @found Was there any result or not. @@ -112,7 +112,7 @@ contract moduleHandler is multiOwner, announcementTypes { function getModuleIDByName(string memory name) public view returns( bool success, bool found, uint256 id ) { /* Search by name for module. The result is an index array. - + @name Name of module. @id Index of module. @found Was there any result or not. @@ -128,7 +128,7 @@ contract moduleHandler is multiOwner, announcementTypes { function getModuleIDByAddress(address addr) public view returns( bool success, bool found, uint256 id ) { /* Search by ethereum address for module. The result is an index array. - + @name Name of module. @id Index of module. @found Was there any result or not. @@ -143,7 +143,7 @@ contract moduleHandler is multiOwner, announcementTypes { function replaceModule(string name, address addr, bool callCallback) external returns (bool success) { /* Module replace, can be called only by the Publisher contract. - + @name Name of module. @addr Address of module. @bool Was there any result or not. @@ -166,7 +166,7 @@ contract moduleHandler is multiOwner, announcementTypes { modules[_id].addr = addr; return true; } - + function callReplaceCallback(string moduleName, address newModule) external returns (bool success) { require( block.number < debugModeUntil ); if ( ! insertAndCheckDo(calcDoHash("callReplaceCallback", keccak256(abi.encodePacked(moduleName, newModule)))) ) { @@ -181,7 +181,7 @@ contract moduleHandler is multiOwner, announcementTypes { function newModule(string name, address addr, bool schellingEvent, bool transferEvent) external returns (bool success) { /* Adding new module to the database. Can be called only by the Publisher contract. - + @name Name of module. @addr Address of module. @schellingEvent Gets it new Schelling round notification? @@ -202,7 +202,7 @@ contract moduleHandler is multiOwner, announcementTypes { function dropModule(string name, bool callCallback) external returns (bool success) { /* Deleting module from the database. Can be called only by the Publisher contract. - + @name Name of module to delete. @bool Was the function successful? @callCallback Call the replaceable module to confirm replacement or not. @@ -223,7 +223,7 @@ contract moduleHandler is multiOwner, announcementTypes { delete modules[_id]; return true; } - + function callDisableCallback(string moduleName) external returns (bool success) { require( block.number < debugModeUntil ); if ( ! insertAndCheckDo(calcDoHash("callDisableCallback", keccak256(bytes(moduleName)))) ) { @@ -234,14 +234,14 @@ contract moduleHandler is multiOwner, announcementTypes { require( abstractModule(modules[_id].addr).disableModule(true) ); return true; } - + function broadcastTransfer(address from, address to, uint256 value) external returns (bool success) { /* Announcing transactions for the modules. - + Can be called only by the token module. Only the configured modules get notifications.( transferEvent ) - + @from from who. @to to who. @value amount. @@ -261,7 +261,7 @@ contract moduleHandler is multiOwner, announcementTypes { Announcing new Schelling round for the modules. Can be called only by the Schelling module. Only the configured modules get notifications( schellingEvent ). - + @roundID Number of Schelling round. @reward Coin emission in this Schelling round. @bool Was the function successful? @@ -278,10 +278,10 @@ contract moduleHandler is multiOwner, announcementTypes { function replaceModuleHandler(address newHandler) external returns (bool success) { /* Replacing ModuleHandler. - + Can be called only by the publisher. Every module will be informed about the ModuleHandler replacement. - + @newHandler Address of the new ModuleHandler. @bool Was the function successful? */ @@ -301,7 +301,7 @@ contract moduleHandler is multiOwner, announcementTypes { function balanceOf(address owner) public view returns (bool success, uint256 value) { /* Query of token balance. - + @owner address @value balance. @success was the function successful? @@ -313,7 +313,7 @@ contract moduleHandler is multiOwner, announcementTypes { function totalSupply() public view returns (bool success, uint256 value) { /* Query of the whole token amount. - + @value amount. @success was the function successful? */ @@ -324,7 +324,7 @@ contract moduleHandler is multiOwner, announcementTypes { function isICO() public view returns (bool success, bool ico) { /* Query of ICO state - + @ico Is ICO in progress?. @success was the function successful? */ @@ -335,7 +335,7 @@ contract moduleHandler is multiOwner, announcementTypes { function getCurrentSchellingRoundID() public view returns (bool success, uint256 round) { /* Query of number of the actual Schelling round. - + @round Schelling round. @success was the function successful? */ @@ -346,10 +346,10 @@ contract moduleHandler is multiOwner, announcementTypes { function mint(address to, uint256 value) external returns (bool success) { /* Token emission request. Can be called only by the provider. - + @to Place of new token @value Token amount - + @success Was the function successful? */ (bool _success, bool _found, uint256 _id) = getModuleIDByAddress(msg.sender); @@ -362,7 +362,7 @@ contract moduleHandler is multiOwner, announcementTypes { function transfer(address from, address to, uint256 value, bool fee) external returns (bool success) { /* Token transaction request. Can be called only by a module. - + @from from who. @to To who. @value Token amount. @@ -379,7 +379,7 @@ contract moduleHandler is multiOwner, announcementTypes { function processTransactionFee(address from, uint256 value) external returns (bool success) { /* Token transaction fee. Can be called only by the provider. - + @from From who. @value Token amount. @success Was the function successful? @@ -394,7 +394,7 @@ contract moduleHandler is multiOwner, announcementTypes { function burn(address from, uint256 value) external returns (bool success) { /* Token burn. Can be called only by Schelling. - + @from From who. @value Token amount. @success Was the function successful? @@ -409,7 +409,7 @@ contract moduleHandler is multiOwner, announcementTypes { function configureModule(string moduleName, announcementType aType, uint256 value) external returns (bool success) { /* Changing configuration of a module. Can be called only by Publisher or while debug mode by owners. - + @moduleName Module name which will be configured @aType Type of variable (announcementType). @value New value @@ -432,14 +432,14 @@ contract moduleHandler is multiOwner, announcementTypes { /* Freezing CORION Platform. Can be called only by the owner. Freeze can not be recalled! - + @forever Is it forever or not? */ require( owners[msg.sender] ); if ( forever ) { if ( ! insertAndCheckDo(calcDoHash("freezing", keccak256(abi.encodePacked(forever)))) ) { return; - } + } } for ( uint256 a=0 ; a<modules.length ; a++ ) { require( abstractModule(modules[a].addr).disableModule(forever) ); diff --git a/test/compilationTests/corion/multiOwner.sol b/test/compilationTests/corion/multiOwner.sol index ecc51ac3..efda554a 100644 --- a/test/compilationTests/corion/multiOwner.sol +++ b/test/compilationTests/corion/multiOwner.sol @@ -3,12 +3,12 @@ pragma solidity ^0.4.11; import "./safeMath.sol"; contract multiOwner is safeMath { - + mapping(address => bool) public owners; uint256 public ownerCount; mapping(bytes32 => address[]) public doDB; - + /* Constructor */ diff --git a/test/compilationTests/corion/owned.sol b/test/compilationTests/corion/owned.sol index 4a5ba673..f5a11c44 100644 --- a/test/compilationTests/corion/owned.sol +++ b/test/compilationTests/corion/owned.sol @@ -1,28 +1,28 @@ -pragma solidity ^0.4.11;
-
-contract ownedDB {
- address private owner;
-
- function replaceOwner(address newOwner) external returns(bool) {
- /*
- Owner replace.
-
- @newOwner Address of new owner.
- */
- require( isOwner() );
- owner = newOwner;
- return true;
- }
-
- function isOwner() internal returns(bool) {
- /*
- Check of owner address.
-
- @bool Owner has called the contract or not
- */
- if ( owner == address(0x00) ) {
- return true;
- }
- return owner == msg.sender;
- }
-}
+pragma solidity ^0.4.11; + +contract ownedDB { + address private owner; + + function replaceOwner(address newOwner) external returns(bool) { + /* + Owner replace. + + @newOwner Address of new owner. + */ + require( isOwner() ); + owner = newOwner; + return true; + } + + function isOwner() internal returns(bool) { + /* + Check of owner address. + + @bool Owner has called the contract or not + */ + if ( owner == address(0x00) ) { + return true; + } + return owner == msg.sender; + } +} diff --git a/test/compilationTests/corion/premium.sol b/test/compilationTests/corion/premium.sol index 45fe7666..65895f33 100644 --- a/test/compilationTests/corion/premium.sol +++ b/test/compilationTests/corion/premium.sol @@ -20,7 +20,7 @@ contract premium is module, safeMath { } modifier isReady { (bool _success, bool _active) = super.isActive(); - require( _success && _active ); + require( _success && _active ); _; } /** @@ -29,22 +29,22 @@ contract premium is module, safeMath { * @author iFA @ Corion Platform * */ - + string public name = "Corion Premium"; string public symbol = "CORP"; uint8 public decimals = 0; - + address public icoAddr; tokenDB public db; bool public isICO; - + mapping(address => bool) public genesis; constructor(bool forReplace, address moduleHandler, address dbAddress, address icoContractAddr, address[] memory genesisAddr, uint256[] memory genesisValue) public { /* Setup function. If an ICOaddress is defined then the balance of the genesis addresses will be set as well. - + @forReplace This address will be replaced with the old one or not. @moduleHandler Modulhandler’s address @dbAddress Address of database @@ -56,7 +56,7 @@ contract premium is module, safeMath { require( dbAddress != address(0x00) ); db = ptokenDB(dbAddress); if ( ! forReplace ) { - require( db.replaceOwner(this) ); + require( db.replaceOwner(address(this)) ); isICO = true; icoAddr = icoContractAddr; assert( genesisAddr.length == genesisValue.length ); @@ -67,18 +67,18 @@ contract premium is module, safeMath { } } } - + function closeIco() external returns (bool success) { /* Finishing the ICO. Can be invited only by an ICO contract. - + @success If the function was successful. */ require( isICO ); isICO = false; return true; } - + /** * @notice `msg.sender` approves `spender` to spend `amount` tokens on its behalf. * @param spender The address of the account able to transfer the tokens @@ -88,18 +88,18 @@ contract premium is module, safeMath { */ function approve(address spender, uint256 amount, uint256 nonce) isReady external returns (bool success) { /* - Authorize another address to use an exact amount of the principal’s balance. - + Authorize another address to use an exact amount of the principal’s balance. + @spender Address of authorised party @amount Token quantity @nonce Transaction count - + @success Was the Function successful? */ _approve(spender, amount, nonce); return true; } - + /** * @notice `msg.sender` approves `spender` to spend `amount` tokens on its behalf and notify the spender from your approve with your `extraData` data. * @param spender The address of the account able to transfer the tokens @@ -112,24 +112,24 @@ contract premium is module, safeMath { /* Authorize another address to use an exact amount of the principal’s balance. After the transaction the approvedCorionPremiumToken function of the address will be called with the given data. - + @spender Authorized address @amount Token quantity @extraData Extra data to be received by the receiver @nonce Transaction count - + @success Was the Function successful? */ _approve(spender, amount, nonce); require( thirdPartyPContractAbstract(spender).approvedCorionPremiumToken(msg.sender, amount, extraData) ); return true; } - + function _approve(address spender, uint256 amount, uint256 nonce) isReady internal { /* - Inner function to authorize another address to use an exact amount of the principal’s balance. + Inner function to authorize another address to use an exact amount of the principal’s balance. If the transaction count not match the authorise fails. - + @spender Address of authorised party @amount Token quantity @nonce Transaction count @@ -143,10 +143,10 @@ contract premium is module, safeMath { function allowance(address owner, address spender) public view returns (uint256 remaining, uint256 nonce) { /* Get the quantity of tokens given to be used - + @owner Authorising address @spender Authorised address - + @remaining Tokens to be spent @nonce Transaction count */ @@ -154,7 +154,7 @@ contract premium is module, safeMath { require( _success ); return (_remaining, _nonce); } - + /** * @notice Send `amount` Corion tokens to `to` from `msg.sender` * @param to The address of the recipient @@ -166,10 +166,10 @@ contract premium is module, safeMath { Launch a transaction where the token is sent from the sender’s address to the receiver’s address. Transaction fee is going to be added as well. If the receiver is not a natural address but also a person then she/he will be invited as well. - + @to For who @amount Amount - + @success Was the function successful? */ bytes memory _data; @@ -181,7 +181,7 @@ contract premium is module, safeMath { emit Transfer(msg.sender, to, amount, _data); return true; } - + /** * @notice Send `amount` tokens to `to` from `from` on the condition it is approved by `from` * @param from The address holding the tokens being transferred @@ -194,11 +194,11 @@ contract premium is module, safeMath { Launch a transaction where we transfer from a given address to another one. It can only be called by an address which was allowed before. Transaction fee will be charged too. If the receiver is not a natural address but also a person then she/he will be invited as well - + @from From who? @to For who? @amount Amount - + @success If the function was successful. */ if ( from != msg.sender ) { @@ -218,7 +218,7 @@ contract premium is module, safeMath { emit Transfer(from, to, amount, _data); return true; } - + /** * @notice Send `amount` Corion tokens to `to` from `msg.sender` and notify the receiver from your transaction with your `extraData` data * @param to The contract address of the recipient @@ -230,11 +230,11 @@ contract premium is module, safeMath { /* Launch a transaction where we transfer from a given address to another one. After thetransaction the approvedCorionPremiumToken function of the receiver’s address is going to be called with the given data. - + @to For who? @amount Amount @extraData Extra data that will be given to the receiver - + @success If the function was successful. */ if ( isContract(to) ) { @@ -245,11 +245,11 @@ contract premium is module, safeMath { emit Transfer(msg.sender, to, amount, extraData); return true; } - + function transferToContract(address from, address to, uint256 amount, bytes memory extraData) internal { /* Inner function in order to transact a contract. - + @to For who? @amount Amount @extraData Extra data that will be given to the receiver @@ -262,13 +262,13 @@ contract premium is module, safeMath { _transfer(to, from, _back); } } - + function _transfer(address from, address to, uint256 amount) isReady internal { /* Inner function to launch a transaction. During the ICO transactions are only possible from the genesis address. 0xa636a97578d26a3b76b060bbc18226d954cf3757 address is blacklisted. - + @from From how? @to For who? @amount Amount @@ -278,38 +278,38 @@ contract premium is module, safeMath { require( db.decrease(from, amount) ); require( db.increase(to, amount) ); } - + function mint(address owner, uint256 value) external returns (bool success) { /* Generating tokens. It can be called only by ICO contract. - + @owner Address @value Amount. - + @success Was the Function successful? */ require( msg.sender == icoAddr || isICO ); _mint(owner, value); return true; } - + function _mint(address owner, uint256 value) isReady internal { /* Inner function to create a token. - + @owner Address of crediting the token. @value Amount */ require( db.increase(owner, value) ); emit Mint(owner, value); } - + function isContract(address addr) internal returns (bool success) { /* Inner function in order to check if the given address is a natural address or a contract. - + @addr The address which is needed to be checked. - + @success Is the address crontact or not */ uint256 _codeLength; @@ -322,7 +322,7 @@ contract premium is module, safeMath { function balanceOf(address owner) public view returns (uint256 value) { /* Token balance query - + @owner Address @value Balance of address */ @@ -332,12 +332,12 @@ contract premium is module, safeMath { function totalSupply() public view returns (uint256 value) { /* Total token quantity query - + @value Total token quantity */ return db.totalSupply(); } - + event AllowanceUsed(address indexed spender, address indexed owner, uint256 indexed value); event Mint(address indexed addr, uint256 indexed value); event Burn(address indexed addr, uint256 indexed value); diff --git a/test/compilationTests/corion/provider.sol b/test/compilationTests/corion/provider.sol index 7d1e04e3..a4ee4a48 100644 --- a/test/compilationTests/corion/provider.sol +++ b/test/compilationTests/corion/provider.sol @@ -20,7 +20,7 @@ contract provider is module, safeMath, announcementTypes { /* Transaction completed. This function is only available for the modulehandler. It should be checked if the sender or the acceptor does not connect to the provider or it is not a provider itself if so than the change should be recorded. - + @from From whom? @to For who? @value amount @@ -36,9 +36,9 @@ contract provider is module, safeMath, announcementTypes { New schelling round. This function is only available for the moduleHandler. We are recording the new schelling round and we are storing the whole current quantity of the tokens. We generate a reward quantity of tokens directed to the providers address. The collected interest will be transferred from this contract. - + @roundID Number of the schelling round. - @reward token emission + @reward token emission @bool Was the function successful? */ require( super.isModuleHandler(msg.sender) ); @@ -50,7 +50,7 @@ contract provider is module, safeMath, announcementTypes { } modifier isReady { (bool _success, bool _active) = super.isActive(); - require( _success && _active ); + require( _success && _active ); _; } /* @@ -98,13 +98,13 @@ contract provider is module, safeMath, announcementTypes { uint256 currentHeight; } mapping(address => _providers) private providers; - + struct _globalFunds { uint256 reward; uint256 supply; } mapping(uint256 => _globalFunds) private globalFunds; - + struct _client{ address providerAddress; uint256 providerHeight; @@ -115,13 +115,13 @@ contract provider is module, safeMath, announcementTypes { uint256 paidUpTo; } mapping(address => _client) private clients; - + uint256 private currentSchellingRound = 1; constructor(address _moduleHandler) public { /* Install function. - + @_moduleHandler Address of the moduleHandler. */ super.registerModuleHandler(_moduleHandler); @@ -129,7 +129,7 @@ contract provider is module, safeMath, announcementTypes { function configure(announcementType a, uint256 b) external returns(bool) { /* Configuration of the provider. Can be invited just by the moduleHandler. - + @a Type of the setting @b value */ @@ -150,7 +150,7 @@ contract provider is module, safeMath, announcementTypes { function getUserDetails(address addr, uint256 schellingRound) public view returns (address ProviderAddress, uint256 ProviderHeight, uint256 ConnectedOn, uint256 value) { /* Collecting the datas of the client. - + @addr Address of the client. @schellingRound Number of the schelling round. If it is not defined then the current one. @ProviderAddress Address of the provider the one where connected to @@ -173,9 +173,9 @@ contract provider is module, safeMath, announcementTypes { the share from the token emission. In case is a private provider it has to be checked if it has enough connected capital to be able to accept share from the token emission. The provider’s account counts as a capital for the emission as well. - + @value amount of the connected capital - @priv Is the provider private or not? + @priv Is the provider private or not? @bool Gets the share from the token emission. */ if ( priv ) { @@ -187,8 +187,8 @@ contract provider is module, safeMath, announcementTypes { /* It checks if the provider has enough connected captital to be able to get from the token emission. In case the provider is not able to get the share from the token emission then the connected capital will not count to the value of the globalFunds, to the current schelling round. - - @oldValue old + + @oldValue old @newValue new @priv Is the provider private? */ @@ -205,12 +205,12 @@ contract provider is module, safeMath, announcementTypes { function checkCorrectRate(bool priv, uint8 rate) internal returns(bool) { /* Inner function which checks if the amount of interest what is given by the provider is fits to the criteria. - + @priv Is the provider private or not? @rate Percentage/rate of the interest @bool Correct or not? */ - return ( ! priv && ( rate >= publicMinRate && rate <= publicMaxRate ) ) || + return ( ! priv && ( rate >= publicMinRate && rate <= publicMaxRate ) ) || ( priv && ( rate >= privateMinRate && rate <= privateMaxRate ) ); } function createProvider(bool priv, string name, string website, string country, string info, uint8 rate, bool isForRent, address admin) isReady external { @@ -222,7 +222,7 @@ contract provider is module, safeMath, announcementTypes { For opening, has to have enough capital. All the functions of the provider except of the closing are going to be handled by the admin. The provider can be start as a rent as well, in this case the isForRent has to be true/correct. In case it runs as a rent the 20% of the profit will belong to the leser and the rest goes to the admin. - + @priv Privat szolgaltato e. Is private provider? @name Provider’s name. @website Provider’s website @@ -241,7 +241,7 @@ contract provider is module, safeMath, announcementTypes { require( getTokenBalance(msg.sender) >= minFundsForPublic ); } require( checkCorrectRate(priv, rate) ); - + providers[msg.sender].currentHeight++; uint256 currHeight = providers[msg.sender].currentHeight; providers[msg.sender].data[currHeight].valid = true; @@ -276,10 +276,10 @@ contract provider is module, safeMath, announcementTypes { This can only be invited by the provider’s admin. The emission rate is only valid for the next schelling round for this one it is not. The admin can only be changed by the address of the provider. - + @addr Address of the provider. @website Website. - @admin The new address of the admin. If we do not want to set it then we should enter 0X00. + @admin The new address of the admin. If we do not want to set it then we should enter 0X00. @country Country @info Short intro. @rate Rate of the emission what will be given to the client. @@ -303,7 +303,7 @@ contract provider is module, safeMath, announcementTypes { /* for the infos of the provider. In case the height is unknown then the system will use the last known height. - + @addr Addr of the provider @height Height @name Name of the provider. @@ -348,7 +348,7 @@ contract provider is module, safeMath, announcementTypes { function getProviderCurrentSupply(address addr) internal view returns (uint256) { /* Inner function for polling the current height and the current quantity of the connected capital of the schelling round. - + @addr Provider’s address. @uint256 Amount of the connected capital */ @@ -363,7 +363,7 @@ contract provider is module, safeMath, announcementTypes { uint256 currHeight = providers[msg.sender].currentHeight; require( providers[msg.sender].data[currHeight].valid ); require( providers[msg.sender].data[currHeight].paidUpTo == currentSchellingRound ); - + providers[msg.sender].data[currHeight].valid = false; providers[msg.sender].data[currHeight].close = currentSchellingRound; setRightForInterest(getProviderCurrentSupply(msg.sender), 0, providers[msg.sender].data[currHeight].priv); @@ -373,8 +373,8 @@ contract provider is module, safeMath, announcementTypes { /* Permition of the user to be able to connect to the provider. This can only be invited by the provider’s admin. - With this kind of call only 100 address can be permitted. - + With this kind of call only 100 address can be permitted. + @addr Array of the addresses for whom the connection is allowed. */ uint256 currHeight = providers[provider].currentHeight; @@ -382,7 +382,7 @@ contract provider is module, safeMath, announcementTypes { require( providers[provider].data[currHeight].priv ); require( providers[provider].data[currHeight].admin == msg.sender ); require( addr.length <= 100 ); - + for ( uint256 a=0 ; a<addr.length ; a++ ) { providers[provider].data[currHeight].allowedUsers[addr[a]] = true; } @@ -391,8 +391,8 @@ contract provider is module, safeMath, announcementTypes { /* Disable of the user not to be able to connect to the provider. It is can called only for the admin of the provider. - With this kind of call only 100 address can be permitted. - + With this kind of call only 100 address can be permitted. + @addr Array of the addresses for whom the connection is allowed. */ uint256 currHeight = providers[provider].currentHeight; @@ -400,7 +400,7 @@ contract provider is module, safeMath, announcementTypes { require( providers[provider].data[currHeight].priv ); require( providers[provider].data[currHeight].admin == msg.sender ); require( addr.length <= 100 ); - + for ( uint256 a=0 ; a<addr.length ; a++ ) { delete providers[provider].data[currHeight].allowedUsers[addr[a]]; } @@ -414,7 +414,7 @@ contract provider is module, safeMath, announcementTypes { If is an active provider then the client can only connect, if address is permitted at the provider (Whitelist). At private providers, the number of the client is restricted. If it reaches the limit no further clients are allowed to connect. This process has a transaction fee based on the senders whole token quantity. - + @provider Address of the provider. */ uint256 currHeight = providers[provider].currentHeight; @@ -427,7 +427,7 @@ contract provider is module, safeMath, announcementTypes { } uint256 bal = getTokenBalance(msg.sender); require( moduleHandler(moduleHandlerAddress).processTransactionFee(msg.sender, bal) ); - + checkFloatingSupply(provider, currHeight, false, bal); providers[provider].data[currHeight].clientsCount++; clients[msg.sender].providerAddress = provider; @@ -455,7 +455,7 @@ contract provider is module, safeMath, announcementTypes { } else { require( clients[msg.sender].paidUpTo == currentSchellingRound ); } - + uint256 bal = getTokenBalance(msg.sender); if ( ! providerHasClosed ) { providers[provider].data[currHeight].clientsCount--; @@ -472,7 +472,7 @@ contract provider is module, safeMath, announcementTypes { function checkReward(address addr) public returns (uint256 reward) { /* Polling the share from the token emission for clients and for providers. - + @addr The address want to check. @reward Accumulated amount. */ @@ -494,7 +494,7 @@ contract provider is module, safeMath, announcementTypes { In case the client/provider was far behind then it is possible that this function should be called several times to check the total generated schelling rounds and to collect the share. If is neither a client nor a provider then the function is not available. The tokens will be sent to the beneficiary from the address of the provider without any transaction fees. - + @beneficiary Address of the beneficiary @limit Quota of the check-rounds. @provider Address of the provider @@ -527,7 +527,7 @@ contract provider is module, safeMath, announcementTypes { function getClientReward(uint256 limit) internal returns (uint256 reward) { /* Inner function for the client in order to collect the share from the token emission - + @limit Quota of checking the schelling-rounds. @reward Collected token amount from the checked rounds. */ @@ -574,7 +574,7 @@ contract provider is module, safeMath, announcementTypes { } function getProviderReward(address addr, uint256 limit) internal returns (uint256 providerReward, uint256 adminReward) { /* - Inner function for the provider in order to collect the share from the token emission + Inner function for the provider in order to collect the share from the token emission @addr Address of the provider. @limit Quota of the check-rounds. @providerReward The reward of the provider’s address from the checked rounds. @@ -594,7 +594,7 @@ contract provider is module, safeMath, announcementTypes { rate = providers[addr].data[currHeight].rateHistory[a].value; } if ( rate > 0 ) { - if ( ( a > LTSID && rightForInterest(providers[addr].data[currHeight].supply[LTSID], providers[addr].data[currHeight].priv) || + if ( ( a > LTSID && rightForInterest(providers[addr].data[currHeight].supply[LTSID], providers[addr].data[currHeight].priv) || rightForInterest(providers[addr].data[currHeight].supply[a], providers[addr].data[currHeight].priv) ) ) { if ( limit > 0 && steps > limit ) { a--; @@ -636,7 +636,7 @@ contract provider is module, safeMath, announcementTypes { /* Inner function for updating the database when some token change has happened. In this case we are checking if despite the changes the provider is still entitled to the token emission. In case the legitimacy changes then the global supply should be set as well. - + @providerAddress Provider address. @providerHeight Provider height. @neg the change was negative or not @@ -646,15 +646,15 @@ contract provider is module, safeMath, announcementTypes { if ( currentSchellingRound != LSID ) { if ( neg ) { setRightForInterest( - providers[providerAddress].data[providerHeight].supply[LSID], - providers[providerAddress].data[providerHeight].supply[LSID] - value, + providers[providerAddress].data[providerHeight].supply[LSID], + providers[providerAddress].data[providerHeight].supply[LSID] - value, providers[providerAddress].data[providerHeight].priv ); providers[providerAddress].data[providerHeight].supply[currentSchellingRound] = providers[providerAddress].data[providerHeight].supply[LSID] - value; } else { setRightForInterest( - providers[providerAddress].data[providerHeight].supply[LSID], - providers[providerAddress].data[providerHeight].supply[LSID] + value, + providers[providerAddress].data[providerHeight].supply[LSID], + providers[providerAddress].data[providerHeight].supply[LSID] + value, providers[providerAddress].data[providerHeight].priv ); providers[providerAddress].data[providerHeight].supply[currentSchellingRound] = providers[providerAddress].data[providerHeight].supply[LSID] + value; @@ -663,15 +663,15 @@ contract provider is module, safeMath, announcementTypes { } else { if ( neg ) { setRightForInterest( - getProviderCurrentSupply(providerAddress), - getProviderCurrentSupply(providerAddress) - value, + getProviderCurrentSupply(providerAddress), + getProviderCurrentSupply(providerAddress) - value, providers[providerAddress].data[providerHeight].priv ); providers[providerAddress].data[providerHeight].supply[currentSchellingRound] -= value; } else { setRightForInterest( - getProviderCurrentSupply(providerAddress), - getProviderCurrentSupply(providerAddress) + value, + getProviderCurrentSupply(providerAddress), + getProviderCurrentSupply(providerAddress) + value, providers[providerAddress].data[providerHeight].priv ); providers[providerAddress].data[providerHeight].supply[currentSchellingRound] += value; @@ -683,7 +683,7 @@ contract provider is module, safeMath, announcementTypes { Inner function for updating the database in case token change has happened. In this case we check if the provider despite the changes is still entitled to the token emission. We just call this only if the private provider and it’s own capital bears emission. - + @providerAddress Provider address. @providerHeight Provider height. @neg Was the change negative? @@ -693,15 +693,15 @@ contract provider is module, safeMath, announcementTypes { if ( currentSchellingRound != LSID ) { if ( neg ) { setRightForInterest( - providers[providerAddress].data[providerHeight].ownSupply[LSID], - providers[providerAddress].data[providerHeight].ownSupply[LSID] - value, + providers[providerAddress].data[providerHeight].ownSupply[LSID], + providers[providerAddress].data[providerHeight].ownSupply[LSID] - value, true ); providers[providerAddress].data[providerHeight].ownSupply[currentSchellingRound] = providers[providerAddress].data[providerHeight].ownSupply[LSID] - value; } else { setRightForInterest( - providers[providerAddress].data[providerHeight].ownSupply[LSID], - providers[providerAddress].data[providerHeight].ownSupply[LSID] + value, + providers[providerAddress].data[providerHeight].ownSupply[LSID], + providers[providerAddress].data[providerHeight].ownSupply[LSID] + value, true ); providers[providerAddress].data[providerHeight].ownSupply[currentSchellingRound] = providers[providerAddress].data[providerHeight].ownSupply[LSID] + value; @@ -710,15 +710,15 @@ contract provider is module, safeMath, announcementTypes { } else { if ( neg ) { setRightForInterest( - getProviderCurrentSupply(providerAddress), - getProviderCurrentSupply(providerAddress) - value, + getProviderCurrentSupply(providerAddress), + getProviderCurrentSupply(providerAddress) - value, true ); providers[providerAddress].data[providerHeight].ownSupply[currentSchellingRound] -= value; } else { setRightForInterest( - getProviderCurrentSupply(providerAddress), - getProviderCurrentSupply(providerAddress) + value, + getProviderCurrentSupply(providerAddress), + getProviderCurrentSupply(providerAddress) + value, true ); providers[providerAddress].data[providerHeight].ownSupply[currentSchellingRound] += value; @@ -728,7 +728,7 @@ contract provider is module, safeMath, announcementTypes { function TEMath(uint256 a, uint256 b, bool neg) internal returns (uint256) { /* Inner function for the changes of the numbers - + @a First number @b 2nd number @neg Operation with numbers. If it is TRUE then subtraction, if it is FALSE then addition. @@ -740,7 +740,7 @@ contract provider is module, safeMath, announcementTypes { /* Inner function for perceiving the changes of the balance and updating the database. If the address is a provider and the balance is decreasing than can not let it go under the minimum level. - + @addr The address where the change happened. @value Rate of the change. @neg ype of the change. If it is TRUE then the balance has been decreased if it is FALSE then it has been increased. @@ -771,9 +771,9 @@ contract provider is module, safeMath, announcementTypes { function getTokenBalance(address addr) internal returns (uint256 balance) { /* Inner function in order to poll the token balance of the address. - + @addr Address - + @balance Balance of the address. */ (bool _success, uint256 _balance) = moduleHandler(moduleHandlerAddress).balanceOf(addr); @@ -783,7 +783,7 @@ contract provider is module, safeMath, announcementTypes { function checkICO() internal returns (bool isICO) { /* Inner function to check the ICO status. - + @isICO Is the ICO in process or not? */ (bool _success, bool _isICO) = moduleHandler(moduleHandlerAddress).isICO(); diff --git a/test/compilationTests/corion/publisher.sol b/test/compilationTests/corion/publisher.sol index 575b99a8..fcba13ad 100644 --- a/test/compilationTests/corion/publisher.sol +++ b/test/compilationTests/corion/publisher.sol @@ -1,278 +1,278 @@ -pragma solidity ^0.4.11;
-
-import "./announcementTypes.sol";
-import "./module.sol";
-import "./moduleHandler.sol";
-import "./safeMath.sol";
-
-contract publisher is announcementTypes, module, safeMath {
- /*
- module callbacks
- */
- function transferEvent(address from, address to, uint256 value) external returns (bool success) {
- /*
- Transaction completed. This function is available only for moduleHandler
- If a transaction is carried out from or to an address which participated in the objection of an announcement, its objection purport is automatically set
- */
- require( super.isModuleHandler(msg.sender) );
- uint256 announcementID;
- uint256 a;
- // need reverse lookup
- for ( a=0 ; a<opponents[from].length ; a++ ) {
- announcementID = opponents[msg.sender][a];
- if ( announcements[announcementID].end < block.number && announcements[announcementID].open ) {
- announcements[announcementID].oppositionWeight = safeSub(announcements[a].oppositionWeight, value);
- }
- }
- for ( a=0 ; a<opponents[to].length ; a++ ) {
- announcementID = opponents[msg.sender][a];
- if ( announcements[announcementID].end < block.number && announcements[announcementID].open ) {
- announcements[announcementID].oppositionWeight = safeAdd(announcements[a].oppositionWeight, value);
- }
- }
- return true;
- }
-
- /*
- Pool
- */
-
- uint256 public minAnnouncementDelay = 40320;
- uint256 public minAnnouncementDelayOnICO = 17280;
- uint8 public oppositeRate = 33;
-
- struct announcements_s {
- announcementType Type;
- uint256 start;
- uint256 end;
- bool open;
- string announcement;
- string link;
- bool oppositable;
- uint256 oppositionWeight;
- bool result;
-
- string _str;
- uint256 _uint;
- address _addr;
- }
- mapping(uint256 => announcements_s) public announcements;
- uint256 announcementsLength = 1;
-
- mapping (address => uint256[]) public opponents;
-
- constructor(address moduleHandler) public {
- /*
- Installation function. The installer will be registered in the admin list automatically
-
- @moduleHandler Address of moduleHandler
- */
- super.registerModuleHandler(moduleHandler);
- }
-
- function Announcements(uint256 id) public view returns (uint256 Type, uint256 Start, uint256 End, bool Closed, string memory Announcement, string memory Link, bool Opposited, string memory _str, uint256 _uint, address _addr) {
- /*
- Announcement data query
-
- @id Its identification
-
- @Type Subject of announcement
- @Start Height of announcement block
- @End Planned completion of announcement
- @Closed Closed or not
- @Announcement Announcement text
- @Link Link perhaps to a Forum
- @Opposited Objected or not
- @_str Text value
- @_uint Number value
- @_addr Address value
- */
- Type = uint256(announcements[id].Type);
- Start = announcements[id].start;
- End = announcements[id].end;
- Closed = ! announcements[id].open;
- Announcement = announcements[id].announcement;
- Link = announcements[id].link;
- if ( checkOpposited(announcements[id].oppositionWeight, announcements[id].oppositable) ) {
- Opposited = true;
- }
- _str = announcements[id]._str;
- _uint = announcements[id]._uint;
- _addr = announcements[id]._addr;
- }
-
- function checkOpposited(uint256 weight, bool oppositable) public view returns (bool success) {
- /*
- Veto check
-
- @weight Purport of objections so far
- @oppositable Opposable at all
-
- @success Opposed or not
- */
- if ( ! oppositable ) { return false; }
- (bool _success, uint256 _amount) = moduleHandler(moduleHandlerAddress).totalSupply();
- require( _success );
- return _amount * oppositeRate / 100 > weight;
- }
-
- function newAnnouncement(announcementType Type, string Announcement, string Link, bool Oppositable, string _str, uint256 _uint, address _addr) onlyOwner external {
- /*
- New announcement. Can be called only by those in the admin list
-
- @Type Topic of announcement
- @Start height of announcement block
- @End planned completion of announcement
- @Closed Completed or not
- @Announcement Announcement text
- @Link link to a Forum
- @Opposition opposed or not
- @_str text box
- @_uint number box
- @_addr address box
- */
- announcementsLength++;
- announcements[announcementsLength].Type = Type;
- announcements[announcementsLength].start = block.number;
- if ( checkICO() ) {
- announcements[announcementsLength].end = block.number + minAnnouncementDelayOnICO;
- } else {
- announcements[announcementsLength].end = block.number + minAnnouncementDelay;
- }
- announcements[announcementsLength].open = true;
- announcements[announcementsLength].announcement = Announcement;
- announcements[announcementsLength].link = Link;
- announcements[announcementsLength].oppositable = Oppositable;
- announcements[announcementsLength].oppositionWeight = 0;
- announcements[announcementsLength].result = false;
- announcements[announcementsLength]._str = _str;
- announcements[announcementsLength]._uint = _uint;
- announcements[announcementsLength]._addr = _addr;
- emit ENewAnnouncement(announcementsLength, Type);
- }
-
- function closeAnnouncement(uint256 id) onlyOwner external {
- /*
- Close announcement. It can be closed only by those in the admin list. Windup is allowed only after the announcement is completed.
-
- @id Announcement identification
- */
- require( announcements[id].open && announcements[id].end < block.number );
- if ( ! checkOpposited(announcements[id].oppositionWeight, announcements[id].oppositable) ) {
- announcements[id].result = true;
- if ( announcements[id].Type == announcementType.newModule ) {
- require( moduleHandler(moduleHandlerAddress).newModule(announcements[id]._str, announcements[id]._addr, true, true) );
- } else if ( announcements[id].Type == announcementType.dropModule ) {
- require( moduleHandler(moduleHandlerAddress).dropModule(announcements[id]._str, true) );
- } else if ( announcements[id].Type == announcementType.replaceModule ) {
- require( moduleHandler(moduleHandlerAddress).replaceModule(announcements[id]._str, announcements[id]._addr, true) );
- } else if ( announcements[id].Type == announcementType.replaceModuleHandler) {
- require( moduleHandler(moduleHandlerAddress).replaceModuleHandler(announcements[id]._addr) );
- } else if ( announcements[id].Type == announcementType.transactionFeeRate ||
- announcements[id].Type == announcementType.transactionFeeMin ||
- announcements[id].Type == announcementType.transactionFeeMax ||
- announcements[id].Type == announcementType.transactionFeeBurn ) {
- require( moduleHandler(moduleHandlerAddress).configureModule("token", announcements[id].Type, announcements[id]._uint) );
- } else if ( announcements[id].Type == announcementType.providerPublicFunds ||
- announcements[id].Type == announcementType.providerPrivateFunds ||
- announcements[id].Type == announcementType.providerPrivateClientLimit ||
- announcements[id].Type == announcementType.providerPublicMinRate ||
- announcements[id].Type == announcementType.providerPublicMaxRate ||
- announcements[id].Type == announcementType.providerPrivateMinRate ||
- announcements[id].Type == announcementType.providerPrivateMaxRate ||
- announcements[id].Type == announcementType.providerGasProtect ||
- announcements[id].Type == announcementType.providerInterestMinFunds ||
- announcements[id].Type == announcementType.providerRentRate ) {
- require( moduleHandler(moduleHandlerAddress).configureModule("provider", announcements[id].Type, announcements[id]._uint) );
- } else if ( announcements[id].Type == announcementType.schellingRoundBlockDelay ||
- announcements[id].Type == announcementType.schellingCheckRounds ||
- announcements[id].Type == announcementType.schellingCheckAboves ||
- announcements[id].Type == announcementType.schellingRate ) {
- require( moduleHandler(moduleHandlerAddress).configureModule("schelling", announcements[id].Type, announcements[id]._uint) );
- } else if ( announcements[id].Type == announcementType.publisherMinAnnouncementDelay) {
- minAnnouncementDelay = announcements[id]._uint;
- } else if ( announcements[id].Type == announcementType.publisherOppositeRate) {
- oppositeRate = uint8(announcements[id]._uint);
- }
- }
- announcements[id].end = block.number;
- announcements[id].open = false;
- }
-
- function oppositeAnnouncement(uint256 id) external {
- /*
- Opposition of announcement
- If announcement is opposable, anyone owning a token can oppose it
- Opposition is automatically with the total amount of tokens
- If the quantity of his tokens changes, the purport of his opposition changes automatically
- The prime time is the windup of the announcement, because this is the moment when the number of tokens in opposition are counted.
- One address is entitled to be in oppositon only once. An opposition cannot be withdrawn.
- Running announcements can be opposed only.
-
- @id Announcement identification
- */
- uint256 newArrayID = 0;
- bool foundEmptyArrayID = false;
- require( announcements[id].open );
- require( announcements[id].oppositable );
- for ( uint256 a=0 ; a<opponents[msg.sender].length ; a++ ) {
- require( opponents[msg.sender][a] != id );
- if ( ! announcements[opponents[msg.sender][a]].open) {
- delete opponents[msg.sender][a];
- if ( ! foundEmptyArrayID ) {
- foundEmptyArrayID = true;
- newArrayID = a;
- }
- }
- if ( ! foundEmptyArrayID ) {
- foundEmptyArrayID = true;
- newArrayID = a;
- }
- }
- (bool _success, uint256 _balance) = moduleHandler(moduleHandlerAddress).balanceOf(msg.sender);
- require( _success );
- require( _balance > 0);
- if ( foundEmptyArrayID ) {
- opponents[msg.sender][newArrayID] = id;
- } else {
- opponents[msg.sender].push(id);
- }
- announcements[id].oppositionWeight += _balance;
- emit EOppositeAnnouncement(id, msg.sender, _balance);
- }
-
- function invalidateAnnouncement(uint256 id) onlyOwner external {
- /*
- Withdraw announcement. Only those in the admin list can withdraw it.
-
- @id Announcement identification
- */
- require( announcements[id].open );
- announcements[id].end = block.number;
- announcements[id].open = false;
- emit EInvalidateAnnouncement(id);
- }
-
- modifier onlyOwner() {
- /*
- Only the owner is allowed to call it.
- */
- require( moduleHandler(moduleHandlerAddress).owners(msg.sender) );
- _;
- }
-
- function checkICO() internal returns (bool isICO) {
- /*
- Inner function to check the ICO status.
- @bool Is the ICO in process or not?
- */
- (bool _success, bool _isICO) = moduleHandler(moduleHandlerAddress).isICO();
- require( _success );
- return _isICO;
- }
-
- event ENewAnnouncement(uint256 id, announcementType typ);
- event EOppositeAnnouncement(uint256 id, address addr, uint256 value);
- event EInvalidateAnnouncement(uint256 id);
- event ECloseAnnouncement(uint256 id);
-}
+pragma solidity ^0.4.11; + +import "./announcementTypes.sol"; +import "./module.sol"; +import "./moduleHandler.sol"; +import "./safeMath.sol"; + +contract publisher is announcementTypes, module, safeMath { + /* + module callbacks + */ + function transferEvent(address from, address to, uint256 value) external returns (bool success) { + /* + Transaction completed. This function is available only for moduleHandler + If a transaction is carried out from or to an address which participated in the objection of an announcement, its objection purport is automatically set + */ + require( super.isModuleHandler(msg.sender) ); + uint256 announcementID; + uint256 a; + // need reverse lookup + for ( a=0 ; a<opponents[from].length ; a++ ) { + announcementID = opponents[msg.sender][a]; + if ( announcements[announcementID].end < block.number && announcements[announcementID].open ) { + announcements[announcementID].oppositionWeight = safeSub(announcements[a].oppositionWeight, value); + } + } + for ( a=0 ; a<opponents[to].length ; a++ ) { + announcementID = opponents[msg.sender][a]; + if ( announcements[announcementID].end < block.number && announcements[announcementID].open ) { + announcements[announcementID].oppositionWeight = safeAdd(announcements[a].oppositionWeight, value); + } + } + return true; + } + + /* + Pool + */ + + uint256 public minAnnouncementDelay = 40320; + uint256 public minAnnouncementDelayOnICO = 17280; + uint8 public oppositeRate = 33; + + struct announcements_s { + announcementType Type; + uint256 start; + uint256 end; + bool open; + string announcement; + string link; + bool oppositable; + uint256 oppositionWeight; + bool result; + + string _str; + uint256 _uint; + address _addr; + } + mapping(uint256 => announcements_s) public announcements; + uint256 announcementsLength = 1; + + mapping (address => uint256[]) public opponents; + + constructor(address moduleHandler) public { + /* + Installation function. The installer will be registered in the admin list automatically + + @moduleHandler Address of moduleHandler + */ + super.registerModuleHandler(moduleHandler); + } + + function Announcements(uint256 id) public view returns (uint256 Type, uint256 Start, uint256 End, bool Closed, string memory Announcement, string memory Link, bool Opposited, string memory _str, uint256 _uint, address _addr) { + /* + Announcement data query + + @id Its identification + + @Type Subject of announcement + @Start Height of announcement block + @End Planned completion of announcement + @Closed Closed or not + @Announcement Announcement text + @Link Link perhaps to a Forum + @Opposited Objected or not + @_str Text value + @_uint Number value + @_addr Address value + */ + Type = uint256(announcements[id].Type); + Start = announcements[id].start; + End = announcements[id].end; + Closed = ! announcements[id].open; + Announcement = announcements[id].announcement; + Link = announcements[id].link; + if ( checkOpposited(announcements[id].oppositionWeight, announcements[id].oppositable) ) { + Opposited = true; + } + _str = announcements[id]._str; + _uint = announcements[id]._uint; + _addr = announcements[id]._addr; + } + + function checkOpposited(uint256 weight, bool oppositable) public view returns (bool success) { + /* + Veto check + + @weight Purport of objections so far + @oppositable Opposable at all + + @success Opposed or not + */ + if ( ! oppositable ) { return false; } + (bool _success, uint256 _amount) = moduleHandler(moduleHandlerAddress).totalSupply(); + require( _success ); + return _amount * oppositeRate / 100 > weight; + } + + function newAnnouncement(announcementType Type, string Announcement, string Link, bool Oppositable, string _str, uint256 _uint, address _addr) onlyOwner external { + /* + New announcement. Can be called only by those in the admin list + + @Type Topic of announcement + @Start height of announcement block + @End planned completion of announcement + @Closed Completed or not + @Announcement Announcement text + @Link link to a Forum + @Opposition opposed or not + @_str text box + @_uint number box + @_addr address box + */ + announcementsLength++; + announcements[announcementsLength].Type = Type; + announcements[announcementsLength].start = block.number; + if ( checkICO() ) { + announcements[announcementsLength].end = block.number + minAnnouncementDelayOnICO; + } else { + announcements[announcementsLength].end = block.number + minAnnouncementDelay; + } + announcements[announcementsLength].open = true; + announcements[announcementsLength].announcement = Announcement; + announcements[announcementsLength].link = Link; + announcements[announcementsLength].oppositable = Oppositable; + announcements[announcementsLength].oppositionWeight = 0; + announcements[announcementsLength].result = false; + announcements[announcementsLength]._str = _str; + announcements[announcementsLength]._uint = _uint; + announcements[announcementsLength]._addr = _addr; + emit ENewAnnouncement(announcementsLength, Type); + } + + function closeAnnouncement(uint256 id) onlyOwner external { + /* + Close announcement. It can be closed only by those in the admin list. Windup is allowed only after the announcement is completed. + + @id Announcement identification + */ + require( announcements[id].open && announcements[id].end < block.number ); + if ( ! checkOpposited(announcements[id].oppositionWeight, announcements[id].oppositable) ) { + announcements[id].result = true; + if ( announcements[id].Type == announcementType.newModule ) { + require( moduleHandler(moduleHandlerAddress).newModule(announcements[id]._str, announcements[id]._addr, true, true) ); + } else if ( announcements[id].Type == announcementType.dropModule ) { + require( moduleHandler(moduleHandlerAddress).dropModule(announcements[id]._str, true) ); + } else if ( announcements[id].Type == announcementType.replaceModule ) { + require( moduleHandler(moduleHandlerAddress).replaceModule(announcements[id]._str, announcements[id]._addr, true) ); + } else if ( announcements[id].Type == announcementType.replaceModuleHandler) { + require( moduleHandler(moduleHandlerAddress).replaceModuleHandler(announcements[id]._addr) ); + } else if ( announcements[id].Type == announcementType.transactionFeeRate || + announcements[id].Type == announcementType.transactionFeeMin || + announcements[id].Type == announcementType.transactionFeeMax || + announcements[id].Type == announcementType.transactionFeeBurn ) { + require( moduleHandler(moduleHandlerAddress).configureModule("token", announcements[id].Type, announcements[id]._uint) ); + } else if ( announcements[id].Type == announcementType.providerPublicFunds || + announcements[id].Type == announcementType.providerPrivateFunds || + announcements[id].Type == announcementType.providerPrivateClientLimit || + announcements[id].Type == announcementType.providerPublicMinRate || + announcements[id].Type == announcementType.providerPublicMaxRate || + announcements[id].Type == announcementType.providerPrivateMinRate || + announcements[id].Type == announcementType.providerPrivateMaxRate || + announcements[id].Type == announcementType.providerGasProtect || + announcements[id].Type == announcementType.providerInterestMinFunds || + announcements[id].Type == announcementType.providerRentRate ) { + require( moduleHandler(moduleHandlerAddress).configureModule("provider", announcements[id].Type, announcements[id]._uint) ); + } else if ( announcements[id].Type == announcementType.schellingRoundBlockDelay || + announcements[id].Type == announcementType.schellingCheckRounds || + announcements[id].Type == announcementType.schellingCheckAboves || + announcements[id].Type == announcementType.schellingRate ) { + require( moduleHandler(moduleHandlerAddress).configureModule("schelling", announcements[id].Type, announcements[id]._uint) ); + } else if ( announcements[id].Type == announcementType.publisherMinAnnouncementDelay) { + minAnnouncementDelay = announcements[id]._uint; + } else if ( announcements[id].Type == announcementType.publisherOppositeRate) { + oppositeRate = uint8(announcements[id]._uint); + } + } + announcements[id].end = block.number; + announcements[id].open = false; + } + + function oppositeAnnouncement(uint256 id) external { + /* + Opposition of announcement + If announcement is opposable, anyone owning a token can oppose it + Opposition is automatically with the total amount of tokens + If the quantity of his tokens changes, the purport of his opposition changes automatically + The prime time is the windup of the announcement, because this is the moment when the number of tokens in opposition are counted. + One address is entitled to be in oppositon only once. An opposition cannot be withdrawn. + Running announcements can be opposed only. + + @id Announcement identification + */ + uint256 newArrayID = 0; + bool foundEmptyArrayID = false; + require( announcements[id].open ); + require( announcements[id].oppositable ); + for ( uint256 a=0 ; a<opponents[msg.sender].length ; a++ ) { + require( opponents[msg.sender][a] != id ); + if ( ! announcements[opponents[msg.sender][a]].open) { + delete opponents[msg.sender][a]; + if ( ! foundEmptyArrayID ) { + foundEmptyArrayID = true; + newArrayID = a; + } + } + if ( ! foundEmptyArrayID ) { + foundEmptyArrayID = true; + newArrayID = a; + } + } + (bool _success, uint256 _balance) = moduleHandler(moduleHandlerAddress).balanceOf(msg.sender); + require( _success ); + require( _balance > 0); + if ( foundEmptyArrayID ) { + opponents[msg.sender][newArrayID] = id; + } else { + opponents[msg.sender].push(id); + } + announcements[id].oppositionWeight += _balance; + emit EOppositeAnnouncement(id, msg.sender, _balance); + } + + function invalidateAnnouncement(uint256 id) onlyOwner external { + /* + Withdraw announcement. Only those in the admin list can withdraw it. + + @id Announcement identification + */ + require( announcements[id].open ); + announcements[id].end = block.number; + announcements[id].open = false; + emit EInvalidateAnnouncement(id); + } + + modifier onlyOwner() { + /* + Only the owner is allowed to call it. + */ + require( moduleHandler(moduleHandlerAddress).owners(msg.sender) ); + _; + } + + function checkICO() internal returns (bool isICO) { + /* + Inner function to check the ICO status. + @bool Is the ICO in process or not? + */ + (bool _success, bool _isICO) = moduleHandler(moduleHandlerAddress).isICO(); + require( _success ); + return _isICO; + } + + event ENewAnnouncement(uint256 id, announcementType typ); + event EOppositeAnnouncement(uint256 id, address addr, uint256 value); + event EInvalidateAnnouncement(uint256 id); + event ECloseAnnouncement(uint256 id); +} diff --git a/test/compilationTests/corion/safeMath.sol b/test/compilationTests/corion/safeMath.sol index 9e27d379..a6680f27 100644 --- a/test/compilationTests/corion/safeMath.sol +++ b/test/compilationTests/corion/safeMath.sol @@ -5,7 +5,7 @@ contract safeMath { /* Biztonsagos hozzadas. Tulcsordulas elleni vedelem. A vegeredmeny nem lehet kevesebb mint az @a, ha igen megall a kod. - + @a Amihez hozzaadni kell @b Amennyit hozzaadni kell. @uint256 Vegeredmeny. @@ -15,12 +15,12 @@ contract safeMath { } return a + b; } - + function safeSub(uint256 a, uint256 b) internal returns(uint256) { /* Biztonsagos kivonas. Tulcsordulas elleni vedelem. A vegeredmeny nem lehet tobb mint az @a, ha igen megall a kod. - + @a Amibol kivonni kell. @b Amennyit kivonni kell. @uint256 Vegeredmeny. diff --git a/test/compilationTests/corion/schelling.sol b/test/compilationTests/corion/schelling.sol index 3905e300..c4f3c02c 100644 --- a/test/compilationTests/corion/schelling.sol +++ b/test/compilationTests/corion/schelling.sol @@ -141,9 +141,9 @@ contract schelling is module, announcementTypes, schellingVars { } function transferEvent(address from, address to, uint256 value) external returns (bool) { /* - Transaction completed. This function can be called only by the ModuleHandler. + Transaction completed. This function can be called only by the ModuleHandler. If this contract is the receiver, the amount will be added to the prize pool of the current round. - + @from From who @to To who @value Amount @@ -160,7 +160,7 @@ contract schelling is module, announcementTypes, schellingVars { } modifier isReady { (bool _success, bool _active) = super.isActive(); - require( _success && _active ); + require( _success && _active ); _; } /* @@ -175,7 +175,7 @@ contract schelling is module, announcementTypes, schellingVars { require( db.setFunds(addr, amount) ); } function setVoter(address owner, _voter memory voter) internal { - require( db.setVoter(owner, + require( db.setVoter(owner, voter.roundID, voter.hash, voter.status, @@ -189,7 +189,7 @@ contract schelling is module, announcementTypes, schellingVars { return _voter(b, c, d, e, f); } function setRound(uint256 id, _rounds memory round) internal { - require( db.setRound(id, + require( db.setRound(id, round.totalAboveWeight, round.totalBelowWeight, round.reward, @@ -250,7 +250,7 @@ contract schelling is module, announcementTypes, schellingVars { constructor(address _moduleHandler, address _db, bool _forReplace) public { /* Installation function. - + @_moduleHandler Address of ModuleHandler. @_db Address of the database. @_forReplace This address will be replaced with the old one or not. @@ -259,13 +259,13 @@ contract schelling is module, announcementTypes, schellingVars { db = schellingDB(_db); super.registerModuleHandler(_moduleHandler); if ( ! _forReplace ) { - require( db.replaceOwner(this) ); + require( db.replaceOwner(address(this)) ); } } function configure(announcementType a, uint256 b) external returns(bool) { /* Can be called only by the ModuleHandler. - + @a Sort of configuration @b Value */ @@ -280,22 +280,22 @@ contract schelling is module, announcementTypes, schellingVars { function prepareVote(bytes32 votehash, uint256 roundID) isReady noContract external { /* Initializing manual vote. - Only the hash of vote will be sent. (Envelope sending). - The address must be in default state, that is there are no vote in progress. + Only the hash of vote will be sent. (Envelope sending). + The address must be in default state, that is there are no vote in progress. Votes can be sent only on the actually Schelling round. - + @votehash Hash of the vote @roundID Number of Schelling round */ nextRound(); - + uint256 currentRound = getCurrentRound(); schellingVars._rounds memory round = getRound(currentRound); _voter memory voter; uint256 funds; - + require( roundID == currentRound ); - + voter = getVoter(msg.sender); funds = getFunds(msg.sender); @@ -304,10 +304,10 @@ contract schelling is module, announcementTypes, schellingVars { voter.roundID = currentRound; voter.hash = votehash; voter.status = voterStatus.afterPrepareVote; - + setVoter(msg.sender, voter); round.voted = true; - + setRound(currentRound, round); } function sendVote(string vote) isReady noContract external { @@ -318,21 +318,21 @@ contract schelling is module, announcementTypes, schellingVars { If the vote invalid, the deposit will be lost. If the “envelope” was opened later than 1,5 Schelling round, the vote is automatically invalid, and deposit can be lost. Lost deposits will be 100% burned. - + @vote Hash of the content of the vote. */ nextRound(); - + uint256 currentRound = getCurrentRound(); _rounds memory round; _voter memory voter; uint256 funds; - + bool lostEverything; voter = getVoter(msg.sender); round = getRound(voter.roundID); funds = getFunds(msg.sender); - + require( voter.status == voterStatus.afterPrepareVote ); require( voter.roundID < currentRound ); if ( keccak256(bytes(vote)) == voter.hash ) { @@ -355,7 +355,7 @@ contract schelling is module, announcementTypes, schellingVars { delete funds; delete voter.status; } - + setVoter(msg.sender, voter); setRound(voter.roundID, round); setFunds(msg.sender, funds); @@ -368,17 +368,17 @@ contract schelling is module, announcementTypes, schellingVars { The right votes take share of deposits. */ nextRound(); - + uint256 currentRound = getCurrentRound(); _rounds memory round; _voter memory voter; uint256 funds; - + voter = getVoter(msg.sender); round = getRound(voter.roundID); funds = getFunds(msg.sender); - - require( voter.status == voterStatus.afterSendVoteOk || + + require( voter.status == voterStatus.afterSendVoteOk || voter.status == voterStatus.afterSendVoteBad ); if ( round.blockHeight+roundBlockDelay/2 <= block.number ) { if ( isWinner(round, voter.voteResult) && voter.status == voterStatus.afterSendVoteOk ) { @@ -390,7 +390,7 @@ contract schelling is module, announcementTypes, schellingVars { delete voter.status; delete voter.roundID; } else { revert(); } - + setVoter(msg.sender, voter); setFunds(msg.sender, funds); } @@ -400,12 +400,12 @@ contract schelling is module, announcementTypes, schellingVars { The prizes will be collected here, and with this function can be transferred to the account of the user. Optionally there can be an address of a beneficiary added, which address the prize will be sent to. Without beneficiary, the owner is the default address. Prize will be sent from the Schelling address without any transaction fee. - + @beneficiary Address of the beneficiary */ schellingVars._voter memory voter = getVoter(msg.sender); uint256 funds = getFunds(msg.sender); - + address _beneficiary = msg.sender; if (beneficiary != address(0x00)) { _beneficiary = beneficiary; } uint256 reward; @@ -414,13 +414,13 @@ contract schelling is module, announcementTypes, schellingVars { reward = voter.rewards; delete voter.rewards; require( moduleHandler(moduleHandlerAddress).transfer(address(this), _beneficiary, reward, false) ); - + setVoter(msg.sender, voter); } function checkReward() public view returns (uint256 reward) { /* Withdraw of the amount of the prize (it’s only information). - + @reward Prize */ schellingVars._voter memory voter = getVoter(msg.sender); @@ -435,9 +435,9 @@ contract schelling is module, announcementTypes, schellingVars { _rounds memory newRound; _rounds memory prevRound; uint256 currentSchellingRound = getCurrentSchellingRound(); - + if ( round.blockHeight+roundBlockDelay > block.number) { return false; } - + newRound.blockHeight = block.number; if ( ! round.voted ) { newRound.reward = round.reward; @@ -452,9 +452,9 @@ contract schelling is module, announcementTypes, schellingVars { if ( above >= interestCheckAboves ) { expansion = getTotalSupply() * interestRate / interestRateM / 100; } - + currentSchellingRound++; - + pushRound(newRound); setSchellingExpansion(currentSchellingRound, expansion); require( moduleHandler(moduleHandlerAddress).broadcastSchellingRound(currentSchellingRound, expansion) ); @@ -466,19 +466,19 @@ contract schelling is module, announcementTypes, schellingVars { Every participant entry with his own deposit. In case of wrong vote only this amount of deposit will be burn. The deposit will be sent to the address of Schelling, charged with transaction fee. - + @amount Amount of deposit. */ _voter memory voter = getVoter(msg.sender); uint256 funds = getFunds(msg.sender); - + (bool a, bool b) = moduleHandler(moduleHandlerAddress).isICO(); require( b && b ); require( voter.status == voterStatus.base ); require( amount > 0 ); require( moduleHandler(moduleHandlerAddress).transfer(msg.sender, address(this), amount, true) ); funds += amount; - + setFunds(msg.sender, funds); } function getFunds() isReady noContract external { @@ -489,17 +489,17 @@ contract schelling is module, announcementTypes, schellingVars { */ _voter memory voter = getVoter(msg.sender); uint256 funds = getFunds(msg.sender); - + require( funds > 0 ); require( voter.status == voterStatus.base ); setFunds(msg.sender, 0); - + require( moduleHandler(moduleHandlerAddress).transfer(address(this), msg.sender, funds, true) ); } function getCurrentSchellingRoundID() public view returns (uint256) { /* Number of actual Schelling round. - + @uint256 Schelling round. */ return getCurrentSchellingRound(); @@ -507,7 +507,7 @@ contract schelling is module, announcementTypes, schellingVars { function getSchellingRound(uint256 id) public view returns (uint256 expansion) { /* Amount of token emission of the Schelling round. - + @id Number of Schelling round @expansion Amount of token emission */ @@ -516,7 +516,7 @@ contract schelling is module, announcementTypes, schellingVars { function getRoundWeight(uint256 aboveW, uint256 belowW) internal returns (uint256) { /* Inside function for calculating the weights of the votes. - + @aboveW Weight of votes: ABOVE @belowW Weight of votes: BELOW @uint256 Calculatet weight @@ -532,7 +532,7 @@ contract schelling is module, announcementTypes, schellingVars { function isWinner(_rounds memory round, bool aboveVote) internal returns (bool) { /* Inside function for calculating the result of the game. - + @round Structure of Schelling round. @aboveVote Is the vote = ABOVE or not @bool Result @@ -543,31 +543,31 @@ contract schelling is module, announcementTypes, schellingVars { } return false; } - + function getTotalSupply() internal returns (uint256 amount) { /* Inside function for querying the whole amount of the tokens. - + @uint256 Whole token amount */ (bool _success, uint256 _amount) = moduleHandler(moduleHandlerAddress).totalSupply(); require( _success ); return _amount; } - + function getTokenBalance(address addr) internal returns (uint256 balance) { /* Inner function in order to poll the token balance of the address. - + @addr Address - + @balance Balance of the address. */ (bool _success, uint256 _balance) = moduleHandler(moduleHandlerAddress).balanceOf(addr); require( _success ); return _balance; } - + modifier noContract { /* Contract can’t call this function, only a natural address. diff --git a/test/compilationTests/corion/token.sol b/test/compilationTests/corion/token.sol index 6c8f6f24..87ec64d6 100644 --- a/test/compilationTests/corion/token.sol +++ b/test/compilationTests/corion/token.sol @@ -23,7 +23,7 @@ contract token is safeMath, module, announcementTypes { } modifier isReady { (bool _success, bool _active) = super.isActive(); - require( _success && _active ); + require( _success && _active ); _; } /** @@ -35,7 +35,7 @@ contract token is safeMath, module, announcementTypes { string public name = "Corion"; string public symbol = "COR"; uint8 public decimals = 6; - + tokenDB public db; address public icoAddr; uint256 public transactionFeeRate = 20; @@ -45,15 +45,15 @@ contract token is safeMath, module, announcementTypes { uint256 public transactionFeeBurn = 80; address public exchangeAddress; bool public isICO = true; - + mapping(address => bool) public genesis; constructor(bool forReplace, address moduleHandler, address dbAddr, address icoContractAddr, address exchangeContractAddress, address[] memory genesisAddr, uint256[] memory genesisValue) public payable { /* Installation function - + When _icoAddr is defined, 0.2 ether has to be attached as many times as many genesis addresses are given - + @forReplace This address will be replaced with the old one or not. @moduleHandler Modulhandler's address @dbAddr Address of database @@ -71,7 +71,7 @@ contract token is safeMath, module, announcementTypes { exchangeAddress = exchangeContractAddress; isICO = ! forReplace; if ( ! forReplace ) { - require( db.replaceOwner(this) ); + require( db.replaceOwner(address(this)) ); assert( genesisAddr.length == genesisValue.length ); require( address(this).balance >= genesisAddr.length * 0.2 ether ); for ( uint256 a=0 ; a<genesisAddr.length ; a++ ) { @@ -82,18 +82,18 @@ contract token is safeMath, module, announcementTypes { } } } - + function closeIco() external returns (bool success) { /* ICO finished. It can be called only by ICO contract - + @success Was the Function successful? */ require( msg.sender == icoAddr ); isICO = false; return true; } - + /** * @notice `msg.sender` approves `spender` to spend `amount` tokens on its behalf. * @param spender The address of the account able to transfer the tokens @@ -104,17 +104,17 @@ contract token is safeMath, module, announcementTypes { function approve(address spender, uint256 amount, uint256 nonce) isReady external returns (bool success) { /* Authorise another address to use a certain quantity of the authorising owner’s balance - + @spender Address of authorised party @amount Token quantity @nonce Transaction count - + @success Was the Function successful? */ _approve(spender, amount, nonce); return true; } - + /** * @notice `msg.sender` approves `spender` to spend `amount` tokens on its behalf and notify the spender from your approve with your `extraData` data. * @param spender The address of the account able to transfer the tokens @@ -127,24 +127,24 @@ contract token is safeMath, module, announcementTypes { /* Authorise another address to use a certain quantity of the authorising owner’s balance Following the transaction the receiver address `approvedCorionToken` function is called by the given data - + @spender Authorized address @amount Token quantity @extraData Extra data to be received by the receiver @nonce Transaction count - + @success Was the Function successful? */ _approve(spender, amount, nonce); require( thirdPartyContractAbstract(spender).approvedCorionToken(msg.sender, amount, extraData) ); return true; } - + function _approve(address spender, uint256 amount, uint256 nonce) internal { /* Internal Function to authorise another address to use a certain quantity of the authorising owner’s balance. If the transaction count not match the authorise fails. - + @spender Address of authorised party @amount Token quantity @nonce Transaction count @@ -158,10 +158,10 @@ contract token is safeMath, module, announcementTypes { function allowance(address owner, address spender) public view returns (uint256 remaining, uint256 nonce) { /* Get the quantity of tokens given to be used - + @owner Authorising address @spender Authorised address - + @remaining Tokens to be spent @nonce Transaction count */ @@ -169,7 +169,7 @@ contract token is safeMath, module, announcementTypes { require( _success ); return (_remaining, _nonce); } - + /** * @notice Send `amount` Corion tokens to `to` from `msg.sender` * @param to The address of the recipient @@ -181,10 +181,10 @@ contract token is safeMath, module, announcementTypes { Start transaction, token is sent from caller’s address to receiver’s address Transaction fee is to be deducted. If receiver is not a natural address but a person, he will be called - + @to To who @amount Quantity - + @success Was the Function successful? */ bytes memory _data; @@ -196,7 +196,7 @@ contract token is safeMath, module, announcementTypes { emit Transfer(msg.sender, to, amount, _data); return true; } - + /** * @notice Send `amount` tokens to `to` from `from` on the condition it is approved by `from` * @param from The address holding the tokens being transferred @@ -209,11 +209,11 @@ contract token is safeMath, module, announcementTypes { Start transaction to send a quantity from a given address to another address. (approve / allowance). This can be called only by the address approved in advance Transaction fee is to be deducted If receiver is not a natural address but a person, he will be called - + @from From who. @to To who @amount Quantity - + @success Was the Function successful? */ if ( from != msg.sender ) { @@ -233,7 +233,7 @@ contract token is safeMath, module, announcementTypes { emit Transfer(from, to, amount, _data); return true; } - + /** * @notice Send `amount` tokens to `to` from `from` on the condition it is approved by `from` * @param from The address holding the tokens being transferred @@ -245,12 +245,12 @@ contract token is safeMath, module, announcementTypes { /* Start transaction to send a quantity from a given address to another address Only ModuleHandler can call it - + @from From who @to To who. @amount Quantity @fee Deduct transaction fee - yes or no? - + @success Was the Function successful? */ bytes memory _data; @@ -259,7 +259,7 @@ contract token is safeMath, module, announcementTypes { emit Transfer(from, to, amount, _data); return true; } - + /** * @notice Send `amount` Corion tokens to `to` from `msg.sender` and notify the receiver from your transaction with your `extraData` data * @param to The contract address of the recipient @@ -272,11 +272,11 @@ contract token is safeMath, module, announcementTypes { Start transaction to send a quantity from a given address to another address After transaction the function `receiveCorionToken`of the receiver is called by the given data When sending an amount, it is possible the total amount cannot be processed, the remaining amount is sent back with no fee charged - + @to To who. @amount Quantity @extraData Extra data the receiver will get - + @success Was the Function successful? */ if ( isContract(to) ) { @@ -287,11 +287,11 @@ contract token is safeMath, module, announcementTypes { emit Transfer(msg.sender, to, amount, extraData); return true; } - + function _transferToContract(address from, address to, uint256 amount, bytes memory extraData) internal { /* Internal function to start transactions to a contract - + @from From who @to To who. @amount Quantity @@ -306,15 +306,15 @@ contract token is safeMath, module, announcementTypes { } _processTransactionFee(from, amount - _back); } - + function _transfer(address from, address to, uint256 amount, bool fee) internal { /* Internal function to start transactions. When Tokens are sent, transaction fee is charged During ICO transactions are allowed only from genesis addresses. - After sending the tokens, the ModuleHandler is notified and it will broadcast the fact among members - + After sending the tokens, the ModuleHandler is notified and it will broadcast the fact among members + The 0xa636a97578d26a3b76b060bbc18226d954cf3757 address are blacklisted. - + @from From who @to To who @amount Quantity @@ -336,7 +336,7 @@ contract token is safeMath, module, announcementTypes { } require( moduleHandler(moduleHandlerAddress).broadcastTransfer(from, to, amount) ); } - + /** * @notice Transaction fee will be deduced from `owner` for transacting `value` * @param owner The address where will the transaction fee deduced @@ -345,23 +345,23 @@ contract token is safeMath, module, announcementTypes { */ function processTransactionFee(address owner, uint256 value) isReady external returns (bool success) { /* - Charge transaction fee. It can be called only by moduleHandler - + Charge transaction fee. It can be called only by moduleHandler + @owner From who. @value Quantity to calculate the fee - + @success Was the Function successful? */ require( super.isModuleHandler(msg.sender) ); _processTransactionFee(owner, value); return true; } - + function _processTransactionFee(address owner, uint256 value) internal { /* Internal function to charge the transaction fee. A certain quantity is burnt, the rest is sent to the Schelling game prize pool. No transaction fee during ICO. - + @owner From who @value Quantity to calculate the fee */ @@ -385,13 +385,13 @@ contract token is safeMath, module, announcementTypes { _burn(owner, _fee); } } - + function getTransactionFee(uint256 value) public view returns (bool success, uint256 fee) { /* Transaction fee query. - + @value Quantity to calculate the fee - + @success Was the Function successful? @fee Amount of Transaction fee */ @@ -401,25 +401,25 @@ contract token is safeMath, module, announcementTypes { else if ( fee < transactionFeeMin ) { fee = transactionFeeMin; } return (true, fee); } - + function mint(address owner, uint256 value) isReady external returns (bool success) { /* Generating tokens. It can be called only by ICO contract or the moduleHandler. - + @owner Address @value Amount. - + @success Was the Function successful? */ require( super.isModuleHandler(msg.sender) || msg.sender == icoAddr ); _mint(owner, value); return true; } - + function _mint(address owner, uint256 value) internal { /* Internal function to generate tokens - + @owner Token is credited to this address @value Quantity */ @@ -430,25 +430,25 @@ contract token is safeMath, module, announcementTypes { } emit Mint(owner, value); } - + function burn(address owner, uint256 value) isReady external returns (bool success) { /* Burning the token. Can call only modulehandler - + @owner Burn the token from this address @value Quantity - + @success Was the Function successful? */ require( super.isModuleHandler(msg.sender) ); _burn(owner, value); return true; } - + function _burn(address owner, uint256 value) internal { /* Internal function to burn the token - + @owner Burn the token from this address @value Quantity */ @@ -456,13 +456,13 @@ contract token is safeMath, module, announcementTypes { require( moduleHandler(moduleHandlerAddress).broadcastTransfer(owner, address(0x00), value) ); emit Burn(owner, value); } - + function isContract(address addr) internal returns (bool success) { /* Internal function to check if the given address is natural, or a contract - + @addr Address to be checked - + @success Is the address crontact or not */ uint256 _codeLength; @@ -475,9 +475,9 @@ contract token is safeMath, module, announcementTypes { function balanceOf(address owner) public view returns (uint256 value) { /* Token balance query - + @owner Address - + @value Balance of address */ return db.balanceOf(owner); @@ -486,19 +486,19 @@ contract token is safeMath, module, announcementTypes { function totalSupply() public view returns (uint256 value) { /* Total token quantity query - + @value Total token quantity */ return db.totalSupply(); } - + function configure(announcementType aType, uint256 value) isReady external returns(bool success) { /* Token settings configuration.It can be call only by moduleHandler - + @aType Type of setting @value Value - + @success Was the Function successful? */ require( super.isModuleHandler(msg.sender) ); @@ -509,7 +509,7 @@ contract token is safeMath, module, announcementTypes { else { return false; } return true; } - + event AllowanceUsed(address indexed spender, address indexed owner, uint256 indexed value); event Mint(address indexed addr, uint256 indexed value); event Burn(address indexed addr, uint256 indexed value); diff --git a/test/compilationTests/corion/tokenDB.sol b/test/compilationTests/corion/tokenDB.sol index 484135ca..1632a89b 100644 --- a/test/compilationTests/corion/tokenDB.sol +++ b/test/compilationTests/corion/tokenDB.sol @@ -1,77 +1,77 @@ -pragma solidity ^0.4.11;
-
-import "./safeMath.sol";
-import "./owned.sol";
-
-contract tokenDB is safeMath, ownedDB {
-
- struct allowance_s {
- uint256 amount;
- uint256 nonce;
- }
-
- mapping(address => mapping(address => allowance_s)) public allowance;
- mapping (address => uint256) public balanceOf;
- uint256 public totalSupply;
-
- function increase(address owner, uint256 value) external returns(bool success) {
- /*
- Increase of balance of the address in database. Only owner can call it.
-
- @owner Address
- @value Quantity
-
- @success Was the Function successful?
- */
- require( isOwner() );
- balanceOf[owner] = safeAdd(balanceOf[owner], value);
- totalSupply = safeAdd(totalSupply, value);
- return true;
- }
-
- function decrease(address owner, uint256 value) external returns(bool success) {
- /*
- Decrease of balance of the address in database. Only owner can call it.
-
- @owner Address
- @value Quantity
-
- @success Was the Function successful?
- */
- require( isOwner() );
- balanceOf[owner] = safeSub(balanceOf[owner], value);
- totalSupply = safeSub(totalSupply, value);
- return true;
- }
-
- function setAllowance(address owner, address spender, uint256 amount, uint256 nonce) external returns(bool success) {
- /*
- Set allowance in the database. Only owner can call it.
-
- @owner Owner address
- @spender Spender address
- @amount Amount to set
- @nonce Transaction count
-
- @success Was the Function successful?
- */
- require( isOwner() );
- allowance[owner][spender].amount = amount;
- allowance[owner][spender].nonce = nonce;
- return true;
- }
-
- function getAllowance(address owner, address spender) public view returns(bool success, uint256 remaining, uint256 nonce) {
- /*
- Get allowance from the database.
-
- @owner Owner address
- @spender Spender address
-
- @success Was the Function successful?
- @remaining Remaining amount of the allowance
- @nonce Transaction count
- */
- return ( true, allowance[owner][spender].amount, allowance[owner][spender].nonce );
- }
-}
+pragma solidity ^0.4.11; + +import "./safeMath.sol"; +import "./owned.sol"; + +contract tokenDB is safeMath, ownedDB { + + struct allowance_s { + uint256 amount; + uint256 nonce; + } + + mapping(address => mapping(address => allowance_s)) public allowance; + mapping (address => uint256) public balanceOf; + uint256 public totalSupply; + + function increase(address owner, uint256 value) external returns(bool success) { + /* + Increase of balance of the address in database. Only owner can call it. + + @owner Address + @value Quantity + + @success Was the Function successful? + */ + require( isOwner() ); + balanceOf[owner] = safeAdd(balanceOf[owner], value); + totalSupply = safeAdd(totalSupply, value); + return true; + } + + function decrease(address owner, uint256 value) external returns(bool success) { + /* + Decrease of balance of the address in database. Only owner can call it. + + @owner Address + @value Quantity + + @success Was the Function successful? + */ + require( isOwner() ); + balanceOf[owner] = safeSub(balanceOf[owner], value); + totalSupply = safeSub(totalSupply, value); + return true; + } + + function setAllowance(address owner, address spender, uint256 amount, uint256 nonce) external returns(bool success) { + /* + Set allowance in the database. Only owner can call it. + + @owner Owner address + @spender Spender address + @amount Amount to set + @nonce Transaction count + + @success Was the Function successful? + */ + require( isOwner() ); + allowance[owner][spender].amount = amount; + allowance[owner][spender].nonce = nonce; + return true; + } + + function getAllowance(address owner, address spender) public view returns(bool success, uint256 remaining, uint256 nonce) { + /* + Get allowance from the database. + + @owner Owner address + @spender Spender address + + @success Was the Function successful? + @remaining Remaining amount of the allowance + @nonce Transaction count + */ + return ( true, allowance[owner][spender].amount, allowance[owner][spender].nonce ); + } +} diff --git a/test/compilationTests/gnosis/Events/Event.sol b/test/compilationTests/gnosis/Events/Event.sol index 5b1a550c..0a40cf7e 100644 --- a/test/compilationTests/gnosis/Events/Event.sol +++ b/test/compilationTests/gnosis/Events/Event.sol @@ -54,7 +54,7 @@ contract Event { public { // Transfer collateral tokens to events contract - require(collateralToken.transferFrom(msg.sender, this, collateralTokenCount)); + require(collateralToken.transferFrom(msg.sender, address(this), collateralTokenCount)); // Issue new outcome tokens to sender for (uint8 i = 0; i < outcomeTokens.length; i++) outcomeTokens[i].issue(msg.sender, collateralTokenCount); diff --git a/test/compilationTests/gnosis/Markets/Campaign.sol b/test/compilationTests/gnosis/Markets/Campaign.sol index f99ede53..119f8df2 100644 --- a/test/compilationTests/gnosis/Markets/Campaign.sol +++ b/test/compilationTests/gnosis/Markets/Campaign.sol @@ -102,12 +102,12 @@ contract Campaign { timedTransitions atStage(Stages.AuctionStarted) { - uint raisedAmount = eventContract.collateralToken().balanceOf(this); + uint raisedAmount = eventContract.collateralToken().balanceOf(address(this)); uint maxAmount = funding.sub(raisedAmount); if (maxAmount < amount) amount = maxAmount; // Collect collateral tokens - require(eventContract.collateralToken().transferFrom(msg.sender, this, amount)); + require(eventContract.collateralToken().transferFrom(msg.sender, address(this), amount)); contributions[msg.sender] = contributions[msg.sender].add(amount); if (amount == maxAmount) stage = Stages.AuctionSuccessful; @@ -138,7 +138,7 @@ contract Campaign { returns (Market) { market = marketFactory.createMarket(eventContract, marketMaker, fee); - require(eventContract.collateralToken().approve(market, funding)); + require(eventContract.collateralToken().approve(address(market), funding)); market.fund(funding); stage = Stages.MarketCreated; emit MarketCreation(market); @@ -156,7 +156,7 @@ contract Campaign { market.close(); market.withdrawFees(); eventContract.redeemWinnings(); - finalBalance = eventContract.collateralToken().balanceOf(this); + finalBalance = eventContract.collateralToken().balanceOf(address(this)); stage = Stages.MarketClosed; emit MarketClosing(); } diff --git a/test/compilationTests/gnosis/Markets/StandardMarket.sol b/test/compilationTests/gnosis/Markets/StandardMarket.sol index 0a9f77db..2f52a896 100644 --- a/test/compilationTests/gnosis/Markets/StandardMarket.sol +++ b/test/compilationTests/gnosis/Markets/StandardMarket.sol @@ -60,8 +60,8 @@ contract StandardMarket is Market { atStage(Stages.MarketCreated) { // Request collateral tokens and allow event contract to transfer them to buy all outcomes - require( eventContract.collateralToken().transferFrom(msg.sender, this, _funding) - && eventContract.collateralToken().approve(eventContract, _funding)); + require( eventContract.collateralToken().transferFrom(msg.sender, address(this), _funding) + && eventContract.collateralToken().approve(address(eventContract), _funding)); eventContract.buyAllOutcomes(_funding); funding = _funding; stage = Stages.MarketFunded; @@ -76,7 +76,7 @@ contract StandardMarket is Market { { uint8 outcomeCount = eventContract.getOutcomeCount(); for (uint8 i = 0; i < outcomeCount; i++) - require(eventContract.outcomeTokens(i).transfer(creator, eventContract.outcomeTokens(i).balanceOf(this))); + require(eventContract.outcomeTokens(i).transfer(creator, eventContract.outcomeTokens(i).balanceOf(address(this)))); stage = Stages.MarketClosed; emit MarketClosing(); } @@ -88,7 +88,7 @@ contract StandardMarket is Market { isCreator returns (uint fees) { - fees = eventContract.collateralToken().balanceOf(this); + fees = eventContract.collateralToken().balanceOf(address(this)); // Transfer fees require(eventContract.collateralToken().transfer(creator, fees)); emit FeeWithdrawal(fees); @@ -112,8 +112,8 @@ contract StandardMarket is Market { // Check cost doesn't exceed max cost require(cost > 0 && cost <= maxCost); // Transfer tokens to markets contract and buy all outcomes - require( eventContract.collateralToken().transferFrom(msg.sender, this, cost) - && eventContract.collateralToken().approve(eventContract, outcomeTokenCost)); + require( eventContract.collateralToken().transferFrom(msg.sender, address(this), cost) + && eventContract.collateralToken().approve(address(eventContract), outcomeTokenCost)); // Buy all outcomes eventContract.buyAllOutcomes(outcomeTokenCost); // Transfer outcome tokens to buyer @@ -142,7 +142,7 @@ contract StandardMarket is Market { // Check profit is not too low require(profit > 0 && profit >= minProfit); // Transfer outcome tokens to markets contract to sell all outcomes - require(eventContract.outcomeTokens(outcomeTokenIndex).transferFrom(msg.sender, this, outcomeTokenCount)); + require(eventContract.outcomeTokens(outcomeTokenIndex).transferFrom(msg.sender, address(this), outcomeTokenCount)); // Sell all outcomes eventContract.sellAllOutcomes(outcomeTokenProfit); // Transfer profit to seller @@ -164,11 +164,11 @@ contract StandardMarket is Market { returns (uint cost) { // Buy all outcomes - require( eventContract.collateralToken().transferFrom(msg.sender, this, outcomeTokenCount) - && eventContract.collateralToken().approve(eventContract, outcomeTokenCount)); + require( eventContract.collateralToken().transferFrom(msg.sender, address(this), outcomeTokenCount) + && eventContract.collateralToken().approve(address(eventContract), outcomeTokenCount)); eventContract.buyAllOutcomes(outcomeTokenCount); // Short sell selected outcome - eventContract.outcomeTokens(outcomeTokenIndex).approve(this, outcomeTokenCount); + eventContract.outcomeTokens(outcomeTokenIndex).approve(address(this), outcomeTokenCount); uint profit = this.sell(outcomeTokenIndex, outcomeTokenCount, minProfit); cost = outcomeTokenCount - profit; // Transfer outcome tokens to buyer diff --git a/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol b/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol index cf851f5b..83d10b2e 100644 --- a/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol +++ b/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol @@ -95,14 +95,14 @@ contract FutarchyOracle is Oracle { isCreator { // Buy all outcomes - require( categoricalEvent.collateralToken().transferFrom(creator, this, funding) - && categoricalEvent.collateralToken().approve(categoricalEvent, funding)); + require( categoricalEvent.collateralToken().transferFrom(creator, address(this), funding) + && categoricalEvent.collateralToken().approve(address(categoricalEvent), funding)); categoricalEvent.buyAllOutcomes(funding); // Fund each market with outcome tokens from categorical event for (uint8 i = 0; i < markets.length; i++) { Market market = markets[i]; // Approve funding for market - require(market.eventContract().collateralToken().approve(market, funding)); + require(market.eventContract().collateralToken().approve(address(market), funding)); market.fund(funding); } emit FutarchyFunding(funding); @@ -122,7 +122,7 @@ contract FutarchyOracle is Oracle { market.withdrawFees(); // Redeem collateral token for winning outcome tokens and transfer collateral tokens to creator categoricalEvent.redeemWinnings(); - require(categoricalEvent.collateralToken().transfer(creator, categoricalEvent.collateralToken().balanceOf(this))); + require(categoricalEvent.collateralToken().transfer(creator, categoricalEvent.collateralToken().balanceOf(address(this)))); emit FutarchyClosing(); } diff --git a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol index b7cc231c..452a34ec 100644 --- a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol +++ b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol @@ -92,7 +92,7 @@ contract UltimateOracle is Oracle { // There was no challenge yet or the challenge period expired require( !isChallenged() && !isChallengePeriodOver() - && collateralToken.transferFrom(msg.sender, this, challengeAmount)); + && collateralToken.transferFrom(msg.sender, address(this), challengeAmount)); outcomeAmounts[msg.sender][_outcome] = challengeAmount; totalOutcomeAmounts[_outcome] = challengeAmount; totalAmount = challengeAmount; @@ -113,7 +113,7 @@ contract UltimateOracle is Oracle { // Outcome is challenged and front runner period is not over yet and tokens can be transferred require( isChallenged() && !isFrontRunnerPeriodOver() - && collateralToken.transferFrom(msg.sender, this, amount)); + && collateralToken.transferFrom(msg.sender, address(this), amount)); outcomeAmounts[msg.sender][_outcome] = outcomeAmounts[msg.sender][_outcome].add(amount); totalOutcomeAmounts[_outcome] = totalOutcomeAmounts[_outcome].add(amount); totalAmount = totalAmount.add(amount); diff --git a/test/compilationTests/gnosis/Tokens/OutcomeToken.sol b/test/compilationTests/gnosis/Tokens/OutcomeToken.sol index 0bc7307d..fccf05e5 100644 --- a/test/compilationTests/gnosis/Tokens/OutcomeToken.sol +++ b/test/compilationTests/gnosis/Tokens/OutcomeToken.sol @@ -36,7 +36,7 @@ contract OutcomeToken is StandardToken { { eventContract = msg.sender; } - + /// @dev Events contract issues new tokens for address. Returns success /// @param _for Address of receiver /// @param outcomeTokenCount Number of tokens to issue diff --git a/test/compilationTests/zeppelin/Bounty.sol b/test/compilationTests/zeppelin/Bounty.sol index 55e64071..d45e130c 100644 --- a/test/compilationTests/zeppelin/Bounty.sol +++ b/test/compilationTests/zeppelin/Bounty.sol @@ -25,14 +25,14 @@ contract Bounty is PullPayment, Destructible { } /** - * @dev Create and deploy the target contract (extension of Target contract), and sets the + * @dev Create and deploy the target contract (extension of Target contract), and sets the * msg.sender as a researcher * @return A target contract */ function createTarget() public returns(Target) { Target target = Target(deployContract()); - researchers[target] = msg.sender; - emit TargetCreated(target); + researchers[address(target)] = msg.sender; + emit TargetCreated(address(target)); return target; } @@ -47,7 +47,7 @@ contract Bounty is PullPayment, Destructible { * @param target contract */ function claim(Target target) public { - address researcher = researchers[target]; + address researcher = researchers[address(target)]; if (researcher == address(0)) { revert(); } @@ -69,10 +69,10 @@ contract Bounty is PullPayment, Destructible { contract Target { /** - * @dev Checks all values a contract assumes to be true all the time. If this function returns - * false, the contract is broken in some way and is in an inconsistent state. - * In order to win the bounty, security researchers will try to cause this broken state. - * @return True if all invariant values are correct, false otherwise. + * @dev Checks all values a contract assumes to be true all the time. If this function returns + * false, the contract is broken in some way and is in an inconsistent state. + * In order to win the bounty, security researchers will try to cause this broken state. + * @return True if all invariant values are correct, false otherwise. */ function checkInvariant() public returns(bool); } diff --git a/test/compilationTests/zeppelin/LimitBalance.sol b/test/compilationTests/zeppelin/LimitBalance.sol index 8bf4b253..d07b3c2c 100644 --- a/test/compilationTests/zeppelin/LimitBalance.sol +++ b/test/compilationTests/zeppelin/LimitBalance.sol @@ -12,7 +12,7 @@ contract LimitBalance { uint256 public limit; /** - * @dev Constructor that sets the passed value as a limit. + * @dev Constructor that sets the passed value as a limit. * @param _limit uint256 to represent the limit. */ constructor(uint256 _limit) public { diff --git a/test/compilationTests/zeppelin/ReentrancyGuard.sol b/test/compilationTests/zeppelin/ReentrancyGuard.sol index 7805ec07..f7abb698 100644 --- a/test/compilationTests/zeppelin/ReentrancyGuard.sol +++ b/test/compilationTests/zeppelin/ReentrancyGuard.sol @@ -9,7 +9,7 @@ pragma solidity ^0.4.11; contract ReentrancyGuard { /** - * @dev We use a single lock for the whole contract. + * @dev We use a single lock for the whole contract. */ bool private rentrancy_lock = false; diff --git a/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol b/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol index da4e3b7f..e94fc9fb 100644 --- a/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol +++ b/test/compilationTests/zeppelin/crowdsale/FinalizableCrowdsale.sol @@ -24,7 +24,7 @@ contract FinalizableCrowdsale is Crowdsale, Ownable { finalization(); emit Finalized(); - + isFinalized = true; } diff --git a/test/compilationTests/zeppelin/lifecycle/Destructible.sol b/test/compilationTests/zeppelin/lifecycle/Destructible.sol index 5b0e9f58..8b57924d 100644 --- a/test/compilationTests/zeppelin/lifecycle/Destructible.sol +++ b/test/compilationTests/zeppelin/lifecycle/Destructible.sol @@ -13,7 +13,7 @@ contract Destructible is Ownable { constructor() public payable { } /** - * @dev Transfers the current balance to the owner and terminates the contract. + * @dev Transfers the current balance to the owner and terminates the contract. */ function destroy() public onlyOwner { selfdestruct(owner); diff --git a/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol b/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol index 51f6b68e..eb141587 100644 --- a/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol +++ b/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol @@ -4,7 +4,7 @@ pragma solidity ^0.4.11; import "../ownership/Ownable.sol"; import "../token/ERC20Basic.sol"; -/** +/** * @title TokenDestructible: * @author Remco Bloemen <remco@2π.com> * @dev Base contract that can be destroyed by owner. All funds in contract including @@ -14,7 +14,7 @@ contract TokenDestructible is Ownable { constructor() public payable { } - /** + /** * @notice Terminate contract and refund to owner * @param tokens List of addresses of ERC20 or ERC20Basic token contracts to refund. @@ -26,7 +26,7 @@ contract TokenDestructible is Ownable { // Transfer tokens to owner for(uint256 i = 0; i < tokens.length; i++) { ERC20Basic token = ERC20Basic(tokens[i]); - uint256 balance = token.balanceOf(this); + uint256 balance = token.balanceOf(address(this)); token.transfer(owner, balance); } diff --git a/test/compilationTests/zeppelin/ownership/Claimable.sol b/test/compilationTests/zeppelin/ownership/Claimable.sol index d7b48a29..7778e2de 100644 --- a/test/compilationTests/zeppelin/ownership/Claimable.sol +++ b/test/compilationTests/zeppelin/ownership/Claimable.sol @@ -6,14 +6,14 @@ import './Ownable.sol'; /** * @title Claimable - * @dev Extension for the Ownable contract, where the ownership needs to be claimed. + * @dev Extension for the Ownable contract, where the ownership needs to be claimed. * This allows the new owner to accept the transfer. */ contract Claimable is Ownable { address public pendingOwner; /** - * @dev Modifier throws if called by any account other than the pendingOwner. + * @dev Modifier throws if called by any account other than the pendingOwner. */ modifier onlyPendingOwner() { if (msg.sender != pendingOwner) { @@ -23,8 +23,8 @@ contract Claimable is Ownable { } /** - * @dev Allows the current owner to set the pendingOwner address. - * @param newOwner The address to transfer ownership to. + * @dev Allows the current owner to set the pendingOwner address. + * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { pendingOwner = newOwner; diff --git a/test/compilationTests/zeppelin/ownership/Contactable.sol b/test/compilationTests/zeppelin/ownership/Contactable.sol index 5f781e13..5053494d 100644 --- a/test/compilationTests/zeppelin/ownership/Contactable.sol +++ b/test/compilationTests/zeppelin/ownership/Contactable.sol @@ -4,7 +4,7 @@ import './Ownable.sol'; /** * @title Contactable token - * @dev Basic version of a contactable contract, allowing the owner to provide a string with their + * @dev Basic version of a contactable contract, allowing the owner to provide a string with their * contact information. */ contract Contactable is Ownable{ diff --git a/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol b/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol index 540a2ce0..f4c8a681 100644 --- a/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol +++ b/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol @@ -15,10 +15,10 @@ contract DelayedClaimable is Claimable { uint256 public start; /** - * @dev Used to specify the time period during which a pending - * owner can claim ownership. + * @dev Used to specify the time period during which a pending + * owner can claim ownership. * @param _start The earliest time ownership can be claimed. - * @param _end The latest time ownership can be claimed. + * @param _end The latest time ownership can be claimed. */ function setLimits(uint256 _start, uint256 _end) public onlyOwner { if (_start > _end) @@ -29,8 +29,8 @@ contract DelayedClaimable is Claimable { /** - * @dev Allows the pendingOwner address to finalize the transfer, as long as it is called within - * the specified start and end time. + * @dev Allows the pendingOwner address to finalize the transfer, as long as it is called within + * the specified start and end time. */ function claimOwnership() public onlyPendingOwner { if ((block.number > end) || (block.number < start)) diff --git a/test/compilationTests/zeppelin/ownership/HasNoContracts.sol b/test/compilationTests/zeppelin/ownership/HasNoContracts.sol index b5bd649d..19b363d4 100644 --- a/test/compilationTests/zeppelin/ownership/HasNoContracts.sol +++ b/test/compilationTests/zeppelin/ownership/HasNoContracts.sol @@ -2,7 +2,7 @@ pragma solidity ^0.4.11; import "./Ownable.sol"; -/** +/** * @title Contracts that should not own Contracts * @author Remco Bloemen <remco@2π.com> * @dev Should contracts (anything Ownable) end up being owned by this contract, it allows the owner diff --git a/test/compilationTests/zeppelin/ownership/HasNoEther.sol b/test/compilationTests/zeppelin/ownership/HasNoEther.sol index 75d90841..5e3d27d2 100644 --- a/test/compilationTests/zeppelin/ownership/HasNoEther.sol +++ b/test/compilationTests/zeppelin/ownership/HasNoEther.sol @@ -2,7 +2,7 @@ pragma solidity ^0.4.11; import "./Ownable.sol"; -/** +/** * @title Contracts that should not own Ether * @author Remco Bloemen <remco@2π.com> * @dev This tries to block incoming ether to prevent accidental loss of Ether. Should Ether end up @@ -16,9 +16,9 @@ contract HasNoEther is Ownable { /** * @dev Constructor that rejects incoming Ether - * @dev The `payable` flag is added so we can access `msg.value` without compiler warning. If we - * leave out payable, then Solidity will allow inheriting contracts to implement a payable - * constructor. By doing it this way we prevent a payable constructor from working. Alternatively + * @dev The `payable` flag is added so we can access `msg.value` without compiler warning. If we + * leave out payable, then Solidity will allow inheriting contracts to implement a payable + * constructor. By doing it this way we prevent a payable constructor from working. Alternatively * we could use assembly to access msg.value. */ constructor() public payable { diff --git a/test/compilationTests/zeppelin/ownership/HasNoTokens.sol b/test/compilationTests/zeppelin/ownership/HasNoTokens.sol index df4284f1..e14d8da7 100644 --- a/test/compilationTests/zeppelin/ownership/HasNoTokens.sol +++ b/test/compilationTests/zeppelin/ownership/HasNoTokens.sol @@ -3,7 +3,7 @@ pragma solidity ^0.4.11; import "./Ownable.sol"; import "../token/ERC20Basic.sol"; -/** +/** * @title Contracts that should not own Tokens * @author Remco Bloemen <remco@2π.com> * @dev This blocks incoming ERC23 tokens to prevent accidental loss of tokens. @@ -12,7 +12,7 @@ import "../token/ERC20Basic.sol"; */ contract HasNoTokens is Ownable { - /** + /** * @dev Reject all ERC23 compatible tokens * @param from_ address The address that is transferring the tokens * @param value_ uint256 the amount of the specified token @@ -28,7 +28,7 @@ contract HasNoTokens is Ownable { */ function reclaimToken(address tokenAddr) external onlyOwner { ERC20Basic tokenInst = ERC20Basic(tokenAddr); - uint256 balance = tokenInst.balanceOf(this); + uint256 balance = tokenInst.balanceOf(address(this)); tokenInst.transfer(owner, balance); } } diff --git a/test/compilationTests/zeppelin/ownership/NoOwner.sol b/test/compilationTests/zeppelin/ownership/NoOwner.sol index 7215abf3..c0ef7f4d 100644 --- a/test/compilationTests/zeppelin/ownership/NoOwner.sol +++ b/test/compilationTests/zeppelin/ownership/NoOwner.sol @@ -4,10 +4,10 @@ import "./HasNoEther.sol"; import "./HasNoTokens.sol"; import "./HasNoContracts.sol"; -/** +/** * @title Base contract for contracts that should not own things. * @author Remco Bloemen <remco@2π.com> - * @dev Solves a class of errors where a contract accidentally becomes owner of Ether, Tokens or + * @dev Solves a class of errors where a contract accidentally becomes owner of Ether, Tokens or * Owned contracts. See respective base contracts for details. */ contract NoOwner is HasNoEther, HasNoTokens, HasNoContracts { diff --git a/test/compilationTests/zeppelin/ownership/Ownable.sol b/test/compilationTests/zeppelin/ownership/Ownable.sol index a862cb74..bd175077 100644 --- a/test/compilationTests/zeppelin/ownership/Ownable.sol +++ b/test/compilationTests/zeppelin/ownership/Ownable.sol @@ -3,14 +3,14 @@ pragma solidity ^0.4.11; /** * @title Ownable - * @dev The Ownable contract has an owner address, and provides basic authorization control - * functions, this simplifies the implementation of "user permissions". + * @dev The Ownable contract has an owner address, and provides basic authorization control + * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; - /** + /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ @@ -20,7 +20,7 @@ contract Ownable { /** - * @dev Throws if called by any account other than the owner. + * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { if (msg.sender != owner) { @@ -32,7 +32,7 @@ contract Ownable { /** * @dev Allows the current owner to transfer control of the contract to a newOwner. - * @param newOwner The address to transfer ownership to. + * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { if (newOwner != address(0)) { diff --git a/test/compilationTests/zeppelin/ownership/Shareable.sol b/test/compilationTests/zeppelin/ownership/Shareable.sol index 0c8d16a5..b2cb165d 100644 --- a/test/compilationTests/zeppelin/ownership/Shareable.sol +++ b/test/compilationTests/zeppelin/ownership/Shareable.sol @@ -3,7 +3,7 @@ pragma solidity ^0.4.11; /** * @title Shareable - * @dev inheritable "property" contract that enables methods to be protected by requiring the + * @dev inheritable "property" contract that enables methods to be protected by requiring the * acquiescence of either a single, or, crucially, each of a number of, designated owners. * @dev Usage: use modifiers onlyowner (just own owned) or onlymanyowners(hash), whereby the same hash must be provided by some number (specified in constructor) of the set of owners (specified in the constructor) before the interior is executed. */ @@ -41,9 +41,9 @@ contract Shareable { } _; } - - /** - * @dev Modifier for multisig functions. + + /** + * @dev Modifier for multisig functions. * @param _operation The operation must have an intrinsic hash in order that later attempts can be * realised as the same underlying operation and thus count as confirmations. */ @@ -53,8 +53,8 @@ contract Shareable { } } - /** - * @dev Constructor is given the number of sigs required to do protected "onlymanyowners" + /** + * @dev Constructor is given the number of sigs required to do protected "onlymanyowners" * transactions as well as the selection of addresses capable of confirming them. * @param _owners A list of owners. * @param _required The amount required for a transaction to be approved. diff --git a/test/compilationTests/zeppelin/token/BasicToken.sol b/test/compilationTests/zeppelin/token/BasicToken.sol index bc085f85..3d5646a4 100644 --- a/test/compilationTests/zeppelin/token/BasicToken.sol +++ b/test/compilationTests/zeppelin/token/BasicToken.sol @@ -7,7 +7,7 @@ import '../math/SafeMath.sol'; /** * @title Basic token - * @dev Basic version of StandardToken, with no allowances. + * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; @@ -27,7 +27,7 @@ contract BasicToken is ERC20Basic { /** * @dev Gets the balance of the specified address. - * @param _owner The address to query the the balance of. + * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { diff --git a/test/compilationTests/zeppelin/token/LimitedTransferToken.sol b/test/compilationTests/zeppelin/token/LimitedTransferToken.sol index 3ce928f6..d668b86f 100644 --- a/test/compilationTests/zeppelin/token/LimitedTransferToken.sol +++ b/test/compilationTests/zeppelin/token/LimitedTransferToken.sol @@ -4,11 +4,11 @@ import "./ERC20.sol"; /** * @title LimitedTransferToken - * @dev LimitedTransferToken defines the generic interface and the implementation to limit token - * transferability for different events. It is intended to be used as a base class for other token - * contracts. + * @dev LimitedTransferToken defines the generic interface and the implementation to limit token + * transferability for different events. It is intended to be used as a base class for other token + * contracts. * LimitedTransferToken has been designed to allow for different limiting factors, - * this can be achieved by recursively calling super.transferableTokens() until the base class is + * this can be achieved by recursively calling super.transferableTokens() until the base class is * hit. For example: * function transferableTokens(address holder, uint64 time) view public returns (uint256) { * return min256(unlockedTokens, super.transferableTokens(holder, time)); @@ -48,7 +48,7 @@ contract LimitedTransferToken is ERC20 { /** * @dev Default transferable tokens function returns all tokens for a holder (no limit). - * @dev Overwriting transferableTokens(address holder, uint64 time) is the way to provide the + * @dev Overwriting transferableTokens(address holder, uint64 time) is the way to provide the * specific logic for limiting token transferability for a holder over time. */ function transferableTokens(address holder, uint64 time) view public returns (uint256) { diff --git a/test/compilationTests/zeppelin/token/SimpleToken.sol b/test/compilationTests/zeppelin/token/SimpleToken.sol index 6c3f5740..d8717562 100644 --- a/test/compilationTests/zeppelin/token/SimpleToken.sol +++ b/test/compilationTests/zeppelin/token/SimpleToken.sol @@ -6,7 +6,7 @@ import "./StandardToken.sol"; /** * @title SimpleToken - * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator. + * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator. * Note they can later distribute these tokens as they wish using `transfer` and other * `StandardToken` functions. */ @@ -18,7 +18,7 @@ contract SimpleToken is StandardToken { uint256 public INITIAL_SUPPLY = 10000; /** - * @dev Constructor that gives msg.sender all of existing tokens. + * @dev Constructor that gives msg.sender all of existing tokens. */ constructor() public { totalSupply = INITIAL_SUPPLY; diff --git a/test/compilationTests/zeppelin/token/TokenTimelock.sol b/test/compilationTests/zeppelin/token/TokenTimelock.sol index fa1af025..4847b648 100644 --- a/test/compilationTests/zeppelin/token/TokenTimelock.sol +++ b/test/compilationTests/zeppelin/token/TokenTimelock.sol @@ -5,11 +5,11 @@ import './ERC20Basic.sol'; /** * @title TokenTimelock - * @dev TokenTimelock is a token holder contract that will allow a + * @dev TokenTimelock is a token holder contract that will allow a * beneficiary to extract the tokens after a given release time */ contract TokenTimelock { - + // ERC20 basic token contract being held ERC20Basic token; @@ -33,7 +33,7 @@ contract TokenTimelock { require(msg.sender == beneficiary); require(now >= releaseTime); - uint amount = token.balanceOf(this); + uint amount = token.balanceOf(address(this)); require(amount > 0); token.transfer(beneficiary, amount); diff --git a/test/compilationTests/zeppelin/token/VestedToken.sol b/test/compilationTests/zeppelin/token/VestedToken.sol index ca13b638..7edc7d16 100644 --- a/test/compilationTests/zeppelin/token/VestedToken.sol +++ b/test/compilationTests/zeppelin/token/VestedToken.sol @@ -226,7 +226,7 @@ contract VestedToken is StandardToken, LimitedTransferToken { * @dev Calculate the amount of non vested tokens at a specific time. * @param grant TokenGrant The grant to be checked. * @param time uint64 The time to be checked - * @return An uint256 representing the amount of non vested tokens of a specific grant on the + * @return An uint256 representing the amount of non vested tokens of a specific grant on the * passed time frame. */ function nonVestedTokens(TokenGrant memory grant, uint64 time) private view returns (uint256) { diff --git a/test/contracts/LLL_ENS.cpp b/test/contracts/LLL_ENS.cpp index 3461c577..cfd6970c 100644 --- a/test/contracts/LLL_ENS.cpp +++ b/test/contracts/LLL_ENS.cpp @@ -28,7 +28,7 @@ #define ACCOUNT(n) h256(account(n), h256::AlignRight) using namespace std; -using namespace dev::eth; +using namespace dev::lll; namespace dev { diff --git a/test/contracts/LLL_ERC20.cpp b/test/contracts/LLL_ERC20.cpp index 89d1c4f0..6c6762dd 100644 --- a/test/contracts/LLL_ERC20.cpp +++ b/test/contracts/LLL_ERC20.cpp @@ -33,7 +33,7 @@ #define SUCCESS encodeArgs(1) using namespace std; -using namespace dev::eth; +using namespace dev::lll; namespace dev { diff --git a/test/liblll/Compiler.cpp b/test/liblll/Compiler.cpp index ebdea185..1e6f6d87 100644 --- a/test/liblll/Compiler.cpp +++ b/test/liblll/Compiler.cpp @@ -46,7 +46,7 @@ namespace bool successCompile(string const& _sourceCode) { vector<string> errors; - bytes bytecode = eth::compileLLL(_sourceCode, dev::test::Options::get().evmVersion(), false, &errors); + bytes bytecode = lll::compileLLL(_sourceCode, dev::test::Options::get().evmVersion(), false, &errors); if (!errors.empty()) return false; if (bytecode.empty()) @@ -358,7 +358,7 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_functional) for (size_t i = 0; i < opcodes_bytecode.size(); i++) { vector<string> errors; - bytes code = eth::compileLLL(opcodes_lll[i], dev::test::Options::get().evmVersion(), false, &errors); + bytes code = lll::compileLLL(opcodes_lll[i], dev::test::Options::get().evmVersion(), false, &errors); BOOST_REQUIRE_MESSAGE(errors.empty(), opcodes_lll[i]); @@ -646,7 +646,7 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_asm) for (size_t i = 0; i < opcodes_bytecode.size(); i++) { vector<string> errors; - bytes code = eth::compileLLL(opcodes_lll[i], dev::test::Options::get().evmVersion(), false, &errors); + bytes code = lll::compileLLL(opcodes_lll[i], dev::test::Options::get().evmVersion(), false, &errors); BOOST_REQUIRE_MESSAGE(errors.empty(), opcodes_lll[i]); diff --git a/test/liblll/ExecutionFramework.h b/test/liblll/ExecutionFramework.h index ae5cd988..7c1ce670 100644 --- a/test/liblll/ExecutionFramework.h +++ b/test/liblll/ExecutionFramework.h @@ -56,7 +56,7 @@ public: BOOST_REQUIRE(_libraryAddresses.empty()); std::vector<std::string> errors; - bytes bytecode = eth::compileLLL(_sourceCode, dev::test::Options::get().evmVersion(), m_optimize, &errors); + bytes bytecode = lll::compileLLL(_sourceCode, dev::test::Options::get().evmVersion(), m_optimize, &errors); if (!errors.empty()) { for (auto const& error: errors) diff --git a/test/liblll/Parser.cpp b/test/liblll/Parser.cpp index fc977b81..d343aab1 100644 --- a/test/liblll/Parser.cpp +++ b/test/liblll/Parser.cpp @@ -39,13 +39,13 @@ namespace bool successParse(std::string const& _source) { - std::string ret = eth::parseLLL(_source); + std::string ret = lll::parseLLL(_source); return ret.size() != 0; } std::string parse(std::string const& _source) { - return eth::parseLLL(_source); + return lll::parseLLL(_source); } } diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 497ee867..736aa46c 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(simple_assert) function f(uint a) public pure { assert(a == 2); } } )"; - CHECK_WARNING(text, "Assertion violation happens here for"); + CHECK_WARNING(text, "Assertion violation happens here"); } BOOST_AUTO_TEST_CASE(simple_assert_with_require) diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 223250fa..e9e7c93b 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -9420,7 +9420,7 @@ BOOST_AUTO_TEST_CASE(failed_create) contract C { uint public x; constructor() public payable {} - function f(uint amount) public returns (address) { + function f(uint amount) public returns (D) { x++; return (new D).value(amount)(); } @@ -9428,7 +9428,7 @@ BOOST_AUTO_TEST_CASE(failed_create) if (depth < 1024) return this.stack(depth - 1); else - return f(0); + return address(f(0)); } } )"; @@ -12524,10 +12524,10 @@ BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure) return (new C()).f(); } function fview() public returns (uint) { - return (CView(new C())).f(); + return (CView(address(new C()))).f(); } function fpure() public returns (uint) { - return (CPure(new C())).f(); + return (CPure(address(new C()))).f(); } } )"; diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index 3e2dce26..119f80d1 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -74,9 +74,9 @@ public: unsigned const _optimizeRuns = 200 ) { - m_nonOptimizedBytecode = compileAndRunWithOptimizer(_sourceCode, _value, _contractName, false, _optimizeRuns); + m_nonOptimizedBytecode = compileAndRunWithOptimizer("pragma solidity >=0.0;\n" + _sourceCode, _value, _contractName, false, _optimizeRuns); m_nonOptimizedContract = m_contractAddress; - m_optimizedBytecode = compileAndRunWithOptimizer(_sourceCode, _value, _contractName, true, _optimizeRuns); + m_optimizedBytecode = compileAndRunWithOptimizer("pragma solidity >=0.0;\n" + _sourceCode, _value, _contractName, true, _optimizeRuns); size_t nonOptimizedSize = numInstructions(m_nonOptimizedBytecode); size_t optimizedSize = numInstructions(m_optimizedBytecode); BOOST_CHECK_MESSAGE( @@ -441,8 +441,6 @@ BOOST_AUTO_TEST_CASE(constant_optimization_early_exit) // This tests that the constant optimizer does not try to find the best representation // indefinitely but instead stops after some number of iterations. char const* sourceCode = R"( - pragma solidity ^0.4.0; - contract HexEncoding { function hexEncodeTest(address addr) public returns (bytes32 ret) { uint x = uint(addr) / 2**32; diff --git a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol index 2a199b3a..17cb701d 100644 --- a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol +++ b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol @@ -3,11 +3,11 @@ contract B { A a; constructor() public { - a = new A(this); + a = new A(address(this)); } } contract A { - constructor(address a) internal {} + constructor(address) internal {} } // ---- // TypeError: (141-146): Contract with internal constructor cannot be created directly. diff --git a/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol index 6cf68d2a..8f5ceef8 100644 --- a/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol +++ b/test/libsolidity/syntaxTests/inheritance/disallow_modifier_style_without_parentheses.sol @@ -1,4 +1,4 @@ contract A { constructor() public { } } contract B is A { constructor() A public { } } // ---- -// Warning: (72-73): Modifier-style base constructor call without arguments. +// DeclarationError: (72-73): Modifier-style base constructor call without arguments. diff --git a/test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol b/test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol new file mode 100644 index 00000000..d8ce0e48 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/modifiers_in_constructor_context.sol @@ -0,0 +1,9 @@ +// This generated an invalid warning on m1 in some compiler versions. +contract A { + constructor() m1 public { } + modifier m1 { _; } +} +contract B is A { + modifier m2 { _; } + constructor() A() m1 m2 public { } +} diff --git a/test/libsolidity/syntaxTests/inheritance/override/function_state_variable.sol b/test/libsolidity/syntaxTests/inheritance/override/function_state_variable.sol new file mode 100644 index 00000000..023a161a --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/function_state_variable.sol @@ -0,0 +1,2 @@ +interface ERC20 { function x() external returns (uint); } +contract C is ERC20 { uint public x; } diff --git a/test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol b/test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol new file mode 100644 index 00000000..0f05cc8e --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/state_variable_function.sol @@ -0,0 +1,8 @@ +contract A { + uint public x; +} +contract C is A { + function x() public returns (uint); +} +// ---- +// DeclarationError: (50-85): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol index b6dd12b8..07113093 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() external { + function() external { uint[] storage y = x; assembly { pop(y) @@ -8,4 +8,4 @@ contract C { } } // ---- -// TypeError: (119-120): You have to use the _slot or _offset suffix to access storage reference variables. +// TypeError: (118-119): You have to use the _slot or _offset suffix to access storage reference variables. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol index d5c8eaf5..dc742142 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_assignment.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() external { + function() external { uint[] storage y = x; assembly { y_slot := 1 @@ -9,5 +9,5 @@ contract C { } } // ---- -// TypeError: (115-121): Storage variables cannot be assigned to. -// TypeError: (139-147): Storage variables cannot be assigned to. +// TypeError: (114-120): Storage variables cannot be assigned to. +// TypeError: (138-146): Storage variables cannot be assigned to. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol index 84f98ed9..b01a7705 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_fine.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() external { + function() external { uint[] storage y = x; assembly { pop(y_slot) diff --git a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol index 4025e11c..704b712d 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/storage_reference_on_memory.sol @@ -1,6 +1,6 @@ contract C { uint[] x; - function() external { + function() external { uint[] memory y = x; assembly { pop(y_slot) @@ -9,5 +9,5 @@ contract C { } } // ---- -// TypeError: (118-124): The suffixes _offset and _slot can only be used on storage variables. -// TypeError: (142-150): The suffixes _offset and _slot can only be used on storage variables. +// TypeError: (117-123): The suffixes _offset and _slot can only be used on storage variables. +// TypeError: (141-149): The suffixes _offset and _slot can only be used on storage variables. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol index 182ba072..7db98577 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiSingleVariableDeclaration.sol @@ -3,4 +3,4 @@ contract C { (uint a) = f(); a; } -} +} diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol index 2b765837..85094d00 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationInvalidType.sol @@ -3,7 +3,7 @@ contract C { (uint a, string memory b,,) = f(); a; b; } -} +} // ---- // TypeError: (85-118): Type string memory is not implicitly convertible to expected type uint256. // TypeError: (85-118): Type uint256 is not implicitly convertible to expected type string memory. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol index 224d9614..1f9e52d1 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping.sol @@ -5,6 +5,6 @@ contract C { } a; } -} +} // ---- // DeclarationError: (99-100): Undeclared identifier. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol index 242a1f39..45b8858b 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationScoping2.sol @@ -4,7 +4,7 @@ contract C { (uint a, uint b, uint c) = (a, b, c); } } -} +} // ---- // DeclarationError: (79-80): Undeclared identifier. "a" is not (or not yet) visible at this point. // DeclarationError: (82-83): Undeclared identifier. "b" is not (or not yet) visible at this point. diff --git a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol index 8ae0eaac..00458908 100644 --- a/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol +++ b/test/libsolidity/syntaxTests/multiVariableDeclaration/multiVariableDeclarationThatIsExpression.sol @@ -4,6 +4,6 @@ contract C { function f() internal pure returns (uint, uint, uint, S storage, uint, uint) { (,,,s.x[2](),,) = f(); } -} +} // ---- // TypeError: (160-168): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol deleted file mode 100644 index 1b6bbae7..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword.sol +++ /dev/null @@ -1,11 +0,0 @@ -contract test { - function f() public { - uintM something = 3; - intM should = 4; - bytesM fail = "now"; - } -} -// ---- -// DeclarationError: (50-55): Identifier not found or not unique. -// DeclarationError: (79-83): Identifier not found or not unique. -// DeclarationError: (104-110): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol new file mode 100644 index 00000000..0d0a0797 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_1.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + uintM something = 3; + } +} +// ---- +// DeclarationError: (50-55): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol new file mode 100644 index 00000000..b9590a8c --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_2.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + intM should = 4; + } +} +// ---- +// DeclarationError: (50-54): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol new file mode 100644 index 00000000..85d4c25b --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/290_varM_disqualified_as_keyword_3.sol @@ -0,0 +1,7 @@ +contract test { + function f() public { + bytesM fail = "now"; + } +} +// ---- +// DeclarationError: (50-56): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol index 56fc4051..d052dab5 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/412_early_exit_on_fatal_errors.sol @@ -8,4 +8,5 @@ contract C { } } // ---- +// DeclarationError: (150-179): Identifier already declared. // DeclarationError: (114-120): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol new file mode 100644 index 00000000..962f4fe4 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/570_function_type_undeclared_type.sol @@ -0,0 +1,5 @@ +contract C { + function a(function(Nested)) external pure {} +} +// ---- +// DeclarationError: (37-43): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol new file mode 100644 index 00000000..735af9e9 --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/571_function_type_undeclared_type_external.sol @@ -0,0 +1,5 @@ +contract C { + function a(function(Nested) external) external pure {} +} +// ---- +// DeclarationError: (37-43): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol new file mode 100644 index 00000000..ffb467cd --- /dev/null +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/572_function_type_undeclared_type_multi_nested.sol @@ -0,0 +1,5 @@ +contract C { + function a(function(function(function(Nested)))) external pure {} +} +// ---- +// DeclarationError: (55-61): Identifier not found or not unique. diff --git a/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol b/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol index 9f714aea..b66253e4 100644 --- a/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol +++ b/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol @@ -3,9 +3,9 @@ contract A { } } contract B { - constructor(address) public { + constructor(C) public { } - function b(address) public returns (A) { + function b(C) public returns (A) { return new A(); } } diff --git a/test/libsolidity/syntaxTests/parsing/tuples_decl_without_rhs.sol b/test/libsolidity/syntaxTests/parsing/tuples_decl_without_rhs.sol new file mode 100644 index 00000000..dba3e7ac --- /dev/null +++ b/test/libsolidity/syntaxTests/parsing/tuples_decl_without_rhs.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + (uint a, uint b, uint c); + } +} +// ---- +// ParserError: (76-77): Expected '=' but got ';' diff --git a/test/libsolidity/syntaxTests/scoping/function_state_variable_conflict.sol b/test/libsolidity/syntaxTests/scoping/function_state_variable_conflict.sol new file mode 100644 index 00000000..d717981b --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/function_state_variable_conflict.sol @@ -0,0 +1,6 @@ +contract C { + function f(uint) public pure {} + uint public f = 0; +} +// ---- +// DeclarationError: (53-70): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict.sol b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict.sol new file mode 100644 index 00000000..0c732f7f --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict.sol @@ -0,0 +1,6 @@ +contract C { + uint public f = 0; + function f(uint) public pure {} +} +// ---- +// DeclarationError: (40-71): Identifier already declared. diff --git a/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol new file mode 100644 index 00000000..fb9180c6 --- /dev/null +++ b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol @@ -0,0 +1,14 @@ +// This used to crash with some compiler versions. +contract SomeContract { + + uint public balance = 0; + + function balance(uint number) public {} + + function doSomething() public { + balance(3); + } +} +// ---- +// DeclarationError: (106-145): Identifier already declared. +// TypeError: (185-195): Type is not callable diff --git a/test/libsolidity/syntaxTests/types/address_to_contract.sol b/test/libsolidity/syntaxTests/types/address_to_contract.sol new file mode 100644 index 00000000..629a3df0 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address_to_contract.sol @@ -0,0 +1,6 @@ +contract C { + function f() public pure returns (C c) { + c = C(address(2)); + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/address_to_contract_implicitly.sol b/test/libsolidity/syntaxTests/types/address_to_contract_implicitly.sol new file mode 100644 index 00000000..efab7c27 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/address_to_contract_implicitly.sol @@ -0,0 +1,7 @@ +contract C { + function f() public view { + C c = address(2); + } +} +// ---- +// TypeError: (46-62): Type address is not implicitly convertible to expected type contract C. diff --git a/test/libsolidity/syntaxTests/types/contract_to_address.sol b/test/libsolidity/syntaxTests/types/contract_to_address.sol new file mode 100644 index 00000000..ec2f8184 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_address.sol @@ -0,0 +1,7 @@ +contract C { + function f() public view { + address a = address(this); + a; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/contract_to_address_implicitly.sol b/test/libsolidity/syntaxTests/types/contract_to_address_implicitly.sol new file mode 100644 index 00000000..8be9daac --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_address_implicitly.sol @@ -0,0 +1,8 @@ +contract C { + function f() public view { + address a = this; + a; + } +} +// ---- +// TypeError: (46-62): Type contract C is not implicitly convertible to expected type address. diff --git a/test/libsolidity/syntaxTests/types/contract_to_base.sol b/test/libsolidity/syntaxTests/types/contract_to_base.sol new file mode 100644 index 00000000..b0a24e62 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_base.sol @@ -0,0 +1,9 @@ +contract A {} +contract B is A {} +contract C { + function f() public { + A a = new B(); + a; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/contract_to_base_base.sol b/test/libsolidity/syntaxTests/types/contract_to_base_base.sol new file mode 100644 index 00000000..e99e5cdc --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_base_base.sol @@ -0,0 +1,10 @@ +contract A {} +contract B is A {} +contract C is B {} +contract D { + function f() public { + A a = new C(); + a; + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/types/contract_to_derived.sol b/test/libsolidity/syntaxTests/types/contract_to_derived.sol new file mode 100644 index 00000000..ac8df5d1 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_derived.sol @@ -0,0 +1,9 @@ +contract B {} +contract A is B {} +contract C { + function f() public pure { + A a = A(new B()); + } +} +// ---- +// TypeError: (85-95): Explicit type conversion not allowed from "contract B" to "contract A". diff --git a/test/libsolidity/syntaxTests/types/contract_to_unrelated_contract.sol b/test/libsolidity/syntaxTests/types/contract_to_unrelated_contract.sol new file mode 100644 index 00000000..b0a4875f --- /dev/null +++ b/test/libsolidity/syntaxTests/types/contract_to_unrelated_contract.sol @@ -0,0 +1,9 @@ +contract A {} +contract B {} +contract C { + function f() public pure { + B b = B(new A()); + } +} +// ---- +// TypeError: (80-90): Explicit type conversion not allowed from "contract A" to "contract B". diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_exhausted.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_exhausted.sol new file mode 100644 index 00000000..c6669746 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_exhausted.sol @@ -0,0 +1,262 @@ +contract A {} +contract Main { + A constant B = C; + A constant C = D; + A constant D = E; + A constant E = F; + A constant F = G; + A constant G = H; + A constant H = I; + A constant I = J; + A constant J = K; + A constant K = L; + A constant L = M; + A constant M = N; + A constant N = O; + A constant O = P; + A constant P = Q; + A constant Q = R; + A constant R = S; + A constant S = T; + A constant T = U; + A constant U = V; + A constant V = W; + A constant W = X; + A constant X = Y; + A constant Y = Z; + A constant Z = BA; + A constant BA = BB; + A constant BB = BC; + A constant BC = BD; + A constant BD = BE; + A constant BE = BF; + A constant BF = BG; + A constant BG = BH; + A constant BH = BI; + A constant BI = BJ; + A constant BJ = BK; + A constant BK = BL; + A constant BL = BM; + A constant BM = BN; + A constant BN = BO; + A constant BO = BP; + A constant BP = BQ; + A constant BQ = BR; + A constant BR = BS; + A constant BS = BT; + A constant BT = BU; + A constant BU = BV; + A constant BV = BW; + A constant BW = BX; + A constant BX = BY; + A constant BY = BZ; + A constant BZ = CA; + A constant CA = CB; + A constant CB = CC; + A constant CC = CD; + A constant CD = CE; + A constant CE = CF; + A constant CF = CG; + A constant CG = CH; + A constant CH = CI; + A constant CI = CJ; + A constant CJ = CK; + A constant CK = CL; + A constant CL = CM; + A constant CM = CN; + A constant CN = CO; + A constant CO = CP; + A constant CP = CQ; + A constant CQ = CR; + A constant CR = CS; + A constant CS = CT; + A constant CT = CU; + A constant CU = CV; + A constant CV = CW; + A constant CW = CX; + A constant CX = CY; + A constant CY = CZ; + A constant CZ = DA; + A constant DA = DB; + A constant DB = DC; + A constant DC = DD; + A constant DD = DE; + A constant DE = DF; + A constant DF = DG; + A constant DG = DH; + A constant DH = DI; + A constant DI = DJ; + A constant DJ = DK; + A constant DK = DL; + A constant DL = DM; + A constant DM = DN; + A constant DN = DO; + A constant DO = DP; + A constant DP = DQ; + A constant DQ = DR; + A constant DR = DS; + A constant DS = DT; + A constant DT = DU; + A constant DU = DV; + A constant DV = DW; + A constant DW = DX; + A constant DX = DY; + A constant DY = DZ; + A constant DZ = EA; + A constant EA = EB; + A constant EB = EC; + A constant EC = ED; + A constant ED = EE; + A constant EE = EF; + A constant EF = EG; + A constant EG = EH; + A constant EH = EI; + A constant EI = EJ; + A constant EJ = EK; + A constant EK = EL; + A constant EL = EM; + A constant EM = EN; + A constant EN = EO; + A constant EO = EP; + A constant EP = EQ; + A constant EQ = ER; + A constant ER = ES; + A constant ES = ET; + A constant ET = EU; + A constant EU = EV; + A constant EV = EW; + A constant EW = EX; + A constant EX = EY; + A constant EY = EZ; + A constant EZ = FA; + A constant FA = FB; + A constant FB = FC; + A constant FC = FD; + A constant FD = FE; + A constant FE = FF; + A constant FF = FG; + A constant FG = FH; + A constant FH = FI; + A constant FI = FJ; + A constant FJ = FK; + A constant FK = FL; + A constant FL = FM; + A constant FM = FN; + A constant FN = FO; + A constant FO = FP; + A constant FP = FQ; + A constant FQ = FR; + A constant FR = FS; + A constant FS = FT; + A constant FT = FU; + A constant FU = FV; + A constant FV = FW; + A constant FW = FX; + A constant FX = FY; + A constant FY = FZ; + A constant FZ = GA; + A constant GA = GB; + A constant GB = GC; + A constant GC = GD; + A constant GD = GE; + A constant GE = GF; + A constant GF = GG; + A constant GG = GH; + A constant GH = GI; + A constant GI = GJ; + A constant GJ = GK; + A constant GK = GL; + A constant GL = GM; + A constant GM = GN; + A constant GN = GO; + A constant GO = GP; + A constant GP = GQ; + A constant GQ = GR; + A constant GR = GS; + A constant GS = GT; + A constant GT = GU; + A constant GU = GV; + A constant GV = GW; + A constant GW = GX; + A constant GX = GY; + A constant GY = GZ; + A constant GZ = HA; + A constant HA = HB; + A constant HB = HC; + A constant HC = HD; + A constant HD = HE; + A constant HE = HF; + A constant HF = HG; + A constant HG = HH; + A constant HH = HI; + A constant HI = HJ; + A constant HJ = HK; + A constant HK = HL; + A constant HL = HM; + A constant HM = HN; + A constant HN = HO; + A constant HO = HP; + A constant HP = HQ; + A constant HQ = HR; + A constant HR = HS; + A constant HS = HT; + A constant HT = HU; + A constant HU = HV; + A constant HV = HW; + A constant HW = HX; + A constant HX = HY; + A constant HY = HZ; + A constant HZ = IA; + A constant IA = IB; + A constant IB = IC; + A constant IC = ID; + A constant ID = IE; + A constant IE = IF; + A constant IF = IG; + A constant IG = IH; + A constant IH = II; + A constant II = IJ; + A constant IJ = IK; + A constant IK = IL; + A constant IL = IM; + A constant IM = IN; + A constant IN = IO; + A constant IO = IP; + A constant IP = IQ; + A constant IQ = IR; + A constant IR = IS; + A constant IS = IT; + A constant IT = IU; + A constant IU = IV; + A constant IV = IW; + A constant IW = IX; + A constant IX = IY; + A constant IY = IZ; + A constant IZ = JA; + A constant JA = JB; + A constant JB = JC; + A constant JC = JD; + A constant JD = JE; + A constant JE = JF; + A constant JF = JG; + A constant JG = JH; + A constant JH = JI; + A constant JI = JJ; + A constant JJ = JK; + A constant JK = JL; + A constant JL = JM; + A constant JM = JN; + A constant JN = JO; + A constant JO = JP; + A constant JP = JQ; + A constant JQ = JR; + A constant JR = JS; + A constant JS = JT; + A constant JT = JU; + A constant JU = JV; + A constant JV = JW; + A constant JW = JX; + A constant JX = A(0x00); +} +// ---- +// DeclarationError: (6105-6123): Variable definition exhausting cyclic dependency validator. diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_good.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_good.sol new file mode 100644 index 00000000..7f8c6189 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_consts_good.sol @@ -0,0 +1,135 @@ +contract A {} +contract Main { + A constant B = C; + A constant C = D; + A constant D = E; + A constant E = F; + A constant F = G; + A constant G = H; + A constant H = I; + A constant I = J; + A constant J = K; + A constant K = L; + A constant L = M; + A constant M = N; + A constant N = O; + A constant O = P; + A constant P = Q; + A constant Q = R; + A constant R = S; + A constant S = T; + A constant T = U; + A constant U = V; + A constant V = W; + A constant W = X; + A constant X = Y; + A constant Y = Z; + A constant Z = BA; + A constant BA = BB; + A constant BB = BC; + A constant BC = BD; + A constant BD = BE; + A constant BE = BF; + A constant BF = BG; + A constant BG = BH; + A constant BH = BI; + A constant BI = BJ; + A constant BJ = BK; + A constant BK = BL; + A constant BL = BM; + A constant BM = BN; + A constant BN = BO; + A constant BO = BP; + A constant BP = BQ; + A constant BQ = BR; + A constant BR = BS; + A constant BS = BT; + A constant BT = BU; + A constant BU = BV; + A constant BV = BW; + A constant BW = BX; + A constant BX = BY; + A constant BY = BZ; + A constant BZ = CA; + A constant CA = CB; + A constant CB = CC; + A constant CC = CD; + A constant CD = CE; + A constant CE = CF; + A constant CF = CG; + A constant CG = CH; + A constant CH = CI; + A constant CI = CJ; + A constant CJ = CK; + A constant CK = CL; + A constant CL = CM; + A constant CM = CN; + A constant CN = CO; + A constant CO = CP; + A constant CP = CQ; + A constant CQ = CR; + A constant CR = CS; + A constant CS = CT; + A constant CT = CU; + A constant CU = CV; + A constant CV = CW; + A constant CW = CX; + A constant CX = CY; + A constant CY = CZ; + A constant CZ = DA; + A constant DA = DB; + A constant DB = DC; + A constant DC = DD; + A constant DD = DE; + A constant DE = DF; + A constant DF = DG; + A constant DG = DH; + A constant DH = DI; + A constant DI = DJ; + A constant DJ = DK; + A constant DK = DL; + A constant DL = DM; + A constant DM = DN; + A constant DN = DO; + A constant DO = DP; + A constant DP = DQ; + A constant DQ = DR; + A constant DR = DS; + A constant DS = DT; + A constant DT = DU; + A constant DU = DV; + A constant DV = DW; + A constant DW = DX; + A constant DX = DY; + A constant DY = DZ; + A constant DZ = EA; + A constant EA = EB; + A constant EB = EC; + A constant EC = ED; + A constant ED = EE; + A constant EE = EF; + A constant EF = EG; + A constant EG = EH; + A constant EH = EI; + A constant EI = EJ; + A constant EJ = EK; + A constant EK = EL; + A constant EL = EM; + A constant EM = EN; + A constant EN = EO; + A constant EO = EP; + A constant EP = EQ; + A constant EQ = ER; + A constant ER = ES; + A constant ES = ET; + A constant ET = EU; + A constant EU = EV; + A constant EV = EW; + A constant EW = EX; + A constant EX = EY; + A constant EY = EZ; + A constant EZ = FA; + A constant FA = FB; + A constant FB = FC; + A constant FC = A(0x00); +} diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol new file mode 100644 index 00000000..db0ff4af --- /dev/null +++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_exhausted.sol @@ -0,0 +1,260 @@ +contract Main { + struct B { C m; } + struct C { D m; } + struct D { E m; } + struct E { F m; } + struct F { G m; } + struct G { H m; } + struct H { I m; } + struct I { J m; } + struct J { K m; } + struct K { L m; } + struct L { M m; } + struct M { N m; } + struct N { O m; } + struct O { P m; } + struct P { Q m; } + struct Q { R m; } + struct R { S m; } + struct S { T m; } + struct T { U m; } + struct U { V m; } + struct V { W m; } + struct W { X m; } + struct X { Y m; } + struct Y { Z m; } + struct Z { BA m; } + struct BA { BB m; } + struct BB { BC m; } + struct BC { BD m; } + struct BD { BE m; } + struct BE { BF m; } + struct BF { BG m; } + struct BG { BH m; } + struct BH { BI m; } + struct BI { BJ m; } + struct BJ { BK m; } + struct BK { BL m; } + struct BL { BM m; } + struct BM { BN m; } + struct BN { BO m; } + struct BO { BP m; } + struct BP { BQ m; } + struct BQ { BR m; } + struct BR { BS m; } + struct BS { BT m; } + struct BT { BU m; } + struct BU { BV m; } + struct BV { BW m; } + struct BW { BX m; } + struct BX { BY m; } + struct BY { BZ m; } + struct BZ { CA m; } + struct CA { CB m; } + struct CB { CC m; } + struct CC { CD m; } + struct CD { CE m; } + struct CE { CF m; } + struct CF { CG m; } + struct CG { CH m; } + struct CH { CI m; } + struct CI { CJ m; } + struct CJ { CK m; } + struct CK { CL m; } + struct CL { CM m; } + struct CM { CN m; } + struct CN { CO m; } + struct CO { CP m; } + struct CP { CQ m; } + struct CQ { CR m; } + struct CR { CS m; } + struct CS { CT m; } + struct CT { CU m; } + struct CU { CV m; } + struct CV { CW m; } + struct CW { CX m; } + struct CX { CY m; } + struct CY { CZ m; } + struct CZ { DA m; } + struct DA { DB m; } + struct DB { DC m; } + struct DC { DD m; } + struct DD { DE m; } + struct DE { DF m; } + struct DF { DG m; } + struct DG { DH m; } + struct DH { DI m; } + struct DI { DJ m; } + struct DJ { DK m; } + struct DK { DL m; } + struct DL { DM m; } + struct DM { DN m; } + struct DN { DO m; } + struct DO { DP m; } + struct DP { DQ m; } + struct DQ { DR m; } + struct DR { DS m; } + struct DS { DT m; } + struct DT { DU m; } + struct DU { DV m; } + struct DV { DW m; } + struct DW { DX m; } + struct DX { DY m; } + struct DY { DZ m; } + struct DZ { EA m; } + struct EA { EB m; } + struct EB { EC m; } + struct EC { ED m; } + struct ED { EE m; } + struct EE { EF m; } + struct EF { EG m; } + struct EG { EH m; } + struct EH { EI m; } + struct EI { EJ m; } + struct EJ { EK m; } + struct EK { EL m; } + struct EL { EM m; } + struct EM { EN m; } + struct EN { EO m; } + struct EO { EP m; } + struct EP { EQ m; } + struct EQ { ER m; } + struct ER { ES m; } + struct ES { ET m; } + struct ET { EU m; } + struct EU { EV m; } + struct EV { EW m; } + struct EW { EX m; } + struct EX { EY m; } + struct EY { EZ m; } + struct EZ { FA m; } + struct FA { FB m; } + struct FB { FC m; } + struct FC { FD m; } + struct FD { FE m; } + struct FE { FF m; } + struct FF { FG m; } + struct FG { FH m; } + struct FH { FI m; } + struct FI { FJ m; } + struct FJ { FK m; } + struct FK { FL m; } + struct FL { FM m; } + struct FM { FN m; } + struct FN { FO m; } + struct FO { FP m; } + struct FP { FQ m; } + struct FQ { FR m; } + struct FR { FS m; } + struct FS { FT m; } + struct FT { FU m; } + struct FU { FV m; } + struct FV { FW m; } + struct FW { FX m; } + struct FX { FY m; } + struct FY { FZ m; } + struct FZ { GA m; } + struct GA { GB m; } + struct GB { GC m; } + struct GC { GD m; } + struct GD { GE m; } + struct GE { GF m; } + struct GF { GG m; } + struct GG { GH m; } + struct GH { GI m; } + struct GI { GJ m; } + struct GJ { GK m; } + struct GK { GL m; } + struct GL { GM m; } + struct GM { GN m; } + struct GN { GO m; } + struct GO { GP m; } + struct GP { GQ m; } + struct GQ { GR m; } + struct GR { GS m; } + struct GS { GT m; } + struct GT { GU m; } + struct GU { GV m; } + struct GV { GW m; } + struct GW { GX m; } + struct GX { GY m; } + struct GY { GZ m; } + struct GZ { HA m; } + struct HA { HB m; } + struct HB { HC m; } + struct HC { HD m; } + struct HD { HE m; } + struct HE { HF m; } + struct HF { HG m; } + struct HG { HH m; } + struct HH { HI m; } + struct HI { HJ m; } + struct HJ { HK m; } + struct HK { HL m; } + struct HL { HM m; } + struct HM { HN m; } + struct HN { HO m; } + struct HO { HP m; } + struct HP { HQ m; } + struct HQ { HR m; } + struct HR { HS m; } + struct HS { HT m; } + struct HT { HU m; } + struct HU { HV m; } + struct HV { HW m; } + struct HW { HX m; } + struct HX { HY m; } + struct HY { HZ m; } + struct HZ { IA m; } + struct IA { IB m; } + struct IB { IC m; } + struct IC { ID m; } + struct ID { IE m; } + struct IE { IF m; } + struct IF { IG m; } + struct IG { IH m; } + struct IH { II m; } + struct II { IJ m; } + struct IJ { IK m; } + struct IK { IL m; } + struct IL { IM m; } + struct IM { IN m; } + struct IN { IO m; } + struct IO { IP m; } + struct IP { IQ m; } + struct IQ { IR m; } + struct IR { IS m; } + struct IS { IT m; } + struct IT { IU m; } + struct IU { IV m; } + struct IV { IW m; } + struct IW { IX m; } + struct IX { IY m; } + struct IY { IZ m; } + struct IZ { JA m; } + struct JA { JB m; } + struct JB { JC m; } + struct JC { JD m; } + struct JD { JE m; } + struct JE { JF m; } + struct JF { JG m; } + struct JG { JH m; } + struct JH { JI m; } + struct JI { JJ m; } + struct JJ { JK m; } + struct JK { JL m; } + struct JL { JM m; } + struct JM { JN m; } + struct JN { JO m; } + struct JO { JP m; } + struct JP { JQ m; } + struct JQ { JR m; } + struct JR { JS m; } + struct JS { JT m; } + struct JT { JU m; } + struct JU { JV m; } + struct JV { JW m; } + struct JW { int i; } +} +// ---- +// DeclarationError: (6091-6111): Struct definition exhausting cyclic dependency validator. diff --git a/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_good.sol b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_good.sol new file mode 100644 index 00000000..0419bea6 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/cyclic_dependency_check_on_struct_good.sol @@ -0,0 +1,134 @@ +contract Main { + struct B { C m; } + struct C { D m; } + struct D { E m; } + struct E { F m; } + struct F { G m; } + struct G { H m; } + struct H { I m; } + struct I { J m; } + struct J { K m; } + struct K { L m; } + struct L { M m; } + struct M { N m; } + struct N { O m; } + struct O { P m; } + struct P { Q m; } + struct Q { R m; } + struct R { S m; } + struct S { T m; } + struct T { U m; } + struct U { V m; } + struct V { W m; } + struct W { X m; } + struct X { Y m; } + struct Y { Z m; } + struct Z { BA m; } + struct BA { BB m; } + struct BB { BC m; } + struct BC { BD m; } + struct BD { BE m; } + struct BE { BF m; } + struct BF { BG m; } + struct BG { BH m; } + struct BH { BI m; } + struct BI { BJ m; } + struct BJ { BK m; } + struct BK { BL m; } + struct BL { BM m; } + struct BM { BN m; } + struct BN { BO m; } + struct BO { BP m; } + struct BP { BQ m; } + struct BQ { BR m; } + struct BR { BS m; } + struct BS { BT m; } + struct BT { BU m; } + struct BU { BV m; } + struct BV { BW m; } + struct BW { BX m; } + struct BX { BY m; } + struct BY { BZ m; } + struct BZ { CA m; } + struct CA { CB m; } + struct CB { CC m; } + struct CC { CD m; } + struct CD { CE m; } + struct CE { CF m; } + struct CF { CG m; } + struct CG { CH m; } + struct CH { CI m; } + struct CI { CJ m; } + struct CJ { CK m; } + struct CK { CL m; } + struct CL { CM m; } + struct CM { CN m; } + struct CN { CO m; } + struct CO { CP m; } + struct CP { CQ m; } + struct CQ { CR m; } + struct CR { CS m; } + struct CS { CT m; } + struct CT { CU m; } + struct CU { CV m; } + struct CV { CW m; } + struct CW { CX m; } + struct CX { CY m; } + struct CY { CZ m; } + struct CZ { DA m; } + struct DA { DB m; } + struct DB { DC m; } + struct DC { DD m; } + struct DD { DE m; } + struct DE { DF m; } + struct DF { DG m; } + struct DG { DH m; } + struct DH { DI m; } + struct DI { DJ m; } + struct DJ { DK m; } + struct DK { DL m; } + struct DL { DM m; } + struct DM { DN m; } + struct DN { DO m; } + struct DO { DP m; } + struct DP { DQ m; } + struct DQ { DR m; } + struct DR { DS m; } + struct DS { DT m; } + struct DT { DU m; } + struct DU { DV m; } + struct DV { DW m; } + struct DW { DX m; } + struct DX { DY m; } + struct DY { DZ m; } + struct DZ { EA m; } + struct EA { EB m; } + struct EB { EC m; } + struct EC { ED m; } + struct ED { EE m; } + struct EE { EF m; } + struct EF { EG m; } + struct EG { EH m; } + struct EH { EI m; } + struct EI { EJ m; } + struct EJ { EK m; } + struct EK { EL m; } + struct EL { EM m; } + struct EM { EN m; } + struct EN { EO m; } + struct EO { EP m; } + struct EP { EQ m; } + struct EQ { ER m; } + struct ER { ES m; } + struct ES { ET m; } + struct ET { EU m; } + struct EU { EV m; } + struct EV { EW m; } + struct EW { EX m; } + struct EX { EY m; } + struct EY { EZ m; } + struct EZ { FA m; } + struct FA { FB m; } + struct FB { FC m; } + struct FC { int i; } +} diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol index 24327db0..898ee8ba 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_event.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_event.sol @@ -1,4 +1,3 @@ -pragma solidity ^0.4.3; contract C { event SomeEvent(); function a() public { @@ -6,4 +5,4 @@ contract C { } } // ---- -// ParserError: (95-99): Expected primary expression. +// ParserError: (71-75): Expected primary expression. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_function.sol b/test/libsolidity/syntaxTests/types/empty_tuple_function.sol index ff31d440..a898f84a 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_function.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_function.sol @@ -1,4 +1,3 @@ -pragma solidity ^0.4.3; contract C { function f() private pure {} function a() public pure { @@ -8,5 +7,5 @@ contract C { } } // ---- -// TypeError: (162-165): Tuple component cannot be empty. -// TypeError: (181-184): Tuple component cannot be empty. +// TypeError: (138-141): Tuple component cannot be empty. +// TypeError: (157-160): Tuple component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol index 3d252f0b..63b039cd 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue.sol @@ -1,4 +1,3 @@ -pragma solidity ^0.4.3; contract C { function f() private pure {} function a() public { @@ -8,6 +7,6 @@ contract C { } } // ---- -// TypeError: (146-149): Tuple component cannot be empty. -// TypeError: (151-154): Tuple component cannot be empty. -// TypeError: (145-155): Type tuple(tuple(),tuple()) is not implicitly convertible to expected type tuple(uint256,uint256). +// TypeError: (122-125): Tuple component cannot be empty. +// TypeError: (127-130): Tuple component cannot be empty. +// TypeError: (121-131): Type tuple(tuple(),tuple()) is not implicitly convertible to expected type tuple(uint256,uint256). diff --git a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol index f8b2ae7e..9bc21561 100644 --- a/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol +++ b/test/libsolidity/syntaxTests/types/empty_tuple_lvalue_array.sol @@ -1,4 +1,3 @@ -pragma solidity ^0.4.3; contract C { function f() private pure {} function a() public { @@ -8,4 +7,4 @@ contract C { } } // ---- -// TypeError: (146-149): Array component cannot be empty. +// TypeError: (122-125): Array component cannot be empty. diff --git a/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol b/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol index 7ed92b58..36b3df9f 100644 --- a/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol +++ b/test/libsolidity/syntaxTests/types/unnamed_tuple_decl.sol @@ -1,5 +1,3 @@ -pragma solidity ^0.4.20; - contract C { function f() internal pure {} function g() internal pure returns (uint) { return 1; } @@ -13,6 +11,6 @@ contract C { } // ---- -// SyntaxError: (249-261): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. -// SyntaxError: (271-283): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. -// SyntaxError: (293-306): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. +// SyntaxError: (223-235): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. +// SyntaxError: (245-257): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. +// SyntaxError: (267-280): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_0.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_0.sol new file mode 100644 index 00000000..51b949de --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_empty_decl_0.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + var (); + var (,); + } +} +// ---- +// SyntaxError: (52-58): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. +// SyntaxError: (68-75): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty. diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol new file mode 100644 index 00000000..20a004ff --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_empty_decl_1.sol @@ -0,0 +1,8 @@ +contract C { + function f() public pure { + var a; + a.NeverReachedByParser(); + } +} +// ---- +// TypeError: (52-57): Use of the "var" keyword is disallowed. diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol new file mode 100644 index 00000000..de2abc9a --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_empty_decl_2.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure { + var (b, c); + b.WeMustNotReachHere(); + c.FailsToLookupToo(); + } +} +// ---- +// TypeError: (52-62): Use of the "var" keyword is disallowed. diff --git a/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol b/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol new file mode 100644 index 00000000..26ee824e --- /dev/null +++ b/test/libsolidity/syntaxTests/types/var_empty_decl_3.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + var (d, e,); + } +} +// ---- +// TypeError: (52-63): Use of the "var" keyword is disallowed. |