x
25
{ parameter (list (pair (string %asset_code) (nat %average_price))) ; storage (pair (big_map %asset_map string (pair (timestamp %last_updated) (nat %average_price))) (address %data_source)) ; code { UNPAIR ; DUP 2 ; GET 2 ; SENDER ; { COMPARE ; NEQ ; IF { PUSH string "price_feed.only the data source can update prices" ; FAILWITH } {} } ; DIP { DUP ; GET 1 } ; ITER { UNPAIR ; SWAP ; NOW ; PAIR ; SOME ; SWAP ; UPDATE } ; UPDATE 1 ; NIL operation ; PAIR } ; view "getPrice" string (pair timestamp nat) { UNPAIR ; DIP { GET 1 } ; GET ; IF_NONE { PUSH string "price_feed.no such asset to retrieve" ; FAILWITH } {} } }