manager.tz 912 Bytes
Newer Older
1
parameter
2 3 4 5 6 7
  (option
     (or
        (pair key_hash mutez)
        (or key_hash
            (or unit
                key_hash))));
8 9 10
storage key_hash;
code {
       UNPAIR ;
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
       IF_SOME {
                 DUUP ;
                 IMPLICIT_ACCOUNT ; ADDRESS ;
                 SENDER ;
                 IFCMPNEQ
                   { SENDER ; PUSH string "Only the owner can operate." ; PAIR ; FAILWITH }
                   { DIP { NIL operation } ;
                     IF_LEFT
                       { DUP ; DIP { CAR ; IMPLICIT_ACCOUNT } ; CDR ; UNIT ; TRANSFER_TOKENS ; CONS ; PAIR }
                       { IF_LEFT
                           { SOME ; SET_DELEGATE ; CONS ; PAIR }
                           { IF_LEFT
                               { DROP ; NONE key_hash ; SET_DELEGATE ; CONS ; PAIR }
                               { DIIP { DROP }; SWAP ; PAIR }}}}}
               { NIL operation; PAIR }}