Update test suite to use address payable.

This commit is contained in:
Daniel Kirchner
2018-09-12 16:21:43 +02:00
parent 1994b51ef3
commit 879251a78b
26 changed files with 121 additions and 67 deletions
+7 -7
View File
@@ -27,12 +27,12 @@ contract ico is safeMath {
uint256 constant oneSegment = 40320;
address public owner;
address public tokenAddr;
address public premiumAddr;
address payable public owner;
address payable public tokenAddr;
address payable public premiumAddr;
uint256 public startBlock;
uint256 public icoDelay;
address public foundationAddress;
address payable public foundationAddress;
address public icoEtcPriceAddr;
uint256 public icoExchangeRate;
uint256 public icoExchangeRateSetBlock;
@@ -50,7 +50,7 @@ contract ico is safeMath {
uint256 public totalMint;
uint256 public totalPremiumMint;
constructor(address foundation, address priceSet, uint256 exchangeRate, uint256 startBlockNum, address[] memory genesisAddr, uint256[] memory genesisValue) public {
constructor(address payable foundation, address priceSet, uint256 exchangeRate, uint256 startBlockNum, address[] memory genesisAddr, uint256[] memory genesisValue) public {
/*
Installation function.
@@ -248,7 +248,7 @@ contract ico is safeMath {
aborted = true;
}
function connectTokens(address tokenContractAddr, address premiumContractAddr) external {
function connectTokens(address payable tokenContractAddr, address payable premiumContractAddr) external {
/*
Installation function which joins the two token contracts with this contract.
Only callable by the owner
@@ -284,7 +284,7 @@ contract ico is safeMath {
require( buy(msg.sender, address(0x00)) );
}
function buy(address beneficiaryAddress, address affilateAddress) public payable returns (bool success) {
function buy(address payable beneficiaryAddress, address affilateAddress) public payable returns (bool success) {
/*
Buying a token
+12 -10
View File
@@ -1,8 +1,8 @@
pragma solidity ^0.4.11;
contract abstractModuleHandler {
function transfer(address from, address to, uint256 value, bool fee) external returns (bool success) {}
function balanceOf(address owner) public view returns (bool success, uint256 value) {}
function transfer(address payable from, address payable to, uint256 value, bool fee) external returns (bool success) {}
function balanceOf(address payable owner) public view returns (bool success, uint256 value) {}
}
contract module {
@@ -19,7 +19,7 @@ contract module {
status public moduleStatus;
uint256 public disabledUntil;
address public moduleHandlerAddress;
address payable public moduleHandlerAddress;
function disableModule(bool forever) external onlyForModuleHandler returns (bool success) {
_disableModule(forever);
@@ -36,11 +36,11 @@ contract module {
else { disabledUntil = block.number + 5760; }
}
function replaceModuleHandler(address newModuleHandlerAddress) external onlyForModuleHandler returns (bool success) {
function replaceModuleHandler(address payable newModuleHandlerAddress) external onlyForModuleHandler returns (bool success) {
_replaceModuleHandler(newModuleHandlerAddress);
return true;
}
function _replaceModuleHandler(address newModuleHandlerAddress) internal {
function _replaceModuleHandler(address payable newModuleHandlerAddress) internal {
/*
Replace the ModuleHandler address.
This function calls the Publisher module.
@@ -77,11 +77,11 @@ contract module {
moduleStatus = status.Disconnected;
}
function replaceModule(address newModuleAddress) external onlyForModuleHandler returns (bool success) {
function replaceModule(address payable newModuleAddress) external onlyForModuleHandler returns (bool success) {
_replaceModule(newModuleAddress);
return true;
}
function _replaceModule(address newModuleAddress) internal {
function _replaceModule(address payable newModuleAddress) internal {
/*
Replace the module for an another new module.
This function calls the Publisher module.
@@ -101,20 +101,20 @@ contract module {
moduleStatus = status.Disconnected;
}
function transferEvent(address from, address to, uint256 value) external onlyForModuleHandler returns (bool success) {
function transferEvent(address payable from, address payable 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 {
function registerModuleHandler(address payable _moduleHandlerAddress) internal {
/*
Module constructor function for registering ModuleHandler address.
*/
moduleHandlerAddress = _moduleHandlerAddress;
}
function isModuleHandler(address addr) internal returns (bool ret) {
function isModuleHandler(address payable addr) internal returns (bool ret) {
/*
Test for ModuleHandler address.
If the module is not connected then returns always false.
@@ -140,4 +140,6 @@ contract module {
require( msg.sender == moduleHandlerAddress );
_;
}
function() external payable {
}
}
@@ -25,7 +25,7 @@ contract abstractModule {
contract moduleHandler is multiOwner, announcementTypes {
struct modules_s {
address addr;
address payable addr;
bytes32 name;
bool schellingEvent;
bool transferEvent;
@@ -37,7 +37,7 @@ contract moduleHandler is multiOwner, announcementTypes {
constructor(address[] memory newOwners) multiOwner(newOwners) public {}
function load(address foundation, bool forReplace, address Token, address Premium, address Publisher, address Schelling, address Provider) public {
function load(address payable foundation, bool forReplace, address payable Token, address payable Premium, address payable Publisher, address payable Schelling, address payable Provider) public {
/*
Loading modulest to ModuleHandler.
@@ -140,7 +140,7 @@ contract moduleHandler is multiOwner, announcementTypes {
}
return (true, false, 0);
}
function replaceModule(string calldata name, address addr, bool callCallback) external returns (bool success) {
function replaceModule(string calldata name, address payable addr, bool callCallback) external returns (bool success) {
/*
Module replace, can be called only by the Publisher contract.
@@ -178,7 +178,7 @@ contract moduleHandler is multiOwner, announcementTypes {
return true;
}
function newModule(string calldata name, address addr, bool schellingEvent, bool transferEvent) external returns (bool success) {
function newModule(string calldata name, address payable addr, bool schellingEvent, bool transferEvent) external returns (bool success) {
/*
Adding new module to the database. Can be called only by the Publisher contract.
+2 -2
View File
@@ -12,7 +12,7 @@ contract thirdPartyPContractAbstract {
contract ptokenDB is tokenDB {}
contract premium is module, safeMath {
function replaceModule(address addr) external returns (bool success) {
function replaceModule(address payable addr) external returns (bool success) {
require( super.isModuleHandler(msg.sender) );
require( db.replaceOwner(addr) );
super._replaceModule(addr);
@@ -40,7 +40,7 @@ contract premium is module, safeMath {
mapping(address => bool) public genesis;
constructor(bool forReplace, address moduleHandler, address dbAddress, address icoContractAddr, address[] memory genesisAddr, uint256[] memory genesisValue) public {
constructor(bool forReplace, address payable 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.
+6 -6
View File
@@ -16,7 +16,7 @@ contract provider is module, safeMath, announcementTypes {
require( _success );
return true;
}
function transferEvent(address from, address to, uint256 value) external returns (bool success) {
function transferEvent(address payable from, address payable to, uint256 value) external returns (bool success) {
/*
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.
@@ -118,7 +118,7 @@ contract provider is module, safeMath, announcementTypes {
uint256 private currentSchellingRound = 1;
constructor(address _moduleHandler) public {
constructor(address payable _moduleHandler) public {
/*
Install function.
@@ -147,7 +147,7 @@ contract provider is module, safeMath, announcementTypes {
else { return false; }
return true;
}
function getUserDetails(address addr, uint256 schellingRound) public view returns (address ProviderAddress, uint256 ProviderHeight, uint256 ConnectedOn, uint256 value) {
function getUserDetails(address payable addr, uint256 schellingRound) public view returns (address ProviderAddress, uint256 ProviderHeight, uint256 ConnectedOn, uint256 value) {
/*
Collecting the datas of the client.
@@ -213,7 +213,7 @@ contract provider is module, safeMath, announcementTypes {
return ( ! priv && ( rate >= publicMinRate && rate <= publicMaxRate ) ) ||
( priv && ( rate >= privateMinRate && rate <= privateMaxRate ) );
}
function createProvider(bool priv, string calldata name, string calldata website, string calldata country, string calldata info, uint8 rate, bool isForRent, address admin) isReady external {
function createProvider(bool priv, string calldata name, string calldata website, string calldata country, string calldata info, uint8 rate, bool isForRent, address payable admin) isReady external {
/*
Creating a provider.
During the ICO its not allowed to create provider.
@@ -270,7 +270,7 @@ contract provider is module, safeMath, announcementTypes {
}
emit EProviderOpen(msg.sender, currHeight);
}
function setProviderDetails(address addr, string calldata website, string calldata country, string calldata info, uint8 rate, address admin) isReady external {
function setProviderDetails(address payable addr, string calldata website, string calldata country, string calldata info, uint8 rate, address payable admin) isReady external {
/*
Modifying the datas of the provider.
This can only be invited by the providers admin.
@@ -321,7 +321,7 @@ contract provider is module, safeMath, announcementTypes {
info = providers[addr].data[height].info;
create = providers[addr].data[height].create;
}
function getProviderDetails(address addr, uint256 height) public view returns (uint8 rate, bool isForRent, uint256 clientsCount, bool priv, bool getInterest, bool valid) {
function getProviderDetails(address payable addr, uint256 height) public view returns (uint8 rate, bool isForRent, uint256 clientsCount, bool priv, bool getInterest, bool valid) {
/*
Asking for the datas of the provider.
In case the height is unknown then the system will use the last known height.
+4 -4
View File
@@ -9,7 +9,7 @@ contract publisher is announcementTypes, module, safeMath {
/*
module callbacks
*/
function transferEvent(address from, address to, uint256 value) external returns (bool success) {
function transferEvent(address payable from, address payable 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
@@ -54,14 +54,14 @@ contract publisher is announcementTypes, module, safeMath {
string _str;
uint256 _uint;
address _addr;
address payable _addr;
}
mapping(uint256 => announcements_s) public announcements;
uint256 announcementsLength = 1;
mapping (address => uint256[]) public opponents;
constructor(address moduleHandler) public {
constructor(address payable moduleHandler) public {
/*
Installation function. The installer will be registered in the admin list automatically
@@ -116,7 +116,7 @@ contract publisher is announcementTypes, module, safeMath {
return _amount * oppositeRate / 100 > weight;
}
function newAnnouncement(announcementType Type, string calldata Announcement, string calldata Link, bool Oppositable, string calldata _str, uint256 _uint, address _addr) onlyOwner external {
function newAnnouncement(announcementType Type, string calldata Announcement, string calldata Link, bool Oppositable, string calldata _str, uint256 _uint, address payable _addr) onlyOwner external {
/*
New announcement. Can be called only by those in the admin list
+3 -3
View File
@@ -133,13 +133,13 @@ contract schelling is module, announcementTypes, schellingVars {
/*
module callbacks
*/
function replaceModule(address addr) external returns (bool) {
function replaceModule(address payable addr) external returns (bool) {
require( super.isModuleHandler(msg.sender) );
require( db.replaceOwner(addr) );
super._replaceModule(addr);
return true;
}
function transferEvent(address from, address to, uint256 value) external returns (bool) {
function transferEvent(address payable from, address payable to, uint256 value) external returns (bool) {
/*
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.
@@ -247,7 +247,7 @@ contract schelling is module, announcementTypes, schellingVars {
bytes1 public belowChar = 0x30;
schellingDB private db;
constructor(address _moduleHandler, address _db, bool _forReplace) public {
constructor(address payable _moduleHandler, address _db, bool _forReplace) public {
/*
Installation function.
+4 -4
View File
@@ -15,7 +15,7 @@ contract token is safeMath, module, announcementTypes {
/*
module callbacks
*/
function replaceModule(address addr) external returns (bool success) {
function replaceModule(address payable addr) external returns (bool success) {
require( super.isModuleHandler(msg.sender) );
require( db.replaceOwner(addr) );
super._replaceModule(addr);
@@ -37,18 +37,18 @@ contract token is safeMath, module, announcementTypes {
uint8 public decimals = 6;
tokenDB public db;
address public icoAddr;
address payable public icoAddr;
uint256 public transactionFeeRate = 20;
uint256 public transactionFeeRateM = 1e3;
uint256 public transactionFeeMin = 20000;
uint256 public transactionFeeMax = 5000000;
uint256 public transactionFeeBurn = 80;
address public exchangeAddress;
address payable 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 {
constructor(bool forReplace, address payable moduleHandler, address dbAddr, address payable icoContractAddr, address payable exchangeContractAddress, address payable[] memory genesisAddr, uint256[] memory genesisValue) public payable {
/*
Installation function
@@ -32,7 +32,7 @@ contract MultisigWallet is Multisig, Shareable, DayLimit {
/**
* @dev destroys the contract sending everything to `_to`.
*/
function destroy(address _to) onlymanyowners(keccak256(msg.data)) external {
function destroy(address payable _to) onlymanyowners(keccak256(msg.data)) external {
selfdestruct(_to);
}
@@ -22,7 +22,7 @@ contract Crowdsale {
uint256 public endBlock;
// address where funds are collected
address public wallet;
address payable public wallet;
// how many token units a buyer gets per wei
uint256 public rate;
@@ -40,7 +40,7 @@ contract Crowdsale {
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
constructor(uint256 _startBlock, uint256 _endBlock, uint256 _rate, address _wallet) public {
constructor(uint256 _startBlock, uint256 _endBlock, uint256 _rate, address payable _wallet) public {
require(_startBlock >= block.number);
require(_endBlock >= _startBlock);
require(_rate > 0);
@@ -15,20 +15,20 @@ contract RefundVault is Ownable {
enum State { Active, Refunding, Closed }
mapping (address => uint256) public deposited;
address public wallet;
address payable public wallet;
State public state;
event Closed();
event RefundsEnabled();
event Refunded(address indexed beneficiary, uint256 weiAmount);
constructor(address _wallet) public {
constructor(address payable _wallet) public {
require(_wallet != address(0x0));
wallet = _wallet;
state = State.Active;
}
function deposit(address investor) public onlyOwner payable {
function deposit(address payable investor) public onlyOwner payable {
require(state == State.Active);
deposited[investor] = deposited[investor].add(msg.value);
}
@@ -46,7 +46,7 @@ contract RefundVault is Ownable {
emit RefundsEnabled();
}
function refund(address investor) public {
function refund(address payable investor) public {
require(state == State.Refunding);
uint256 depositedValue = deposited[investor];
deposited[investor] = 0;
@@ -19,7 +19,7 @@ contract Destructible is Ownable {
selfdestruct(owner);
}
function destroyAndSend(address _recipient) public onlyOwner {
function destroyAndSend(address payable _recipient) public onlyOwner {
selfdestruct(_recipient);
}
}
@@ -10,7 +10,7 @@ import './Ownable.sol';
* This allows the new owner to accept the transfer.
*/
contract Claimable is Ownable {
address public pendingOwner;
address payable public pendingOwner;
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
@@ -26,7 +26,7 @@ contract Claimable is Ownable {
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
function transferOwnership(address payable newOwner) public onlyOwner {
pendingOwner = newOwner;
}
@@ -7,7 +7,7 @@ pragma solidity ^0.4.11;
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
address payable public owner;
/**
@@ -34,7 +34,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.
*/
function transferOwnership(address newOwner) public onlyOwner {
function transferOwnership(address payable newOwner) public onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
@@ -29,7 +29,7 @@ contract PullPayment {
* @dev withdraw accumulated balance, called by payee.
*/
function withdrawPayments() public {
address payee = msg.sender;
address payable payee = msg.sender;
uint256 payment = payments[payee];
if (payment == 0) {