Compare commits

...

24 Commits

Author SHA1 Message Date
radrow 0320ac959b CHANGELOG update 2021-07-15 20:43:11 +02:00
radrow dcef89b486 Add Option.force_msg 2021-07-15 20:41:38 +02:00
Hans Svensson 4957d01e9e Merge pull request #327 from aeternity/fix_doc
Fix stdlib doc
2021-07-13 20:40:49 +02:00
Hans Svensson 9d76e6186a Fix stdlib doc 2021-07-13 20:01:54 +02:00
Radosław Rowicki ae3edac53e Prepare 6.0.2 (#326)
* Prepare 6.0.2

* Minor note
2021-07-06 17:31:35 +02:00
Ulf Norell acec32e744 Merge pull request #325 from aeternity/issue324
Fix #324: bug when compiling default init in the presence of child contracts
2021-07-05 10:33:26 +02:00
Hans Svensson 5784f074a6 Merge pull request #323 from aeternity/fromtostep
Add check in from_to_step
2021-07-05 09:39:32 +02:00
Ulf Norell d07b321b25 Fix #324: bug when compiling default init in the presence of child contracts 2021-07-05 09:29:43 +02:00
radrow 2e6c01cb75 Fix var 2021-06-26 19:10:49 +02:00
radrow b22eeffc3d Formatting in stdlib doc 2021-06-26 19:10:15 +02:00
radrow b366bed24b Add check in from_to_step 2021-06-25 11:19:19 +02:00
Hans Svensson 1975ccf804 Merge pull request #322 from aeternity/prepare_6.0.1
Prepare 6.0.1
2021-06-24 09:38:05 +02:00
Hans Svensson 4f68729631 Prepare v6.0.1 2021-06-24 09:34:05 +02:00
Denis Davidyuk 10c845d3cf Use consistent event definitions between examples 2021-06-24 09:34:05 +02:00
Hans Svensson 393d7710c1 Merge pull request #318 from aeternity/stdlib-tests
Fix Frac library and add stdlib compilation test
2021-06-24 09:29:12 +02:00
Hans Svensson 37e5a92b2e Merge pull request #314 from aeternity/call-fee-doc
Call.fee doc
2021-06-24 09:28:17 +02:00
Hans Svensson cb9c9df103 Merge pull request #321 from aeternity/calldata-fix
Fix calldata
2021-06-24 09:19:05 +02:00
radrow c09313a92c newline 2021-06-22 17:55:31 +02:00
radrow 75b2d6981f Fix calldata 2021-06-22 17:54:05 +02:00
Hans Svensson 78d94786b6 Merge pull request #320 from aeternity/nikita-fuchs-patch-1
fix child contract deployment example
2021-06-22 14:52:36 +02:00
Nikita Fuchs 216f7f8a25 fix child contract deployment example 2021-06-22 14:47:58 +02:00
radrow 254172e3a3 Properly refer the stdlib 2021-06-02 17:06:36 +02:00
radrow eadb4e8c83 Fix Frac library and add stdlib compilation test 2021-06-02 17:03:23 +02:00
radrow 3996b6a711 Call.fee doc 2021-05-25 10:53:40 +02:00
13 changed files with 88 additions and 18 deletions
+1
View File
@@ -21,3 +21,4 @@ rebar3.crashdump
aesophia
.qcci
current_counterexample.eqc
test/contracts/test.aes
+15 -1
View File
@@ -6,9 +6,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- `Option.force_msg`
### Changed
### Removed
## [6.0.2] 2021-07-05
### Changed
- `List.from_to_step` now forbids non-positive step (this change does
*not* alter the behavior of the previously deployed contracts)
- Fixed leaking state between contracts
## [6.0.1] 2021-06-24
### Changed
- Fixed a bug in calldata encoding for contracts containing multiple contracts
- Fixed a missing `include` in the `Frac` standard library
## [6.0.0] 2021-05-26
### Added
- Child contracts
@@ -298,7 +310,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Simplify calldata creation - instead of passing a compiled contract, simply
pass a (stubbed) contract string.
[Unreleased]: https://github.com/aeternity/aesophia/compare/v6.0.0...HEAD
[Unreleased]: https://github.com/aeternity/aesophia/compare/v6.0.2...HEAD
[6.0.2]: https://github.com/aeternity/aesophia/compare/v6.0.1...v6.0.2
[6.0.1]: https://github.com/aeternity/aesophia/compare/v6.0.0...v6.0.1
[6.0.0]: https://github.com/aeternity/aesophia/compare/v5.0.0...v6.0.0
[5.0.0]: https://github.com/aeternity/aesophia/compare/v4.3.0...v5.0.0
[4.3.0]: https://github.com/aeternity/aesophia/compare/v4.2.0...v4.3.0
+3 -3
View File
@@ -194,7 +194,7 @@ contract IntHolder =
entrypoint get() = state
main contract IntHolderFactory =
entrypoint new(x : int) : IntHolder =
stateful entrypoint new(x : int) : IntHolder =
let ih = Chain.create(x) : IntHolder
ih
```
@@ -802,8 +802,8 @@ will emit one Event of each kind in the example.
```sophia
entrypoint emit_events() : () =
Chain.event(TheFirstEvent(42))
Chain.event(AnotherEvent(Contract.address, "This is not indexed"))
Chain.event(Event1(42, 34, "foo"))
Chain.event(Event2("This is not indexed", Contract.address))
```
#### Argument order
+26 -8
View File
@@ -362,7 +362,7 @@ namespace Chain =
#### tx_hash
```
Auth.tx_hash : option(Chain.tx)
Auth.tx_hash : option(hash)
```
Gets the transaction hash during authentication.
@@ -645,7 +645,7 @@ Call.value : int
The amount of coins transferred to the contract in the call.
#### gas
#### gas_price
```
Call.gas_price : int
```
@@ -653,7 +653,15 @@ Call.gas_price : int
The gas price of the current call.
#### gas
#### fee
```
Call.fee : int
```
The fee of the current call.
#### gas_left
```
Call.gas_left() : int
```
@@ -816,7 +824,7 @@ payable contract Auction =
stateful entrypoint sell(amount) =
require(amount >= 0, "negative_amount")
...
main contract Market =
type state = list(Auction)
entrypoint init() = []
@@ -868,7 +876,7 @@ payable contract interface Auction =
entrypoint init : (int, string) => void
stateful payable entrypoint buy : (int) => ()
stateful entrypoint sell : (int) => ()
main contract Market =
type state = list(Auction)
entrypoint init() = []
@@ -1208,7 +1216,7 @@ List.unzip(l : list('a * 'b)) : list('a) * list('b)
Opposite to the `zip` operation. Takes a list of pairs and returns pair of lists with respective elements on same indices.
### merge
#### merge
```
List.merge(lesser_cmp : ('a, 'a) => bool, l1 : list('a), l2 : list('a)) : list('a)
```
@@ -1216,7 +1224,7 @@ List.merge(lesser_cmp : ('a, 'a) => bool, l1 : list('a), l2 : list('a)) : list('
Merges two sorted lists into a single sorted list. O(length(l1) + length(l2))
### sort
#### sort
```
List.sort(lesser_cmp : ('a, 'a) => bool, l : list('a)) : list('a)
```
@@ -1285,7 +1293,17 @@ Escapes `option` wrapping by providing default value for `None`.
Option.force(o : option('a)) : 'a
```
Forcefully escapes `option` wrapping assuming it is `Some`. Throws error on `None`.
Forcefully escapes the `option` wrapping assuming it is `Some`.
Aborts on `None`.
#### force_msg
```
Option.force_msg(o : option('a), err : string) : 'a
```
Forcefully escapes the `option` wrapping assuming it is `Some`.
Aborts with `err` error message on `None`.
#### contains
+2
View File
@@ -1,3 +1,5 @@
include "String.aes"
namespace Frac =
private function gcd(a : int, b : int) =
+1
View File
@@ -80,6 +80,7 @@ namespace List =
* `b` only if `(b - a) mod step == 0`. `step` should be bigger than 0.
*/
function from_to_step(a : int, b : int, s : int) : list(int) =
require(s > 0, "List.from_to_step: non-positive step")
from_to_step_(a, b - (b-a) mod s, s, [])
private function from_to_step_(a : int, b : int, s : int, acc : list(int)) : list(int) =
if(b < a) acc
+6
View File
@@ -26,6 +26,12 @@ namespace Option =
None => abort("Forced None value")
Some(x) => x
/** Assume it is `Some` with custom error message
*/
function force_msg(o : option('a), err : string) : 'a = switch(o)
None => abort(err)
Some(x) => x
function contains(e : 'a, o : option('a)) = o == Some(e)
function on_elem(o : option('a), f : 'a => unit) : unit = match((), f, o)
+1 -1
View File
@@ -15,7 +15,7 @@
{base_plt_apps, [erts, kernel, stdlib, crypto, mnesia]}
]}.
{relx, [{release, {aesophia, "6.0.0"},
{relx, [{release, {aesophia, "6.0.2"},
[aesophia, aebytecode, getopt]},
{dev_mode, true},
+3 -2
View File
@@ -330,10 +330,11 @@ to_fcode(Env, [{Contract, Attrs, Con = {con, _, Name}, Decls}|Rest])
case Contract =:= contract_interface of
false ->
#{ builtins := Builtins } = Env,
ConEnv = Env#{ context => {contract_def, Name},
ConEnv = maps:remove(state_layout,
Env#{ context => {contract_def, Name},
builtins => Builtins#{[Name, "state"] => {get_state, none},
[Name, "put"] => {set_state, 1},
[Name, "Chain", "event"] => {chain_event, 1}} },
[Name, "Chain", "event"] => {chain_event, 1}} }),
#{ functions := PrevFuns } = ConEnv,
#{ functions := Funs } = Env1 =
decls_to_fcode(ConEnv, Decls),
+2 -1
View File
@@ -244,8 +244,9 @@ check_call1(ContractString0, FunName, Args, Options) ->
fate ->
%% First check the contract without the __call function
#{ fcode := OrgFcode
, fcode_env := #{child_con_env := ChildContracts}
, ast := Ast } = string_to_code(ContractString0, Options),
FateCode = aeso_fcode_to_fate:compile(OrgFcode, []),
FateCode = aeso_fcode_to_fate:compile(ChildContracts, OrgFcode, []),
%% collect all hashes and compute the first name without hash collision to
SymbolHashes = maps:keys(aeb_fate_code:symbols(FateCode)),
CallName = first_none_match(?CALL_NAME, SymbolHashes,
+2 -2
View File
@@ -1,6 +1,6 @@
{application, aesophia,
[{description, "Contract Language for aeternity"},
{vsn, "6.0.0"},
[{description, "Compiler for Aeternity Sophia language"},
{vsn, "6.0.2"},
{registered, []},
{applications,
[kernel,
+18
View File
@@ -90,6 +90,23 @@ simple_compile_test_() ->
end} || Backend <- [aevm, fate] ] ++
[].
%% Check if all modules in the standard library compile
stdlib_test_() ->
{ok, Files} = file:list_dir(aeso_stdlib:stdlib_include_path()),
[ { "Testing " ++ File ++ " from the stdlib",
fun() ->
String = "include \"" ++ File ++ "\"\nmain contract Test =\n entrypoint f(x) = x",
Options = [{src_file, File}, {backend, fate}],
case aeso_compiler:from_string(String, Options) of
{ok, #{fate_code := Code}} ->
Code1 = aeb_fate_code:deserialize(aeb_fate_code:serialize(Code)),
?assertMatch({X, X}, {Code1, Code});
{error, Error} -> io:format("\n\n~p\n\n", [Error]), print_and_throw(Error)
end
end} || File <- Files,
lists:suffix(".aes", File)
].
check_errors(no_error, Actual) -> ?assertMatch(#{}, Actual);
check_errors(Expect, #{}) ->
?assertEqual({error, Expect}, ok);
@@ -182,6 +199,7 @@ compilable_contracts() ->
"clone",
"clone_simple",
"create",
"child_contract_init_bug",
"test" % Custom general-purpose test file. Keep it last on the list.
].
@@ -0,0 +1,8 @@
contract Identity =
record state = {foo: int, bar: string}
entrypoint init() = {foo = 0, bar = ""}
main contract IdentityService =
stateful entrypoint createNewIdentity() : Identity =
put(())
Chain.create()