Skip to content

Commit

Permalink
Add new data publisher. LIGO files don't compile.
Browse files Browse the repository at this point in the history
  • Loading branch information
thealmarty committed Jul 5, 2019
1 parent a9195a8 commit 3c7c80c
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ligo/id_strings.ligo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type storage = unit

let%entry main
(_parameter : string)
storage =
( [], storage )

12 changes: 12 additions & 0 deletions ligo/send_one_tez.ligo
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(* A contract that sends 1 tez to anyone who asks. *)

type storage = unit

(* Initialize storage to (). *)
let%init storage = ()

let%entry main
(key : key_hash)
_storage =
let op = Account.transfer ~dest:key ~amount:1tz in
( [op], () )
17 changes: 17 additions & 0 deletions liquidity/examples/data_publisher/data_publisher_hash.liq
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(* A contract that publishes data securely. *)

type storage = {
publisher : address;
data : bytes
}

let%entry main (param : string) storage =
if (Crypto.sha512 (Bytes.pack param)) = storage.data then
if Current.amount() < 1tz then
failwith "Not enough money, queries cost 1 tez."
else
([], storage)
else if Current.sender () <> storage.publisher then
failwith "Cannot authenticate."
else
([], storage.data <- Crypto.sha512 (Bytes.pack param))
34 changes: 34 additions & 0 deletions liquidity/examples/data_publisher/data_publisher_hash.tz
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
parameter string;
storage (pair :storage (address %publisher) (bytes %data));
code { DUP ;
DIP { CDR @storage_slash_1 } ;
CAR @param_slash_2 ;
DUUP @storage ;
CDR %data ;
DUUP @param ;
PACK ;
SHA512 ;
COMPARE ;
EQ ;
IF { PUSH mutez 1000000 ;
AMOUNT ;
COMPARE ;
LT ;
IF { PUSH string "Not enough money, queries cost 1 tez." ; FAILWITH }
{ DUUP @storage ; NIL operation ; PAIR } }
{ DUUP @storage ;
CAR %publisher ;
SENDER ;
COMPARE ;
NEQ ;
IF { PUSH string "Cannot authenticate." ; FAILWITH }
{ DUUP @storage ;
CAR %publisher ;
DUUP @param ;
PACK ;
SHA512 ;
SWAP ;
PAIR %publisher %data ;
NIL operation ;
PAIR } } ;
DIP { DROP ; DROP } };

0 comments on commit 3c7c80c

Please sign in to comment.