aboutsummaryrefslogtreecommitdiffstats
path: root/docs/common-patterns.rst
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-04-17 05:03:49 +0800
committerGitHub <noreply@github.com>2018-04-17 05:03:49 +0800
commit4cb486ee993cadde5564fb6c611d2bcf4fc44414 (patch)
tree6b971913021037cf28141c38af97c7ecda77719f /docs/common-patterns.rst
parentdfe3193c7382c80f1814247a162663a97c3f5e67 (diff)
parentb8431c5c4a6795db8c42a1a3389047658bb87301 (diff)
downloaddexon-solidity-4cb486ee993cadde5564fb6c611d2bcf4fc44414.tar
dexon-solidity-4cb486ee993cadde5564fb6c611d2bcf4fc44414.tar.gz
dexon-solidity-4cb486ee993cadde5564fb6c611d2bcf4fc44414.tar.bz2
dexon-solidity-4cb486ee993cadde5564fb6c611d2bcf4fc44414.tar.lz
dexon-solidity-4cb486ee993cadde5564fb6c611d2bcf4fc44414.tar.xz
dexon-solidity-4cb486ee993cadde5564fb6c611d2bcf4fc44414.tar.zst
dexon-solidity-4cb486ee993cadde5564fb6c611d2bcf4fc44414.zip
Merge pull request #3892 from ethereum/develop
Merge develop into release for 0.4.22
Diffstat (limited to 'docs/common-patterns.rst')
-rw-r--r--docs/common-patterns.rst25
1 files changed, 19 insertions, 6 deletions
diff --git a/docs/common-patterns.rst b/docs/common-patterns.rst
index 7e09f534..739e136f 100644
--- a/docs/common-patterns.rst
+++ b/docs/common-patterns.rst
@@ -130,7 +130,7 @@ restrictions highly readable.
::
- pragma solidity ^0.4.11;
+ pragma solidity ^0.4.22;
contract AccessRestriction {
// These will be assigned at the construction
@@ -147,7 +147,10 @@ restrictions highly readable.
// a certain address.
modifier onlyBy(address _account)
{
- require(msg.sender == _account);
+ require(
+ msg.sender == _account,
+ "Sender not authorized."
+ );
// Do not forget the "_;"! It will
// be replaced by the actual function
// body when the modifier is used.
@@ -164,7 +167,10 @@ restrictions highly readable.
}
modifier onlyAfter(uint _time) {
- require(now >= _time);
+ require(
+ now >= _time,
+ "Function called too early."
+ );
_;
}
@@ -186,7 +192,10 @@ restrictions highly readable.
// This was dangerous before Solidity version 0.4.0,
// where it was possible to skip the part after `_;`.
modifier costs(uint _amount) {
- require(msg.value >= _amount);
+ require(
+ msg.value >= _amount,
+ "Not enough Ether provided."
+ );
_;
if (msg.value > _amount)
msg.sender.send(msg.value - _amount);
@@ -194,6 +203,7 @@ restrictions highly readable.
function forceOwnerChange(address _newOwner)
public
+ payable
costs(200 ether)
{
owner = _newOwner;
@@ -272,7 +282,7 @@ function finishes.
::
- pragma solidity ^0.4.11;
+ pragma solidity ^0.4.22;
contract StateMachine {
enum Stages {
@@ -289,7 +299,10 @@ function finishes.
uint public creationTime = now;
modifier atStage(Stages _stage) {
- require(stage == _stage);
+ require(
+ stage == _stage,
+ "Function cannot be called at this time."
+ );
_;
}