From 8251c4f8b5aabed4333712d78564d00084016eef Mon Sep 17 00:00:00 2001 From: Nikita Fuchs Date: Tue, 6 Oct 2020 22:16:45 +0200 Subject: [PATCH 1/3] Update sophia.md --- docs/sophia.md | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/docs/sophia.md b/docs/sophia.md index 73b82a4..3b57acc 100644 --- a/docs/sophia.md +++ b/docs/sophia.md @@ -8,7 +8,6 @@ - [Language Features](#language-features) - [Contracts](#contracts) - [Calling other contracts](#calling-other-contracts) - - [Protected contract calls](#protected-contract-calls) - [Mutable state](#mutable-state) - [Stateful functions](#stateful-functions) - [Payable](#payable) @@ -143,36 +142,6 @@ without calling it you can write Chain.spend(v.address, amount) ``` -#### Protected contract calls - -If a contract call fails for any reason (for instance, the remote contract -crashes or runs out of gas, or the entrypoint doesn't exist or has the wrong -type) the parent call also fails. To make it possible to recover from failures, -contract calls takes a named argument `protected : bool` (default `false`). - -The protected argument must be a literal boolean, and when set to `true` -changes the type of the contract call, wrapping the result in an `option` type. -If the call fails the result is `None`, otherwise it's `Some(r)` where `r` is -the return value of the call. - -```sophia -contract VotingType = - entrypoint : vote : string => unit - -contract Voter = - entrypoint tryVote(v : VotingType, alt : string) = - switch(v.vote(alt, protected = true) : option(unit)) - None => "Voting failed" - Some(_) => "Voting successful" -``` - -Any gas that was consumed by the contract call before the failure stays -consumed, which means that in order to protect against the remote contract -running out of gas it is necessary to set a gas limit using the `gas` argument. -However, note that errors that would normally consume all the gas in the -transaction still only uses up the gas spent running the contract. - - ### Mutable state Sophia does not have arbitrary mutable state, but only a limited form of From a7ea6deae3e5ecabb6f310ea06f516bf1bbacb68 Mon Sep 17 00:00:00 2001 From: Nikita Fuchs Date: Wed, 7 Oct 2020 16:39:02 +0200 Subject: [PATCH 2/3] cherrypick to remove iris content --- docs/docs/contracts.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/docs/docs/contracts.md b/docs/docs/contracts.md index 887eb24..4b613dc 100644 --- a/docs/docs/contracts.md +++ b/docs/docs/contracts.md @@ -504,15 +504,6 @@ the hash functions described below. Please refer to the `String` [library documentation](sophia_stdlib.md#String). -### Chars - -There is a builtin type `char` (the underlying representation being an integer), -mainly used to manipulate strings via `String.to_list`/`String.from_list`. - -Characters can also be introduced as character literals (`'x', '+', ...). - -Please refer to the `Char` [library documentation](sophia_stdlib.md#Char). - ### Byte arrays Byte arrays are fixed size arrays of 8-bit integers. They are described in hexadecimal system, From 6b66b47144cdb5b2231de16e014c967bf43912ed Mon Sep 17 00:00:00 2001 From: Nikita Fuchs Date: Wed, 7 Oct 2020 16:42:04 +0200 Subject: [PATCH 3/3] cherrypick lima changes --- docs/docs/contracts.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/contracts.md b/docs/docs/contracts.md index 4b613dc..c55a104 100644 --- a/docs/docs/contracts.md +++ b/docs/docs/contracts.md @@ -550,7 +550,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) @@ -571,13 +571,13 @@ contract Oracles = Oracle.extend(o, ttl) stateful entrypoint signExtendOracle(o : oracle(string, int), - sign : signature, // Signed oracle address + contract address + 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 address + contract address r : int) = Oracle.respond(o, q, signature = sign, r)