aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/abi-spec.rst6
-rw-r--r--docs/style-guide.rst121
2 files changed, 122 insertions, 5 deletions
diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst
index f249bbcd..07c8e0ce 100644
--- a/docs/abi-spec.rst
+++ b/docs/abi-spec.rst
@@ -155,15 +155,15 @@ on the type of ``X`` being
``enc(X) = enc(enc_utf8(X))``, i.e. ``X`` is utf-8 encoded and this value is interpreted as of ``bytes`` type and encoded further. Note that the length used in this subsequent encoding is the number of bytes of the utf-8 encoded string, not its number of characters.
-- ``uint<M>``: ``enc(X)`` is the big-endian encoding of ``X``, padded on the higher-order (left) side with zero-bytes such that the length is a multiple of 32 bytes.
+- ``uint<M>``: ``enc(X)`` is the big-endian encoding of ``X``, padded on the higher-order (left) side with zero-bytes such that the length is 32 bytes.
- ``address``: as in the ``uint160`` case
-- ``int<M>``: ``enc(X)`` is the big-endian two's complement encoding of ``X``, padded on the higher-order (left) side with ``0xff`` for negative ``X`` and with zero bytes for positive ``X`` such that the length is a multiple of 32 bytes.
+- ``int<M>``: ``enc(X)`` is the big-endian two's complement encoding of ``X``, padded on the higher-order (left) side with ``0xff`` for negative ``X`` and with zero bytes for positive ``X`` such that the length is 32 bytes.
- ``bool``: as in the ``uint8`` case, where ``1`` is used for ``true`` and ``0`` for ``false``
- ``fixed<M>x<N>``: ``enc(X)`` is ``enc(X * 10**N)`` where ``X * 10**N`` is interpreted as a ``int256``.
- ``fixed``: as in the ``fixed128x19`` case
- ``ufixed<M>x<N>``: ``enc(X)`` is ``enc(X * 10**N)`` where ``X * 10**N`` is interpreted as a ``uint256``.
- ``ufixed``: as in the ``ufixed128x19`` case
-- ``bytes<M>``: ``enc(X)`` is the sequence of bytes in ``X`` padded with zero-bytes to a length of 32.
+- ``bytes<M>``: ``enc(X)`` is the sequence of bytes in ``X`` padded with trailing zero-bytes to a length of 32 bytes.
Note that for any ``X``, ``len(enc(X))`` is a multiple of 32.
diff --git a/docs/style-guide.rst b/docs/style-guide.rst
index ab1af13d..ade37d0b 100644
--- a/docs/style-guide.rst
+++ b/docs/style-guide.rst
@@ -112,6 +112,109 @@ No::
}
}
+Maximum Line Length
+===================
+
+Keeping lines under the `PEP 8 recommendation <https://www.python.org/dev/peps/pep-0008/#maximum-line-length>`_ of 79 (or 99)
+characters helps readers easily parse the code.
+
+Wrapped lines should conform to the following guidelines.
+
+1. The first argument should not be attached to the opening parenthesis.
+2. One, and only one, indent should be used.
+3. Each argument should fall on its own line.
+4. The terminating element, :code:`);`, should be placed on the final line by itself.
+
+Function Calls
+
+Yes::
+
+ thisFunctionCallIsReallyLong(
+ longArgument1,
+ longArgument2,
+ longArgument3
+ );
+
+No::
+
+ thisFunctionCallIsReallyLong(longArgument1,
+ longArgument2,
+ longArgument3
+ );
+
+ thisFunctionCallIsReallyLong(longArgument1,
+ longArgument2,
+ longArgument3
+ );
+
+ thisFunctionCallIsReallyLong(
+ longArgument1, longArgument2,
+ longArgument3
+ );
+
+ thisFunctionCallIsReallyLong(
+ longArgument1,
+ longArgument2,
+ longArgument3
+ );
+
+ thisFunctionCallIsReallyLong(
+ longArgument1,
+ longArgument2,
+ longArgument3);
+
+Assignment Statements
+
+Yes::
+
+ thisIsALongNestedMapping[being][set][to_some_value] = someFunction(
+ argument1,
+ argument2,
+ argument3,
+ argument4
+ );
+
+No::
+
+ thisIsALongNestedMapping[being][set][to_some_value] = someFunction(argument1,
+ argument2,
+ argument3,
+ argument4);
+
+Event Definitions and Event Emitters
+
+Yes::
+
+ event LongAndLotsOfArgs(
+ adress sender,
+ adress recipient,
+ uint256 publicKey,
+ uint256 amount,
+ bytes32[] options
+ );
+
+ LongAndLotsOfArgs(
+ sender,
+ recipient,
+ publicKey,
+ amount,
+ options
+ );
+
+No::
+
+ event LongAndLotsOfArgs(adress sender,
+ adress recipient,
+ uint256 publicKey,
+ uint256 amount,
+ bytes32[] options);
+
+ LongAndLotsOfArgs(sender,
+ recipient,
+ publicKey,
+ amount,
+ options);
+
Source File Encoding
====================
@@ -391,7 +494,7 @@ function body to be kept on the same line as the function declaration.
The closing brace should be at the same indentation level as the function
declaration.
-The opening brace should be preceeded by a single space.
+The opening brace should be preceded by a single space.
Yes::
@@ -421,7 +524,21 @@ No::
function increment(uint x) public pure returns (uint) {
return x + 1;}
-The visibility modifiers for a function should come before any custom
+You should explicitly label the visibility of all functions, including constructors.
+
+Yes::
+
+ function explicitlyPublic(uint val) public {
+ doSomething();
+ }
+
+No::
+
+ function implicitlyPublic(uint val) {
+ doSomething();
+ }
+
+The visibility modifier for a function should come before any custom
modifiers.
Yes::