# This is a small experimental Prettifier tool for Michelson. # You can copy-paste badly indented Michelson code and it will try to indent it properly. # # It is typically useful for hand-crafted Michelson code. parameter (or (or (nat %divisor) (unit %double)) (nat %value)); storage (nat %storedValue); code { DUP; # pair(params, storage).pair(params, storage) CDR; # storage.pair(params, storage) SWAP; # pair(params, storage).storage CAR; # params.storage IF_LEFT { IF_LEFT { # Entry point: divide # params.storage PAIR; # pair(params, storage) # sp.verify(params.divisor > 5) # pair(params, storage) DUP; # pair(params, storage).pair(params, storage) CAR; # Rec(divisor = nat).pair(params, storage) PUSH nat 5; # nat.Rec(divisor = nat).pair(params, storage) SWAP; # Rec(divisor = nat).nat.pair(params, storage) COMPARE; # int.pair(params, storage) GT; # bool.pair(params, storage) IF { } { PUSH string "WrongCondition: params.divisor > 5"; # string.pair(params, storage) FAILWITH; # pair(params, storage) }; # self.data.storedValue //= params.divisor # pair(params, storage) DUP; # pair(params, storage).pair(params, storage) CDR; # storage.pair(params, storage) DUUP; # pair(params, storage).nat.pair(params, storage) CAR; # params.nat.pair(params, storage) EDIV; # option(pair(nat, nat)).pair(params, storage) IF_SOME { CAR; # nat.pair(params, storage) } { PUSH string "division by zero"; # string.pair(params, storage) FAILWITH; # FAILED }; SWAP; # pair(params, storage).storage DROP; # storage NIL operation; # operations.storage PAIR; # pair(operations, storage) } { # Entry point: double # params.storage PAIR; # pair(params, storage) # self.data.storedValue *= 2 # pair(params, storage) DUP; # pair(params, storage).pair(params, storage) CDR; # storage.pair(params, storage) PUSH nat 2; # nat.nat.pair(params, storage) MUL; # nat.pair(params, storage) SWAP; # pair(params, storage).storage DROP; # storage NIL operation; # operations.storage PAIR; # pair(operations, storage) }; } { # Entry point: replace # params.storage PAIR; # pair(params, storage) # self.data.storedValue = params.value # pair(params, storage) DUP; # pair(params, storage).pair(params, storage) CAR; # params.pair(params, storage) SWAP; # pair(params, storage).storage DROP; # storage NIL operation; # operations.storage PAIR; # pair(operations, storage) }; }
Initialization of the SmartPy Prettifier.
Please wait for a few seconds...