Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0320ac959b | |||
| dcef89b486 | |||
| 4957d01e9e | |||
| 9d76e6186a | |||
| ae3edac53e | |||
| acec32e744 | |||
| 5784f074a6 | |||
| d07b321b25 | |||
| 2e6c01cb75 | |||
| b22eeffc3d | |||
| b366bed24b | |||
| 1975ccf804 | |||
| 4f68729631 | |||
| 10c845d3cf | |||
| 393d7710c1 | |||
| 37e5a92b2e | |||
| cb9c9df103 | |||
| c09313a92c | |||
| 75b2d6981f | |||
| 78d94786b6 | |||
| 216f7f8a25 | |||
| 254172e3a3 | |||
| eadb4e8c83 | |||
| 3996b6a711 |
@@ -21,3 +21,4 @@ rebar3.crashdump
|
||||
aesophia
|
||||
.qcci
|
||||
current_counterexample.eqc
|
||||
test/contracts/test.aes
|
||||
|
||||
+15
-1
@@ -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
@@ -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
@@ -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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
include "String.aes"
|
||||
|
||||
namespace Frac =
|
||||
|
||||
private function gcd(a : int, b : int) =
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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},
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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()
|
||||
Reference in New Issue
Block a user