mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Update test suite to use address payable.
This commit is contained in:
parent
1994b51ef3
commit
879251a78b
@ -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
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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 provider’s 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.
|
||||
|
@ -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
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -66,7 +66,7 @@ contract AuctionSystem {
|
||||
/// Function that is called once an auction ends.
|
||||
function onAuctionEnd(string memory _name) internal;
|
||||
|
||||
function bid(string memory _name, address _bidder, uint _value) internal {
|
||||
function bid(string memory _name, address payable _bidder, uint _value) internal {
|
||||
Auction storage auction = m_auctions[_name];
|
||||
if (auction.endDate > 0 && now > auction.endDate)
|
||||
{
|
||||
@ -91,7 +91,7 @@ contract AuctionSystem {
|
||||
uint constant c_biddingTime = 7 days;
|
||||
|
||||
struct Auction {
|
||||
address highestBidder;
|
||||
address payable highestBidder;
|
||||
uint highestBid;
|
||||
uint secondHighestBid;
|
||||
uint sumOfBids;
|
||||
@ -102,7 +102,7 @@ contract AuctionSystem {
|
||||
|
||||
contract GlobalRegistrar is Registrar, AuctionSystem {
|
||||
struct Record {
|
||||
address owner;
|
||||
address payable owner;
|
||||
address primary;
|
||||
address subRegistrar;
|
||||
bytes32 content;
|
||||
@ -156,7 +156,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
|
||||
|
||||
modifier onlyrecordowner(string memory _name) { if (m_toRecord[_name].owner == msg.sender) _; }
|
||||
|
||||
function transfer(string memory _name, address _newOwner) onlyrecordowner(_name) public {
|
||||
function transfer(string memory _name, address payable _newOwner) onlyrecordowner(_name) public {
|
||||
m_toRecord[_name].owner = _newOwner;
|
||||
emit Changed(_name);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ contract FixedFeeRegistrar is Registrar {
|
||||
emit Changed(_name);
|
||||
}
|
||||
}
|
||||
function disown(string memory _name, address _refund) onlyrecordowner(_name) public {
|
||||
function disown(string memory _name, address payable _refund) onlyrecordowner(_name) public {
|
||||
delete m_recordData[uint(keccak256(bytes(_name))) / 8];
|
||||
if (!_refund.send(c_fee))
|
||||
revert();
|
||||
|
@ -375,7 +375,7 @@ contract Wallet is multisig, multiowned, daylimit {
|
||||
}
|
||||
|
||||
// destroys the contract sending everything to `_to`.
|
||||
function kill(address _to) onlymanyowners(keccak256(msg.data)) external {
|
||||
function kill(address payable _to) onlymanyowners(keccak256(msg.data)) external {
|
||||
selfdestruct(_to);
|
||||
}
|
||||
|
||||
|
@ -2215,7 +2215,7 @@ BOOST_AUTO_TEST_CASE(send_ether)
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
constructor() payable public {}
|
||||
function a(address addr, uint amount) public returns (uint ret) {
|
||||
function a(address payable addr, uint amount) public returns (uint ret) {
|
||||
addr.send(amount);
|
||||
return address(this).balance;
|
||||
}
|
||||
@ -2233,11 +2233,11 @@ BOOST_AUTO_TEST_CASE(transfer_ether)
|
||||
char const* sourceCode = R"(
|
||||
contract A {
|
||||
constructor() public payable {}
|
||||
function a(address addr, uint amount) public returns (uint) {
|
||||
function a(address payable addr, uint amount) public returns (uint) {
|
||||
addr.transfer(amount);
|
||||
return address(this).balance;
|
||||
}
|
||||
function b(address addr, uint amount) public {
|
||||
function b(address payable addr, uint amount) public {
|
||||
addr.transfer(amount);
|
||||
}
|
||||
}
|
||||
@ -2406,7 +2406,7 @@ BOOST_AUTO_TEST_CASE(selfdestruct)
|
||||
char const* sourceCode = R"(
|
||||
contract test {
|
||||
constructor() public payable {}
|
||||
function a(address receiver) public returns (uint ret) {
|
||||
function a(address payable receiver) public returns (uint ret) {
|
||||
selfdestruct(receiver);
|
||||
return 10;
|
||||
}
|
||||
@ -7151,7 +7151,7 @@ BOOST_AUTO_TEST_CASE(failing_send)
|
||||
}
|
||||
contract Main {
|
||||
constructor() public payable {}
|
||||
function callHelper(address _a) public returns (bool r, uint bal) {
|
||||
function callHelper(address payable _a) public returns (bool r, uint bal) {
|
||||
r = !_a.send(5);
|
||||
bal = address(this).balance;
|
||||
}
|
||||
@ -8838,7 +8838,7 @@ BOOST_AUTO_TEST_CASE(reject_ether_sent_to_library)
|
||||
library lib {}
|
||||
contract c {
|
||||
constructor() public payable {}
|
||||
function f(address x) public returns (bool) {
|
||||
function f(address payable x) public returns (bool) {
|
||||
return x.send(1);
|
||||
}
|
||||
function () external payable {}
|
||||
@ -10095,6 +10095,54 @@ BOOST_AUTO_TEST_CASE(cleanup_bytes_types_shortening)
|
||||
ABI_CHECK(callContractFunction("f()"), encodeArgs("\xff\xff\xff\xff"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(cleanup_address_types)
|
||||
{
|
||||
// Checks that address types are properly cleaned before they are compared.
|
||||
char const* sourceCode = R"(
|
||||
contract C {
|
||||
function f(address a) public returns (uint) {
|
||||
if (a != 0x1234567890123456789012345678901234567890) return 1;
|
||||
return 0;
|
||||
}
|
||||
function g(address payable a) public returns (uint) {
|
||||
if (a != 0x1234567890123456789012345678901234567890) return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
// We input longer data on purpose.
|
||||
ABI_CHECK(callContractFunction("f(address)", u256("0xFFFF1234567890123456789012345678901234567890")), encodeArgs(0));
|
||||
ABI_CHECK(callContractFunction("g(address)", u256("0xFFFF1234567890123456789012345678901234567890")), encodeArgs(0));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(cleanup_address_types_shortening)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract C {
|
||||
function f() public pure returns (address r) {
|
||||
bytes21 x = 0x1122334455667788990011223344556677889900ff;
|
||||
bytes20 y;
|
||||
assembly { y := x }
|
||||
address z = address(y);
|
||||
assembly { r := z }
|
||||
require(z == 0x1122334455667788990011223344556677889900);
|
||||
}
|
||||
function g() public pure returns (address payable r) {
|
||||
bytes21 x = 0x1122334455667788990011223344556677889900ff;
|
||||
bytes20 y;
|
||||
assembly { y := x }
|
||||
address payable z = address(y);
|
||||
assembly { r := z }
|
||||
require(z == 0x1122334455667788990011223344556677889900);
|
||||
}
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256("0x1122334455667788990011223344556677889900")));
|
||||
ABI_CHECK(callContractFunction("g()"), encodeArgs(u256("0x1122334455667788990011223344556677889900")));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(skip_dynamic_types)
|
||||
{
|
||||
// The EVM cannot provide access to dynamically-sized return values, so we have to skip them.
|
||||
@ -12446,7 +12494,7 @@ BOOST_AUTO_TEST_CASE(interface_contract)
|
||||
}
|
||||
|
||||
contract C {
|
||||
function f(address _interfaceAddress) public returns (bool) {
|
||||
function f(address payable _interfaceAddress) public returns (bool) {
|
||||
I i = I(_interfaceAddress);
|
||||
return i.f();
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
contract C {
|
||||
function f() public {
|
||||
address addr;
|
||||
address payable addr;
|
||||
uint balance = addr.balance;
|
||||
(bool callSuc,) = addr.call("");
|
||||
(bool delegatecallSuc,) = addr.delegatecall("");
|
||||
|
@ -6,6 +6,8 @@ contract C {
|
||||
function transfer(uint amount) public {
|
||||
address(this).transfer(amount); // to avoid pureness warning
|
||||
}
|
||||
function() payable external {
|
||||
}
|
||||
}
|
||||
contract D {
|
||||
function f() public {
|
||||
|
@ -16,6 +16,8 @@ contract C {
|
||||
(bool success,) = address(this).call("");
|
||||
require(success);
|
||||
}
|
||||
function() payable external {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (52-77): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
|
Loading…
Reference in New Issue
Block a user