Merge branch 'feature/self-account-address-ops' into 'dev'
Add SELF_ADDRESS, ADDRESS, and IMPLICIT ACCOUNT to LIGO See merge request ligolang/ligo!230
This commit is contained in:
commit
d1d9cea599
@ -73,6 +73,9 @@ module Simplify = struct
|
||||
("unit" , "UNIT") ;
|
||||
("source" , "SOURCE") ;
|
||||
("sender" , "SENDER") ;
|
||||
("address", "ADDRESS") ;
|
||||
("self_address", "SELF_ADDRESS") ;
|
||||
("implicit_account", "IMPLICIT_ACCOUNT") ;
|
||||
("failwith" , "FAILWITH") ;
|
||||
("bitwise_or" , "OR") ;
|
||||
("bitwise_and" , "AND") ;
|
||||
@ -136,6 +139,9 @@ module Simplify = struct
|
||||
("gas", "STEPS_TO_QUOTA") ;
|
||||
("Current.sender" , "SENDER") ;
|
||||
("sender", "SENDER") ;
|
||||
("Current.address", "ADDRESS") ;
|
||||
("Current.self_address", "SELF_ADDRESS") ;
|
||||
("Current.implicit_account", "IMPLICIT_ACCOUNT") ;
|
||||
("Current.source" , "SOURCE") ;
|
||||
("source", "SOURCE") ;
|
||||
("Current.failwith", "FAILWITH") ;
|
||||
@ -466,6 +472,13 @@ module Typer = struct
|
||||
let%bind () = assert_t_contract contract in
|
||||
ok @@ t_address ()
|
||||
|
||||
let self_address = typer_0 "SELF_ADDRESS" @@ fun _ ->
|
||||
ok @@ t_address ()
|
||||
|
||||
let implicit_account = typer_1 "IMPLICIT_ACCOUNT" @@ fun key_hash ->
|
||||
let%bind () = assert_t_key_hash key_hash in
|
||||
ok @@ t_contract (t_unit () ) ()
|
||||
|
||||
let now = constant "NOW" @@ t_timestamp ()
|
||||
|
||||
let transaction = typer_3 "CALL" @@ fun param amount contract ->
|
||||
@ -794,6 +807,8 @@ module Typer = struct
|
||||
now ;
|
||||
slice ;
|
||||
address ;
|
||||
self_address ;
|
||||
implicit_account ;
|
||||
assertion ;
|
||||
list_cons ;
|
||||
]
|
||||
@ -865,6 +880,8 @@ module Compiler = struct
|
||||
("BALANCE" , simple_constant @@ prim I_BALANCE) ;
|
||||
("AMOUNT" , simple_constant @@ prim I_AMOUNT) ;
|
||||
("ADDRESS" , simple_unary @@ prim I_ADDRESS) ;
|
||||
("SELF_ADDRESS", simple_constant @@ (seq [prim I_SELF ; prim I_ADDRESS])) ;
|
||||
("IMPLICIT_CONTRACT", simple_unary @@ prim I_IMPLICIT_ACCOUNT) ;
|
||||
("NOW" , simple_constant @@ prim I_NOW) ;
|
||||
("CALL" , simple_ternary @@ prim I_TRANSFER_TOKENS) ;
|
||||
("SOURCE" , simple_constant @@ prim I_SOURCE) ;
|
||||
|
1
src/test/contracts/address.ligo
Normal file
1
src/test/contracts/address.ligo
Normal file
@ -0,0 +1 @@
|
||||
function main (const c: contract(unit)) : address is address(c)
|
1
src/test/contracts/address.mligo
Normal file
1
src/test/contracts/address.mligo
Normal file
@ -0,0 +1 @@
|
||||
let main (c: unit contract) : address = Current.address c
|
1
src/test/contracts/implicit_account.ligo
Normal file
1
src/test/contracts/implicit_account.ligo
Normal file
@ -0,0 +1 @@
|
||||
function main (const kh: key_hash) : contract(unit) is implicit_account(kh)
|
1
src/test/contracts/implicit_account.mligo
Normal file
1
src/test/contracts/implicit_account.mligo
Normal file
@ -0,0 +1 @@
|
||||
let main (kh: key_hash) : unit contract = Current.implicit_account kh
|
1
src/test/contracts/self_address.ligo
Normal file
1
src/test/contracts/self_address.ligo
Normal file
@ -0,0 +1 @@
|
||||
function main (const p: unit) : address is self_address
|
1
src/test/contracts/self_address.mligo
Normal file
1
src/test/contracts/self_address.mligo
Normal file
@ -0,0 +1 @@
|
||||
let main (p: unit) : address = Current.self_address
|
@ -1233,6 +1233,30 @@ let balance_constant_mligo () : unit result =
|
||||
let expected = e_tuple [e_list []; e_mutez 4000000000000] in
|
||||
expect_eq program "main" input expected
|
||||
|
||||
let address () : unit result =
|
||||
let%bind _ = type_file "./contracts/address.ligo" in
|
||||
ok ()
|
||||
|
||||
let address_mligo () : unit result =
|
||||
let%bind _ = mtype_file "./contracts/address.mligo" in
|
||||
ok ()
|
||||
|
||||
let self_address () : unit result =
|
||||
let%bind _ = type_file "./contracts/self_address.ligo" in
|
||||
ok ()
|
||||
|
||||
let self_address_mligo () : unit result =
|
||||
let%bind _ = mtype_file "./contracts/self_address.mligo" in
|
||||
ok ()
|
||||
|
||||
let implicit_account () : unit result =
|
||||
let%bind _ = type_file "./contracts/implicit_account.ligo" in
|
||||
ok ()
|
||||
|
||||
let implicit_account_mligo () : unit result =
|
||||
let%bind _ = mtype_file "./contracts/implicit_account.mligo" in
|
||||
ok ()
|
||||
|
||||
let is_nat () : unit result =
|
||||
let%bind program = type_file "./contracts/isnat.ligo" in
|
||||
let%bind () =
|
||||
@ -1398,6 +1422,12 @@ let main = test_suite "Integration (End to End)" [
|
||||
test "let multiple (mligo)" mligo_let_multiple ;
|
||||
test "balance constant" balance_constant ;
|
||||
test "balance constant (mligo)" balance_constant_mligo ;
|
||||
test "address" address ;
|
||||
test "address_mligo" address_mligo ;
|
||||
test "self address" self_address ;
|
||||
test "self address (mligo)" self_address_mligo ;
|
||||
test "implicit account" implicit_account ;
|
||||
test "implicit account (mligo)" implicit_account_mligo ;
|
||||
test "is_nat" is_nat ;
|
||||
test "is_not (mligo)" is_nat_mligo ;
|
||||
test "simple_access (ligo)" simple_access_ligo;
|
||||
|
Loading…
Reference in New Issue
Block a user