26 lines
669 B
Plaintext
26 lines
669 B
Plaintext
type storage is int
|
|
|
|
type parameter is
|
|
Increment of int
|
|
| Decrement of int
|
|
| Reset
|
|
|
|
type return is list (operation) * storage
|
|
|
|
(* Two entrypoints *)
|
|
|
|
function add (const store : storage; const delta : int) : storage is store + delta
|
|
|
|
function sub (const store : storage; const delta : int) : storage is store - delta
|
|
|
|
(* Main access point that dispatches to the entrypoints according to
|
|
the smart contract parameter. *)
|
|
|
|
function main (const action : parameter; const store : storage) : return is
|
|
((nil : list (operation)), // No operations
|
|
case action of
|
|
Increment (n) -> add (store, n)
|
|
| Decrement (n) -> sub (store, n)
|
|
| Reset -> 0
|
|
end)
|