Update common-patterns.rst

This commit is contained in:
Matt Wisniewski
2017-05-03 12:03:02 +02:00
committed by chriseth
parent 00933b99cc
commit 2b4b86aa7f
7 changed files with 73 additions and 99 deletions
+5 -6
View File
@@ -79,7 +79,7 @@ outlined further below:
::
pragma solidity ^0.4.0;
pragma solidity ^0.4.11;
contract Fund {
/// Mapping of ether shares of the contract.
@@ -88,8 +88,7 @@ outlined further below:
function withdraw() {
var share = shares[msg.sender];
shares[msg.sender] = 0;
if (!msg.sender.send(share))
throw;
require(msg.sender.send(share));
}
}
@@ -162,7 +161,7 @@ Never use tx.origin for authorization. Let's say you have a wallet contract like
::
pragma solidity ^0.4.0;
pragma solidity ^0.4.11;
// THIS CONTRACT CONTAINS A BUG - DO NOT USE
contract TxUserWallet {
@@ -173,8 +172,8 @@ Never use tx.origin for authorization. Let's say you have a wallet contract like
}
function transfer(address dest, uint amount) {
if (tx.origin != owner) { throw; }
if (!dest.call.value(amount)()) throw;
require(tx.origin == owner);
require(dest.call.value(amount)());
}
}