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