Skip to content

Commit

Permalink
Changed whitespace formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Denton-L committed May 18, 2016
1 parent ff26ea6 commit 7c22a38
Show file tree
Hide file tree
Showing 9 changed files with 219 additions and 186 deletions.
7 changes: 7 additions & 0 deletions docs/common-patterns.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ function finishes.
AreWeDoneYet,
Finished
}

// This is the current stage.
Stages public stage = Stages.AcceptingBlindedBids;

Expand All @@ -188,9 +189,11 @@ function finishes.
if (stage != _stage) throw;
_
}

function nextStage() internal {
stage = Stages(uint(stage) + 1);
}

// Perform timed transitions. Be sure to mention
// this modifier first, otherwise the guards
// will not take the new stage into account.
Expand All @@ -211,6 +214,7 @@ function finishes.
{
// We will not implement that here
}

function reveal()
timedTransitions
atStage(Stages.RevealBids)
Expand All @@ -227,6 +231,7 @@ function finishes.
_
nextStage();
}

function g()
timedTransitions
atStage(Stages.AnotherStage)
Expand All @@ -235,12 +240,14 @@ function finishes.
// If you want to use `return` here,
// you have to call `nextStage()` manually.
}

function h()
timedTransitions
atStage(Stages.AreWeDoneYet)
transitionNext
{
}

function i()
timedTransitions
atStage(Stages.Finished)
Expand Down
47 changes: 24 additions & 23 deletions docs/contracts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,28 @@ API, this is done as follows::

// The json abi array generated by the compiler
var abiArray = [
{
"inputs":[
{"name":"x","type":"uint256"},
{"name":"y","type":"uint256"}
],
"type":"constructor"
},
{
"constant":true,
"inputs":[],
"name":"x",
"outputs":[{"name":"","type":"bytes32"}],
"type":"function"
}
{
"inputs":[
{"name":"x","type":"uint256"},
{"name":"y","type":"uint256"}
],
"type":"constructor"
},
{
"constant":true,
"inputs":[],
"name":"x",
"outputs":[{"name":"","type":"bytes32"}],
"type":"function"
}
];

var MyContract = web3.eth.contract(abiArray);
// deploy new contract
var contractInstance = MyContract.new(
10, 11,
{from: myAccount, gas: 1000000}
10,
11,
{from: myAccount, gas: 1000000}
);

.. index:: constructor;arguments
Expand Down Expand Up @@ -375,13 +376,13 @@ possible.


contract Caller {
function callTest(address testAddress) {
Test(testAddress).call(0xabcdef01); // hash does not exist
// results in Test(testAddress).x becoming == 1.
Rejector r = Rejector(0x123);
r.send(2 ether);
// results in r.balance == 0
}
function callTest(address testAddress) {
Test(testAddress).call(0xabcdef01); // hash does not exist
// results in Test(testAddress).x becoming == 1.
Rejector r = Rejector(0x123);
r.send(2 ether);
// results in r.balance == 0
}
}

.. index:: ! event
Expand Down
7 changes: 6 additions & 1 deletion docs/control-structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ of other contracts, the amount of Wei sent with the call and the gas can be spec
contract InfoFeed {
function info() returns (uint ret) { return 42; }
}


contract Consumer {
InfoFeed feed;
function setFeed(address addr) { feed = InfoFeed(addr); }
Expand All @@ -77,10 +79,12 @@ of unused parameters (especially return parameters) can be omitted.

contract c {
function f(uint key, uint value) { ... }

function g() {
// named arguments
f({value: 2, key: 3});
}

// omitted parameters
function func(uint k, uint) returns(uint) {
return k;
Expand Down Expand Up @@ -212,7 +216,7 @@ In the following example, we show how `throw` can be used to easily revert an Et

contract Sharer {
function sendHalf(address addr) returns (uint balance) {
if (!addr.send(msg.value/2))
if (!addr.send(msg.value / 2))
throw; // also reverts the transfer to Sharer
return this.balance;
}
Expand Down Expand Up @@ -290,6 +294,7 @@ you really know what you are doing.
for (uint i = 0; i < _data.length; ++i)
o_sum += _data[i];
}
// We know that we only access the array in bounds, so we can avoid the check.
// 0x20 needs to be added to an array because the first slot contains the
// array length.
Expand Down
30 changes: 16 additions & 14 deletions docs/frequently-asked-questions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -692,11 +692,11 @@ What happens to a struct's mapping when copying over a struct?

This is a very interesting question. Suppose that we have a contract field set up like such::

struct user{
struct user {
mapping(string => address) usedContracts;
}

function somefunction{
function somefunction {
user user1;
user1.usedContracts["Hello"] = "World";
user user2 = user1;
Expand All @@ -715,6 +715,8 @@ You will need to make sure that you have both contracts aware of each other's pr
In this example::

contract B {}


contract A {
address child;

Expand Down Expand Up @@ -758,21 +760,21 @@ Sure. Take care that if you cross the memory / storage boundary,
independent copies will be created::

contract C {
uint[20] x;
uint[20] x;

function f() {
g(x);
h(x);
}
function f() {
g(x);
h(x);
}

function g(uint[20] y) {
y[2] = 3;
}
function g(uint[20] y) {
y[2] = 3;
}

function h(uint[20] storage y) {
y[3] = 4;
}
}
function h(uint[20] storage y) {
y[3] = 4;
}
}

The call to `g(x)` will not have an effect on `x` because it needs
to create an independent copy of the storage value in memory
Expand Down
2 changes: 2 additions & 0 deletions docs/miscellaneous.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ There are some types in Solidity's type system that have no counterpart in the s
if (useB) f = b;
return f(x);
}

function a(uint x) returns (uint z) {
return x * x;
}

function b(uint x) returns (uint z) {
return 2 * x;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/solidity-by-example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ activate themselves.
}

Blind Auction
================
=============

The previous open auction is extended to a blind auction
in the following. The advantage of a blind auction is
Expand Down
50 changes: 25 additions & 25 deletions docs/structure-of-a-contract.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ State variables are values which are permanently stored in contract storage.
::

contract SimpleStorage {
uint storedData; // State variable
// ...
uint storedData; // State variable
// ...
}

See the :ref:`types` section for valid state variable types and
Expand All @@ -39,9 +39,9 @@ Functions are the executable units of code within a contract.
::

contract SimpleAuction {
function bid() { // Function
// ...
}
function bid() { // Function
// ...
}
}

:ref:`function-calls` can happen internally or externally
Expand All @@ -59,16 +59,16 @@ Function modifiers can be used to amend the semantics of functions in a declarat
::

contract Purchase {
address public seller;
address public seller;

modifier onlySeller() { // Modifier
if (msg.sender != seller) throw;
_
}
modifier onlySeller() { // Modifier
if (msg.sender != seller) throw;
_
}

function abort() onlySeller { // Modifier usage
// ...
}
function abort() onlySeller { // Modifier usage
// ...
}
}

.. _structure-events:
Expand All @@ -81,12 +81,12 @@ Events are convenience interfaces with the EVM logging facilities.
::

contract SimpleAuction {
event HighestBidIncreased(address bidder, uint amount); // Event
event HighestBidIncreased(address bidder, uint amount); // Event

function bid() {
// ...
HighestBidIncreased(msg.sender, msg.value); // Triggering event
}
function bid() {
// ...
HighestBidIncreased(msg.sender, msg.value); // Triggering event
}
}

See :ref:`events` in contracts section for information on how events are declared
Expand All @@ -103,12 +103,12 @@ Structs are custom defined types that can group several variables (see
::

contract Ballot {
struct Voter { // Struct
uint weight;
bool voted;
address delegate;
uint vote;
}
struct Voter { // Struct
uint weight;
bool voted;
address delegate;
uint vote;
}
}

.. _structure-enum-types:
Expand All @@ -122,5 +122,5 @@ Enums can be used to create custom types with a finite set of values (see
::

contract Purchase {
enum State { Created, Locked, Inactive } // Enum
enum State { Created, Locked, Inactive } // Enum
}
Loading

0 comments on commit 7c22a38

Please sign in to comment.