Merge branch 'rinderknecht@contracts' into 'dev'
Refactoring of the test contracts See merge request ligolang/ligo!465
This commit is contained in:
commit
adc31a6e01
@ -7,7 +7,7 @@ let bad_contract basename =
|
|||||||
|
|
||||||
let%expect_test _ =
|
let%expect_test _ =
|
||||||
run_ligo_good [ "measure-contract" ; contract "coase.ligo" ; "main" ] ;
|
run_ligo_good [ "measure-contract" ; contract "coase.ligo" ; "main" ] ;
|
||||||
[%expect {| 1747 bytes |}] ;
|
[%expect {| 1870 bytes |}] ;
|
||||||
|
|
||||||
run_ligo_good [ "measure-contract" ; contract "multisig.ligo" ; "main" ] ;
|
run_ligo_good [ "measure-contract" ; contract "multisig.ligo" ; "main" ] ;
|
||||||
[%expect {| 1324 bytes |}] ;
|
[%expect {| 1324 bytes |}] ;
|
||||||
@ -16,7 +16,7 @@ let%expect_test _ =
|
|||||||
[%expect {| 3231 bytes |}] ;
|
[%expect {| 3231 bytes |}] ;
|
||||||
|
|
||||||
run_ligo_good [ "measure-contract" ; contract "vote.mligo" ; "main" ] ;
|
run_ligo_good [ "measure-contract" ; contract "vote.mligo" ; "main" ] ;
|
||||||
[%expect {| 642 bytes |}] ;
|
[%expect {| 589 bytes |}] ;
|
||||||
|
|
||||||
run_ligo_good [ "compile-parameter" ; contract "coase.ligo" ; "main" ; "Buy_single (record card_to_buy = 1n end)" ] ;
|
run_ligo_good [ "compile-parameter" ; contract "coase.ligo" ; "main" ; "Buy_single (record card_to_buy = 1n end)" ] ;
|
||||||
[%expect {| (Left (Left 1)) |}] ;
|
[%expect {| (Left (Left 1)) |}] ;
|
||||||
@ -86,7 +86,9 @@ let%expect_test _ =
|
|||||||
SWAP ;
|
SWAP ;
|
||||||
DIP { DUP ; CAR ; CAR } ;
|
DIP { DUP ; CAR ; CAR } ;
|
||||||
GET ;
|
GET ;
|
||||||
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
|
IF_NONE
|
||||||
|
{ PUSH string "buy_single: No card pattern." ; FAILWITH }
|
||||||
|
{ DUP ; DIP { DROP } } ;
|
||||||
DUP ;
|
DUP ;
|
||||||
CAR ;
|
CAR ;
|
||||||
DIP { DUP ; CDR ; PUSH nat 1 ; ADD } ;
|
DIP { DUP ; CDR ; PUSH nat 1 ; ADD } ;
|
||||||
@ -159,7 +161,9 @@ let%expect_test _ =
|
|||||||
SWAP ;
|
SWAP ;
|
||||||
DIP { DUP ; CAR ; CDR } ;
|
DIP { DUP ; CAR ; CDR } ;
|
||||||
GET ;
|
GET ;
|
||||||
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
|
IF_NONE
|
||||||
|
{ PUSH string "sell_single: No card." ; FAILWITH }
|
||||||
|
{ DUP ; DIP { DROP } } ;
|
||||||
DUP ;
|
DUP ;
|
||||||
CAR ;
|
CAR ;
|
||||||
SENDER ;
|
SENDER ;
|
||||||
@ -173,7 +177,9 @@ let%expect_test _ =
|
|||||||
CDR ;
|
CDR ;
|
||||||
DIP { DIP 2 { DUP } ; DIG 2 ; CAR ; CAR } ;
|
DIP { DIP 2 { DUP } ; DIG 2 ; CAR ; CAR } ;
|
||||||
GET ;
|
GET ;
|
||||||
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
|
IF_NONE
|
||||||
|
{ PUSH string "sell_single: No card pattern." ; FAILWITH }
|
||||||
|
{ DUP ; DIP { DROP } } ;
|
||||||
DUP ;
|
DUP ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
@ -209,7 +215,9 @@ let%expect_test _ =
|
|||||||
MUL ;
|
MUL ;
|
||||||
SENDER ;
|
SENDER ;
|
||||||
CONTRACT unit ;
|
CONTRACT unit ;
|
||||||
IF_NONE { PUSH string "bad address for get_contract" ; FAILWITH } {} ;
|
IF_NONE
|
||||||
|
{ PUSH string "sell_single: No contract." ; FAILWITH }
|
||||||
|
{ DUP ; DIP { DROP } } ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
@ -246,7 +254,9 @@ let%expect_test _ =
|
|||||||
CAR ;
|
CAR ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
GET ;
|
GET ;
|
||||||
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
|
IF_NONE
|
||||||
|
{ PUSH string "transfer_single: No card." ; FAILWITH }
|
||||||
|
{ DUP ; DIP { DROP } } ;
|
||||||
DUP ;
|
DUP ;
|
||||||
CAR ;
|
CAR ;
|
||||||
SENDER ;
|
SENDER ;
|
||||||
@ -938,40 +948,27 @@ let%expect_test _ =
|
|||||||
run_ligo_good [ "compile-contract" ; contract "vote.mligo" ; "main" ] ;
|
run_ligo_good [ "compile-contract" ; contract "vote.mligo" ; "main" ] ;
|
||||||
[%expect {|
|
[%expect {|
|
||||||
{ parameter
|
{ parameter
|
||||||
(or (pair %init
|
(or (pair %reset (pair (timestamp %finish_time) (timestamp %start_time)) (string %title))
|
||||||
(pair (timestamp %beginning_time) (timestamp %finish_time))
|
(or %vote (unit %nay) (unit %yea))) ;
|
||||||
(string %title))
|
|
||||||
(string %vote)) ;
|
|
||||||
storage
|
storage
|
||||||
(pair (pair (pair (timestamp %beginning_time) (map %candidates string int))
|
(pair (pair (pair (timestamp %finish_time) (nat %nay))
|
||||||
(pair (timestamp %finish_time) (string %title)))
|
(pair (timestamp %start_time) (string %title)))
|
||||||
(set %voters address)) ;
|
(pair (set %voters address) (nat %yea))) ;
|
||||||
code { DUP ;
|
code { DUP ;
|
||||||
|
DUP ;
|
||||||
CAR ;
|
CAR ;
|
||||||
IF_LEFT
|
IF_LEFT
|
||||||
{ DUP ;
|
{ DUP ;
|
||||||
DIP { DIP { DUP } ; SWAP ; CDR } ;
|
|
||||||
PAIR ;
|
|
||||||
DUP ;
|
DUP ;
|
||||||
CAR ;
|
CAR ;
|
||||||
CAR ;
|
CAR ;
|
||||||
CAR ;
|
PUSH nat 0 ;
|
||||||
DIP { PUSH int 0 ;
|
|
||||||
SOME ;
|
|
||||||
DIP { PUSH int 0 ;
|
|
||||||
SOME ;
|
|
||||||
EMPTY_MAP string int ;
|
|
||||||
SWAP ;
|
|
||||||
PUSH string "Yes" ;
|
|
||||||
UPDATE } ;
|
|
||||||
PUSH string "No" ;
|
|
||||||
UPDATE } ;
|
|
||||||
PAIR ;
|
|
||||||
DIP { DUP ; CAR ; CAR ; CDR ; DIP { DUP ; CAR ; CDR } ; PAIR } ;
|
|
||||||
PAIR ;
|
|
||||||
EMPTY_SET address ;
|
|
||||||
SWAP ;
|
SWAP ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
|
DIP { DUP ; CAR ; CDR ; DIP { DUP ; CDR } ; PAIR } ;
|
||||||
|
PAIR ;
|
||||||
|
DIP { PUSH nat 0 ; EMPTY_SET address ; PAIR } ;
|
||||||
|
PAIR ;
|
||||||
NIL operation ;
|
NIL operation ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DROP 2 } }
|
DIP { DROP 2 } }
|
||||||
@ -979,41 +976,56 @@ let%expect_test _ =
|
|||||||
DIP { DIP { DUP } ; SWAP ; CDR } ;
|
DIP { DIP { DUP } ; SWAP ; CDR } ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DUP ;
|
DUP ;
|
||||||
|
CDR ;
|
||||||
|
DIP { DUP } ;
|
||||||
|
SWAP ;
|
||||||
CAR ;
|
CAR ;
|
||||||
DIP { DUP ; CDR ; CAR ; CAR ; CDR } ;
|
IF_LEFT
|
||||||
GET ;
|
{ DIP { DUP } ;
|
||||||
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
|
SWAP ;
|
||||||
|
DIP 2 { DUP } ;
|
||||||
|
DIG 2 ;
|
||||||
|
CAR ;
|
||||||
|
CAR ;
|
||||||
|
CDR ;
|
||||||
|
PUSH nat 1 ;
|
||||||
|
ADD ;
|
||||||
|
DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CDR ; SWAP ; CAR ; CAR } ;
|
||||||
|
SWAP ;
|
||||||
|
PAIR ;
|
||||||
|
PAIR ;
|
||||||
|
PAIR ;
|
||||||
|
DIP { DROP } }
|
||||||
|
{ DIP { DUP } ;
|
||||||
|
SWAP ;
|
||||||
|
DIP 2 { DUP } ;
|
||||||
|
DIG 2 ;
|
||||||
|
CDR ;
|
||||||
|
CDR ;
|
||||||
|
PUSH nat 1 ;
|
||||||
|
ADD ;
|
||||||
|
DIP { DUP ; CAR ; SWAP ; CDR ; CAR } ;
|
||||||
|
SWAP ;
|
||||||
|
PAIR ;
|
||||||
|
SWAP ;
|
||||||
|
PAIR ;
|
||||||
|
DIP { DROP } } ;
|
||||||
|
DUP ;
|
||||||
DIP { DUP } ;
|
DIP { DUP } ;
|
||||||
SWAP ;
|
SWAP ;
|
||||||
CDR ;
|
CDR ;
|
||||||
CAR ;
|
CAR ;
|
||||||
CAR ;
|
PUSH bool True ;
|
||||||
CAR ;
|
SENDER ;
|
||||||
DIP { DIP { DUP } ;
|
UPDATE ;
|
||||||
SWAP ;
|
DIP { DUP ; CAR ; SWAP ; CDR ; CDR } ;
|
||||||
CAR ;
|
|
||||||
DIP { DUP ;
|
|
||||||
PUSH int 1 ;
|
|
||||||
ADD ;
|
|
||||||
SOME ;
|
|
||||||
DIP { DIP { DUP } ; SWAP ; CDR ; CAR ; CAR ; CDR } } ;
|
|
||||||
UPDATE } ;
|
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DIP { DUP } ;
|
SWAP ;
|
||||||
SWAP ;
|
|
||||||
CDR ;
|
|
||||||
CAR ;
|
|
||||||
CDR ;
|
|
||||||
CAR ;
|
|
||||||
DIP { DIP { DUP } ; SWAP ; CDR ; CAR ; CDR ; CDR } ;
|
|
||||||
PAIR } ;
|
|
||||||
PAIR ;
|
|
||||||
DIP { DIP { DUP } ; SWAP ; CDR ; CDR ; PUSH bool True ; SENDER ; UPDATE } ;
|
|
||||||
PAIR ;
|
PAIR ;
|
||||||
NIL operation ;
|
NIL operation ;
|
||||||
PAIR ;
|
PAIR ;
|
||||||
DIP { DROP 3 } } ;
|
DIP { DROP 4 } } ;
|
||||||
DIP { DROP } } } |}]
|
DIP { DROP 2 } } } |}]
|
||||||
|
|
||||||
let%expect_test _ =
|
let%expect_test _ =
|
||||||
run_ligo_good [ "compile-contract" ; contract "implicit.mligo" ; "main" ] ;
|
run_ligo_good [ "compile-contract" ; contract "implicit.mligo" ; "main" ] ;
|
||||||
@ -1054,7 +1066,7 @@ let%expect_test _ =
|
|||||||
let%expect_test _ =
|
let%expect_test _ =
|
||||||
run_ligo_bad [ "compile-contract" ; contract "bad_address_format.religo" ; "main" ] ;
|
run_ligo_bad [ "compile-contract" ; contract "bad_address_format.religo" ; "main" ] ;
|
||||||
[%expect {|
|
[%expect {|
|
||||||
ligo: in file "bad_address_format.religo", line 2, characters 25-47. Badly formatted literal: @"KT1badaddr" {"location":"in file \"bad_address_format.religo\", line 2, characters 25-47"}
|
ligo: in file "bad_address_format.religo", line 2, characters 26-48. Badly formatted literal: @"KT1badaddr" {"location":"in file \"bad_address_format.religo\", line 2, characters 26-48"}
|
||||||
|
|
||||||
|
|
||||||
If you're not sure how to fix this error, you can
|
If you're not sure how to fix this error, you can
|
||||||
@ -1149,29 +1161,29 @@ let%expect_test _ =
|
|||||||
let%expect_test _ =
|
let%expect_test _ =
|
||||||
run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_toplevel.mligo" ; "main" ] ;
|
run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_toplevel.mligo" ; "main" ] ;
|
||||||
[%expect {|
|
[%expect {|
|
||||||
ligo: in file "create_contract_toplevel.mligo", line 4, character 35 to line 8, character 8. No free variable allowed in this lambda: variable 'store' {"expression":"CREATE_CONTRACT(lambda (#P : ( nat * string ):Some(( nat * string ))) : None return let rhs#756 = #P in let p = rhs#756.0 in let s = rhs#756.1 in ( list[] : (TO_list(operation)) , store ) , NONE() : (TO_option(key_hash)) , 300000000mutez , \"un\")","location":"in file \"create_contract_toplevel.mligo\", line 4, character 35 to line 8, character 8"}
|
ligo: in file "create_contract_toplevel.mligo", line 4, character 35 to line 8, character 8. No free variable allowed in this lambda: variable 'store' {"expression":"CREATE_CONTRACT(lambda (#P : ( nat * string ):Some(( nat * string ))) : None return let rhs#808 = #P in let p = rhs#808.0 in let s = rhs#808.1 in ( list[] : (TO_list(operation)) , store ) , NONE() : (TO_option(key_hash)) , 300000000mutez , \"un\")","location":"in file \"create_contract_toplevel.mligo\", line 4, character 35 to line 8, character 8"}
|
||||||
|
|
||||||
|
|
||||||
If you're not sure how to fix this error, you can
|
If you're not sure how to fix this error, you can
|
||||||
do one of the following:
|
do one of the following:
|
||||||
|
|
||||||
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
|
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
|
||||||
* Ask a question on our Discord: https://discord.gg/9rhYaEt
|
* Ask a question on our Discord: https://discord.gg/9rhYaEt
|
||||||
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
|
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
|
||||||
* Check the changelog by running 'ligo changelog' |}] ;
|
* Check the changelog by running 'ligo changelog' |}] ;
|
||||||
|
|
||||||
run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_var.mligo" ; "main" ] ;
|
run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_var.mligo" ; "main" ] ;
|
||||||
[%expect {|
|
[%expect {|
|
||||||
ligo: in file "create_contract_var.mligo", line 6, character 35 to line 10, character 5. No free variable allowed in this lambda: variable 'a' {"expression":"CREATE_CONTRACT(lambda (#P : ( nat * int ):Some(( nat * int ))) : None return let rhs#759 = #P in let p = rhs#759.0 in let s = rhs#759.1 in ( list[] : (TO_list(operation)) , a ) , NONE() : (TO_option(key_hash)) , 300000000mutez , 1)","location":"in file \"create_contract_var.mligo\", line 6, character 35 to line 10, character 5"}
|
ligo: in file "create_contract_var.mligo", line 6, character 35 to line 10, character 5. No free variable allowed in this lambda: variable 'a' {"expression":"CREATE_CONTRACT(lambda (#P : ( nat * int ):Some(( nat * int ))) : None return let rhs#811 = #P in let p = rhs#811.0 in let s = rhs#811.1 in ( list[] : (TO_list(operation)) , a ) , NONE() : (TO_option(key_hash)) , 300000000mutez , 1)","location":"in file \"create_contract_var.mligo\", line 6, character 35 to line 10, character 5"}
|
||||||
|
|
||||||
|
|
||||||
If you're not sure how to fix this error, you can
|
If you're not sure how to fix this error, you can
|
||||||
do one of the following:
|
do one of the following:
|
||||||
|
|
||||||
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
|
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
|
||||||
* Ask a question on our Discord: https://discord.gg/9rhYaEt
|
* Ask a question on our Discord: https://discord.gg/9rhYaEt
|
||||||
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
|
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
|
||||||
* Check the changelog by running 'ligo changelog' |}] ;
|
* Check the changelog by running 'ligo changelog' |}] ;
|
||||||
|
|
||||||
run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_no_inline.mligo" ; "main" ] ;
|
run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_no_inline.mligo" ; "main" ] ;
|
||||||
[%expect {|
|
[%expect {|
|
||||||
|
@ -68,31 +68,30 @@ module Simplify = struct
|
|||||||
(* Tezos module (ex-Michelson) *)
|
(* Tezos module (ex-Michelson) *)
|
||||||
|
|
||||||
| "Tezos.chain_id" -> ok C_CHAIN_ID
|
| "Tezos.chain_id" -> ok C_CHAIN_ID
|
||||||
| "chain_id" -> ok C_CHAIN_ID (* Deprecated *)
|
| "chain_id" -> ok C_CHAIN_ID (* Deprecated *)
|
||||||
| "get_chain_id" -> ok C_CHAIN_ID (* Deprecated *)
|
| "get_chain_id" -> ok C_CHAIN_ID (* Deprecated *)
|
||||||
| "Tezos.balance" -> ok C_BALANCE
|
| "Tezos.balance" -> ok C_BALANCE
|
||||||
| "balance" -> ok C_BALANCE (* Deprecated *)
|
| "balance" -> ok C_BALANCE (* Deprecated *)
|
||||||
| "Tezos.now" -> ok C_NOW
|
| "Tezos.now" -> ok C_NOW
|
||||||
| "now" -> ok C_NOW (* Deprecated *)
|
| "now" -> ok C_NOW (* Deprecated *)
|
||||||
| "Tezos.amount" -> ok C_AMOUNT
|
| "Tezos.amount" -> ok C_AMOUNT
|
||||||
| "amount" -> ok C_AMOUNT (* Deprecated *)
|
| "amount" -> ok C_AMOUNT (* Deprecated *)
|
||||||
| "Tezos.sender" -> ok C_SENDER
|
| "Tezos.sender" -> ok C_SENDER
|
||||||
| "sender" -> ok C_SENDER (* Deprecated *)
|
| "sender" -> ok C_SENDER (* Deprecated *)
|
||||||
| "Tezos.address" -> ok C_ADDRESS
|
| "Tezos.address" -> ok C_ADDRESS
|
||||||
| "address" -> ok C_ADDRESS (* Deprecated *)
|
| "address" -> ok C_ADDRESS (* Deprecated *)
|
||||||
| "Tezos.self_address" -> ok C_SELF_ADDRESS
|
| "Tezos.self_address" -> ok C_SELF_ADDRESS
|
||||||
| "self_address" -> ok C_SELF_ADDRESS (* Deprecated *)
|
| "self_address" -> ok C_SELF_ADDRESS (* Deprecated *)
|
||||||
| "Tezos.implicit_account" -> ok C_IMPLICIT_ACCOUNT
|
| "Tezos.implicit_account" -> ok C_IMPLICIT_ACCOUNT
|
||||||
| "implicit_account" -> ok C_IMPLICIT_ACCOUNT (* Deprecated *)
|
| "implicit_account" -> ok C_IMPLICIT_ACCOUNT (* Deprecated *)
|
||||||
| "Tezos.source" -> ok C_SOURCE
|
| "Tezos.source" -> ok C_SOURCE
|
||||||
| "source" -> ok C_SOURCE (* Deprecated *)
|
| "source" -> ok C_SOURCE (* Deprecated *)
|
||||||
| "Tezos.failwith" -> ok C_FAILWITH
|
| "Tezos.failwith" -> ok C_FAILWITH
|
||||||
| "failwith" -> ok C_FAILWITH
|
| "failwith" -> ok C_FAILWITH
|
||||||
| "Tezos.create_contract" -> ok C_CREATE_CONTRACT
|
| "Tezos.create_contract" -> ok C_CREATE_CONTRACT
|
||||||
|
| "Tezos.transaction" -> ok C_CALL
|
||||||
| "Tezos.transaction" -> ok C_CALL
|
|
||||||
| "transaction" -> ok C_CALL (* Deprecated *)
|
| "transaction" -> ok C_CALL (* Deprecated *)
|
||||||
| "Tezos.set_delegate" -> ok C_SET_DELEGATE
|
| "Tezos.set_delegate" -> ok C_SET_DELEGATE
|
||||||
| "set_delegate" -> ok C_SET_DELEGATE (* Deprecated *)
|
| "set_delegate" -> ok C_SET_DELEGATE (* Deprecated *)
|
||||||
| "get_contract" -> ok C_CONTRACT (* Deprecated *)
|
| "get_contract" -> ok C_CONTRACT (* Deprecated *)
|
||||||
| "Tezos.get_contract_opt" -> ok C_CONTRACT_OPT
|
| "Tezos.get_contract_opt" -> ok C_CONTRACT_OPT
|
||||||
@ -145,7 +144,7 @@ module Simplify = struct
|
|||||||
| "Bytes.unpack" -> ok C_BYTES_UNPACK
|
| "Bytes.unpack" -> ok C_BYTES_UNPACK
|
||||||
| "bytes_unpack" -> ok C_BYTES_UNPACK (* Deprecated *)
|
| "bytes_unpack" -> ok C_BYTES_UNPACK (* Deprecated *)
|
||||||
| "Bytes.length" -> ok C_SIZE
|
| "Bytes.length" -> ok C_SIZE
|
||||||
| "Bytes.size" -> ok C_SIZE
|
| "Bytes.size" -> ok C_SIZE (* Deprecated *)
|
||||||
| "bytes_concat" -> ok C_CONCAT (* Deprecated *)
|
| "bytes_concat" -> ok C_CONCAT (* Deprecated *)
|
||||||
| "Bytes.concat" -> ok C_CONCAT
|
| "Bytes.concat" -> ok C_CONCAT
|
||||||
| "Bytes.slice" -> ok C_SLICE
|
| "Bytes.slice" -> ok C_SLICE
|
||||||
@ -166,7 +165,8 @@ module Simplify = struct
|
|||||||
|
|
||||||
(* Set module *)
|
(* Set module *)
|
||||||
|
|
||||||
| "Set.size" -> ok C_SIZE
|
| "Set.cardinal" -> ok C_SIZE
|
||||||
|
| "Set.size" -> ok C_SIZE (* Deprecated *)
|
||||||
| "set_size" -> ok C_SIZE (* Deprecated *)
|
| "set_size" -> ok C_SIZE (* Deprecated *)
|
||||||
| "set_empty" -> ok C_SET_EMPTY (* Deprecated *)
|
| "set_empty" -> ok C_SET_EMPTY (* Deprecated *)
|
||||||
| "Set.mem" -> ok C_SET_MEM
|
| "Set.mem" -> ok C_SET_MEM
|
||||||
@ -326,9 +326,9 @@ module Simplify = struct
|
|||||||
| "Bytes.pack" -> ok C_BYTES_PACK
|
| "Bytes.pack" -> ok C_BYTES_PACK
|
||||||
| "Bytes.unpack" -> ok C_BYTES_UNPACK
|
| "Bytes.unpack" -> ok C_BYTES_UNPACK
|
||||||
| "Bytes.length" -> ok C_SIZE
|
| "Bytes.length" -> ok C_SIZE
|
||||||
| "Bytes.size" -> ok C_SIZE
|
| "Bytes.size" -> ok C_SIZE (* Deprecated *)
|
||||||
| "Bytes.concat" -> ok C_CONCAT
|
| "Bytes.concat" -> ok C_CONCAT
|
||||||
| "Bytes.slice" -> ok C_SLICE
|
| "Bytes.slice" -> ok C_SLICE (* Deprecated *)
|
||||||
| "Bytes.sub" -> ok C_SLICE
|
| "Bytes.sub" -> ok C_SLICE
|
||||||
|
|
||||||
(* List module *)
|
(* List module *)
|
||||||
@ -341,14 +341,15 @@ module Simplify = struct
|
|||||||
|
|
||||||
(* Set module *)
|
(* Set module *)
|
||||||
|
|
||||||
| "Set.mem" -> ok C_SET_MEM
|
| "Set.mem" -> ok C_SET_MEM
|
||||||
| "Set.iter" -> ok C_SET_ITER
|
| "Set.iter" -> ok C_SET_ITER
|
||||||
| "Set.empty" -> ok C_SET_EMPTY
|
| "Set.empty" -> ok C_SET_EMPTY
|
||||||
| "Set.literal" -> ok C_SET_LITERAL
|
| "Set.literal" -> ok C_SET_LITERAL
|
||||||
| "Set.add" -> ok C_SET_ADD
|
| "Set.add" -> ok C_SET_ADD
|
||||||
| "Set.remove" -> ok C_SET_REMOVE
|
| "Set.remove" -> ok C_SET_REMOVE
|
||||||
| "Set.fold" -> ok C_SET_FOLD
|
| "Set.fold" -> ok C_SET_FOLD
|
||||||
| "Set.size" -> ok C_SIZE
|
| "Set.size" -> ok C_SIZE (* Deprecated *)
|
||||||
|
| "Set.cardinal" -> ok C_SIZE
|
||||||
|
|
||||||
(* Map module *)
|
(* Map module *)
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// function main (const c : contract (unit)) : address is address (c)
|
|
||||||
|
|
||||||
function main (const p : key_hash) : address is block {
|
function main (const p : key_hash) : address is block {
|
||||||
const c : contract (unit) = implicit_account (p);
|
const c : contract (unit) = Tezos.implicit_account (p);
|
||||||
} with address (c)
|
} with Tezos.address (c)
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
let main (p : key_hash) =
|
let main (p : key_hash) =
|
||||||
let c : unit contract = Current.implicit_account p in
|
let c : unit contract = Tezos.implicit_account p
|
||||||
Current.address c
|
in Tezos.address c
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
let main = (p : key_hash) : address => {
|
let main = (p : key_hash) : address => {
|
||||||
let c : contract(unit) = Current.implicit_account(p) ;
|
let c : contract (unit) = Tezos.implicit_account (p);
|
||||||
Current.address(c) ;
|
Tezos.address(c);
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
function check (const p: unit) : int is
|
function check (const p : unit) : int is
|
||||||
begin
|
block {
|
||||||
var result : int := 0;
|
var result : int := 0;
|
||||||
if amount = 100tz then
|
if amount = 100tez then result := 42 else result := 0
|
||||||
result := 42
|
} with result
|
||||||
else
|
|
||||||
result := 0
|
|
||||||
end with result
|
|
||||||
|
@ -1 +1 @@
|
|||||||
let check_ (p: unit) : int = if Current.amount = 100tz then 42 else 0
|
let check_ (p : unit) : int = if Tezos.amount = 100tez then 42 else 0
|
||||||
|
@ -1,7 +1,2 @@
|
|||||||
let check_ = (p: unit) : int =>
|
let check_ = (p : unit) : int =>
|
||||||
if (Current.amount == 100tz) {
|
if (Tezos.amount == 100tez) { 42; } else { 0; };
|
||||||
42;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0;
|
|
||||||
};
|
|
||||||
|
@ -1,15 +1,7 @@
|
|||||||
// Test PascaLIGO arithmetic operators
|
function mod_op (const n : int) : nat is n mod 42
|
||||||
|
function plus_op (const n : int) : int is n + 42
|
||||||
function mod_op (const n : int) : nat is n mod 42
|
|
||||||
|
|
||||||
function plus_op (const n : int) : int is n + 42
|
|
||||||
|
|
||||||
function minus_op (const n : int) : int is n - 42
|
function minus_op (const n : int) : int is n - 42
|
||||||
|
|
||||||
function times_op (const n : int) : int is n * 42
|
function times_op (const n : int) : int is n * 42
|
||||||
|
function div_op (const n : int) : int is n / 2
|
||||||
function div_op (const n : int) : int is n / 2
|
function int_op (const n : nat) : int is int (n)
|
||||||
|
function neg_op (const n : int) : int is -n
|
||||||
function int_op (const n : nat) : int is int (n)
|
|
||||||
|
|
||||||
function neg_op (const n : int) : int is -n
|
|
||||||
|
@ -1,30 +1,8 @@
|
|||||||
// Test CameLIGO arithmetic operators
|
let mod_op (n : int) : nat = n mod 42
|
||||||
|
let plus_op (n : int) : int = n + 42
|
||||||
let mod_op (n : int) : nat =
|
let minus_op (n : int) : int = n - 42
|
||||||
n mod 42
|
let times_op (n : int) : int = n * 42
|
||||||
|
let div_op (n : int) : int = n / 2
|
||||||
let plus_op (n : int) : int =
|
let neg_op (n : int) : int = -n
|
||||||
n + 42
|
let foo (n : int) : int = n + 10
|
||||||
|
let neg_op_2 (b : int) : int = -(foo b)
|
||||||
let minus_op (n : int) : int =
|
|
||||||
n - 42
|
|
||||||
|
|
||||||
let times_op (n : int) : int =
|
|
||||||
n * 42
|
|
||||||
|
|
||||||
let div_op (n : int) : int =
|
|
||||||
n / 2
|
|
||||||
|
|
||||||
(* TODO (?): Support conversion from nat to int and back
|
|
||||||
|
|
||||||
let int_op (n : nat) : int =
|
|
||||||
Int n
|
|
||||||
|
|
||||||
*)
|
|
||||||
|
|
||||||
let neg_op (n : int) : int =
|
|
||||||
-n
|
|
||||||
|
|
||||||
let foo (n : int) : int = n + 10
|
|
||||||
|
|
||||||
let neg_op_2 (b: int) : int = -(foo b)
|
|
||||||
|
@ -1,24 +1,10 @@
|
|||||||
/* Test ReasonLIGO arithmetic operators */
|
/* Test ReasonLIGO arithmetic operators */
|
||||||
|
|
||||||
let mod_op = (n: int): nat => n mod 42;
|
let mod_op = (n : int) : nat => n mod 42;
|
||||||
|
let plus_op = (n : int) : int => n + 42;
|
||||||
let plus_op = (n: int): int => n + 42;
|
let minus_op = (n : int) : int => n - 42;
|
||||||
|
let times_op = (n : int) : int => n * 42;
|
||||||
let minus_op = (n: int): int => n - 42;
|
let div_op = (n : int) : int => n / 2;
|
||||||
|
let neg_op = (n : int): int => - n;
|
||||||
let times_op = (n: int): int => n * 42;
|
let foo = (n : int): int => n + 10;
|
||||||
|
let neg_op_2 = (b : int): int => -foo(b);
|
||||||
let div_op = (n: int): int => n / 2;
|
|
||||||
|
|
||||||
/* TODO (?): Support conversion from nat to int and back
|
|
||||||
|
|
||||||
let int_op (n : nat) : int =
|
|
||||||
Int n
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
let neg_op = (n: int): int => - n;
|
|
||||||
|
|
||||||
let foo = (n: int): int => n + 10;
|
|
||||||
|
|
||||||
let neg_op_2 = (b: int): int => - foo(b);
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
let main (p, s: bool * unit) =
|
let main (p, s : bool * unit) =
|
||||||
let u : unit = assert p
|
let u : unit = assert p
|
||||||
in ([] : operation list), s
|
in ([] : operation list), s
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
let main = (p: bool, s: unit) => {
|
let main = (p, s : bool, unit) => {
|
||||||
let u: unit = assert(p);
|
let u : unit = assert (p);
|
||||||
([]: list(operation), s);
|
([]: list (operation), s);
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1 @@
|
|||||||
function main (const i : int) : int is
|
function main (const i : int) : int is block {i := i + 1} with i
|
||||||
block {
|
|
||||||
i := i + 1
|
|
||||||
} with i
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
let x = 1 [@@inline]
|
let x = 1 [@@inline]
|
||||||
|
let foo (a : int): int =
|
||||||
let foo (a: int): int =
|
|
||||||
(let test = 2 + a [@@inline] in test) [@@inline]
|
(let test = 2 + a [@@inline] in test) [@@inline]
|
||||||
|
|
||||||
let y = 1 [@@inline][@@other]
|
let y = 1 [@@inline][@@other]
|
||||||
|
let bar (b : int): int =
|
||||||
let bar (b: int): int =
|
let test = fun (z : int) -> 2 + b + z [@@inline][@@foo][@@bar]
|
||||||
let test = fun (z: int) -> 2 + b + z [@@inline][@@foo][@@bar]
|
|
||||||
in test b
|
in test b
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
let x = 1;
|
let x = 1;
|
||||||
|
|
||||||
[@inline]
|
[@inline]
|
||||||
let foo = (a: int): int => {
|
let foo = (a : int) : int => {
|
||||||
[@inline]
|
[@inline]
|
||||||
let test = 2 + a;
|
let test = 2 + a;
|
||||||
test;
|
test;
|
||||||
@ -11,8 +11,8 @@ let foo = (a: int): int => {
|
|||||||
[@inline][@other]
|
[@inline][@other]
|
||||||
let y = 1;
|
let y = 1;
|
||||||
|
|
||||||
let bar = (b: int): int => {
|
let bar = (b : int) : int => {
|
||||||
[@inline][@foo][@bar]
|
[@inline][@foo][@bar]
|
||||||
let test = (z: int) => 2 + b + z;
|
let test = (z : int) => 2 + b + z;
|
||||||
test(b);
|
test (b);
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
let main = (parameter: int, storage: address) => {
|
let main = (parameter : int, storage : address) =>
|
||||||
([]:list(operation), "KT1badaddr" : address);
|
([] : list (operation), "KT1badaddr" : address);
|
||||||
};
|
|
||||||
|
@ -6,4 +6,4 @@ function main (const p : parameter; const s : storage) : return is
|
|||||||
block {
|
block {
|
||||||
var stamp : timestamp := ("badtimestamp" : timestamp)
|
var stamp : timestamp := ("badtimestamp" : timestamp)
|
||||||
}
|
}
|
||||||
with ((nil: list(operation)), stamp)
|
with ((nil : list (operation)), stamp)
|
||||||
|
@ -9,4 +9,4 @@ type storage is tez
|
|||||||
type return is list (operation) * storage
|
type return is list (operation) * storage
|
||||||
|
|
||||||
function main (const param : parameter; const store: storage) : return is
|
function main (const param : parameter; const store: storage) : return is
|
||||||
((nil : list (operation)), balance)
|
((nil : list (operation)), Tezos.balance)
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
(**
|
(*
|
||||||
|
|
||||||
This test makes sure that the balance is accessible in CameLIGO.
|
This test makes sure that the balance is accessible in CameLIGO.
|
||||||
It's there to detect a regression of: https://gitlab.com/ligolang/ligo/issues/61
|
|
||||||
|
|
||||||
Which results in this error when you attempt to compile this contract:
|
It is there to detect a regression of:
|
||||||
|
https://gitlab.com/ligolang/ligo/issues/61
|
||||||
|
|
||||||
|
which results in this error when you attempt to compile this contract:
|
||||||
|
|
||||||
generated. unrecognized constant: {"constant":"BALANCE","location":"generated"}
|
generated. unrecognized constant: {"constant":"BALANCE","location":"generated"}
|
||||||
|
|
||||||
|
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
type parameter = unit
|
||||||
type storage = tez
|
type storage = tez
|
||||||
|
type return = operation list * storage
|
||||||
|
|
||||||
let main (p, s : unit * storage) =
|
let main (p, s : parameter * storage) : return =
|
||||||
([] : operation list), balance
|
([] : operation list), Tezos.balance
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ generated. unrecognized constant: {"constant":"BALANCE","location":"generated"}
|
|||||||
|
|
||||||
type storage = tez;
|
type storage = tez;
|
||||||
|
|
||||||
let main2 = (p: unit, s: storage) => ([]: list(operation), balance);
|
let main2 = (p : unit, storage) =>
|
||||||
|
([]: list (operation), Tezos.balance);
|
||||||
|
|
||||||
let main = (x: (unit, storage)) => main2(x[0],x[1]);
|
let main = (x : (unit, storage)) => main2 (x[0], x[1]);
|
||||||
|
@ -8,7 +8,7 @@ function main (const p : parameter; const s : storage) : return is
|
|||||||
toto := s.0[23];
|
toto := s.0[23];
|
||||||
s.0[2] := 444
|
s.0[2] := 444
|
||||||
}
|
}
|
||||||
with ((nil: list(operation)), s)
|
with ((nil : list (operation)), s)
|
||||||
|
|
||||||
type foo is big_map (int, int)
|
type foo is big_map (int, int)
|
||||||
|
|
||||||
@ -16,14 +16,12 @@ function set_ (var n : int; var m : foo) : foo is block {
|
|||||||
m[23] := n
|
m[23] := n
|
||||||
} with m
|
} with m
|
||||||
|
|
||||||
function add (var n : int ; var m : foo) : foo is set_(n,m)
|
function add (var n : int ; var m : foo) : foo is set_ (n,m)
|
||||||
|
|
||||||
function rm (var m : foo) : foo is block {
|
function rm (var m : foo) : foo is block {
|
||||||
remove 42 from map m
|
remove 42 from map m
|
||||||
} with m
|
} with m
|
||||||
|
|
||||||
function gf (const m : foo) : int is get_force (23, m)
|
|
||||||
|
|
||||||
function get (const m : foo) : option (int) is m[42]
|
function get (const m : foo) : option (int) is m[42]
|
||||||
|
|
||||||
const empty_big_map : big_map (int,int) = big_map []
|
const empty_big_map : big_map (int,int) = big_map []
|
||||||
|
@ -1,23 +1,18 @@
|
|||||||
type foo = (int, int) big_map
|
type foo = (int, int) big_map
|
||||||
|
|
||||||
let set_ (n, m: int * foo) : foo = Big_map.update 23 (Some n) m
|
let set_ (n, m: int * foo) : foo = Big_map.update 23 (Some n) m
|
||||||
|
let add (n, m : int * foo) : foo = Big_map.add 23 n m
|
||||||
let add (n,m : int * foo) : foo = Big_map.add 23 n m
|
|
||||||
|
|
||||||
let rm (m : foo) : foo = Big_map.remove 42 m
|
let rm (m : foo) : foo = Big_map.remove 42 m
|
||||||
|
|
||||||
let gf (m : foo) : int = Big_map.find 23 m
|
let gf (m : foo) : int = Big_map.find 23 m
|
||||||
|
|
||||||
let get (m: foo): int option = Big_map.find_opt 42 m
|
let get (m : foo): int option = Big_map.find_opt 42 m
|
||||||
|
|
||||||
let empty_map : foo = Big_map.empty
|
let empty_map : foo = Big_map.empty
|
||||||
|
|
||||||
let map1 : foo = Big_map.literal
|
let map1 : foo = Big_map.literal [(23,0); (42,0)]
|
||||||
[ (23 , 0) ; (42, 0) ]
|
let map1 : foo = Big_map.literal [(23,0); (42,0)]
|
||||||
|
|
||||||
let map1 : foo = Big_map.literal
|
|
||||||
[ (23 , 0) ; (42, 0) ]
|
|
||||||
|
|
||||||
let mutimaps (m : foo) (n : foo) : foo =
|
let mutimaps (m : foo) (n : foo) : foo =
|
||||||
let bar : foo = Big_map.update 42 (Some 0) m in
|
let bar : foo = Big_map.update 42 (Some 0) m
|
||||||
Big_map.update 42 (get bar) n
|
in Big_map.update 42 (get bar) n
|
||||||
|
@ -1,24 +1,22 @@
|
|||||||
type foo = big_map(int, int);
|
type foo = big_map(int, int);
|
||||||
|
|
||||||
let set2 = (n: int, m: foo): foo => Big_map.update(23, Some(n), m);
|
let set2 = (n : int, m : foo) : foo => Big_map.update (23, Some (n), m);
|
||||||
|
|
||||||
let set_ = (x: (int, foo)): foo => set2(x[0], x[1]);
|
let set_ = (x : (int, foo)) : foo => set2 (x[0], x[1]);
|
||||||
|
|
||||||
let add = ((n,m): (int, foo)): foo => Big_map.add(23, n, m);
|
let add = ((n,m) : (int, foo)) : foo => Big_map.add (23, n, m);
|
||||||
|
|
||||||
let rm = (m: foo): foo => Big_map.remove(42, m);
|
let rm = (m : foo) : foo => Big_map.remove (42, m);
|
||||||
|
|
||||||
let gf = (m: foo): int => Big_map.find(23, m);
|
let gf = (m : foo) : int => Big_map.find (23, m);
|
||||||
|
|
||||||
let get = (m: foo): option(int) => Big_map.find_opt(42, m);
|
let get = (m : foo) : option (int) => Big_map.find_opt (42, m);
|
||||||
|
|
||||||
let empty_map: foo = Big_map.empty;
|
let empty_map : foo = Big_map.empty;
|
||||||
|
|
||||||
let map1: foo = Big_map.literal([(23, 0), (42, 0)]);
|
let map1 : foo = Big_map.literal ([(23,0), (42,0)]);
|
||||||
|
|
||||||
let map1: foo = Big_map.literal([(23, 0), (42, 0)]);
|
|
||||||
|
|
||||||
let mutimaps = (m: foo, n: foo): foo => {
|
let mutimaps = (m: foo, n: foo): foo => {
|
||||||
let bar: foo = Big_map.update(42, Some(0), m);
|
let bar : foo = Big_map.update (42, Some (0), m);
|
||||||
Big_map.update(42, get(bar), n);
|
Big_map.update (42, get (bar), n);
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
(* Test CameLIGO bitwise operators *)
|
(* Test CameLIGO bitwise operators *)
|
||||||
|
|
||||||
let or_op (n: nat) : nat = Bitwise.or n 4n
|
let or_op (n : nat) : nat = Bitwise.or n 4n
|
||||||
let and_op (n: nat) : nat = Bitwise.and n 7n
|
let and_op (n : nat) : nat = Bitwise.and n 7n
|
||||||
let xor_op (n: nat) : nat = Bitwise.xor n 7n
|
let xor_op (n : nat) : nat = Bitwise.xor n 7n
|
||||||
let lsl_op (n: nat) : nat = Bitwise.shift_left n 7n
|
let lsl_op (n : nat) : nat = Bitwise.shift_left n 7n
|
||||||
let lsr_op (n: nat) : nat = Bitwise.shift_right n 7n
|
let lsr_op (n : nat) : nat = Bitwise.shift_right n 7n
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
// Test PascaLIGO boolean operators
|
function or_true (const b : bool) : bool is b or True
|
||||||
|
function or_false (const b : bool) : bool is b or False
|
||||||
function or_true (const b : bool) : bool is b or True
|
function and_true (const b : bool) : bool is b and True
|
||||||
|
|
||||||
function or_false (const b : bool) : bool is b or False
|
|
||||||
|
|
||||||
function and_true (const b : bool) : bool is b and True
|
|
||||||
|
|
||||||
function and_false (const b : bool) : bool is b and False
|
function and_false (const b : bool) : bool is b and False
|
||||||
|
function not_bool (const b : bool) : bool is not b
|
||||||
function not_bool (const b : bool) : bool is not b
|
|
||||||
|
@ -1,16 +1,7 @@
|
|||||||
// Test CameLIGO boolean operators
|
// Test CameLIGO boolean operators
|
||||||
|
|
||||||
let or_true (b : bool) : bool =
|
let or_true (b : bool) : bool = b || true
|
||||||
b || true
|
let or_false (b : bool) : bool = b || false
|
||||||
|
let and_true (b : bool) : bool = b && true
|
||||||
let or_false (b : bool) : bool =
|
let and_false (b : bool) : bool = b && false
|
||||||
b || false
|
let not_bool (b : bool) : bool = not b
|
||||||
|
|
||||||
let and_true (b : bool) : bool =
|
|
||||||
b && true
|
|
||||||
|
|
||||||
let and_false (b : bool) : bool =
|
|
||||||
b && false
|
|
||||||
|
|
||||||
let not_bool (b: bool) : bool =
|
|
||||||
not b
|
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
// Test ReasonLIGO boolean operators
|
// Test ReasonLIGO boolean operators
|
||||||
|
|
||||||
let or_true = (b: bool): bool => b || true;
|
let or_true = (b : bool) : bool => b || true;
|
||||||
|
let or_false = (b : bool) : bool => b || false;
|
||||||
let or_false = (b: bool): bool => b || false;
|
let and_true = (b : bool) : bool => b && true;
|
||||||
|
let and_false = (b : bool) : bool => b && false;
|
||||||
let and_true = (b: bool): bool => b && true;
|
let not_bool = (b : bool) : bool => !b;
|
||||||
|
|
||||||
let and_false = (b: bool): bool => b && false;
|
|
||||||
|
|
||||||
let not_bool = (b: bool): bool => !b;
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
function concat_op (const s : bytes) : bytes is bytes_concat (s, 0x7070)
|
function concat_op (const s : bytes) : bytes is Bytes.concat (s, 0x7070)
|
||||||
|
function slice_op (const s : bytes) : bytes is Bytes.sub (1n, 2n, s)
|
||||||
function slice_op (const s : bytes) : bytes is bytes_slice (1n, 2n, s)
|
function hasherman (const s : bytes) : bytes is Crypto.sha256 (s)
|
||||||
|
|
||||||
function hasherman (const s : bytes) : bytes is sha_256 (s)
|
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
let concat_op (s : bytes) : bytes =
|
let concat_op (s : bytes) : bytes = Bytes.concat s 0x7070
|
||||||
Bytes.concat s 0x7070
|
let slice_op (s : bytes) : bytes = Bytes.sub 1n 2n s
|
||||||
|
let hasherman (s : bytes) : bytes = Crypto.sha256 s
|
||||||
let slice_op (s : bytes) : bytes =
|
|
||||||
Bytes.slice 1n 2n s
|
|
||||||
|
|
||||||
let hasherman (s : bytes) : bytes =
|
|
||||||
Crypto.sha256 s
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
function id_string (const p : string) : option (string) is block {
|
function id_string (const p : string) : option (string) is block {
|
||||||
const packed : bytes = bytes_pack (p)
|
const packed : bytes = Bytes.pack (p)
|
||||||
} with (bytes_unpack (packed) : option (string))
|
} with (Bytes.unpack (packed) : option (string))
|
||||||
|
|
||||||
function id_int (const p : int) : option (int) is block {
|
function id_int (const p : int) : option (int) is block {
|
||||||
const packed : bytes = bytes_pack (p)
|
const packed : bytes = Bytes.pack (p)
|
||||||
} with (bytes_unpack (packed) : option (int))
|
} with (Bytes.unpack (packed) : option (int))
|
||||||
|
|
||||||
function id_address (const p : address) : option (address) is block {
|
function id_address (const p : address) : option (address) is block {
|
||||||
const packed : bytes = bytes_pack (p)
|
const packed : bytes = Bytes.pack (p)
|
||||||
} with (bytes_unpack (packed) : option (address))
|
} with (Bytes.unpack (packed) : option (address))
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
let id_string (p: string) : string option =
|
let id_string (p : string) : string option =
|
||||||
let packed: bytes = Bytes.pack p in
|
let packed : bytes = Bytes.pack p in
|
||||||
((Bytes.unpack packed): string option)
|
(Bytes.unpack packed : string option)
|
||||||
|
|
||||||
let id_int (p: int) : int option =
|
let id_int (p : int) : int option =
|
||||||
let packed: bytes = Bytes.pack p in
|
let packed : bytes = Bytes.pack p in
|
||||||
((Bytes.unpack packed): int option)
|
(Bytes.unpack packed : int option)
|
||||||
|
|
||||||
let id_address (p: address) : address option =
|
let id_address (p : address) : address option =
|
||||||
let packed: bytes = Bytes.pack p in
|
let packed : bytes = Bytes.pack p in
|
||||||
((Bytes.unpack packed): address option)
|
(Bytes.unpack packed : address option)
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
let id_string = (p: string) : option(string) => {
|
let id_string = (p : string) : option(string) => {
|
||||||
let packed : bytes = Bytes.pack(p);
|
let packed : bytes = Bytes.pack (p);
|
||||||
((Bytes.unpack(packed)): option(string));
|
((Bytes.unpack (packed)) : option (string));
|
||||||
};
|
};
|
||||||
|
|
||||||
let id_int = (p: int) : option(int) => {
|
let id_int = (p : int) : option (int) => {
|
||||||
let packed: bytes = Bytes.pack(p);
|
let packed : bytes = Bytes.pack (p);
|
||||||
((Bytes.unpack(packed)): option(int));
|
((Bytes.unpack (packed)) : option (int));
|
||||||
};
|
};
|
||||||
|
|
||||||
let id_address = (p: address) : option(address) => {
|
let id_address = (p : address) : option (address) => {
|
||||||
let packed: bytes = Bytes.pack(p);
|
let packed : bytes = Bytes.pack (p);
|
||||||
((Bytes.unpack(packed)): option(address));
|
((Bytes.unpack (packed)) : option (address));
|
||||||
};
|
};
|
||||||
|
@ -1 +1 @@
|
|||||||
function chain_id (const tt : chain_id) : chain_id is get_chain_id
|
function chain_id (const tt : chain_id) : chain_id is Tezos.chain_id
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
function check_signature (const pk : key;
|
function check_signature (const pk : key;
|
||||||
const signed : signature;
|
const signed : signature;
|
||||||
const msg: bytes) : bool
|
const msg : bytes) : bool
|
||||||
is crypto_check (pk, signed, msg)
|
is Crypto.check (pk, signed, msg)
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
let check_signature (pk, signed, msg: key * signature * bytes) : bool =
|
let check_signature (pk, signed, msg : key * signature * bytes) : bool =
|
||||||
Crypto.check pk signed msg
|
Crypto.check pk signed msg
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
let check_signature = (param: (key, signature, bytes)) : bool => {
|
let check_signature = (param : (key, signature, bytes)) : bool => {
|
||||||
let pk, signed, msg = param;
|
let pk, signed, msg = param;
|
||||||
Crypto.check(pk, signed, msg);
|
Crypto.check (pk, signed, msg);
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
(* Test whether closures retain values in CameLIGO *)
|
(* Test whether closures capture variables in CameLIGO *)
|
||||||
|
|
||||||
let test (k: int) : int =
|
let test (k : int) : int =
|
||||||
let j: int = k + 5 in
|
let j : int = k + 5 in
|
||||||
let close: (int -> int) =
|
let close : int -> int = fun (i : int) -> i + j in
|
||||||
fun (i: int) -> i + j
|
let j : int = 20 (* Shadow original variable *)
|
||||||
in
|
in close 20
|
||||||
let j: int = 20 in (* Shadow original variable to see if value close'd *)
|
|
||||||
close 20
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/* Test whether closures retain values in ReasonLIGO */
|
/* Test whether closures retain values in ReasonLIGO */
|
||||||
|
|
||||||
let test = (k: int): int => {
|
let test = (k : int) : int => {
|
||||||
let j: int = k + 5;
|
let j : int = k + 5;
|
||||||
let close: (int => int) = (i: int) => i + j;
|
let close : (int => int) = (i : int) => i + j;
|
||||||
|
|
||||||
let j: int = 20; /* Shadow original variable to see if value close'd */
|
let j : int = 20; /* Shadow original variable */
|
||||||
close(20);
|
close (20);
|
||||||
};
|
};
|
||||||
|
@ -45,27 +45,38 @@ type parameter is
|
|||||||
| Transfer_single of action_transfer_single
|
| Transfer_single of action_transfer_single
|
||||||
|
|
||||||
function transfer_single (const action : action_transfer_single;
|
function transfer_single (const action : action_transfer_single;
|
||||||
const s : storage) : return is block {
|
const s : storage) : return is
|
||||||
|
block {
|
||||||
const cards : cards = s.cards;
|
const cards : cards = s.cards;
|
||||||
const card : card = get_force (action.card_to_transfer, cards);
|
const card : card =
|
||||||
|
case cards[action.card_to_transfer] of
|
||||||
|
Some (card) -> card
|
||||||
|
| None -> (failwith ("transfer_single: No card.") : card)
|
||||||
|
end;
|
||||||
if card.card_owner =/= sender then
|
if card.card_owner =/= sender then
|
||||||
failwith ("This card doesn't belong to you")
|
failwith ("This card doesn't belong to you")
|
||||||
else skip;
|
else skip;
|
||||||
card.card_owner := action.destination;
|
card.card_owner := action.destination;
|
||||||
cards[action.card_to_transfer] := card;
|
cards[action.card_to_transfer] := card;
|
||||||
s.cards := cards;
|
s.cards := cards
|
||||||
const operations : list (operation) = nil
|
} with ((nil : list (operation)), s)
|
||||||
} with (operations, s)
|
|
||||||
|
|
||||||
function sell_single (const action : action_sell_single;
|
function sell_single (const action : action_sell_single;
|
||||||
const s : storage) : return is
|
const s : storage) : return is
|
||||||
block {
|
block {
|
||||||
const card : card = get_force (action.card_to_sell, s.cards);
|
const card : card =
|
||||||
|
case s.cards[action.card_to_sell] of
|
||||||
|
Some (card) -> card
|
||||||
|
| None -> (failwith ("sell_single: No card.") : card)
|
||||||
|
end;
|
||||||
if card.card_owner =/= sender
|
if card.card_owner =/= sender
|
||||||
then failwith ("This card doesn't belong to you")
|
then failwith ("This card doesn't belong to you")
|
||||||
else skip;
|
else skip;
|
||||||
const card_pattern : card_pattern =
|
const card_pattern : card_pattern =
|
||||||
get_force (card.card_pattern, s.card_patterns);
|
case s.card_patterns[card.card_pattern] of
|
||||||
|
Some (pattern) -> pattern
|
||||||
|
| None -> (failwith ("sell_single: No card pattern.") : card_pattern)
|
||||||
|
end;
|
||||||
card_pattern.quantity := abs (card_pattern.quantity - 1n);
|
card_pattern.quantity := abs (card_pattern.quantity - 1n);
|
||||||
const card_patterns : card_patterns = s.card_patterns;
|
const card_patterns : card_patterns = s.card_patterns;
|
||||||
card_patterns[card.card_pattern] := card_pattern;
|
card_patterns[card.card_pattern] := card_pattern;
|
||||||
@ -74,8 +85,12 @@ function sell_single (const action : action_sell_single;
|
|||||||
remove action.card_to_sell from map cards;
|
remove action.card_to_sell from map cards;
|
||||||
s.cards := cards;
|
s.cards := cards;
|
||||||
const price : tez = card_pattern.coefficient * card_pattern.quantity;
|
const price : tez = card_pattern.coefficient * card_pattern.quantity;
|
||||||
const receiver : contract (unit) = get_contract (sender);
|
const receiver : contract (unit) =
|
||||||
const op : operation = transaction (unit, price, receiver);
|
case (Tezos.get_contract_opt (Tezos.sender) : option (contract (unit))) of
|
||||||
|
Some (contract) -> contract
|
||||||
|
| None -> (failwith ("sell_single: No contract.") : contract (unit))
|
||||||
|
end;
|
||||||
|
const op : operation = Tezos.transaction (unit, price, receiver);
|
||||||
const operations : list (operation) = list [op]
|
const operations : list (operation) = list [op]
|
||||||
} with (operations, s)
|
} with (operations, s)
|
||||||
|
|
||||||
@ -84,12 +99,13 @@ function buy_single (const action : action_buy_single;
|
|||||||
block {
|
block {
|
||||||
// Check funds
|
// Check funds
|
||||||
const card_pattern : card_pattern =
|
const card_pattern : card_pattern =
|
||||||
get_force (action.card_to_buy, s.card_patterns);
|
case s.card_patterns[action.card_to_buy] of
|
||||||
|
Some (pattern) -> pattern
|
||||||
|
| None -> (failwith ("buy_single: No card pattern.") : card_pattern)
|
||||||
|
end;
|
||||||
const price : tez =
|
const price : tez =
|
||||||
card_pattern.coefficient * (card_pattern.quantity + 1n);
|
card_pattern.coefficient * (card_pattern.quantity + 1n);
|
||||||
if price > amount then failwith ("Not enough money") else skip;
|
if price > amount then failwith ("Not enough money") else skip;
|
||||||
// Administrative procedure
|
|
||||||
const operations : list(operation) = nil;
|
|
||||||
// Increase quantity
|
// Increase quantity
|
||||||
card_pattern.quantity := card_pattern.quantity + 1n;
|
card_pattern.quantity := card_pattern.quantity + 1n;
|
||||||
const card_patterns : card_patterns = s.card_patterns;
|
const card_patterns : card_patterns = s.card_patterns;
|
||||||
@ -103,7 +119,7 @@ function buy_single (const action : action_buy_single;
|
|||||||
];
|
];
|
||||||
s.cards := cards;
|
s.cards := cards;
|
||||||
s.next_id := s.next_id + 1n
|
s.next_id := s.next_id + 1n
|
||||||
} with (operations, s)
|
} with ((nil : list (operation)), s)
|
||||||
|
|
||||||
function main (const action : parameter; const s : storage) : return is
|
function main (const action : parameter; const s : storage) : return is
|
||||||
case action of
|
case action of
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
let main (i: int) =
|
type integer = int
|
||||||
if (i=2 : bool) then (42: int) else (0: int)
|
|
||||||
|
let main (i : int) =
|
||||||
|
if (i = 2 : bool) then (42 : int) else (0 : integer)
|
||||||
|
@ -1,6 +1,2 @@
|
|||||||
let main = (i: int) =>
|
let main = (i : int) =>
|
||||||
if (((i == 2): bool)) {
|
if (((i == 2) : bool)) { (42 : int); } else { (0 : int); };
|
||||||
(42: int);
|
|
||||||
} else {
|
|
||||||
(0: int);
|
|
||||||
};
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
(* TODO : make a test using mutation, not shadowing *)
|
let main (i : int) =
|
||||||
|
|
||||||
let main (i: int) =
|
|
||||||
let result = 0 in
|
let result = 0 in
|
||||||
if i = 2 then
|
if i = 2
|
||||||
let result = 42 in result
|
then let result = 42 in result
|
||||||
else
|
else let result = 0 in result
|
||||||
let result = 0 in result
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
// Test conditional in CameLIGO
|
// Test conditional in CameLIGO
|
||||||
|
|
||||||
let main (i: int) = if i = 2 then 42 else 0
|
let main (i : int) = if i = 2 then 42 else 0
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
/* Test conditional in ReasonLIGO */
|
/* Test conditional in ReasonLIGO */
|
||||||
|
|
||||||
let main = (i: int) =>
|
let main = (i : int) => if (i == 2) { 42; } else { 0; };
|
||||||
if (i == 2) {
|
|
||||||
42;
|
|
||||||
} else {
|
|
||||||
0;
|
|
||||||
};
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
type t is int
|
type t is int
|
||||||
|
|
||||||
function main (const p : int ; const s : t) : list (operation) * int is
|
function main (const p : int; const s : t) : list (operation) * int is
|
||||||
block {
|
block {
|
||||||
skip
|
skip
|
||||||
} // skip is a do nothing instruction, needed for empty blocks
|
} // skip is a do nothing instruction, needed for empty blocks
|
||||||
with ((nil : list(operation)), p + s)
|
with ((nil : list (operation)), p+s)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
type storage = int
|
type storage = int
|
||||||
|
|
||||||
let main (ps: int * storage) =
|
let main (p, s : int * storage) = ([] : operation list), p + s
|
||||||
(([] : operation list) , ps.0 + ps.1)
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
|
|
||||||
type storage = int;
|
type storage = int;
|
||||||
|
|
||||||
let main2 = (p: int, s: storage): string => ([]: list(operation), p + s);
|
let main = ((p, s) : (int, storage)) : (list (operation), storage) =>
|
||||||
|
([] : list (operation), p + s);
|
||||||
let main = (x: (int, storage)) : string => main2(x[0],x[1]);
|
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
function hasherman512 (const s: bytes) : bytes is sha_512 (s)
|
function hasherman512 (const s : bytes) : bytes is Crypto.sha512 (s)
|
||||||
|
function hasherman_blake (const s : bytes) : bytes is Crypto.blake2b (s)
|
||||||
function hasherman_blake (const s: bytes) : bytes is blake2b (s)
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
let hasherman512 (s: bytes) : bytes = Crypto.sha512 s
|
let hasherman512 (s : bytes) : bytes = Crypto.sha512 s
|
||||||
let hasherman_blake (s: bytes) : bytes = Crypto.blake2b s
|
let hasherman_blake (s : bytes) : bytes = Crypto.blake2b s
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
let hasherman512 = (s: bytes) => Crypto.sha512(s);
|
let hasherman512 = (s : bytes) => Crypto.sha512 (s);
|
||||||
let hasherman_blake = (s: bytes) => Crypto.blake2b(s);
|
let hasherman_blake = (s : bytes) => Crypto.blake2b (s);
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
let conv_test (j: int) (k: int) = j + k
|
let conv_test (j : int) (k : int) = j + k
|
||||||
|
let main (i : int) : int = conv_test i 10
|
||||||
let main (i: int) : int = conv_test i 10
|
let partial (a : int) (b : int) : int = a + b
|
||||||
|
let mk_partial (j : int) : int -> int = partial j
|
||||||
let partial (a: int) (b: int) : int = a + b
|
let partial_apply (i : int) : int = mk_partial 10 i
|
||||||
|
|
||||||
let mk_partial (j: int) : (int -> int) = partial j
|
|
||||||
|
|
||||||
let partial_apply (i: int) : int = (mk_partial 10) i
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// Test PascaLIGO top-level declarations
|
|
||||||
|
|
||||||
const foo : int = 42
|
const foo : int = 42
|
||||||
|
|
||||||
function main (const i : int) : int is i + foo
|
function main (const i : int) : int is i + foo
|
||||||
|
@ -21,9 +21,12 @@ function asymetric_tuple_access (const foo : unit) : int is
|
|||||||
} with tuple.0 + tuple.1.0 + tuple.1.1.0 + tuple.1.1.1
|
} with tuple.0 + tuple.1.0 + tuple.1.1.0 + tuple.1.1.1
|
||||||
|
|
||||||
type nested_record_t is
|
type nested_record_t is
|
||||||
record [nesty : record [mymap : map (int,string)]]
|
record [nesty : record [mymap : map (int, string)]]
|
||||||
|
|
||||||
function nested_record (var nee : nested_record_t) : string is
|
function nested_record (var nee : nested_record_t) : string is
|
||||||
block {
|
block {
|
||||||
nee.nesty.mymap[1] := "one"
|
nee.nesty.mymap[1] := "one"
|
||||||
} with get_force (1, nee.nesty.mymap)
|
} with case nee.nesty.mymap[1] of
|
||||||
|
Some (s) -> s
|
||||||
|
| None -> (failwith ("Should not happen.") : string)
|
||||||
|
end
|
||||||
|
@ -7,7 +7,6 @@ type storage is int
|
|||||||
type return is list (operation) * storage
|
type return is list (operation) * storage
|
||||||
|
|
||||||
function increment (const i : int; const n : int) : int is i+n
|
function increment (const i : int; const n : int) : int is i+n
|
||||||
|
|
||||||
function decrement (const i : int; const n : int) : int is i-n
|
function decrement (const i : int; const n : int) : int is i-n
|
||||||
|
|
||||||
const nop : list (operation) = nil
|
const nop : list (operation) = nil
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
type foo =
|
type foo =
|
||||||
| Bar of int
|
Bar of int
|
||||||
| Baz
|
| Baz
|
||||||
|
|
||||||
let main (f: foo): int =
|
let main (f : foo) : int =
|
||||||
match f with
|
match f with
|
||||||
| Bar i -> i
|
Bar i -> i
|
||||||
| Baz -> -1
|
| Baz -> -1
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
type foo =
|
type foo =
|
||||||
| Bar(int)
|
| Bar (int)
|
||||||
| Baz;
|
| Baz;
|
||||||
|
|
||||||
let main = (f: foo): int =>
|
let main = (f : foo) : int =>
|
||||||
switch (f) {
|
switch (f) {
|
||||||
| Bar(i) => i
|
| Bar (i) => i
|
||||||
| Baz => (-1)
|
| Baz => (-1)
|
||||||
};
|
};
|
||||||
|
@ -5,8 +5,7 @@ type return is list (operation) * storage
|
|||||||
function cb (const a : address; const s : storage) : return is
|
function cb (const a : address; const s : storage) : return is
|
||||||
block {
|
block {
|
||||||
const c : contract (unit) = get_entrypoint ("%cb", a)
|
const c : contract (unit) = get_entrypoint ("%cb", a)
|
||||||
}
|
} with (list [Tezos.transaction (unit, 0tez, c)], s)
|
||||||
with (list [transaction (unit, 0mutez, c)], s)
|
|
||||||
|
|
||||||
|
|
||||||
function cbo (const a : address; const s : storage) : return is
|
function cbo (const a : address; const s : storage) : return is
|
||||||
@ -14,6 +13,6 @@ function cbo (const a : address; const s : storage) : return is
|
|||||||
const c : contract (unit) =
|
const c : contract (unit) =
|
||||||
case (get_entrypoint_opt ("%cbo", a) : option (contract (unit))) of
|
case (get_entrypoint_opt ("%cbo", a) : option (contract (unit))) of
|
||||||
Some (c) -> c
|
Some (c) -> c
|
||||||
| None -> (failwith ("entrypoint not found") : contract (unit))
|
| None -> (failwith ("cbo: Entrypoint not found.") : contract (unit))
|
||||||
end
|
end
|
||||||
} with (list [transaction(unit, 0mutez, c)], s)
|
} with (list [Tezos.transaction (unit, 0tez, c)], s)
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
// Test conditional in CameLIGO
|
// Test conditional in CameLIGO
|
||||||
|
|
||||||
let main (a , b : bool * bool) = if a = b then 999 else 1
|
let main (a, b : bool * bool) = if a = b then 999 else 1
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
/* Test boolean comparison in ReasonLIGO */
|
/* Test boolean comparison in ReasonLIGO */
|
||||||
|
|
||||||
let main = ((a , b) : (bool , bool)) =>
|
let main = ((a, b) : (bool, bool)) =>
|
||||||
if (a == b) {
|
if (a == b) { 999; } else { 1; };
|
||||||
999;
|
|
||||||
} else {
|
|
||||||
1;
|
|
||||||
};
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
type storage = unit
|
type storage = unit
|
||||||
|
|
||||||
let main (p: unit) (s:storage) =
|
let main (p, store : unit * storage) : operation list * storage =
|
||||||
if true then failwith "This contract always fails" else ()
|
(failwith "This contract always fails" : operation list * storage)
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
type storage = unit;
|
type storage = unit;
|
||||||
|
|
||||||
let main = (p: unit, storage) =>
|
let main = (p: unit, storage) =>
|
||||||
if (true) {
|
if (true) { failwith("This contract always fails"); };
|
||||||
failwith("This contract always fails");
|
|
||||||
} else {
|
|
||||||
();
|
|
||||||
};
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
type storage = unit
|
type storage = unit
|
||||||
|
|
||||||
let main (p: unit) storage =
|
let main (p, store : unit * storage) : operation list * storage =
|
||||||
(fun (f: (int * int) -> int) (x: int) (y: int) -> f (y,x))
|
let n =
|
||||||
(fun (x: int) (y: int) -> x + y)
|
(fun (f : int * int -> int) (x : int) (y : int) -> f (y,x))
|
||||||
0
|
(fun (x : int) (y : int) -> x + y)
|
||||||
1
|
0
|
||||||
|
1
|
||||||
|
in ([] : operation list), store
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
type storage = unit
|
type storage = unit
|
||||||
|
|
||||||
let main (p: unit) storage =
|
let main (p : unit; store : storage) : operation list * storage =
|
||||||
(fun (f: int -> int) (_: int) (y: int) -> f y)
|
let n =
|
||||||
(fun (x: int) -> x)
|
(fun (f : int -> int) (z : int) (y : int) -> f y)
|
||||||
0
|
(fun (x : int) -> x)
|
||||||
1
|
0
|
||||||
|
1
|
||||||
|
in ([] : operation list), store
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
type storage = unit
|
type storage = unit
|
||||||
|
|
||||||
let main (p: unit) storage =
|
let main (p, s : unit * storage) : operation list * storage =
|
||||||
(fun (f: int -> int -> int) (x: int) (y: int) -> f y (x+y))
|
let n =
|
||||||
(fun (x: int) (y: int) -> x + y)
|
(fun (f : int -> int -> int) (x : int) (y : int) -> f y (x+y))
|
||||||
0
|
(fun (x : int) (y : int) -> x + y)
|
||||||
1
|
0
|
||||||
|
1
|
||||||
|
in ([] : operation list), store
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
type storage = unit
|
type storage = unit
|
||||||
|
|
||||||
let main (p: unit) storage =
|
let main (p, s : unit * storage) =
|
||||||
(fun (f: int -> int) (x: int) -> f x)
|
(fun (f : int -> int) (x : int) -> f x)
|
||||||
(fun (x: int) -> x)
|
(fun (x : int) -> x)
|
||||||
1
|
1
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
function main (const a: int) : int is
|
function main (const a : int) : int is
|
||||||
block { for i := 0 to 100 block { skip } } with i
|
block { for i := 0 to 100 block { skip } } with i
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
(* Test use of multiple subroutines in a CameLIGO function *)
|
(* Test use of multiple subroutines in a CameLIGO function *)
|
||||||
|
|
||||||
let foo (i: int) : int = i + 20
|
let foo (i : int) : int = i + 20
|
||||||
|
let bar (i : int) : int = i + 50
|
||||||
let bar (i: int) : int = i + 50
|
let foobar (i : int) : int = foo i + bar i
|
||||||
|
|
||||||
let foobar (i: int) : int = (foo i) + (bar i)
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
/* Test use of multiple subroutines in a ReasonLIGO function */
|
/* Test use of multiple subroutines in a ReasonLIGO function */
|
||||||
|
|
||||||
let foo = (i: int): int => i + 20;
|
let foo = (i : int) : int => i + 20;
|
||||||
|
let bar = (i : int) : int => i + 50;
|
||||||
let bar = (i: int): int => i + 50;
|
let foobar = (i : int) : int => foo (i) + bar (i);
|
||||||
|
|
||||||
let foobar = (i: int): int => foo(i) + bar(i);
|
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
type storage is unit
|
type storage is unit
|
||||||
type return is list (operation) * storage
|
type return is list (operation) * storage
|
||||||
|
|
||||||
function cb (const s : storage) : return is
|
function cb (const s : storage) : return is block {
|
||||||
block {
|
const c : contract (unit) = get_contract (Tezos.sender)
|
||||||
const c : contract(unit) = get_contract(sender)
|
} with (list [Tezos.transaction (unit, 0tez, c)], s)
|
||||||
}
|
|
||||||
with (list [transaction(unit, 0mutez, c)], s)
|
|
||||||
|
|
||||||
|
|
||||||
function cbo (const s : unit) : return is
|
function cbo (const s : unit) : return is
|
||||||
block {
|
block {
|
||||||
const c : contract (unit) =
|
const c : contract (unit) =
|
||||||
case (get_contract_opt(sender) : option(contract(unit))) of
|
case (Tezos.get_contract_opt (Tezos.sender) : option (contract (unit))) of
|
||||||
Some (c) -> c
|
Some (contract) -> contract
|
||||||
| None -> (failwith ("contract not found") : contract (unit))
|
| None -> (failwith ("contract not found") : contract (unit))
|
||||||
end
|
end
|
||||||
}
|
} with (list [Tezos.transaction (unit, 0tez, c)], s)
|
||||||
with (list [transaction(unit, 0mutez, c)], s)
|
|
||||||
|
@ -1,20 +1,22 @@
|
|||||||
type storage = {
|
type storage = {
|
||||||
challenge : string;
|
challenge : string
|
||||||
}
|
}
|
||||||
|
|
||||||
type param = {
|
type param = {
|
||||||
new_challenge : string;
|
new_challenge : string;
|
||||||
attempt : string;
|
attempt : string
|
||||||
}
|
}
|
||||||
|
|
||||||
let attempt (p: param) storage =
|
type return = operation list * storage
|
||||||
(* if p.attempt <> storage.challenge then failwith "Failed challenge" else *)
|
|
||||||
|
let attempt (p, store : param * storage) : return =
|
||||||
|
(* if p.attempt <> store.challenge then failwith "Failed challenge" else *)
|
||||||
let contract : unit contract =
|
let contract : unit contract =
|
||||||
Operation.get_contract sender in
|
match (Tezos.get_contract_opt Tezos.sender : unit contract option) with
|
||||||
|
Some contract -> contract
|
||||||
|
| None -> (failwith "No contract" : unit contract)
|
||||||
|
in
|
||||||
let transfer : operation =
|
let transfer : operation =
|
||||||
Operation.transaction (unit , contract , 10.00tz) in
|
Tezos.transaction (unit, contract, 10.00tez) in
|
||||||
(* TODO: no syntax for functional updates yet *)
|
let store : storage = {challenge = p.new_challenge}
|
||||||
(* let storage : storage = { storage with challenge = p.new_challenge } in *)
|
in ([] : operation list), store
|
||||||
(* for now, rebuild the record by hand. *)
|
|
||||||
let storage : storage = { challenge = p.new_challenge }
|
|
||||||
in ([] : operation list), storage
|
|
||||||
|
@ -1,56 +1,67 @@
|
|||||||
type commit = {
|
type commit = {
|
||||||
date: timestamp;
|
date : timestamp;
|
||||||
salted_hash: bytes;
|
salted_hash : bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
type commit_set = (address, commit) big_map
|
type commit_set = (address, commit) big_map
|
||||||
|
|
||||||
type storage = {
|
type storage = {
|
||||||
hashed: bytes;
|
hashed : bytes;
|
||||||
unused: bool;
|
unused : bool;
|
||||||
commits: commit_set;
|
commits : commit_set
|
||||||
}
|
}
|
||||||
|
|
||||||
type reveal = {
|
type reveal = {
|
||||||
hashable: bytes;
|
hashable : bytes;
|
||||||
message: unit -> operation list;
|
message : unit -> operation list
|
||||||
}
|
}
|
||||||
|
|
||||||
type parameter =
|
type parameter =
|
||||||
| Commit of bytes
|
Commit of bytes
|
||||||
| Reveal of reveal
|
| Reveal of reveal
|
||||||
|
|
||||||
(* We use hash-commit so that a baker can't steal *)
|
type return = operation list * storage
|
||||||
let commit ((p,s): bytes * storage) : operation list * storage =
|
|
||||||
let commit: commit = {date = Current.time + 86400; salted_hash = p;} in
|
|
||||||
let updated_map: commit_set = Big_map.update sender (Some commit) s.commits in
|
|
||||||
let s = {hashed = s.hashed; unused = s.unused; commits = updated_map} in
|
|
||||||
(([]: operation list), s)
|
|
||||||
|
|
||||||
let reveal ((p,s): reveal * storage) : operation list * storage =
|
(* We use hash-commit so that a baker can not steal *)
|
||||||
|
|
||||||
|
let commit (p, s : bytes * storage) : return =
|
||||||
|
let commit : commit =
|
||||||
|
{date = Tezos.now + 86_400; salted_hash = p} in
|
||||||
|
let updated_map: commit_set =
|
||||||
|
Big_map.update Tezos.sender (Some commit) s.commits in
|
||||||
|
let s = {s with commits = updated_map}
|
||||||
|
in ([] : operation list), s
|
||||||
|
|
||||||
|
let reveal (p, s : reveal * storage) : return =
|
||||||
if not s.unused
|
if not s.unused
|
||||||
then (failwith "This contract has already been used.": operation list * storage)
|
|
||||||
else
|
|
||||||
let commit: commit =
|
|
||||||
match (Big_map.find_opt sender s.commits) with
|
|
||||||
| Some c -> c
|
|
||||||
| None -> (failwith "You haven't made a commitment to hash against yet.": commit)
|
|
||||||
in
|
|
||||||
if Current.time < commit.date
|
|
||||||
then (failwith "It hasn't been 24 hours since your commit yet.": operation list * storage)
|
|
||||||
else
|
|
||||||
let salted = Crypto.sha256 (Bytes.concat p.hashable (Bytes.pack sender)) in
|
|
||||||
if (salted <> commit.salted_hash)
|
|
||||||
then (failwith "This reveal doesn't match your commitment.": operation list * storage)
|
|
||||||
else
|
|
||||||
if (s.hashed = Crypto.sha256 p.hashable)
|
|
||||||
then
|
then
|
||||||
let s: storage = {hashed = s.hashed; unused = false; commits = s.commits} in
|
(failwith "This contract has already been used." : return)
|
||||||
((p.message ()), s)
|
else
|
||||||
else (failwith "Your commitment did not match the storage hash.":
|
let commit : commit =
|
||||||
operation list * storage)
|
match Big_map.find_opt sender s.commits with
|
||||||
|
| Some c -> c
|
||||||
|
| None ->
|
||||||
|
(failwith "You have not made a commitment to hash against yet."
|
||||||
|
: commit)
|
||||||
|
in
|
||||||
|
if Tezos.now < commit.date
|
||||||
|
then
|
||||||
|
(failwith "It has not been 24 hours since your commit yet.": return)
|
||||||
|
else
|
||||||
|
let salted =
|
||||||
|
Crypto.sha256 (Bytes.concat p.hashable (Bytes.pack sender)) in
|
||||||
|
if salted <> commit.salted_hash
|
||||||
|
then
|
||||||
|
(failwith "This reveal does not match your commitment.": return)
|
||||||
|
else
|
||||||
|
if s.hashed = Crypto.sha256 p.hashable
|
||||||
|
then
|
||||||
|
let s : storage = {s with unused = false}
|
||||||
|
in p.message (), s
|
||||||
|
else (failwith "Your commitment did not match the storage hash."
|
||||||
|
: return)
|
||||||
|
|
||||||
let main ((p,s): parameter * storage) : operation list * storage =
|
let main (p, s : parameter * storage) : return =
|
||||||
match p with
|
match p with
|
||||||
| Commit c -> commit (c, s)
|
| Commit c -> commit (c,s)
|
||||||
| Reveal r -> reveal (r, s)
|
| Reveal r -> reveal (r,s)
|
||||||
|
@ -10,8 +10,12 @@ function get_top (const h : heap) : heap_elt is get_force (1n, h)
|
|||||||
function pop_switch (const h : heap) : heap is
|
function pop_switch (const h : heap) : heap is
|
||||||
block {
|
block {
|
||||||
const result : heap_elt = get_top (h);
|
const result : heap_elt = get_top (h);
|
||||||
const s : nat = size (h);
|
const s : nat = Map.size (h);
|
||||||
const last : heap_elt = get_force (s, h);
|
const last : heap_elt =
|
||||||
|
case h[s] of
|
||||||
|
Some (e) -> e
|
||||||
|
| None -> (failwith ("No element.") : heap_elt)
|
||||||
|
end;
|
||||||
remove 1n from map h;
|
remove 1n from map h;
|
||||||
h[1n] := last
|
h[1n] := last
|
||||||
} with h
|
} with h
|
||||||
@ -19,8 +23,12 @@ function pop_switch (const h : heap) : heap is
|
|||||||
function pop_ (const h : heap) : nat is
|
function pop_ (const h : heap) : nat is
|
||||||
block {
|
block {
|
||||||
const result : heap_elt = get_top (h);
|
const result : heap_elt = get_top (h);
|
||||||
const s : nat = size (h);
|
const s : nat = Map.size (h);
|
||||||
var current : heap_elt := get_force (s, h);
|
var current : heap_elt :=
|
||||||
|
case h[s] of
|
||||||
|
Some (e) -> e
|
||||||
|
| None -> (failwith ("No element.") : heap_elt)
|
||||||
|
end;
|
||||||
const i : nat = 1n;
|
const i : nat = 1n;
|
||||||
const left : nat = 2n * i;
|
const left : nat = 2n * i;
|
||||||
const right : nat = left + 1n;
|
const right : nat = left + 1n;
|
||||||
|
@ -1,30 +1,24 @@
|
|||||||
(* Test a function which takes another function as an argument *)
|
(* Test a function which takes another function as an argument *)
|
||||||
|
|
||||||
let foobar (i : int) : int =
|
let foobar (i : int) : int =
|
||||||
let foo: (int -> int) =
|
let foo: (int -> int) = fun (i : int) -> i in
|
||||||
fun (i : int) -> i
|
let bar: ((int -> int) -> int) = fun (f : int -> int) -> f i
|
||||||
in
|
in bar foo
|
||||||
let bar: ((int -> int) -> int) =
|
|
||||||
fun (f : int -> int) -> f i
|
|
||||||
in
|
|
||||||
bar foo
|
|
||||||
|
|
||||||
(* higher order function with more than one argument *)
|
(* higher order function with more than one argument *)
|
||||||
let higher2 (i: int) (f: int -> int): int =
|
|
||||||
|
let higher2 (i : int) (f : int -> int): int =
|
||||||
let ii: int = f i in ii
|
let ii: int = f i in ii
|
||||||
|
|
||||||
let foobar2 (i : int) : int =
|
let foobar2 (i : int) : int =
|
||||||
let foo2: (int -> int) =
|
let foo2 : (int -> int) = fun (i : int) -> i
|
||||||
fun (i : int) -> i
|
in higher2 i foo2
|
||||||
in
|
|
||||||
higher2 i foo2
|
|
||||||
|
|
||||||
let a : int = 0
|
let a : int = 0
|
||||||
|
|
||||||
let foobar3 (i : int) : int =
|
let foobar3 (i : int) : int =
|
||||||
let foo2: (int -> int) =
|
let foo2 : (int -> int) = fun (i : int) -> a + i
|
||||||
fun (i : int) -> a + i
|
in higher2 i foo2
|
||||||
in
|
|
||||||
higher2 i foo2
|
|
||||||
|
|
||||||
let f (i : int) : int = i
|
let f (i : int) : int = i
|
||||||
|
|
||||||
@ -32,15 +26,11 @@ let g (i : int) : int = f i
|
|||||||
|
|
||||||
let foobar4 (i : int) : int = g (g i)
|
let foobar4 (i : int) : int = g (g i)
|
||||||
|
|
||||||
let higher3 (i: int) (f: int -> int) (g: int -> int) : int =
|
let higher3 (i : int) (f : int -> int) (g : int -> int) : int =
|
||||||
let ii: int = f (g i) in ii
|
let ii : int = f (g i) in ii
|
||||||
|
|
||||||
let foobar5 (i : int) : int =
|
let foobar5 (i : int) : int =
|
||||||
let a : int = 0 in
|
let a : int = 0 in
|
||||||
let foo: (int -> int) =
|
let foo : (int -> int) = fun (i : int) -> a + i in
|
||||||
fun (i : int) -> a + i
|
let goo : (int -> int) = fun (i : int) -> foo i
|
||||||
in
|
in higher3 i foo goo
|
||||||
let goo: (int -> int) =
|
|
||||||
fun (i : int) -> foo i
|
|
||||||
in
|
|
||||||
higher3 i foo goo
|
|
||||||
|
@ -1,48 +1,44 @@
|
|||||||
/* Test a function which takes another function as an argument */
|
/* Test a function which takes another function as an argument */
|
||||||
let foobar = (i: int): int => {
|
|
||||||
|
let foobar = (i : int): int => {
|
||||||
let foo: int => int = (i: int) => i;
|
let foo: int => int = (i: int) => i;
|
||||||
|
let bar: ((int => int) => int) = (f : (int => int)) => f (i);
|
||||||
let bar: ((int => int) => int) = (f: (int => int)) => f(i);
|
bar (foo);
|
||||||
|
|
||||||
bar(foo);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* higher order function with more than one argument */
|
/* higher order function with more than one argument */
|
||||||
let higher2 = (i: int, f: (int => int)): int => {
|
|
||||||
let ii: int = f(i);
|
let higher2 = (i : int, f : (int => int)) : int => {
|
||||||
|
let ii : int = f (i);
|
||||||
ii;
|
ii;
|
||||||
};
|
};
|
||||||
|
|
||||||
let foobar2 = (i: int): int => {
|
let foobar2 = (i : int) : int => {
|
||||||
let foo2: int => int = (i: int) => i;
|
let foo2 : int => int = (i : int) => i;
|
||||||
|
higher2 (i, foo2);
|
||||||
higher2(i, foo2);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let a: int = 0;
|
let a : int = 0;
|
||||||
|
|
||||||
let foobar3 = (i: int): int => {
|
let foobar3 = (i : int) : int => {
|
||||||
let foo2: int => int = (i: int) => a + i;
|
let foo2: int => int = (i : int) => a + i;
|
||||||
|
higher2 (i, foo2);
|
||||||
higher2(i, foo2);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let f = (i: int): int => i;
|
let f = (i : int) : int => i;
|
||||||
|
|
||||||
let g = (i: int): int => f(i);
|
let g = (i : int) : int => f (i);
|
||||||
|
|
||||||
let foobar4 = (i: int): int => g(g(i));
|
let foobar4 = (i : int) : int => g (g (i));
|
||||||
|
|
||||||
let higher3 = (i: int, f: (int => int), g: (int => int)): int => {
|
let higher3 = (i : int, f : (int => int), g : (int => int)) : int => {
|
||||||
let ii: int = f(g(i));
|
let ii : int = f (g (i));
|
||||||
ii;
|
ii;
|
||||||
};
|
};
|
||||||
|
|
||||||
let foobar5 = (i: int): int => {
|
let foobar5 = (i : int) : int => {
|
||||||
let a: int = 0;
|
let a : int = 0;
|
||||||
let foo: int => int = (i: int) => a + i;
|
let foo : int => int = (i : int) => a + i;
|
||||||
|
let goo : int => int = (i : int) => foo (i);
|
||||||
let goo: int => int = (i: int) => foo(i);
|
higher3 (i, foo, goo);
|
||||||
|
|
||||||
higher3(i, foo, goo);
|
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@ type id = int
|
|||||||
type id_details = {
|
type id_details = {
|
||||||
owner: address;
|
owner: address;
|
||||||
controller: address;
|
controller: address;
|
||||||
profile: bytes;
|
profile: bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
type buy = bytes * address option
|
type buy = bytes * address option
|
||||||
@ -14,126 +14,118 @@ type action =
|
|||||||
| Buy of buy
|
| Buy of buy
|
||||||
| Update_owner of update_owner
|
| Update_owner of update_owner
|
||||||
| Update_details of update_details
|
| Update_details of update_details
|
||||||
| Skip of unit
|
| Skip
|
||||||
|
|
||||||
|
(* The prices kept in storage can be changed by bakers, though they
|
||||||
|
should only be adjusted down over time, not up. *)
|
||||||
|
|
||||||
(* The prices kept in storage can be changed by bakers, though they should only be
|
|
||||||
adjusted down over time, not up. *)
|
|
||||||
type storage = (id, id_details) big_map * int * (tez * tez)
|
type storage = (id, id_details) big_map * int * (tez * tez)
|
||||||
|
|
||||||
(** Preliminary thoughts on ids:
|
type return = operation list * storage
|
||||||
|
|
||||||
I very much like the simplicity of http://gurno.com/adam/mne/.
|
(* Preliminary thoughts on ids:
|
||||||
5 three letter words means you have a 15 character identity, not actually more
|
|
||||||
annoying than an IP address and a lot more memorable than the raw digits. This
|
|
||||||
can be stored as a single integer which is then translated into the corresponding
|
|
||||||
series of 5 words.
|
|
||||||
|
|
||||||
I in general like the idea of having a 'skip' mechanism, but it does need to cost
|
I very much like the simplicity of http://gurno.com/adam/mne/. 5 three
|
||||||
something so people don't eat up the address space. 256 ^ 5 means you have a lot
|
letter words means you have a 15 character identity, not actually more
|
||||||
of address space, but if people troll by skipping a lot that could be eaten up.
|
annoying than an IP address and a lot more memorable than the raw
|
||||||
Should probably do some napkin calculations for how expensive skipping needs to
|
digits. This can be stored as a single integer which is then
|
||||||
be to deter people from doing it just to chew up address space.
|
translated into the corresponding series of 5 words.
|
||||||
*)
|
|
||||||
|
I in general like the idea of having a 'skip' mechanism, but it does
|
||||||
|
need to cost something so people don't eat up the address space. 256^5
|
||||||
|
means you have a lot of address space, but if people troll by skipping
|
||||||
|
a lot that could be eaten up. Should probably do some napkin
|
||||||
|
calculations for how expensive skipping needs to be to deter people
|
||||||
|
from doing it just to chew up address space. *)
|
||||||
|
|
||||||
let buy (parameter, storage: (bytes * address option) * storage) =
|
let buy (parameter, storage: (bytes * address option) * storage) =
|
||||||
let void: unit =
|
let void : unit =
|
||||||
if amount = storage.2.0
|
if Tezos.amount <> storage.2.0
|
||||||
then ()
|
then (failwith "Incorrect amount paid.": unit) in
|
||||||
else (failwith "Incorrect amount paid.": unit)
|
|
||||||
in
|
|
||||||
let profile, initial_controller = parameter in
|
let profile, initial_controller = parameter in
|
||||||
let identities, new_id, prices = storage in
|
let identities, new_id, prices = storage in
|
||||||
let controller: address =
|
let controller : address =
|
||||||
match initial_controller with
|
match initial_controller with
|
||||||
| Some addr -> addr
|
| Some addr -> addr
|
||||||
| None -> sender
|
| None -> sender in
|
||||||
in
|
|
||||||
let new_id_details: id_details = {
|
let new_id_details: id_details = {
|
||||||
owner = sender ;
|
owner = sender;
|
||||||
controller = controller ;
|
controller = controller;
|
||||||
profile = profile ;
|
profile = profile} in
|
||||||
}
|
let updated_identities : (id, id_details) big_map =
|
||||||
in
|
|
||||||
let updated_identities: (id, id_details) big_map =
|
|
||||||
Big_map.update new_id (Some new_id_details) identities
|
Big_map.update new_id (Some new_id_details) identities
|
||||||
in
|
in ([]: operation list), (updated_identities, new_id + 1, prices)
|
||||||
([]: operation list), (updated_identities, new_id + 1, prices)
|
|
||||||
|
|
||||||
let update_owner (parameter, storage: (id * address) * storage) =
|
let update_owner (parameter, storage : (id * address) * storage) =
|
||||||
if (amount <> 0mutez)
|
if amount <> 0tez
|
||||||
then (failwith "Updating owner doesn't cost anything.": (operation list) * storage)
|
then (failwith "Updating owner doesn't cost anything.": return)
|
||||||
else
|
else
|
||||||
let id, new_owner = parameter in
|
let id, new_owner = parameter in
|
||||||
let identities, last_id, prices = storage in
|
let identities, last_id, prices = storage in
|
||||||
let current_id_details: id_details =
|
let current_id_details : id_details =
|
||||||
match Big_map.find_opt id identities with
|
match Big_map.find_opt id identities with
|
||||||
| Some id_details -> id_details
|
| Some id_details -> id_details
|
||||||
| None -> (failwith "This ID does not exist.": id_details)
|
| None -> (failwith "This ID does not exist." : id_details) in
|
||||||
in
|
let is_allowed : bool =
|
||||||
let is_allowed: bool =
|
if Tezos.sender = current_id_details.owner
|
||||||
if sender = current_id_details.owner
|
then true
|
||||||
then true
|
else (failwith "You are not the owner of this ID." : bool) in
|
||||||
else (failwith "You are not the owner of this ID.": bool)
|
let updated_id_details : id_details = {
|
||||||
in
|
|
||||||
let updated_id_details: id_details = {
|
|
||||||
owner = new_owner;
|
owner = new_owner;
|
||||||
controller = current_id_details.controller;
|
controller = current_id_details.controller;
|
||||||
profile = current_id_details.profile;
|
profile = current_id_details.profile} in
|
||||||
}
|
let updated_identities =
|
||||||
in
|
Big_map.update id (Some updated_id_details) identities
|
||||||
let updated_identities = Big_map.update id (Some updated_id_details) identities in
|
in ([]: operation list), (updated_identities, last_id, prices)
|
||||||
([]: operation list), (updated_identities, last_id, prices)
|
|
||||||
|
|
||||||
let update_details (parameter, storage: (id * bytes option * address option) * storage) =
|
let update_details (parameter, storage: (id * bytes option * address option) * storage) =
|
||||||
if (amount <> 0mutez)
|
if Tezos.amount <> 0tez
|
||||||
then (failwith "Updating details doesn't cost anything.": (operation list) * storage)
|
then
|
||||||
|
(failwith "Updating details doesn't cost anything." : return)
|
||||||
else
|
else
|
||||||
let id, new_profile, new_controller = parameter in
|
let id, new_profile, new_controller = parameter in
|
||||||
let identities, last_id, prices = storage in
|
let identities, last_id, prices = storage in
|
||||||
let current_id_details: id_details =
|
let current_id_details: id_details =
|
||||||
match Big_map.find_opt id identities with
|
match Big_map.find_opt id identities with
|
||||||
| Some id_details -> id_details
|
| Some id_details -> id_details
|
||||||
| None -> (failwith "This ID does not exist.": id_details)
|
| None -> (failwith "This ID does not exist.": id_details) in
|
||||||
in
|
let is_allowed : bool =
|
||||||
let is_allowed: bool =
|
if Tezos.sender = current_id_details.controller
|
||||||
if (sender = current_id_details.controller) || (sender = current_id_details.owner)
|
|| Tezos.sender = current_id_details.owner
|
||||||
then true
|
then true
|
||||||
else (failwith ("You are not the owner or controller of this ID."): bool)
|
else
|
||||||
in
|
(failwith ("You are not the owner or controller of this ID.")
|
||||||
let owner: address = current_id_details.owner in
|
: bool) in
|
||||||
let profile: bytes =
|
let owner : address = current_id_details.owner in
|
||||||
match new_profile with
|
let profile : bytes =
|
||||||
| None -> (* Default *) current_id_details.profile
|
match new_profile with
|
||||||
| Some new_profile -> new_profile
|
| None -> (* Default *) current_id_details.profile
|
||||||
in
|
| Some new_profile -> new_profile in
|
||||||
let controller: address =
|
let controller : address =
|
||||||
match new_controller with
|
match new_controller with
|
||||||
| None -> (* Default *) current_id_details.controller
|
| None -> (* Default *) current_id_details.controller
|
||||||
| Some new_controller -> new_controller
|
| Some new_controller -> new_controller in
|
||||||
in
|
let updated_id_details: id_details = {
|
||||||
let updated_id_details: id_details = {
|
owner = owner;
|
||||||
owner = owner;
|
controller = controller;
|
||||||
controller = controller;
|
profile = profile} in
|
||||||
profile = profile;
|
|
||||||
}
|
|
||||||
in
|
|
||||||
let updated_identities: (id, id_details) big_map =
|
let updated_identities: (id, id_details) big_map =
|
||||||
Big_map.update id (Some updated_id_details) identities in
|
Big_map.update id (Some updated_id_details) identities
|
||||||
([]: operation list), (updated_identities, last_id, prices)
|
in ([]: operation list), (updated_identities, last_id, prices)
|
||||||
|
|
||||||
(* Let someone skip the next identity so nobody has to take one that's undesirable *)
|
(* Let someone skip the next identity so nobody has to take one that's
|
||||||
let skip (p,storage: unit * storage) =
|
undesirable *)
|
||||||
let void: unit =
|
|
||||||
if amount = storage.2.1
|
let skip (p, storage: unit * storage) =
|
||||||
then ()
|
let void : unit =
|
||||||
else (failwith "Incorrect amount paid.": unit)
|
if Tezos.amount <> storage.2.1
|
||||||
in
|
then (failwith "Incorrect amount paid." : unit) in
|
||||||
let identities, last_id, prices = storage in
|
let identities, last_id, prices = storage in
|
||||||
([]: operation list), (identities, last_id + 1, prices)
|
([]: operation list), (identities, last_id + 1, prices)
|
||||||
|
|
||||||
let main (action, storage: action * storage) : operation list * storage =
|
let main (action, storage : action * storage) : return =
|
||||||
match action with
|
match action with
|
||||||
| Buy b -> buy (b, storage)
|
| Buy b -> buy (b, storage)
|
||||||
| Update_owner uo -> update_owner (uo, storage)
|
| Update_owner uo -> update_owner (uo, storage)
|
||||||
| Update_details ud -> update_details (ud, storage)
|
| Update_details ud -> update_details (ud, storage)
|
||||||
| Skip s -> skip ((), storage)
|
| Skip -> skip ((), storage)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
let main2 (p : key_hash) (s : unit) =
|
let main2 (p : key_hash) (s : unit) =
|
||||||
let c : unit contract = Current.implicit_account p in
|
let c : unit contract = Tezos.implicit_account p
|
||||||
(([] : operation list), unit)
|
in ([] : operation list), unit
|
||||||
|
|
||||||
let main (t: key_hash * unit) = main2 t.0 t.1
|
let main (p,s : key_hash * unit) = main2 p s
|
||||||
|
@ -1 +1,2 @@
|
|||||||
function main (const kh: key_hash) : contract (unit) is implicit_account (kh)
|
function main (const kh: key_hash) : contract (unit) is
|
||||||
|
Tezos.implicit_account (kh)
|
||||||
|
@ -1 +1 @@
|
|||||||
let main (kh: key_hash) : unit contract = Current.implicit_account kh
|
let main (kh : key_hash) : unit contract = Tezos.implicit_account kh
|
||||||
|
@ -1 +1,2 @@
|
|||||||
let main = (kh: key_hash): contract(unit) => Current.implicit_account(kh);
|
let main = (kh : key_hash) : contract (unit) =>
|
||||||
|
Tezos.implicit_account (kh);
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
type storage = int
|
type storage = int
|
||||||
|
|
||||||
(* variant defining pseudo multi-entrypoint actions *)
|
type parameter =
|
||||||
|
|
||||||
type action =
|
|
||||||
Increment of int
|
Increment of int
|
||||||
| Decrement of int
|
| Decrement of int
|
||||||
|
|
||||||
let add (a: int) (b: int) : int = a + b
|
type return = operation list * storage
|
||||||
let sub (a: int) (b: int) : int = a - b
|
|
||||||
|
|
||||||
(* real entrypoint that re-routes the flow based on the action provided *)
|
let add (a : int) (b : int) : int = a + b
|
||||||
|
let sub (a : int) (b : int) : int = a - b
|
||||||
|
|
||||||
let main (p: action) storage =
|
let main (action, store : parameter * storage) : return =
|
||||||
let storage =
|
let store =
|
||||||
match p with
|
match action with
|
||||||
Increment n -> add s n
|
Increment n -> add s n
|
||||||
| Decrement n -> sub s n
|
| Decrement n -> sub s n
|
||||||
in ([] : operation list), storage
|
in ([] : operation list), store
|
||||||
|
@ -1,87 +1,87 @@
|
|||||||
let lambda_call =
|
let lambda_call =
|
||||||
let a = 3 in
|
let a = 3 in
|
||||||
let foo = fun (i : int) -> i * i in
|
let foo = fun (i : int) -> i * i
|
||||||
foo (a + 1)
|
in foo (a + 1)
|
||||||
|
|
||||||
let higher_order1 =
|
let higher_order1 =
|
||||||
let a = 2 in
|
let a = 2 in
|
||||||
let foo = fun (i:int) (j:int) (k:int) ->
|
let foo = fun (i : int) (j : int) (k : int) -> a + i + j + 0 in
|
||||||
a + i + j + 0 in
|
let bar = (foo 1 2)
|
||||||
let bar = (foo 1 2) in
|
in bar 3
|
||||||
bar 3
|
|
||||||
|
|
||||||
let higher_order2 =
|
let higher_order2 =
|
||||||
let a = 2 in
|
let a = 2 in
|
||||||
let foo = fun (i:int) ->
|
let foo = fun (i : int) ->
|
||||||
let b = 2 in
|
let b = 2 in
|
||||||
let bar = fun (i:int) -> i + a + b
|
let bar = fun (i : int) -> i + a + b
|
||||||
in bar i
|
in bar i
|
||||||
in foo 1
|
in foo 1
|
||||||
|
|
||||||
let higher_order3 =
|
let higher_order3 =
|
||||||
let foo = fun (i:int) -> i + 1 in
|
let foo = fun (i : int) -> i + 1 in
|
||||||
let bar = fun (f:int->int) (i:int) -> (f i) + 1 in
|
let bar = fun (f : int -> int) (i : int) -> f i + 1 in
|
||||||
let baz : (int -> int ) = bar foo in
|
let baz : int -> int = bar foo
|
||||||
baz 3
|
in baz 3
|
||||||
|
|
||||||
let higher_order4 =
|
let higher_order4 =
|
||||||
let a = 3 in
|
let a = 3 in
|
||||||
let foo = fun (i : int) -> a + i in
|
let foo = fun (i : int) -> a + i in
|
||||||
let bar: (int -> int) = fun (i : int) -> foo i in
|
let bar : int -> int = fun (i : int) -> foo i
|
||||||
bar 2
|
in bar 2
|
||||||
|
|
||||||
let concats =
|
let concats = 0x70 ^ 0x70
|
||||||
0x70 ^ 0x70
|
|
||||||
|
|
||||||
type foo_record = {
|
type foo_record = {
|
||||||
a : string ;
|
a : string;
|
||||||
b : string ;
|
b : string
|
||||||
}
|
}
|
||||||
|
|
||||||
let record_concat =
|
let record_concat =
|
||||||
let ab : foo_record = { a = "a" ; b = "b" } in
|
let ab : foo_record = {a="a"; b="b"}
|
||||||
ab.a ^ ab.b
|
in ab.a ^ ab.b
|
||||||
|
|
||||||
let record_patch =
|
let record_patch =
|
||||||
let ab : foo_record = { a = "a" ; b = "b" } in
|
let ab : foo_record = {a="a"; b="b"}
|
||||||
{ab with b = "c"}
|
in {ab with b = "c"}
|
||||||
|
|
||||||
type bar_record = {
|
type bar_record = {
|
||||||
f : int -> int ;
|
f : int -> int;
|
||||||
arg : int ;
|
arg : int
|
||||||
}
|
}
|
||||||
|
|
||||||
let record_lambda =
|
let record_lambda =
|
||||||
let a = 1 in
|
let a = 1 in
|
||||||
let foo : (int -> int) = fun (i:int) -> a+(i*2) in
|
let foo : int -> int = fun (i : int) -> a + i*2 in
|
||||||
let farg : bar_record = { f = foo ; arg = 2 } in
|
let farg : bar_record = {f = foo; arg = 2}
|
||||||
farg.f farg.arg
|
in farg.f farg.arg
|
||||||
|
|
||||||
type foo_variant =
|
type foo_variant =
|
||||||
| Foo
|
| Foo
|
||||||
| Bar of int
|
| Bar of int
|
||||||
| Baz of string
|
| Baz of string
|
||||||
|
|
||||||
let variant_exp =
|
let variant_exp = Foo, Bar 1, Baz "b"
|
||||||
(Foo, Bar 1, Baz "b")
|
|
||||||
|
|
||||||
let variant_match =
|
let variant_match =
|
||||||
let a = Bar 1 in
|
let a = Bar 1 in
|
||||||
match a with
|
match a with
|
||||||
| Foo -> 1
|
| Foo -> 1
|
||||||
| Bar(i) -> 2
|
| Bar i -> 2
|
||||||
| Baz(s) -> 3
|
| Baz s -> 3
|
||||||
|
|
||||||
/* UNSUPPORTED
|
(* UNSUPPORTED: No deep patterns yet.
|
||||||
type bar_variant =
|
type bar_variant =
|
||||||
| Baz
|
| Baz
|
||||||
| Buz of int * int
|
| Buz of int * int
|
||||||
| Biz of int * int * string
|
| Biz of int * int * string
|
||||||
|
|
||||||
let long_variant_match =
|
let long_variant_match =
|
||||||
let a = Biz (1,2,"Biz") in
|
let a = Biz (1,2,"Biz") in
|
||||||
match a with
|
match a with
|
||||||
| Baz -> "Baz"
|
| Baz -> "Baz"
|
||||||
| Buz(a,b) -> "Buz"
|
| Buz (a,b) -> "Buz"
|
||||||
| Biz(a,b,c) -> c
|
| Biz (a,b,c) -> c
|
||||||
*/
|
*)
|
||||||
|
|
||||||
let bool_match =
|
let bool_match =
|
||||||
let b = true in
|
let b = true in
|
||||||
@ -90,149 +90,145 @@ let bool_match =
|
|||||||
| false -> 2
|
| false -> 2
|
||||||
|
|
||||||
let list_match =
|
let list_match =
|
||||||
let a = [ 1 ; 2 ; 3 ; 4 ] in
|
let a = [1; 2; 3; 4] in
|
||||||
match a with
|
match a with
|
||||||
| hd :: tl -> hd::a
|
| hd::tl -> hd::a
|
||||||
| [] -> a
|
| [] -> a
|
||||||
|
|
||||||
let tuple_proj =
|
let tuple_proj =
|
||||||
let (a,b) = (true,false) in
|
let a, b = true, false
|
||||||
a or b
|
in a or b
|
||||||
|
|
||||||
let list_const =
|
let list_const =
|
||||||
let a = [1 ; 2 ; 3 ; 4] in
|
let a = [1; 2; 3; 4]
|
||||||
0 :: a
|
in 0::a
|
||||||
|
|
||||||
type foobar = int option
|
type foobar = int option
|
||||||
|
|
||||||
let options_match_some =
|
let options_match_some =
|
||||||
let a = Some 0 in
|
let a = Some 0 in
|
||||||
match a with
|
match a with
|
||||||
| Some(i) -> i
|
| Some i -> i
|
||||||
| None -> 1
|
| None -> 1
|
||||||
|
|
||||||
let options_match_none =
|
let options_match_none =
|
||||||
let a : foobar = None in
|
let a : foobar = None in
|
||||||
match a with
|
match a with
|
||||||
| Some(i) -> i
|
| Some i -> i
|
||||||
| None -> 0
|
| None -> 0
|
||||||
|
|
||||||
let is_nat_nat =
|
let is_nat_nat =
|
||||||
let i : int = 1 in
|
let i : int = 1 in
|
||||||
let j : int = -1 in
|
let j : int = -1
|
||||||
(Michelson.is_nat i, Michelson.is_nat j)
|
in is_nat i, is_nat j
|
||||||
|
|
||||||
let abs_int = abs (-5)
|
let abs_int = abs (-5)
|
||||||
|
|
||||||
let nat_int = int (5n)
|
let nat_int = int 5n
|
||||||
|
|
||||||
let map_list =
|
let map_list =
|
||||||
let a = [1 ; 2 ; 3 ; 4] in
|
let a = [1; 2; 3; 4] in
|
||||||
let add_one: (int -> int) = fun (i : int) -> i + 1 in
|
let add_one : (int -> int) = fun (i : int) -> i + 1
|
||||||
List.map add_one a
|
in List.map add_one a
|
||||||
|
|
||||||
let fail_alone = failwith "you failed"
|
let fail_alone = failwith "you failed"
|
||||||
|
|
||||||
let iter_list_fail =
|
let iter_list_fail =
|
||||||
let a = [1 ; 2 ; 3 ; 4] in
|
let a = [1; 2; 3; 4] in
|
||||||
let check_something: (int -> unit) = fun (i : int) ->
|
let check_something : int -> unit =
|
||||||
if i = 2 then failwith "you failed"
|
fun (i : int) ->
|
||||||
else ()
|
if i = 2 then failwith "you failed"
|
||||||
in
|
in List.iter check_something a
|
||||||
List.iter check_something a
|
|
||||||
|
|
||||||
let fold_list =
|
let fold_list =
|
||||||
let a = [1 ; 2 ; 3 ; 4] in
|
let a = [1; 2; 3; 4] in
|
||||||
let acc : (int * int -> int) =
|
let acc : int * int -> int =
|
||||||
fun (prev, el : int * int) -> prev + el in
|
fun (prev, el : int * int) -> prev + el
|
||||||
List.fold acc a 0
|
in List.fold acc a 0
|
||||||
|
|
||||||
let comparison_int =
|
let comparison_int = 1 > 2, 2 > 1, 1 >=2, 2 >= 1
|
||||||
(1 > 2, 2 > 1, 1 >=2 , 2 >= 1)
|
|
||||||
|
|
||||||
let comparison_string =
|
let comparison_string = "foo"="bar", "baz"="baz"
|
||||||
("foo" = "bar", "baz" = "baz")
|
|
||||||
|
|
||||||
let divs : (int * nat * tez * nat) =
|
let divs : int * nat * tez * nat = 1/2, 1n/2n, 1tez/2n, 1tez/2tez
|
||||||
(1/2 , 1n/2n , 1tz/2n , 1tz/2tz)
|
|
||||||
|
|
||||||
let var_neg =
|
let var_neg =
|
||||||
let a = 2 in
|
let a = 2 in -a
|
||||||
-a
|
|
||||||
|
|
||||||
let sizes =
|
let sizes =
|
||||||
let a = [ 1 ; 2 ; 3 ; 4 ; 5 ] in
|
let a = [1; 2; 3; 4; 5] in
|
||||||
let b = "12345" in
|
let b = "12345" in
|
||||||
let c = Set.literal [ 1 ; 2 ; 3 ; 4 ; 5 ] in
|
let c = Set.literal [1; 2; 3; 4; 5] in
|
||||||
let d = Map.literal [ (1,1) ; (2,2) ; (3,3) ] in
|
let d = Map.literal [(1,1); (2,2); (3,3)] in
|
||||||
let e = 0xFFFF in
|
let e = 0xFFFF in
|
||||||
(List.size a, String.size b, Set.size c, Map.size d, Bytes.size e)
|
List.length a,
|
||||||
|
String.length b,
|
||||||
|
Set.cardinal c,
|
||||||
|
Map.size d,
|
||||||
|
Bytes.length e
|
||||||
|
|
||||||
let modi = 3 mod 2
|
let modi = 3 mod 2
|
||||||
|
|
||||||
let fold_while =
|
let fold_while =
|
||||||
let aux : int -> bool * int = fun (i:int) ->
|
let aux : int -> bool * int =
|
||||||
if i < 10 then continue (i + 1) else stop i in
|
fun (i : int) ->
|
||||||
(Loop.fold_while aux 20, Loop.fold_while aux 0)
|
if i < 10 then Loop.resume (i + 1) else Loop.stop i
|
||||||
|
in (Loop.fold_while aux 20, Loop.fold_while aux 0)
|
||||||
|
|
||||||
let assertion_pass =
|
let assertion_pass = assert (1=1)
|
||||||
assert (1=1)
|
|
||||||
|
|
||||||
let assertion_fail =
|
let assertion_fail = assert (1=2)
|
||||||
assert (1=2)
|
|
||||||
|
|
||||||
let lit_address = ("KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" : address)
|
let lit_address = ("KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" : address)
|
||||||
|
|
||||||
let map_finds =
|
let map_finds =
|
||||||
let m = Map.literal [ ("one" , 1) ; ("two" , 2) ; ("three" , 3) ] in
|
let m = Map.literal [("one", 1); ("two", 2); ("three", 3)]
|
||||||
Map.find_opt "two" m
|
in Map.find_opt "two" m
|
||||||
|
|
||||||
let map_finds_fail =
|
let map_finds_fail =
|
||||||
let m = Map.literal [ ("one" , 1) ; ("two" , 2) ; ("three" , 3) ] in
|
let m = Map.literal [("one", 1); ("two", 2); ("three", 3)]
|
||||||
Map.find "four" m
|
in Map.find "four" m
|
||||||
|
|
||||||
let map_empty =
|
let map_empty =
|
||||||
((Map.empty : (int,int) map) , (Map.literal [] : (int,int) map))
|
((Map.empty : (int, int) map), (Map.literal [] : (int, int) map))
|
||||||
|
|
||||||
let m = Map.literal [ ("one" , 1) ; ("two" , 2) ; ("three" , 3) ]
|
let m = Map.literal [("one", 1); ("two", 2); ("three", 3)]
|
||||||
|
|
||||||
let map_fold =
|
let map_fold =
|
||||||
let aux = fun (i: int * (string * int)) -> i.0 + i.1.1 in
|
let aux = fun (i : int * (string * int)) -> i.0 + i.1.1
|
||||||
Map.fold aux m (-2)
|
in Map.fold aux m (-2)
|
||||||
|
|
||||||
let map_iter =
|
let map_iter =
|
||||||
let aux = fun (i: string * int) -> if (i.1=12) then failwith "never" else () in
|
let aux =
|
||||||
Map.iter aux m
|
fun (i : string * int) -> if i.1 = 12 then failwith "never"
|
||||||
|
in Map.iter aux m
|
||||||
|
|
||||||
let map_map =
|
let map_map =
|
||||||
let aux = fun (i: string * int) -> i.1 + (String.size i.0) in
|
let aux = fun (i : string * int) -> i.1 + String.length i.0
|
||||||
Map.map aux m
|
in Map.map aux m
|
||||||
|
|
||||||
let map_mem = (Map.mem "one" m , Map.mem "four" m)
|
let map_mem = Map.mem "one" m, Map.mem "four" m
|
||||||
|
|
||||||
let map_remove = (Map.remove "one" m, Map.remove "four" m)
|
let map_remove = Map.remove "one" m, Map.remove "four" m
|
||||||
|
|
||||||
let map_update = (
|
let map_update =
|
||||||
Map.update "one" (Some(1)) (Map.literal [ "one", 2 ]),
|
Map.update "one" (Some 1) (Map.literal ["one", 2]),
|
||||||
Map.update "one" (None : int option) (Map.literal [ "one", 1]),
|
Map.update "one" (None : int option) (Map.literal ["one", 1]),
|
||||||
Map.update "one" (None : int option) (Map.literal []:(string,int) map),
|
Map.update "one" (None : int option) (Map.empty : (string, int) map),
|
||||||
Map.update "one" (Some(1)) (Map.literal []:(string,int) map)
|
Map.update "one" (Some 1) (Map.literal [] : (string, int) map)
|
||||||
)
|
|
||||||
|
|
||||||
let s = Set.literal [ 1 ; 2 ; 3 ]
|
let s = Set.literal [1; 2; 3]
|
||||||
|
|
||||||
let set_add = (
|
let set_add =
|
||||||
Set.add 1 s,
|
Set.add 1 s,
|
||||||
Set.add 4 s,
|
Set.add 4 s,
|
||||||
Set.add 1 (Set.literal [] : int set)
|
Set.add 1 (Set.empty : int set)
|
||||||
)
|
|
||||||
|
|
||||||
let set_iter_fail =
|
let set_iter_fail =
|
||||||
let aux = fun (i:int) -> if i = 1 then failwith "set_iter_fail" else () in
|
let aux = fun (i : int) -> if i = 1 then failwith "set_iter_fail"
|
||||||
Set.iter aux (Set.literal [1 ; 2 ; 3])
|
in Set.iter aux (Set.literal [1; 2; 3])
|
||||||
|
|
||||||
let set_mem = (
|
let set_mem =
|
||||||
Set.mem 1 s,
|
Set.mem 1 s,
|
||||||
Set.mem 4 s,
|
Set.mem 4 s,
|
||||||
Set.mem 1 (Set.literal [] : int set)
|
Set.mem 1 (Set.empty : int set)
|
||||||
)
|
|
||||||
|
@ -1 +1 @@
|
|||||||
let main (i: int) : nat option = Michelson.is_nat i
|
let main (i : int) : nat option = is_nat i
|
||||||
|
@ -1 +1 @@
|
|||||||
let main = (i: int): option(nat) => Michelson.is_nat(i);
|
let main = (i : int): option (nat) => is_nat (i);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
function check_hash_key (const kh1 : key_hash;
|
function check_hash_key (const kh1 : key_hash;
|
||||||
const k2 : key) : bool * key_hash is
|
const k2 : key) : bool * key_hash is
|
||||||
block {
|
block {
|
||||||
var ret : bool := False;
|
var kh2 : key_hash := Crypto.hash_key (k2);
|
||||||
var kh2 : key_hash := crypto_hash_key (k2);
|
} with ((kh1 = kh2), kh2)
|
||||||
if kh1 = kh2 then ret := True else skip
|
|
||||||
} with (ret, kh2)
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
let check_hash_key (kh1, k2: key_hash * key) : bool * key_hash =
|
let check_hash_key (kh1, k2 : key_hash * key) : bool * key_hash =
|
||||||
let kh2 : key_hash = Crypto.hash_key k2 in
|
let kh2 : key_hash = Crypto.hash_key k2
|
||||||
if kh1 = kh2
|
in kh1 = kh2, kh2
|
||||||
then (true, kh2)
|
|
||||||
else (false, kh2)
|
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
let check_hash_key = (kh1_k2: (key_hash, key)) : (bool, key_hash) => {
|
let check_hash_key = (kh1_k2 : (key_hash, key)) : (bool, key_hash) => {
|
||||||
let kh1, k2 = kh1_k2;
|
let kh1, k2 = kh1_k2;
|
||||||
let kh2 : key_hash = Crypto.hash_key(k2);
|
let kh2 : key_hash = Crypto.hash_key (k2);
|
||||||
if (kh1 == kh2) {
|
((kh1 == kh2), kh2)
|
||||||
(true, kh2);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
(false, kh2);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
type storage is record
|
type storage is record [
|
||||||
one: map(key_hash, nat);
|
one : map (key_hash, nat);
|
||||||
two: big_map(key_hash, bool);
|
two : big_map (key_hash, bool)
|
||||||
end
|
]
|
||||||
|
|
||||||
type return is list (operation) * storage
|
type return is list (operation) * storage
|
||||||
|
|
||||||
function main (const a : int; const store : storage) : return is ((nil: list(operation)), store)
|
function main (const a : int; const store : storage) : return is
|
||||||
|
((nil : list (operation)), store)
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
type storage = unit
|
type storage = unit
|
||||||
|
|
||||||
(* not supported yet
|
(* not supported yet
|
||||||
let main (p:unit) storage =
|
let main (p, s : unit * storage) = (fun x -> ()) ()
|
||||||
(fun x -> ()) ()
|
|
||||||
*)
|
*)
|
||||||
|
|
||||||
let main (ps: unit * storage) = (fun (_: unit) -> ()) ()
|
let main (p, s : unit * storage) = (fun (_ : unit) -> ()) ()
|
||||||
|
@ -5,6 +5,5 @@ type storage = unit;
|
|||||||
(fun x -> ()) ()
|
(fun x -> ()) ()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let main2 = ((p: unit), s: storage) => (((xxx: unit)) => ())();
|
let main = ((p,s) : (unit, storage)) : unit =>
|
||||||
|
(((useless : unit)) => ()) ();
|
||||||
let main = (x: (unit, storage)) => main2(x[0], x[1]);
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
type storage = unit
|
type storage = unit
|
||||||
|
|
||||||
(* Not supported yet:
|
(* Not supported yet:
|
||||||
let main (p:unit) storage = (fun x -> ()) ()
|
let main (a, s : unit * storage) = (fun x -> ()) ()
|
||||||
*)
|
*)
|
||||||
|
|
||||||
let main (_: unit * storage) =
|
let main (a, s : unit * storage) =
|
||||||
(fun (f: unit -> unit) -> f ()) (fun (_: unit) -> unit)
|
(fun (f : unit -> unit) -> f ()) (fun (_ : unit) -> unit)
|
||||||
|
@ -4,7 +4,5 @@ type storage = unit;
|
|||||||
let main (p:unit) storage = (fun x -> ()) ()
|
let main (p:unit) storage = (fun x -> ()) ()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let main2 = (z: unit, s: storage) =>
|
let main = ((a, s) : (unit, storage)) : unit =>
|
||||||
((f: (unit => unit)) => f())((z: unit) => unit);
|
((f : (unit => unit)) => f ()) ((useless : unit) => unit);
|
||||||
|
|
||||||
let main = (x: (unit, storage)) => main2(x[0],x[1]);
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
let sum (p: int * int) : int =
|
let sum (p : int * int) : int =
|
||||||
let i, result = p in i + result
|
let i, result = p in i + result
|
||||||
|
|
||||||
let sum2 (p: string * string * string * string) : string =
|
let sum2 (p: string * string * string * string) : string =
|
||||||
|
@ -1,38 +1,36 @@
|
|||||||
(* Simple test of binding multiple values *)
|
(* Simple test of binding multiple values *)
|
||||||
|
|
||||||
let (x: int), (y: int) = 1,2
|
let (x : int), (y : int) = 1,2
|
||||||
|
|
||||||
let main (p: unit) : int = x + y
|
let main (p : unit) : int = x + y
|
||||||
|
|
||||||
let ((x : int) , (y :int)) = 3,3
|
let ((x : int) , (y : int)) = 3,3
|
||||||
|
|
||||||
let main_paren (p: unit) : int = x + y
|
let main_paren (p : unit) : int = x + y
|
||||||
|
|
||||||
let foobar : (int * int) = (23 , 42)
|
let foobar : (int * int) = (23 , 42)
|
||||||
let (foo : int) , (bar : int) = foobar
|
let (foo : int) , (bar : int) = foobar
|
||||||
|
|
||||||
(* Here to prevent a regression of https://gitlab.com/ligolang/ligo/issues/63#note_254106580 *)
|
(* Here to prevent a regression of https://gitlab.com/ligolang/ligo/issues/63#note_254106580 *)
|
||||||
|
|
||||||
let correct_values_bound (p: unit) : int * int =
|
let correct_values_bound (p : unit) : int * int = foo, bar
|
||||||
foo, bar
|
|
||||||
|
|
||||||
let non_tuple_rhs (p: unit) : int =
|
let non_tuple_rhs (p : unit) : int = bar - foo
|
||||||
bar - foo
|
|
||||||
|
|
||||||
(* Here to prevent a regression of https://gitlab.com/ligolang/ligo/issues/63#note_254106580 *)
|
(* Here to prevent a regression of https://gitlab.com/ligolang/ligo/issues/63#note_254106580 *)
|
||||||
|
|
||||||
let big_tuple : (int * int * int * int * int) = (10, 20, 30, 40, 50)
|
let big_tuple : int * int * int * int * int = 10, 20, 30, 40, 50
|
||||||
|
|
||||||
let (a: int), (b: int), (c: int), (d: int), (e: int) = big_tuple
|
let (a: int), (b: int), (c: int), (d: int), (e: int) = big_tuple
|
||||||
|
|
||||||
let correct_values_big_tuple (p: unit) : int * int * int * int * int =
|
let correct_values_big_tuple (p : unit) : int * int * int * int * int =
|
||||||
a, b, c, d, e
|
a, b, c, d, e
|
||||||
|
|
||||||
(* Here to prevent a regression of https://gitlab.com/ligolang/ligo/issues/63#note_254106580 *)
|
(* Here to prevent a regression of https://gitlab.com/ligolang/ligo/issues/63#note_254106580 *)
|
||||||
|
|
||||||
let different_types: (int * string) = 10, "hello"
|
let different_types : int * string = 10, "hello"
|
||||||
|
|
||||||
let (greet_num: int), (greeting: string) = different_types
|
let (greet_num : int), (greeting : string) = different_types
|
||||||
|
|
||||||
let correct_values_different_types (p: unit) : int * string =
|
let correct_values_different_types (p : unit) : int * string =
|
||||||
greet_num, greeting
|
greet_num, greeting
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
/* Simple test of binding multiple values */
|
/* Simple test of binding multiple values */
|
||||||
|
|
||||||
let ((x: int), (y: int)) = (1, 2);
|
let ((x : int), (y : int)) = (1,2);
|
||||||
|
|
||||||
let main = (p: unit): int => x + y;
|
let main = (p : unit): int => x + y;
|
||||||
|
|
||||||
let ((x: int), (y: int)) = (3, 3);
|
let ((x : int), (y : int)) = (3,3);
|
||||||
|
|
||||||
let main_paren = (p: unit): int => x + y;
|
let main_paren = (p : unit): int => x + y;
|
||||||
|
|
||||||
let foobar: (int, int) = (23, 42);
|
let foobar : (int, int) = (23, 42);
|
||||||
let ((foo: int), (bar: int)) = foobar;
|
|
||||||
|
|
||||||
let non_tuple_rhs = (p: unit): int => foo + bar;
|
let ((foo : int), (bar : int)) = foobar;
|
||||||
|
|
||||||
|
let non_tuple_rhs = (p : unit) : int => foo + bar;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
type storage = int * int
|
type storage = int * int
|
||||||
|
|
||||||
let main (n: int * storage) =
|
let main (n : int * storage) : operation list * storage =
|
||||||
let x : int * int =
|
let x : int * int =
|
||||||
let x : int = 7
|
let x : int = 7
|
||||||
in x + n.0, n.1.0 + n.1.1
|
in x + n.0, n.1.0 + n.1.1
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
type storage = (int, int);
|
type storage = (int, int);
|
||||||
|
|
||||||
let main2 = ((n : int), s: storage) => {
|
let main = (n : (int, storage)) : (list (operation), storage) => {
|
||||||
let x: (int, int) = {
|
let x : (int, int) = {
|
||||||
let x: int = 7;
|
let x : int = 7;
|
||||||
(x + n, s[0] + s[1]);
|
(x + n[0], n[1][0] + n[1][1]);
|
||||||
};
|
};
|
||||||
([]: list(operation), x);
|
([]: list (operation), x);
|
||||||
};
|
};
|
||||||
|
|
||||||
let main = (x: (int, storage)) => main2(x[0],x[1]);
|
|
||||||
|
@ -17,17 +17,17 @@ const bl : foobar = list [144; 51; 42; 120; 421]
|
|||||||
function fold_op (const s : list (int)) : int is
|
function fold_op (const s : list (int)) : int is
|
||||||
block {
|
block {
|
||||||
function aggregate (const prec: int; const cur: int) : int is prec+cur
|
function aggregate (const prec: int; const cur: int) : int is prec+cur
|
||||||
} with list_fold (aggregate, s, 10)
|
} with List.fold (aggregate, s, 10)
|
||||||
|
|
||||||
function iter_op (const s : list (int)) : int is
|
function iter_op (const s : list (int)) : int is
|
||||||
block {
|
block {
|
||||||
var r : int := 0;
|
var r : int := 0;
|
||||||
function aggregate (const i : int) : unit is
|
function aggregate (const i : int) : unit is
|
||||||
block { r := r + i } with unit;
|
block { r := r + i } with unit;
|
||||||
list_iter (aggregate, s)
|
List.iter (aggregate, s)
|
||||||
} with r
|
} with r
|
||||||
|
|
||||||
function map_op (const s : list (int)) : list (int) is
|
function map_op (const s : list (int)) : list (int) is
|
||||||
block {
|
block {
|
||||||
function increment (const i : int) : int is i+1
|
function increment (const i : int) : int is i+1
|
||||||
} with list_map (increment, s)
|
} with List.map (increment, s)
|
||||||
|
@ -1,27 +1,29 @@
|
|||||||
type storage = int * int list
|
type storage = int * int list
|
||||||
|
|
||||||
type param = int list
|
type parameter = int list
|
||||||
|
|
||||||
|
type return = operation list * storage
|
||||||
|
|
||||||
let x : int list = []
|
let x : int list = []
|
||||||
let y : int list = [3; 4; 5]
|
let y : int list = [3; 4; 5]
|
||||||
let z : int list = 2::y
|
let z : int list = 2::y
|
||||||
|
|
||||||
let main (p, s: param * storage) =
|
let main (p, s: parameter * storage) : return =
|
||||||
let storage =
|
let storage =
|
||||||
match p with
|
match p with
|
||||||
[] -> s
|
[] -> s
|
||||||
| hd::tl -> s.0 + hd, tl
|
| hd::tl -> s.0 + hd, tl
|
||||||
in ([] : operation list), storage
|
in ([] : operation list), storage
|
||||||
|
|
||||||
let size_ (s: int list) : nat = List.size s
|
let size_ (s : int list) : nat = List.length s
|
||||||
|
|
||||||
let fold_op (s: int list) : int =
|
let fold_op (s : int list) : int =
|
||||||
let aggregate = fun (t: int * int) -> t.0 + t.1
|
let aggregate = fun (t : int * int) -> t.0 + t.1
|
||||||
in List.fold aggregate s 10
|
in List.fold aggregate s 10
|
||||||
|
|
||||||
let map_op (s: int list) : int list =
|
let map_op (s : int list) : int list =
|
||||||
List.map (fun (cur: int) -> cur + 1) s
|
List.map (fun (cur : int) -> cur + 1) s
|
||||||
|
|
||||||
let iter_op (s : int list) : unit =
|
let iter_op (s : int list) : unit =
|
||||||
let do_nothing = fun (_: int) -> unit
|
let do_nothing = fun (_ : int) -> unit
|
||||||
in List.iter do_nothing s
|
in List.iter do_nothing s
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
type storage = (int, list(int));
|
type storage = (int, list (int));
|
||||||
|
|
||||||
type param = list(int);
|
type parameter = list (int);
|
||||||
|
|
||||||
let x: list(int) = [];
|
type return = (list (operation), storage);
|
||||||
let y: list(int) = [3, 4, 5];
|
|
||||||
let z: list(int) = [2, ...y];
|
|
||||||
|
|
||||||
let main2 = (p: param, storage : storage) => {
|
let x : list (int) = [];
|
||||||
|
let y : list (int) = [3, 4, 5];
|
||||||
|
let z : list (int) = [2, ...y];
|
||||||
|
|
||||||
|
let main = ((action, s) : (parameter, storage)) : return => {
|
||||||
let storage =
|
let storage =
|
||||||
switch (p) {
|
switch (action) {
|
||||||
| [] => storage
|
| [] => s
|
||||||
| [hd, ...tl] => (storage[0] + hd, tl)
|
| [hd, ...tl] => (s[0] + hd, tl)
|
||||||
};
|
};
|
||||||
([]: list(operation), storage);
|
([]: list(operation), storage);
|
||||||
};
|
};
|
||||||
|
|
||||||
let main = (x: (param, storage)) => main2(x[0],x[1]);
|
let size_ = (s : list (int)) : nat => List.length (s);
|
||||||
|
|
||||||
let size_ = (s: list(int)): nat => List.size(s);
|
let fold_op = (s : list (int)) : int => {
|
||||||
|
let aggregate = (t: (int, int)) => t[0] + t[1];
|
||||||
let fold_op = (s: list(int)): int => {
|
List.fold (aggregate, s, 10);
|
||||||
let aggregate = (prec_cur: (int, int)) => prec_cur[0] + prec_cur[1];
|
|
||||||
List.fold(aggregate, s, 10);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let map_op = (s: list(int)): list(int) =>
|
let map_op = (s : list (int)) : list (int) =>
|
||||||
List.map((cur: int) => cur + 1, s);
|
List.map ((cur : int) => cur + 1, s);
|
||||||
|
|
||||||
let iter_op = (s: list(int)): unit => {
|
let iter_op = (s : list (int)) : unit => {
|
||||||
let do_nothing = (z: int) => unit;
|
let do_nothing = (useless : int) => unit;
|
||||||
List.iter(do_nothing, s);
|
List.iter (do_nothing, s);
|
||||||
};
|
};
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user