ligo/test/contracts/weather_insurance.tz

17 lines
900 B
Plaintext
Raw Normal View History

2017-07-24 17:06:56 +04:00
# (pair signed_weather_data actual_level)
parameter (pair signature uint16);
# (pair (under_key over_key) (pair weather_service_key (pair rain_level days_in_future)))
storage (pair (pair (contract unit unit) (contract unit unit)) (pair uint16 key));
return unit;
code {DUP; DUP;
CAR; DUP; DIP{CDR; H}; CAR; PAIR;
2017-07-24 17:06:56 +04:00
SWAP; CDDDR; CHECK_SIGNATURE; # Check if the data has been correctly signed
IF {} {FAIL} # If signature is not correct, end the execution
2017-07-24 17:06:56 +04:00
DUP; DUP; DUP; DIIIP{CDR}; # Place storage type on bottom of stack
DIIP{CDAR}; # Place contracts below numbers
DIP{CADR}; # Get actual rain
2017-07-24 17:06:56 +04:00
CDDAR; # Get rain threshold
CMPLT; IF {CAR} {CDR}; # Select contract to receive tokens
BALANCE; UNIT; TRANSFER_TOKENS; # Setup and execute transfer
PAIR}; # Save storage