ligo/src/test/contracts/replaceable_id.ligo

36 lines
1.0 KiB
Plaintext
Raw Normal View History

2019-12-17 14:18:09 +00:00
// storage type
2020-02-27 17:51:29 +01:00
type storage_t is address
2019-12-17 14:18:09 +00:00
// entry points parameter types
type change_addr_pt is address
2020-02-27 17:51:29 +01:00
type message_t is list (operation)
type pass_message_pt is unit -> message_t
2019-12-17 14:18:09 +00:00
2020-02-27 17:51:29 +01:00
type contract_return_t is list (operation) * storage_t
2019-12-17 14:18:09 +00:00
type entry_point_t is
2020-02-27 17:51:29 +01:00
Change_address of change_addr_pt
| Pass_message of pass_message_pt
2019-12-17 14:18:09 +00:00
function change_address (const param : change_addr_pt;
const s : storage_t) : contract_return_t is
2020-02-27 17:51:29 +01:00
block {
if sender =/= s then failwith ("Unauthorized sender")
2019-12-17 14:18:09 +00:00
else skip
2020-02-27 17:51:29 +01:00
} with ((nil : list (operation)), param)
2019-12-17 14:18:09 +00:00
2020-02-27 17:51:29 +01:00
function pass_message (const param: pass_message_pt;
const s : storage_t ) : contract_return_t is
block {
if sender =/= s then failwith("Unauthorized sender") else skip;
var message : pass_message_pt := param
} with (param (unit), s)
2019-12-17 14:18:09 +00:00
2020-02-27 17:51:29 +01:00
function main (const param : entry_point_t; const s : storage_t) :
contract_return_t is
2019-12-17 14:18:09 +00:00
case param of
2020-02-27 17:51:29 +01:00
Change_address (p) -> change_address (p,s)
| Pass_message (p) -> pass_message (p,s)
end