From 097be3946cd424044605e6369b602b668e5fc909 Mon Sep 17 00:00:00 2001 From: Hans Svensson Date: Fri, 16 Jun 2023 08:59:37 +0200 Subject: [PATCH 1/2] Document Chain.spend and sort Chain functions --- docs/sophia_stdlib.md | 66 ++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/docs/sophia_stdlib.md b/docs/sophia_stdlib.md index d136669..a9d45f5 100644 --- a/docs/sophia_stdlib.md +++ b/docs/sophia_stdlib.md @@ -470,38 +470,6 @@ Chain.block_height : int" The height of the current block (i.e. the block in which the current call will be included). -##### coinbase -``` -Chain.coinbase : address -``` - -The address of the account that mined the current block. - - -##### timestamp -``` -Chain.timestamp : int -``` - -The timestamp of the current block (unix time, milliseconds). - - -##### difficulty -``` -Chain.difficulty : int -``` - -The difficulty of the current block. - - -##### gas -``` -Chain.gas_limit : int -``` - -The gas limit of the current block. - - ##### bytecode_hash ``` Chain.bytecode_hash : 'c => option(hash) @@ -565,6 +533,7 @@ main contract Market = The typechecker must be certain about the created contract's type, so it is worth writing it explicitly as shown in the example. + ##### clone ``` Chain.clone : ( ref : 'c, gas : int, value : int, protected : bool, ... @@ -623,6 +592,22 @@ implementation of the `init` function does not actually return `state`, but calls `put` instead. Moreover, FATE prevents even handcrafted calls to `init`. +##### coinbase +``` +Chain.coinbase : address +``` + +The address of the account that mined the current block. + + +##### difficulty +``` +Chain.difficulty : int +``` + +The difficulty of the current block. + + ##### event ``` Chain.event(e : event) : unit @@ -630,6 +615,23 @@ Chain.event(e : event) : unit Emits the event. To use this function one needs to define the `event` type as a `datatype` in the contract. +##### spend +``` +Chain.spend(to : address, amount : int) : unit +``` + +Spend `amount` tokens to `to`. Will fail (and abort the contract) if contract +doesn't have `amount` tokens to transfer, or, if `to` is not `payable`. + + +##### timestamp +``` +Chain.timestamp : int +``` + +The timestamp of the current block (unix time, milliseconds). + + ### Char #### to_int -- 2.30.2 From 1e24462efc2486cf24f026ff78a8bc965ec241e9 Mon Sep 17 00:00:00 2001 From: Hans Svensson Date: Fri, 16 Jun 2023 09:13:51 +0200 Subject: [PATCH 2/2] Too little coffee, re-adding gas-limit --- docs/sophia_stdlib.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/sophia_stdlib.md b/docs/sophia_stdlib.md index a9d45f5..9fcdd7e 100644 --- a/docs/sophia_stdlib.md +++ b/docs/sophia_stdlib.md @@ -612,7 +612,17 @@ The difficulty of the current block. ``` Chain.event(e : event) : unit ``` -Emits the event. To use this function one needs to define the `event` type as a `datatype` in the contract. + +Emits the event. To use this function one needs to define the `event` type as a +`datatype` in the contract. + + +##### gas\_limit +``` +Chain.gas_limit : int +``` + +The gas limit of the current block. ##### spend -- 2.30.2