Tests/Docs: changing type of msg.sender and tx.origin into address

And also making the type of address(literal) as non-payable address.
This commit is contained in:
hrkrshnn
2020-12-14 16:55:48 +01:00
parent e1a95cfd42
commit 88c99a7538
45 changed files with 159 additions and 89 deletions
+4 -4
View File
@@ -65,7 +65,7 @@ contract ico is safeMath {
icoExchangeRate = exchangeRate;
icoExchangeRateSetBlock = block.number + exchangeRateDelay;
icoEtcPriceAddr = priceSet;
owner = msg.sender;
owner = payable(msg.sender);
if ( startBlockNum > 0 ) {
require( startBlockNum >= block.number );
startBlock = startBlockNum;
@@ -272,7 +272,7 @@ contract ico is safeMath {
require( brought[msg.sender].eth > 0 );
uint256 _val = brought[msg.sender].eth * 90 / 100;
delete brought[msg.sender];
require( msg.sender.send(_val) );
require( payable(msg.sender).send(_val) );
}
receive () external payable {
@@ -281,7 +281,7 @@ contract ico is safeMath {
If they call the contract without any function then this process will be taken place.
*/
require( isICO() );
require( buy(msg.sender, address(0x00)) );
require( buy(payable(msg.sender), address(0x00)) );
}
function buy(address payable beneficiaryAddress, address affilateAddress) public payable returns (bool success) {
@@ -300,7 +300,7 @@ contract ico is safeMath {
@affilateAddress The address of the person who offered who will get the referral reward. It can not be equal with the beneficiaryAddress.
*/
require( isICO() );
if ( beneficiaryAddress == address(0x00)) { beneficiaryAddress = msg.sender; }
if ( beneficiaryAddress == address(0x00)) { beneficiaryAddress = payable(msg.sender); }
if ( beneficiaryAddress == affilateAddress ) {
affilateAddress = address(0x00);
}
+1 -1
View File
@@ -19,7 +19,7 @@ contract ptokenDB is tokenDB {}
*/
contract premium is module, safeMath {
function replaceModule(address payable addr) external override returns (bool success) {
require( super.isModuleHandler(msg.sender) );
require( super.isModuleHandler(payable(msg.sender)) );
require( db.replaceOwner(addr) );
super._replaceModule(addr);
return true;
+4 -4
View File
@@ -10,7 +10,7 @@ contract provider is module, safeMath, announcementTypes {
module callbacks
*/
function connectModule() external override returns (bool success) {
require( super.isModuleHandler(msg.sender) );
require( super.isModuleHandler(payable(msg.sender)) );
super._connectModule();
(bool _success, uint256 currentSchellingRound) = moduleHandler(moduleHandlerAddress).getCurrentSchellingRoundID();
require( _success );
@@ -26,7 +26,7 @@ contract provider is module, safeMath, announcementTypes {
@value amount
@bool Was the function successful?
*/
require( super.isModuleHandler(msg.sender) );
require( super.isModuleHandler(payable(msg.sender)) );
transferEvent_(from, value, true);
transferEvent_(to, value, false);
return true;
@@ -41,7 +41,7 @@ contract provider is module, safeMath, announcementTypes {
@reward token emission
@bool Was the function successful?
*/
require( super.isModuleHandler(msg.sender) );
require( super.isModuleHandler(payable(msg.sender)) );
globalFunds[roundID].reward = reward;
globalFunds[roundID].supply = globalFunds[roundID-1].supply;
currentSchellingRound = roundID;
@@ -133,7 +133,7 @@ contract provider is module, safeMath, announcementTypes {
@a Type of the setting
@b value
*/
require( super.isModuleHandler(msg.sender) );
require( super.isModuleHandler(payable(msg.sender)) );
if ( a == announcementType.providerPublicFunds ) { minFundsForPublic = b; }
else if ( a == announcementType.providerPrivateFunds ) { minFundsForPrivate = b; }
else if ( a == announcementType.providerPrivateClientLimit ) { privateProviderLimit = b; }
+1 -1
View File
@@ -14,7 +14,7 @@ contract publisher is announcementTypes, module, safeMath {
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) );
require( super.isModuleHandler(payable(msg.sender)) );
uint256 announcementID;
uint256 a;
// need reverse lookup
+3 -3
View File
@@ -136,7 +136,7 @@ contract schelling is module, announcementTypes, schellingVars {
module callbacks
*/
function replaceModule(address payable addr) external override returns (bool) {
require( super.isModuleHandler(msg.sender) );
require( super.isModuleHandler(payable(msg.sender)) );
require( db.replaceOwner(addr) );
super._replaceModule(addr);
return true;
@@ -151,7 +151,7 @@ contract schelling is module, announcementTypes, schellingVars {
@value Amount
@bool Was the transaction successful?
*/
require( super.isModuleHandler(msg.sender) );
require( super.isModuleHandler(payable(msg.sender)) );
if ( to == address(this) ) {
uint256 currentRound = getCurrentRound();
schellingVars._rounds memory round = getRound(currentRound);
@@ -271,7 +271,7 @@ contract schelling is module, announcementTypes, schellingVars {
@a Sort of configuration
@b Value
*/
require( super.isModuleHandler(msg.sender) );
require( super.isModuleHandler(payable(msg.sender)) );
if ( a == announcementType.schellingRoundBlockDelay ) { roundBlockDelay = b; }
else if ( a == announcementType.schellingCheckRounds ) { interestCheckRounds = uint8(b); }
else if ( a == announcementType.schellingCheckAboves ) { interestCheckAboves = uint8(b); }
+6 -6
View File
@@ -22,7 +22,7 @@ contract token is safeMath, module, announcementTypes {
module callbacks
*/
function replaceModule(address payable addr) external override returns (bool success) {
require( super.isModuleHandler(msg.sender) );
require( super.isModuleHandler(payable(msg.sender)) );
require( db.replaceOwner(addr) );
super._replaceModule(addr);
return true;
@@ -255,7 +255,7 @@ contract token is safeMath, module, announcementTypes {
@success Was the Function successful?
*/
bytes memory _data;
require( super.isModuleHandler(msg.sender) );
require( super.isModuleHandler(payable(msg.sender)) );
_transfer( from, to, amount, fee);
emit Transfer(from, to, amount, _data);
return true;
@@ -353,7 +353,7 @@ contract token is safeMath, module, announcementTypes {
@success Was the Function successful?
*/
require( super.isModuleHandler(msg.sender) );
require( super.isModuleHandler(payable(msg.sender)) );
_processTransactionFee(owner, value);
return true;
}
@@ -412,7 +412,7 @@ contract token is safeMath, module, announcementTypes {
@success Was the Function successful?
*/
require( super.isModuleHandler(msg.sender) || msg.sender == icoAddr );
require( super.isModuleHandler(payable(msg.sender)) || msg.sender == icoAddr );
_mint(owner, value);
return true;
}
@@ -441,7 +441,7 @@ contract token is safeMath, module, announcementTypes {
@success Was the Function successful?
*/
require( super.isModuleHandler(msg.sender) );
require( super.isModuleHandler(payable(msg.sender)) );
_burn(owner, value);
return true;
}
@@ -502,7 +502,7 @@ contract token is safeMath, module, announcementTypes {
@success Was the Function successful?
*/
require( super.isModuleHandler(msg.sender) );
require( super.isModuleHandler(payable(msg.sender)) );
if ( aType == announcementType.transactionFeeRate ) { transactionFeeRate = value; }
else if ( aType == announcementType.transactionFeeMin ) { transactionFeeMin = value; }
else if ( aType == announcementType.transactionFeeMax ) { transactionFeeMax = value; }
@@ -41,7 +41,7 @@ contract EtherToken is StandardToken {
// Balance covers value
balances[msg.sender] = balances[msg.sender].sub(value);
totalTokens = totalTokens.sub(value);
msg.sender.transfer(value);
payable(msg.sender).transfer(value);
emit Withdrawal(msg.sender, value);
}
}
+3 -3
View File
@@ -43,7 +43,7 @@ namespace solidity::frontend::test
namespace
{
static char const* registrarCode = R"DELIMITER(
pragma solidity >=0.4.0 <0.9.0;
pragma solidity >=0.7.0 <0.9.0;
abstract contract NameRegister {
function addr(string memory _name) public virtual view returns (address o_owner);
@@ -143,12 +143,12 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
{
if (block.timestamp < m_toRecord[_name].renewalDate)
revert();
bid(_name, msg.sender, msg.value);
bid(_name, payable(msg.sender), msg.value);
} else {
Record storage record = m_toRecord[_name];
if (record.owner != 0x0000000000000000000000000000000000000000)
revert();
m_toRecord[_name].owner = msg.sender;
m_toRecord[_name].owner = payable(msg.sender);
emit Changed(_name);
}
}
+6 -6
View File
@@ -391,7 +391,7 @@ contract DAO is DAOInterface, Token, TokenCreation {
receive() external payable override(DAOInterface, TokenCreation) {
if (block.timestamp < closingTime + creationGracePeriod && msg.sender != address(extraBalance))
createTokenProxy(msg.sender);
createTokenProxy(payable(msg.sender));
else
receiveEther();
}
@@ -459,7 +459,7 @@ contract DAO is DAOInterface, Token, TokenCreation {
p.newCurator = _newCurator;
if (_newCurator)
p.splitData.push();
p.creator = msg.sender;
p.creator = payable(msg.sender);
p.proposalDeposit = msg.value;
sumOfProposalDeposits += msg.value;
@@ -663,7 +663,7 @@ contract DAO is DAOInterface, Token, TokenCreation {
uint fundsToBeMoved =
(balances[msg.sender] * p.splitData[0].splitBalance) /
p.splitData[0].totalSupply;
if (p.splitData[0].newDAO.createTokenProxy{value: fundsToBeMoved}(msg.sender) == false)
if (p.splitData[0].newDAO.createTokenProxy{value: fundsToBeMoved}(payable(msg.sender)) == false)
revert();
@@ -687,7 +687,7 @@ contract DAO is DAOInterface, Token, TokenCreation {
// Burn DAO Tokens
emit Transfer(msg.sender, 0x0000000000000000000000000000000000000000, balances[msg.sender]);
withdrawRewardFor(msg.sender); // be nice, and get his rewards
withdrawRewardFor(payable(msg.sender)); // be nice, and get his rewards
totalSupply -= balances[msg.sender];
balances[msg.sender] = 0;
paidOut[msg.sender] = 0;
@@ -711,7 +711,7 @@ contract DAO is DAOInterface, Token, TokenCreation {
function retrieveDAOReward(bool _toMembers) external override returns (bool _success) {
DAO dao = DAO(msg.sender);
DAO dao = DAO(payable(msg.sender));
if ((rewardToken[msg.sender] * DAOrewardAccount.accumulatedInput()) /
totalRewardToken < DAOpaidOut[msg.sender])
@@ -736,7 +736,7 @@ contract DAO is DAOInterface, Token, TokenCreation {
}
function getMyReward() public override returns (bool _success) {
return withdrawRewardFor(msg.sender);
return withdrawRewardFor(payable(msg.sender));
}
@@ -445,8 +445,8 @@
"tryCall": false,
"typeDescriptions":
{
"typeIdentifier": "t_address_payable",
"typeString": "address payable"
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"src": "232:17:1",
@@ -3,7 +3,7 @@ contract C {
bytes2 constant b = 0xabcd;
bytes3 constant c = "abc";
bool constant d = true;
address payable constant e = 0x1212121212121212121212121212121212121212;
address constant e = 0x1212121212121212121212121212121212121212;
function f() public pure returns (uint w, bytes2 x, bytes3 y, bool z, address t) {
assembly {
w := a
@@ -10,8 +10,8 @@ contract C {
bytes3 constant cccc = ccc;
bool constant d = true;
bool constant dd = d;
address payable constant e = 0x1212121212121212121212121212121212121212;
address payable constant ee = e;
address constant e = 0x1212121212121212121212121212121212121212;
address constant ee = e;
function f() public pure returns (uint w, bytes2 x, bytes3 y, bool z, address t) {
assembly {
w := aaa
@@ -4,7 +4,7 @@ contract test {
x;
}
function g() public {
suicide(0x0000000000000000000000000000000000000001);
suicide(payable(0x0000000000000000000000000000000000000001));
}
}
// ----
@@ -0,0 +1,7 @@
contract C {
function f() public {
(msg.sender).send(10);
}
}
// ----
// TypeError 9862: (47-64): "send" and "transfer" are only available for objects of type "address payable", not "address".
@@ -0,0 +1,7 @@
contract C {
function f() public {
(msg.sender).transfer(10);
}
}
// ----
// TypeError 9862: (47-68): "send" and "transfer" are only available for objects of type "address payable", not "address".
@@ -0,0 +1,7 @@
contract C {
function f() public {
(tx.origin).send(10);
}
}
// ----
// TypeError 9862: (47-63): "send" and "transfer" are only available for objects of type "address payable", not "address".
@@ -0,0 +1,7 @@
contract C {
function f() public {
(tx.origin).transfer(10);
}
}
// ----
// TypeError 9862: (47-67): "send" and "transfer" are only available for objects of type "address payable", not "address".
@@ -1,6 +1,6 @@
contract test {
function f() public {
address(0x12).send(1);
payable(0x12).send(1);
}
}
// ----
@@ -1,6 +1,6 @@
contract C {
function f() public {
(0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E).transfer(2);
payable(0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E).transfer(2);
}
}
// ----
@@ -1,3 +1,3 @@
contract C {
address payable constant a = address(0);
address payable constant a = payable(0);
}
@@ -9,7 +9,7 @@ contract C {
}
}
// ----
// TypeError 2271: (85-108): Operator + not compatible with types address payable and address payable. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
// TypeError 2271: (122-145): Operator - not compatible with types address payable and address payable. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
// TypeError 2271: (159-182): Operator * not compatible with types address payable and address payable. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
// TypeError 2271: (196-219): Operator / not compatible with types address payable and address payable. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
// TypeError 2271: (85-108): Operator + not compatible with types address and address. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
// TypeError 2271: (122-145): Operator - not compatible with types address and address. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
// TypeError 2271: (159-182): Operator * not compatible with types address and address. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
// TypeError 2271: (196-219): Operator / not compatible with types address and address. Arithmetic operations on addresses are not supported. Convert to integer first before using them.
@@ -1,6 +1,6 @@
contract C {
address constant a = address(0);
address payable constant b = address(0);
address payable constant b = payable(0);
function f() public pure returns (address, address) {
return (a,b);
}
@@ -1,9 +1,9 @@
contract C {
address constant a = address(0);
address payable constant b = address(0);
address payable constant b = payable(0);
function f() public {
a = address(0);
b = address(0);
b = payable(0);
}
}
// ----
@@ -0,0 +1,9 @@
contract C {
function f() public pure {
address payable a = payable(address(0x00000000219ab540356cBB839Cbe05303d7705Fa));
address payable b = payable(0x00000000219ab540356cBB839Cbe05303d7705Fa);
a = b;
b = a;
}
}
// ----
@@ -0,0 +1,9 @@
contract C {
function f() public pure {
address payable a = address(0x00000000219ab540356cBB839Cbe05303d7705Fa);
address payable b = 0x00000000219ab540356cBB839Cbe05303d7705Fa;
}
}
// ----
// TypeError 9574: (52-123): Type address is not implicitly convertible to expected type address payable.
// TypeError 9574: (133-195): Type address is not implicitly convertible to expected type address payable.
@@ -2,7 +2,7 @@ contract C {
function f(address payable) internal pure {}
function f(address) internal pure {}
function g() internal pure {
address payable a = address(0);
address payable a = payable(0);
f(a);
}
}
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
// TypeError 9574: (46-62): Type address payable is not implicitly convertible to expected type contract C.
// TypeError 9574: (46-62): Type address is not implicitly convertible to expected type contract C.
@@ -1,6 +1,6 @@
contract C {
function f() public pure returns (C c) {
c = C(address(2));
c = C(payable(2));
}
fallback() external payable {
}
@@ -1,6 +1,6 @@
contract C {
function f() public pure returns (C c) {
c = C(address(2));
c = C(payable(2));
}
receive() external payable {
}
@@ -1,6 +1,6 @@
contract C {
function f() public view returns (address payable a, address b) {
(address c, address payable d) = (address(this), address(0));
(address c, address payable d) = (address(this), payable(0));
(a,b) = (c,d);
}
}
@@ -1,6 +1,6 @@
contract C {
function f() public view returns (address payable a, address b) {
(address c, address payable d) = (address(this), address(0));
(address c, address payable d) = (address(this), payable(0));
(a,b) = (d,c);
}
}
}
@@ -0,0 +1,5 @@
contract C {
function f() public returns (bool success) {
(success, ) = (address(0)).call{value: 30}("");
}
}
@@ -1,8 +1,8 @@
contract C {
function f() public pure {
address payable a = address(0);
a = address(1);
address payable b = 0x0123456789012345678901234567890123456789;
b = 0x9876543210987654321098765432109876543210;
address payable a = payable(0);
a = payable(1);
address payable b = payable(0x0123456789012345678901234567890123456789);
b = payable(0x9876543210987654321098765432109876543210);
}
}
}
@@ -0,0 +1,7 @@
contract C {
function f() public pure {
address payable a = address(0);
}
}
// ----
// TypeError 9574: (52-82): Type address is not implicitly convertible to expected type address payable.
@@ -41,7 +41,7 @@ contract C
// TypeError 9640: (183-213): Explicit type conversion not allowed from "uint16" to "int8".
// TypeError 9640: (270-277): Explicit type conversion not allowed from "uint16" to "int8".
// TypeError 9640: (300-329): Explicit type conversion not allowed from "uint256" to "address".
// TypeError 9640: (349-365): Explicit type conversion not allowed from "address payable" to "uint256".
// TypeError 9640: (349-365): Explicit type conversion not allowed from "address" to "uint256".
// TypeError 9640: (421-431): Explicit type conversion not allowed from "uint256" to "address".
// TypeError 9640: (452-471): Explicit type conversion not allowed from "bytes10" to "int80".
// TypeError 9640: (493-511): Explicit type conversion not allowed from "int80" to "bytes10".