Skip to content

Commit

Permalink
[Docs] Add draft grammars and examples for Schedule Transaction and V…
Browse files Browse the repository at this point in the history
…alidator-Only Contract
  • Loading branch information
hydai committed Aug 27, 2018
1 parent 45ea72d commit f9bdc8e
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 7 deletions.
27 changes: 20 additions & 7 deletions docs/documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ Rule Engine
- :ref:`Lity Rule by Examples <rule-tutorial>`
- `Lity rule engine v1.0 spec <_static/files/lity-rule-engine-spec-v1-0.pdf>`_

Security & Safe
```````````````

ERC Contract Standard Checker
`````````````````````````````
+++++++++++++++++++++++++++++

- :ref:`ERC20 Checker <erc20-contract-standard-checker>`
- :ref:`ERC223 Checker <erc223-contract-standard-checker>`
Expand All @@ -29,21 +32,31 @@ ERC Contract Standard Checker
- :ref:`ERC884 Checker <erc884-contract-standard-checker>`

Overflow Protection
```````````````````
+++++++++++++++++++

- :ref:`safeuint - a new type with native SafeMath support <safeuint-type>`
- :ref:`Bec token with overflow protection <overflow-protection>`

Validator-Only Contract
+++++++++++++++++++++++

- :ref:`Validator-Only Contract <validator-only-contract>`

Analysis Tool
`````````````
+++++++++++++

- :ref:`Oyente Integration <oyente-integration>`

Ethereum Native Interface (ENI)
```````````````````````````````
Performant & Flexible
`````````````````````

ENI Tutorial
++++++++++++
Schedule Transaction
++++++++++++++++++++

- :ref:`Schedule Transaction <schedule-tx>`

Ethereum Native Interface (ENI) Tutorial
++++++++++++++++++++++++++++++++++++++++

- :ref:`Tutorial <eni-tutorial>`

Expand Down
40 changes: 40 additions & 0 deletions docs/schedule-tx.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Schedule Transaction
====================

.. _schedule-tx:

Warning: Schedule Transaction is under development.

Schedule Transaction is not fully supported by Lity yet.

Draft Grammar
-------------

.. code:: ts
schedule(<External Function Call>, <Timestamp>);
// <External Function Call>:
// Some examples:
// this.deposit(1000, 0x95...185)
// erc223receiver.tokenFallBack(...)
// <Timestamp>:
// Unix timestamp
// The <External Function Call> will be executed at <Timestamp>.
Examples
--------

.. code:: ts
// pragma lity ^1.3.0;
contract Schedule {
function deposit(uint amount, address to) private {
to.transfer(amount);
}
function setTimer(uint amount, address to, uint timestamp) public {
schedule(this.deposit(amount, to), timestamp);
}
}
45 changes: 45 additions & 0 deletions docs/validator-only-contract.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Validator Only Contract
=======================

.. _validator-only-contract:

Warning: Validator only contract is under development.

Validator only contract is not fully supported by Lity yet.

Draft Grammar
-------------

.. code:: ts
isValidator(<address>) returns (bool returnValue);
// isValidator is a built-in function provided by Lity.
// isValidator only takes one parameter, an address, to check this address is a validtor or not.
// If the address is in validator list => return true
// Otherwise => return false
Examples
--------

.. code:: ts
// pragma lity ^1.3.0;
contract BTERelay {
uint[] BTCHeaders;
modifier ValidatorOnly() {
require(isValidator(msg.sender));
_;
}
function saveBTCHeader(uint blockHash) ValidatorOnly {
BTCHeaders.append(headerHash);
}
function getBTCHeader(uint blockNum) pure public returns (uint) {
return BTCHeaders[blockNum];
}
}

0 comments on commit f9bdc8e

Please sign in to comment.