Merge branch 'lima' into master

This commit is contained in:
radrow
2020-10-13 10:22:05 +02:00
16 changed files with 193 additions and 96 deletions
+10 -10
View File
@@ -83,7 +83,7 @@ The main unit of code in Sophia is the *contract*.
- A contract may define a type `state` encapsulating its local
state. When creating a new contract the `init` entrypoint is executed and the
state is initialized to its return value.
The language offers some primitive functions to interact with the blockchain and contracts.
Please refer to the [Chain](sophia_stdlib.md#Chain), [Contract](sophia_stdlib.md#Contract)
and the [Call](sophia_stdlib.md#Call) namespaces in the documentation.
@@ -314,7 +314,7 @@ so even cyclic includes should be working without any special tinkering.
### Standard library
Sophia offers [standard library](sophia_stdlib.md) which exposes some
Sophia offers [standard library](sophia_stdlib.md) which exposes some
primitive operations and some higher level utilities. The builtin
namespaces like `Chain`, `Contract`, `Map`
are included by default and are supported internally by the compiler.
@@ -481,7 +481,7 @@ Example syntax:
Lists can be constructed using the range syntax using special `..` operator:
```
[1..4] == [1,2,3,4]
[1..4] == [1,2,3,4]
```
The ranges are always ascending and have step equal to 1.
@@ -595,7 +595,7 @@ Please refer to the `Bytes` [library documentation](sophia_stdlib.md#Bytes).
### Cryptographic builins
Libraries [Crypto](sophia_stdlib.md#Crypto) and [String](sophia_stdlib.md#String) provide functions to
Libraries [Crypto](sophia_stdlib.md#Crypto) and [String](sophia_stdlib.md#String) provide functions to
hash objects, verify signatures etc. The `hash` is a type alias for `bytes(32)`.
#### AEVM note
@@ -630,7 +630,7 @@ Example for an oracle answering questions of type `string` with answers of type
contract Oracles =
stateful entrypoint registerOracle(acct : address,
sign : signature, // Signed oracle address + contract address
sign : signature, // Signed network id + oracle address + contract address
qfee : int,
ttl : Chain.ttl) : oracle(string, int) =
Oracle.register(acct, signature = sign, qfee, ttl)
@@ -651,13 +651,13 @@ contract Oracles =
Oracle.extend(o, ttl)
stateful entrypoint signExtendOracle(o : oracle(string, int),
sign : signature, // Signed oracle address + contract address
ttl : Chain.ttl) : unit =
sign : signature, // Signed network id + oracle address + contract address
ttl : Chain.ttl) : unit =
Oracle.extend(o, signature = sign, ttl)
stateful entrypoint respond(o : oracle(string, int),
q : oracle_query(string, int),
sign : signature, // Signed oracle query id + contract address
sign : signature, // Signed network id + oracle query id + contract address
r : int) =
Oracle.respond(o, q, signature = sign, r)
@@ -678,7 +678,7 @@ contract Oracles =
#### Sanity checks
When an Oracle literal is passed to a contract, no deep checks are performed.
When an Oracle literal is passed to a contract, no deep checks are performed.
For extra safety [Oracle.check](sophia_stdlib.md#check) and [Oracle.check_query](sophia_stdlib.md#check_query)
functions are provided.
@@ -738,7 +738,7 @@ To use events a contract must declare a datatype `event`, and events are then
logged using the `Chain.event` function:
```
datatype event
datatype event
= Event1(int, int, string)
| Event2(string, address)
+30 -8
View File
@@ -347,7 +347,7 @@ Registers new oracle answering questions of type `'a` with answers of type `'b`.
* The `acct` is the address of the oracle to register (can be the same as the contract).
* `signature` is a signature proving that the contract is allowed to register the account -
the account address + the contract address (concatenated as byte arrays) is
the `network id` + `account address` + `contract address` (concatenated as byte arrays) is
[signed](./sophia.md#delegation-signature) with the
private key of the account, proving you have the private key of the oracle to be. If the
address is the same as the contract `sign` is ignored and can be left out entirely.
@@ -381,7 +381,8 @@ Responds to the question `q` on `o`.
Unless the contract address is the same as the oracle address the `signature`
(which is an optional, named argument)
needs to be provided. Proving that we have the private key of the oracle by
[signing](./sophia.md#delegation-signature) the oracle query id + contract address
[signing](./sophia.md#delegation-signature)
the `network id` + `oracle query id` + `contract address`
#### extend
@@ -455,7 +456,8 @@ Naming System (AENS).
If `owner` is equal to `Contract.address` the signature `signature` is
ignored, and can be left out since it is a named argument. Otherwise we need
a signature to prove that we are allowed to do AENS operations on behalf of
`owner`
`owner`. The [signature is tied to a network id](https://github.com/aeternity/protocol/blob/iris/consensus/consensus.md#transaction-signature),
i.e. the signature material should be prefixed by the network id.
### Types
@@ -505,8 +507,8 @@ let Some(Name(owner, FixedTTL(expiry), ptrs)) = AENS.lookup("example.chain")
AENS.preclaim(owner : address, commitment_hash : hash, <signature : signature>) : unit
```
The [signature](./sophia.md#delegation-signature) should be over `owner address` + `Contract.address`
(concatenated as byte arrays).
The [signature](./sophia.md#delegation-signature) should be over
`network id` + `owner address` + `Contract.address` (concatenated as byte arrays).
#### claim
@@ -514,7 +516,9 @@ The [signature](./sophia.md#delegation-signature) should be over `owner address`
AENS.claim(owner : address, name : string, salt : int, name_fee : int, <signature : signature>) : unit
```
The [signature](./sophia.md#delegation-signature) should be over `owner address` + `name_hash` + `Contract.address`
The [signature](./sophia.md#delegation-signature) should be over
`network id` + `owner address` + `name_hash` + `Contract.address`
(concatenated as byte arrays)
using the private key of the `owner` account for signing.
@@ -525,7 +529,9 @@ AENS.transfer(owner : address, new_owner : address, name : string, <signature :
Transfers name to the new owner.
The [signature](./sophia.md#delegation-signature) should be over `owner address` + `name_hash` + `Contract.address`
The [signature](./sophia.md#delegation-signature) should be over
`network id` + `owner address` + `name_hash` + `Contract.address`
(concatenated as byte arrays)
using the private key of the `owner` account for signing.
@@ -536,7 +542,9 @@ AENS.revoke(owner : address, name : string, <signature : signature>) : unit
Revokes the name to extend the ownership time.
The [signature](./sophia.md#delegation-signature) should be over `owner address` + `name_hash` + `Contract.address`
The [signature](./sophia.md#delegation-signature) should be over
`network id` + `owner address` + `name_hash` + `Contract.address`
(concatenated as byte arrays)
using the private key of the `owner` account for signing.
@@ -773,6 +781,13 @@ List.last(l : list('a)) : option('a)
Returns `Some` of the last element of a list or `None` if the list is empty.
#### contains
```
List.contains(e : 'a, l : list('a)) : bool
```
Checks if list `l` contains element `e`. Equivalent to `List.find(x => x == e, l) != None`.
#### find
```
List.find(p : 'a => bool, l : list('a)) : option('a)
@@ -1113,6 +1128,13 @@ Option.force(o : option('a)) : 'a
Forcefully escapes `option` wrapping assuming it is `Some`. Throws error on `None`.
#### contains
```
Option.contains(e : 'a, o : option('a)) : bool
```
Returns `true` if and only if `o` contains element equal to `e`. Equivalent to `Option.match(false, x => x == e, o)`.
#### on_elem
```
Option.on_elem(o : option('a), f : 'a => unit) : unit