-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Docs] Add draft grammars and examples for Schedule Transaction and V…
…alidator-Only Contract
- Loading branch information
Showing
3 changed files
with
105 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | ||
} | ||
} | ||