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
+3 -3
View File
@@ -114,7 +114,7 @@ to receive their money - contracts cannot activate themselves.
// before `send` returns.
pendingReturns[msg.sender] = 0;
if (!msg.sender.send(amount)) {
if (!payable(msg.sender).send(amount)) {
// No need to call throw here, just reset the amount owing
pendingReturns[msg.sender] = amount;
return false;
@@ -280,7 +280,7 @@ invalid bids.
// the same deposit.
bidToCheck.blindedBid = bytes32(0);
}
msg.sender.transfer(refund);
payable(msg.sender).transfer(refund);
}
/// Withdraw a bid that was overbid.
@@ -293,7 +293,7 @@ invalid bids.
// conditions -> effects -> interaction).
pendingReturns[msg.sender] = 0;
msg.sender.transfer(amount);
payable(msg.sender).transfer(amount);
}
}
+3 -3
View File
@@ -159,13 +159,13 @@ The full contract
require(recoverSigner(message, signature) == owner);
msg.sender.transfer(amount);
payable(msg.sender).transfer(amount);
}
/// destroy the contract and reclaim the leftover funds.
function shutdown() public {
require(msg.sender == owner);
selfdestruct(msg.sender);
selfdestruct(payable(msg.sender));
}
/// signature methods.
@@ -347,7 +347,7 @@ The full contract
constructor (address payable _recipient, uint256 duration)
payable
{
sender = msg.sender;
sender = payable(msg.sender);
recipient = _recipient;
expiration = block.timestamp + duration;
}
+2 -2
View File
@@ -74,7 +74,7 @@ you can use state machine-like constructs inside a contract.
// Division will truncate if it is an odd number.
// Check via multiplication that it wasn't an odd number.
constructor() payable {
seller = msg.sender;
seller = payable(msg.sender);
value = msg.value / 2;
require((2 * value) == msg.value, "Value has to be even.");
}
@@ -107,7 +107,7 @@ you can use state machine-like constructs inside a contract.
payable
{
emit PurchaseConfirmed();
buyer = msg.sender;
buyer = payable(msg.sender);
state = State.Locked;
}