x
52
{ parameter (or (unit %deposit) (unit %withdraw)) ; storage (big_map address mutez) ; code { UNPAIR ; IF_LEFT { DROP ; PUSH mutez 0 ; AMOUNT ; COMPARE ; LE ; IF { DROP ; PUSH string "Send some tez to this entrypoint." ; FAILWITH } { DUP ; SENDER ; GET ; IF_NONE { AMOUNT } { AMOUNT ; ADD } ; SOME ; SENDER ; UPDATE ; NIL operation ; PAIR } } { DROP ; PUSH mutez 0 ; AMOUNT ; COMPARE ; GT ; IF { DROP ; PUSH string "Do not send tez to this entrypoint" ; FAILWITH } { DUP ; SENDER ; GET ; IF_NONE { DROP ; PUSH string "You do not currently have a balance." ; FAILWITH } { SWAP ; SENDER ; PAIR ; PUSH string "Account not found" ; SENDER ; CONTRACT unit ; IF_NONE { FAILWITH } { SWAP ; DROP } ; DIG 2 ; UNIT ; TRANSFER_TOKENS ; SWAP ; UNPAIR ; NONE mutez ; SWAP ; UPDATE ; NIL operation ; DIG 2 ; CONS ; PAIR } } } } ; view "balance" address mutez { UNPAIR ; GET ; IF_NONE { PUSH mutez 0 } {} } }