Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht-dev
This commit is contained in:
commit
e6a9bf6510
@ -131,6 +131,7 @@ module Simplify = struct
|
||||
| "address" -> ok C_ADDRESS
|
||||
| "self_address" -> ok C_SELF_ADDRESS
|
||||
| "implicit_account"-> ok C_IMPLICIT_ACCOUNT
|
||||
| "set_delegate" -> ok C_SET_DELEGATE
|
||||
| _ -> simple_fail "Not a PascaLIGO constant"
|
||||
|
||||
let type_constants = type_constants
|
||||
@ -224,6 +225,7 @@ module Simplify = struct
|
||||
| "stop" -> ok C_STOP
|
||||
|
||||
| "Operation.transaction" -> ok C_CALL
|
||||
| "Operation.set_delegate" -> ok C_SET_DELEGATE
|
||||
| "Operation.get_contract" -> ok C_CONTRACT
|
||||
| "Operation.get_entrypoint" -> ok C_CONTRACT_ENTRYPOINT
|
||||
| "int" -> ok C_INT
|
||||
@ -851,6 +853,7 @@ module Typer = struct
|
||||
| C_ADDRESS -> ok @@ address ;
|
||||
| C_SELF_ADDRESS -> ok @@ self_address;
|
||||
| C_IMPLICIT_ACCOUNT -> ok @@ implicit_account;
|
||||
| C_SET_DELEGATE -> ok @@ set_delegate ;
|
||||
| _ -> simple_fail @@ Format.asprintf "Typer not implemented for consant %a" Stage_common.PP.constant c
|
||||
|
||||
|
||||
@ -923,6 +926,7 @@ module Compiler = struct
|
||||
| C_ADDRESS -> ok @@ simple_unary @@ prim I_ADDRESS
|
||||
| C_SELF_ADDRESS -> ok @@ simple_constant @@ seq [prim I_SELF; prim I_ADDRESS]
|
||||
| C_IMPLICIT_ACCOUNT -> ok @@ simple_unary @@ prim I_IMPLICIT_ACCOUNT
|
||||
| C_SET_DELEGATE -> ok @@ simple_unary @@ prim I_SET_DELEGATE
|
||||
| C_NOW -> ok @@ simple_constant @@ prim I_NOW
|
||||
| C_CALL -> ok @@ simple_ternary @@ prim I_TRANSFER_TOKENS
|
||||
| C_SOURCE -> ok @@ simple_constant @@ prim I_SOURCE
|
||||
|
@ -116,6 +116,7 @@ let constant ppf : constant -> unit = function
|
||||
| C_ADDRESS -> fprintf ppf "ADDRESS"
|
||||
| C_SELF_ADDRESS -> fprintf ppf "SELF_ADDRESS"
|
||||
| C_IMPLICIT_ACCOUNT -> fprintf ppf "IMPLICIT_ACCOUNT"
|
||||
| C_SET_DELEGATE -> fprintf ppf "SET_DELEGATE"
|
||||
| C_STEPS_TO_QUOTA -> fprintf ppf "STEPS_TO_QUOTA"
|
||||
|
||||
let cmap_sep value sep ppf m =
|
||||
|
@ -232,4 +232,5 @@ type constant =
|
||||
| C_ADDRESS
|
||||
| C_SELF_ADDRESS
|
||||
| C_IMPLICIT_ACCOUNT
|
||||
| C_SET_DELEGATE
|
||||
| C_STEPS_TO_QUOTA
|
||||
|
6
src/test/contracts/set_delegate.ligo
Normal file
6
src/test/contracts/set_delegate.ligo
Normal file
@ -0,0 +1,6 @@
|
||||
function main (const p: key_hash) : list(operation) is
|
||||
begin
|
||||
const unused: operation = set_delegate(Some(p)) ;
|
||||
const dummy: list(operation) = nil;
|
||||
end with dummy
|
||||
|
3
src/test/contracts/set_delegate.mligo
Normal file
3
src/test/contracts/set_delegate.mligo
Normal file
@ -0,0 +1,3 @@
|
||||
let main (p: key_hash) : operation list =
|
||||
let unused: operation = (Operation.set_delegate (Some p)) in ([]: operation list)
|
||||
|
4
src/test/contracts/set_delegate.religo
Normal file
4
src/test/contracts/set_delegate.religo
Normal file
@ -0,0 +1,4 @@
|
||||
let main = (p: key_hash) : list(operation) => {
|
||||
let unused: operation = (Operation.set_delegate(Some(p)));
|
||||
([]: list(operation));
|
||||
} ;
|
@ -1765,6 +1765,30 @@ let key_hash () : unit result =
|
||||
let%bind () = expect_eq program "check_hash_key" make_input make_expected in
|
||||
ok ()
|
||||
|
||||
let set_delegate () : unit result =
|
||||
let open Tezos_crypto in
|
||||
let (raw_pkh,_,_) = Signature.generate_key () in
|
||||
let pkh_str = Signature.Public_key_hash.to_b58check raw_pkh in
|
||||
let%bind program = type_file "./contracts/set_delegate.ligo" in
|
||||
let%bind () = expect_eq program "main" (e_key_hash pkh_str) (e_typed_list [] t_operation)
|
||||
in ok ()
|
||||
|
||||
let set_delegate_mligo () : unit result =
|
||||
let open Tezos_crypto in
|
||||
let (raw_pkh,_,_) = Signature.generate_key () in
|
||||
let pkh_str = Signature.Public_key_hash.to_b58check raw_pkh in
|
||||
let%bind program = mtype_file "./contracts/set_delegate.mligo" in
|
||||
let%bind () = expect_eq program "main" (e_key_hash pkh_str) (e_typed_list [] t_operation)
|
||||
in ok ()
|
||||
|
||||
let set_delegate_religo () : unit result =
|
||||
let open Tezos_crypto in
|
||||
let (raw_pkh,_,_) = Signature.generate_key () in
|
||||
let pkh_str = Signature.Public_key_hash.to_b58check raw_pkh in
|
||||
let%bind program = retype_file "./contracts/set_delegate.religo" in
|
||||
let%bind () = expect_eq program "main" (e_key_hash pkh_str) (e_typed_list [] t_operation)
|
||||
in ok ()
|
||||
|
||||
let type_tuple_destruct () : unit result =
|
||||
let%bind program = mtype_file "./contracts/type_tuple_destruct.mligo" in
|
||||
let%bind () = expect_eq program "type_tuple_d" (e_unit ()) (e_int 35) in
|
||||
@ -1898,6 +1922,9 @@ let main = test_suite "Integration (End to End)" [
|
||||
test "implicit account" implicit_account ;
|
||||
test "implicit account (mligo)" implicit_account_mligo ;
|
||||
test "implicit account (religo)" implicit_account_religo ;
|
||||
test "set delegate" set_delegate ;
|
||||
test "set delegate (mligo)" set_delegate_mligo ;
|
||||
test "set delegate (religo)" set_delegate_religo ;
|
||||
test "is_nat" is_nat ;
|
||||
test "is_nat (mligo)" is_nat_mligo ;
|
||||
test "is_nat (religo)" is_nat_religo ;
|
||||
|
Loading…
Reference in New Issue
Block a user