Michelson: replace direct transfers with an internal operation queue

This commit is contained in:
Benjamin Canou 2018-04-05 17:17:27 +02:00 committed by Grégoire Henry
parent 59cccd53aa
commit 595685cf42
279 changed files with 1521 additions and 1827 deletions

View File

@ -6,15 +6,14 @@
parameter (or key_hash (pair key (pair tez signature))); parameter (or key_hash (pair key (pair tez signature)));
# Maps the key to the balance they have stored # Maps the key to the balance they have stored
storage (map key_hash tez); storage (map key_hash tez);
return unit;
code { DUP; CAR; code { DUP; CAR;
# Deposit into account # Deposit into account
IF_LEFT { DUP; DIIP{ CDR; DUP }; IF_LEFT { DUP; DIIP{ CDR; DUP };
DIP{ SWAP }; GET; DIP{ SWAP }; GET;
# Create the account # Create the account
IF_NONE { DIP{ AMOUNT; SOME }; UPDATE; UNIT; PAIR } IF_NONE { DIP{ AMOUNT; SOME }; UPDATE; NIL operation; PAIR }
# Add to an existing account # Add to an existing account
{ AMOUNT; ADD; SOME; SWAP; UPDATE; UNIT; PAIR }} { AMOUNT; ADD; SOME; SWAP; UPDATE; NIL operation; PAIR }}
# Withdrawl # Withdrawl
{ DUP; DUP; DUP; DUP; { DUP; DUP; DUP; DUP;
# Check signature on data # Check signature on data
@ -38,5 +37,7 @@ code { DUP; CAR;
SWAP; CAR; HASH_KEY; UPDATE; SWAP; CAR; HASH_KEY; UPDATE;
SWAP; DUP; CDAR; SWAP; DUP; CDAR;
# Execute the transfer # Execute the transfer
DIP{ CAR; HASH_KEY; IMPLICIT_ACCOUNT }; UNIT; TRANSFER_TOKENS; DIP{ CAR; HASH_KEY; IMPLICIT_ACCOUNT }; UNIT;
TRANSFER_TOKENS;
NIL operation; SWAP; CONS;
PAIR }}}} PAIR }}}}

View File

@ -1,10 +1,7 @@
parameter int; parameter int;
storage unit; storage int;
return int;
code {CAR; # Get the parameter code {CAR; # Get the parameter
PUSH int 1; # We're adding 1, so we need to put 1 on the stack PUSH int 1; # We're adding 1, so we need to put 1 on the stack
ADD; # Add the two numbers ADD; # Add the two numbers
UNIT; # We need to put the storage value on the stack NIL operation; # We put an empty list of operations on the stack
SWAP; # The values must be rearranged to match the return calling convention
PAIR} # Create the end value PAIR} # Create the end value

View File

@ -1,9 +1,7 @@
parameter (list int); parameter (list int);
storage unit; storage (list int);
return (list int); code { CAR; # Get the parameter
code { CAR; # Get the parameter
LAMBDA int int { PUSH int 1; ADD }; # Create a lambda that adds 1 LAMBDA int int { PUSH int 1; ADD }; # Create a lambda that adds 1
MAP; # Map over the list MAP; # Map over the list
UNIT; # Push Unit NIL operation; # No internal op
SWAP; # Reorder the stack for the PAIR PAIR } # Match the calling convetion
PAIR } # Match the calling convetion

View File

@ -1,4 +1,3 @@
parameter (pair int timestamp); parameter (pair int timestamp);
storage unit; storage (option timestamp);
return timestamp; code { CAR; DUP; CAR; DIP{CDR}; ADD; SOME; NIL operation; PAIR}
code { CAR; DUP; CAR; DIP{CDR}; ADD; UNIT; SWAP; PAIR}

View File

@ -1,4 +1,3 @@
parameter (pair timestamp int); parameter (pair timestamp int);
storage unit; storage (option timestamp);
return timestamp; code { CAR; DUP; CAR; DIP{CDR}; ADD; SOME; NIL operation; PAIR}
code { CAR; DUP; CAR; DIP{CDR}; ADD; UNIT; SWAP; PAIR}

View File

@ -1,4 +1,3 @@
parameter nat; parameter nat;
storage timestamp; storage (pair (pair nat bool) timestamp);
return (pair nat bool); code {DUP; CAR; DIP{CDDR; DUP; NOW; CMPGT}; PAIR; PAIR ; NIL operation ; PAIR};
code {DUP; CAR; DIP{CDR; DUP; NOW; CMPGT}; PAIR; PAIR};

View File

@ -1,6 +1,4 @@
parameter nat; parameter nat;
return (pair nat bool); storage (pair nat bool);
storage unit;
code { CAR; PUSH bool True; SWAP; code { CAR; PUSH bool True; SWAP;
PAIR; UNIT; SWAP; PAIR} PAIR; NIL operation; PAIR}

View File

@ -1,4 +1,3 @@
parameter (pair (bool @first) (bool @second)); parameter (pair (bool @first) (bool @second));
return bool; storage (option bool);
storage unit; code { CAR @param; DUP; CAR @first; DIP{CDR @second}; AND; SOME; NIL operation; PAIR };
code { CAR @param; DUP; CAR @first; DIP{CDR @second}; AND; UNIT; SWAP; PAIR };

View File

@ -1,7 +1,5 @@
parameter (pair (list int) (list int)); parameter (pair (list int) (list int));
return (list int); storage (list int);
storage unit;
code { CAR; DUP; DIP{CDR}; CAR; # Unpack lists code { CAR; DUP; DIP{CDR}; CAR; # Unpack lists
NIL int; SWAP; # Setup reverse accumulator NIL int; SWAP; # Setup reverse accumulator
LAMBDA (pair int (list int)) LAMBDA (pair int (list int))
@ -12,4 +10,4 @@ code { CAR; DUP; DIP{CDR}; CAR; # Unpack lists
(list int) (list int)
{DUP; CAR; DIP{CDR}; CONS}; {DUP; CAR; DIP{CDR}; CONS};
REDUCE; # Append reversed list REDUCE; # Append reversed list
UNIT; SWAP; PAIR} # Calling convention NIL operation; PAIR} # Calling convention

View File

@ -1,4 +1,3 @@
parameter bool; parameter bool;
storage unit; storage unit;
return unit; code {CAR; ASSERT; UNIT; NIL operation; PAIR}
code {CAR; ASSERT; UNIT; UNIT; PAIR}

View File

@ -1,4 +1,3 @@
parameter (pair int int); parameter (pair int int);
storage unit; storage unit;
return unit; code {CAR; DUP; CAR; DIP{CDR}; ASSERT_CMPEQ; UNIT; NIL operation; PAIR}
code {CAR; DUP; CAR; DIP{CDR}; ASSERT_CMPEQ; UNIT; DUP; PAIR}

View File

@ -1,4 +1,3 @@
parameter (pair int int); parameter (pair int int);
storage unit; storage unit;
return unit; code {CAR; DUP; CAR; DIP{CDR}; ASSERT_CMPGE; UNIT; NIL operation; PAIR}
code {CAR; DUP; CAR; DIP{CDR}; ASSERT_CMPGE; UNIT; DUP; PAIR}

View File

@ -1,4 +1,3 @@
parameter (pair int int); parameter (pair int int);
storage unit; storage unit;
return unit; code {CAR; DUP; CAR; DIP{CDR}; ASSERT_CMPGT; UNIT; NIL operation; PAIR}
code {CAR; DUP; CAR; DIP{CDR}; ASSERT_CMPGT; UNIT; DUP; PAIR}

View File

@ -1,4 +1,3 @@
parameter (pair int int); parameter (pair int int);
storage unit; storage unit;
return unit; code {CAR; DUP; CAR; DIP{CDR}; ASSERT_CMPLE; UNIT; NIL operation; PAIR}
code {CAR; DUP; CAR; DIP{CDR}; ASSERT_CMPLE; UNIT; DUP; PAIR}

View File

@ -1,4 +1,3 @@
parameter (pair int int); parameter (pair int int);
storage unit; storage unit;
return unit; code {CAR; DUP; CAR; DIP{CDR}; ASSERT_CMPLT; UNIT; NIL operation; PAIR}
code {CAR; DUP; CAR; DIP{CDR}; ASSERT_CMPLT; UNIT; DUP; PAIR}

View File

@ -1,4 +1,3 @@
parameter (pair int int); parameter (pair int int);
storage unit; storage unit;
return unit; code {CAR; DUP; CAR; DIP{CDR}; ASSERT_CMPNEQ; UNIT; NIL operation; PAIR}
code {CAR; DUP; CAR; DIP{CDR}; ASSERT_CMPNEQ; UNIT; DUP; PAIR}

View File

@ -1,4 +1,3 @@
parameter (pair int int); parameter (pair int int);
storage unit; storage unit;
return unit; code {CAR; DUP; CAR; DIP{CDR}; COMPARE; ASSERT_EQ; UNIT; NIL operation; PAIR}
code {CAR; DUP; CAR; DIP{CDR}; COMPARE; ASSERT_EQ; UNIT; DUP; PAIR}

View File

@ -1,4 +1,3 @@
parameter (pair int int); parameter (pair int int);
storage unit; storage unit;
return unit; code {CAR; DUP; CAR; DIP{CDR}; COMPARE; ASSERT_GE; UNIT; NIL operation; PAIR}
code {CAR; DUP; CAR; DIP{CDR}; COMPARE; ASSERT_GE; UNIT; DUP; PAIR}

View File

@ -1,4 +1,3 @@
parameter (pair int int); parameter (pair int int);
storage unit; storage unit;
return unit; code {CAR; DUP; CAR; DIP{CDR}; COMPARE; ASSERT_GT; UNIT; NIL operation; PAIR}
code {CAR; DUP; CAR; DIP{CDR}; COMPARE; ASSERT_GT; UNIT; DUP; PAIR}

View File

@ -1,4 +1,3 @@
parameter (pair int int); parameter (pair int int);
storage unit; storage unit;
return unit; code {CAR; DUP; CAR; DIP{CDR}; COMPARE; ASSERT_LE; UNIT; NIL operation; PAIR}
code {CAR; DUP; CAR; DIP{CDR}; COMPARE; ASSERT_LE; UNIT; DUP; PAIR}

View File

@ -1,4 +1,3 @@
parameter (pair int int); parameter (pair int int);
storage unit; storage unit;
return unit; code {CAR; DUP; CAR; DIP{CDR}; COMPARE; ASSERT_LT; UNIT; NIL operation; PAIR}
code {CAR; DUP; CAR; DIP{CDR}; COMPARE; ASSERT_LT; UNIT; DUP; PAIR}

View File

@ -1,4 +1,3 @@
parameter (pair int int); parameter (pair int int);
storage unit; storage unit;
return unit; code {CAR; DUP; CAR; DIP{CDR}; COMPARE; ASSERT_NEQ; UNIT; NIL operation; PAIR}
code {CAR; DUP; CAR; DIP{CDR}; COMPARE; ASSERT_NEQ; UNIT; DUP; PAIR}

View File

@ -1,7 +1,6 @@
parameter unit; parameter unit;
return unit;
storage tez; # How much you have to send me storage tez; # How much you have to send me
code {CDR; DUP; # Get the amount required (once for comparison, once to save back in storage) code {CDR; DUP; # Get the amount required (once for comparison, once to save back in storage)
AMOUNT; CMPLT; # Check to make sure no one is wasting my time AMOUNT; CMPLT; # Check to make sure no one is wasting my time
IF {FAIL} {UNIT; PAIR}} # Finish the transaction or reject the person IF {FAIL} # Reject the person
{NIL operation;PAIR}} # Finish the transaction

View File

@ -1,9 +1,8 @@
parameter key_hash; parameter key_hash;
storage (pair timestamp (pair tez key_hash)); storage (pair timestamp (pair tez key_hash));
return unit;
code { DUP; CDAR; DUP; NOW; CMPGT; IF {FAIL} {}; SWAP; # Check if auction has ended code { DUP; CDAR; DUP; NOW; CMPGT; IF {FAIL} {}; SWAP; # Check if auction has ended
DUP; CAR; DIP{CDDR}; AMOUNT; PAIR; SWAP; DIP{SWAP; PAIR}; # Setup replacement storage DUP; CAR; DIP{CDDR}; AMOUNT; PAIR; SWAP; DIP{SWAP; PAIR}; # Setup replacement storage
DUP; CAR; AMOUNT; CMPLE; IF {FAIL} {}; # Check to make sure that the new amount is greater DUP; CAR; AMOUNT; CMPLE; IF {FAIL} {}; # Check to make sure that the new amount is greater
DUP; CAR; # Get amount of refund DUP; CAR; # Get amount of refund
DIP{CDR; IMPLICIT_ACCOUNT}; UNIT; TRANSFER_TOKENS; # Make refund DIP{CDR; IMPLICIT_ACCOUNT}; UNIT; TRANSFER_TOKENS; # Make refund
PAIR} # Calling convention NIL operation; SWAP; CONS; PAIR} # Calling convention

View File

@ -1,6 +1,6 @@
parameter unit; parameter unit;
storage (pair timestamp (pair (contract unit unit) (contract unit unit))); storage (pair timestamp (pair (contract unit) (contract unit)));
return unit;
code { CDR; DUP; CAR; NOW; CMPLT; IF {FAIL} {}; code { CDR; DUP; CAR; NOW; CMPLT; IF {FAIL} {};
DUP; CDAR; PUSH tez "100"; UNIT; TRANSFER_TOKENS; DROP; DUP; CDAR; PUSH tez "100"; UNIT; TRANSFER_TOKENS; SWAP;
DUP; CDDR; PUSH tez "100"; UNIT; TRANSFER_TOKENS; PAIR } DUP; CDDR; PUSH tez "100"; UNIT; TRANSFER_TOKENS; DIP {SWAP} ;
NIL operation ; SWAP ; CONS ; SWAP ; CONS ; PAIR }

View File

@ -1,4 +1,3 @@
parameter unit; parameter unit;
storage unit; storage tez;
return tez; code {DROP; BALANCE; NIL operation; PAIR};
code {DROP; UNIT; BALANCE; PAIR};

View File

@ -1,8 +1,7 @@
parameter (pair (pair @set_pair int (option int)) (pair @check_pair int (option int))) ; parameter (pair (pair @set_pair int (option int)) (pair @check_pair int (option int))) ;
storage (pair (big_map int int) unit) ; storage (pair (big_map int int) unit) ;
return unit ;
code { DUP ; DIP { CDAR } ; code { DUP ; DIP { CDAR } ;
DUP ; DIP { CADR; DUP ; CAR ; DIP { CDR } ; UPDATE ; DUP } ; DUP ; DIP { CADR; DUP ; CAR ; DIP { CDR } ; UPDATE ; DUP } ;
CADR ; DUP ; CDR ; DIP { CAR ; GET } ; CADR ; DUP ; CDR ; DIP { CAR ; GET } ;
IF_SOME { SWAP ; IF_SOME { ASSERT_CMPEQ } {FAIL}} { ASSERT_NONE } ; IF_SOME { SWAP ; IF_SOME { ASSERT_CMPEQ } {FAIL}} { ASSERT_NONE } ;
UNIT ; SWAP ; PAIR ; UNIT ; PAIR } UNIT ; SWAP ; PAIR ; NIL operation ; PAIR }

View File

@ -1,6 +1,5 @@
# Fails if the boolean does not match the membership criteria # Fails if the boolean does not match the membership criteria
parameter (pair int bool) ; parameter (pair int bool) ;
storage (pair (big_map int unit) unit) ; storage (pair (big_map int unit) unit) ;
return unit ;
code { DUP ; DUP ; CADR ; DIP { CAAR ; DIP { CDAR ; DUP } ; MEM } ; code { DUP ; DUP ; CADR ; DIP { CAAR ; DIP { CDAR ; DUP } ; MEM } ;
ASSERT_CMPEQ ; UNIT ; SWAP ; PAIR ; UNIT ; PAIR } ASSERT_CMPEQ ; UNIT ; SWAP ; PAIR ; NIL operation ; PAIR }

View File

@ -1,9 +1,8 @@
parameter (list (pair string int)) ; parameter (list (pair string int)) ;
storage (pair (big_map string int) unit) ; storage (pair (big_map string int) unit) ;
return unit ;
code { UNPAAIAIR ; code { UNPAAIAIR ;
ITER { UNPAIR ; DUUUP ; DUUP; GET ; ITER { UNPAIR ; DUUUP ; DUUP; GET ;
IF_NONE { PUSH int 0 } {} ; IF_NONE { PUSH int 0 } {} ;
SWAP ; DIP { ADD ; SOME } ; SWAP ; DIP { ADD ; SOME } ;
UPDATE } ; UPDATE } ;
PAIR ; UNIT ; PAIR } PAIR ; NIL operation ; PAIR }

View File

@ -1,7 +1,6 @@
parameter nat; parameter nat;
return (list nat); storage (list nat);
storage unit;
code { CAR @counter; NIL @acc nat; SWAP; DUP @cmp_num; PUSH nat 0; CMPNEQ; code { CAR @counter; NIL @acc nat; SWAP; DUP @cmp_num; PUSH nat 0; CMPNEQ;
LOOP { DUP; DIP {SWAP}; CONS @acc; SWAP; PUSH nat 1; SWAP; SUB @counter; LOOP { DUP; DIP {SWAP}; CONS @acc; SWAP; PUSH nat 1; SWAP; SUB @counter;
DUP; DIP{ABS}; PUSH int 0; CMPNEQ}; DUP; DIP{ABS}; PUSH int 0; CMPNEQ};
CONS; UNIT; SWAP; PAIR}; CONS; NIL operation; PAIR};

View File

@ -1,4 +1,3 @@
parameter (pair (pair unit (string @no_name)) bool); parameter (pair (pair unit (string @no_name)) bool);
storage unit; storage unit;
return unit; code { CAR @name; CADR @second_name; DROP; UNIT; NIL operation; PAIR }
code { CAR @name; CADR @second_name; DROP; UNIT; UNIT; PAIR }

View File

@ -1,7 +1,8 @@
parameter key; parameter key;
storage (pair signature string); storage (pair signature string);
return bool;
code { DUP; DUP; code { DUP; DUP;
DIP{ CDR; DUP; CAR; DIP{ CDR; DUP; CAR;
DIP{CDR; H}; PAIR}; DIP{CDR; H}; PAIR};
CAR; CHECK_SIGNATURE; DIP{CDR}; PAIR}; CAR; CHECK_SIGNATURE;
IF {} {FAIL} ;
CDR; NIL operation ; PAIR};

View File

@ -1,10 +1,9 @@
parameter (pair tez tez); parameter (pair tez tez);
return (list bool); storage (list bool);
storage unit;
code {CAR; DUP; DUP; DUP; DUP; DIIIIIP {NIL bool}; code {CAR; DUP; DUP; DUP; DUP; DIIIIIP {NIL bool};
DIIIIP {DUP; CAR; DIP {CDR}; COMPARE; LE; CONS}; DIIIIP {DUP; CAR; DIP {CDR}; COMPARE; LE; CONS};
DIIIP {DUP; CAR; DIP {CDR}; COMPARE; GE; CONS}; DIIIP {DUP; CAR; DIP {CDR}; COMPARE; GE; CONS};
DIIP{DUP; CAR; DIP {CDR}; COMPARE; LT; CONS}; DIIP{DUP; CAR; DIP {CDR}; COMPARE; LT; CONS};
DIP {DUP; CAR; DIP {CDR}; COMPARE; GT; CONS}; DIP {DUP; CAR; DIP {CDR}; COMPARE; GT; CONS};
DUP; CAR; DIP {CDR}; COMPARE; EQ; CONS; DUP; CAR; DIP {CDR}; COMPARE; EQ; CONS;
UNIT; SWAP; PAIR}; NIL operation; PAIR};

View File

@ -1,11 +1,8 @@
parameter string; parameter string;
storage string; storage string;
return string;
code {DUP; # We're going to need both the storage and parameter code {DUP; # We're going to need both the storage and parameter
CAR; # Get the parameter CAR; # Get the parameter
DIP{CDR; # Get the storage value DIP{CDR}; # Get the storage value
DUP}; # We need to replace it in the storage, so we dup it
SWAP; # Get the order we want (this is optional) SWAP; # Get the order we want (this is optional)
CONCAT; # Concatenate the strings CONCAT; # Concatenate the strings
PAIR} # Pair them up, matching the calling convention NIL operation; PAIR} # Match the calling convention

View File

@ -1,5 +1,4 @@
parameter (list string); parameter (list string);
return (list string); storage (list string);
storage unit;
code{ CAR; LAMBDA string string { PUSH @hello string "Hello "; CONCAT }; code{ CAR; LAMBDA string string { PUSH @hello string "Hello "; CONCAT };
MAP; UNIT; SWAP; PAIR}; MAP; NIL operation; PAIR};

View File

@ -1,6 +1,5 @@
parameter (list string); parameter (list string);
return string; storage string;
storage unit;
code {CAR; PUSH string ""; SWAP; code {CAR; PUSH string ""; SWAP;
LAMBDA (pair string string) string {DUP; CDR; DIP{CAR}; CONCAT}; LAMBDA (pair string string) string {DUP; CDR; DIP{CAR}; CONCAT};
REDUCE; UNIT; SWAP; PAIR}; REDUCE; NIL operation; PAIR};

View File

@ -1,11 +1,9 @@
parameter (or string (option int)); parameter (or string (option int));
storage unit; storage string;
return string;
code { CAR; # Access the storage code { CAR; # Access the storage
IF_LEFT {} # The string is on top of the stack, nothing to do IF_LEFT {} # The string is on top of the stack, nothing to do
{ IF_NONE { FAIL} # Fail if None { IF_NONE { FAIL} # Fail if None
{ PUSH int 0; CMPGT; # Check for negative number { PUSH int 0; CMPGT; # Check for negative number
IF {FAIL} # Fail if negative IF {FAIL} # Fail if negative
{PUSH string ""}}}; # Push the empty string {PUSH string ""}}}; # Push the empty string
UNIT; SWAP; PAIR} # Calling convention NIL operation; PAIR} # Calling convention

View File

@ -1,12 +1,9 @@
parameter nat; parameter nat;
storage (list nat); storage (list nat);
return unit;
code { DUP; # Duplicate the storage and parameter code { DUP; # Duplicate the storage and parameter
CAR; # Extract the parameter CAR; # Extract the parameter
DIP{CDR}; # Extract the storage DIP{CDR}; # Extract the storage
DUP; # Duplicate the parameter DUP; # Duplicate the parameter
DIP{CONS}; # Add the first instance of the parameter to the list DIP{CONS}; # Add the first instance of the parameter to the list
CONS; # Add the second instance of the parameter to the list CONS; # Add the second instance of the parameter to the list
PUSH unit Unit; # Put the value Unit on the stack (calling convention) NIL operation; PAIR} # Finish the calling convention
PAIR} # Finish the calling convention

View File

@ -1,10 +1,9 @@
parameter (pair (list string) (list string)); parameter (pair (list string) (list string));
storage unit; storage (option bool);
return bool;
code {CAR; DUP; CAR; DIP{CDR}; EMPTY_SET string; SWAP; code {CAR; DUP; CAR; DIP{CDR}; EMPTY_SET string; SWAP;
LAMBDA (pair string (set string)) (set string) {DUP; CAR; DIP{CDR}; PUSH bool True; SWAP; UPDATE}; LAMBDA (pair string (set string)) (set string) {DUP; CAR; DIP{CDR}; PUSH bool True; SWAP; UPDATE};
REDUCE; PUSH bool True; SWAP; PAIR; SWAP; REDUCE; PUSH bool True; SWAP; PAIR; SWAP;
LAMBDA (pair string (pair (set string) bool)) LAMBDA (pair string (pair (set string) bool))
(pair (set string) bool) (pair (set string) bool)
{DUP; DUP; CAR; DIP{CDAR; DIP{CDDR}; DUP}; MEM; DIP{SWAP}; AND; SWAP; PAIR}; {DUP; DUP; CAR; DIP{CDAR; DIP{CDDR}; DUP}; MEM; DIP{SWAP}; AND; SWAP; PAIR};
REDUCE; CDR; UNIT; SWAP; PAIR}; REDUCE; CDR; SOME; NIL operation; PAIR};

View File

@ -0,0 +1,16 @@
storage nat ;
parameter nat ;
code { UNPAIR ;
DIP { SELF ; ADDRESS ; SOURCE;
IFCMPEQ {} { DROP ; PUSH @storage nat 1 } };
DUP ;
PUSH nat 1 ;
IFCMPGE
{ DROP ; NIL operation ; PAIR }
{ PUSH nat 1 ; SWAP ; SUB @parameter ; ISNAT ;
IF_NONE
{ NIL operation ; PAIR }
{ DUP ; DIP { PUSH nat 1 ; ADD ; MUL @storage } ; SWAP;
DIP { DIP { PUSH nat 4000 ; SELF; PUSH tez "0" } ;
TRANSFER_TOKENS ; NIL operation ; SWAP ; CONS } ;
SWAP ; PAIR } } }

View File

@ -1,5 +1,4 @@
parameter key_hash; parameter key_hash;
return unit; storage (contract unit);
storage (contract unit unit);
code {CAR; DIP{PUSH tez "100.00"; PUSH bool False; NONE key_hash}; code {CAR; DIP{PUSH tez "100.00"; PUSH bool False; NONE key_hash};
CREATE_ACCOUNT; UNIT; PAIR}; CREATE_ACCOUNT; NIL operation; PAIR};

View File

@ -1,15 +1,13 @@
parameter unit; parameter unit;
return (contract (list int) (list int)); storage (contract (list int));
storage unit; code { DROP; NIL int; # starting storage for contract
code { CAR; # Get the UNIT value (starting storage for contract) LAMBDA (pair (list int) (list int)) # Start of stack for contract (see above)
LAMBDA (pair (list int) unit) # Start of stack for contract (see above) (pair (list operation) (list int)) # End of stack for contract (see above)
(pair (list int) unit) # End of stack for contract (see above)
# See the contract above. I copied and pasted # See the contract above. I copied and pasted
{ CAR; { CAR;
LAMBDA int int {PUSH int 1; ADD}; LAMBDA int int {PUSH int 1; ADD};
MAP; MAP;
UNIT; NIL operation;
SWAP;
PAIR }; PAIR };
AMOUNT; # Push the starting balance AMOUNT; # Push the starting balance
PUSH bool False; # Not spendable PUSH bool False; # Not spendable
@ -17,6 +15,4 @@ code { CAR; # Get the UNIT value (starting storage for cont
NONE key_hash; # No delegate NONE key_hash; # No delegate
PUSH key_hash "tz1cxcwwnzENRdhe2Kb8ZdTrdNy4bFNyScx5"; PUSH key_hash "tz1cxcwwnzENRdhe2Kb8ZdTrdNy4bFNyScx5";
CREATE_CONTRACT; # Create the contract CREATE_CONTRACT; # Create the contract
UNIT; # Ending calling convention stuff NIL operation; PAIR} # Ending calling convention stuff
SWAP;
PAIR}

View File

@ -1,13 +1,12 @@
parameter key_hash; parameter key_hash;
storage string; storage string;
return unit;
code {CAR; code {CAR;
DIP{UNIT; DIP{PUSH string "dummy";
LAMBDA (pair string unit) LAMBDA (pair string string)
(pair string unit) (pair (list operation) string)
{CAR; UNIT; SWAP; PAIR}; {CAR; NIL operation; PAIR};
PUSH tez "100.00"; PUSH bool False; PUSH tez "100.00"; PUSH bool False;
PUSH bool False; NONE key_hash}; PUSH bool False; NONE key_hash};
CREATE_CONTRACT; DIP{PUSH string ""}; PUSH tez "0.00"; CREATE_CONTRACT; DIP{PUSH string ""}; PUSH tez "0.00";
PUSH string "abcdefg"; TRANSFER_TOKENS; PUSH string "abcdefg"; TRANSFER_TOKENS;
DIP{DROP}; UNIT; PAIR}; NIL operation; SWAP; CONS; PAIR};

View File

@ -1,14 +1,12 @@
parameter key_hash; parameter key_hash;
storage string; storage unit;
return unit;
code { CAR; code { CAR;
DIP { UNIT; DIP { PUSH string "dummy";
PUSH tez "100.00"; PUSH bool False; PUSH tez "100.00"; PUSH bool False;
PUSH bool False; NONE key_hash }; PUSH bool False; NONE key_hash };
CREATE_CONTRACT { parameter string ; CREATE_CONTRACT { parameter string ;
storage unit ; storage string ;
return string ; code {CAR; NIL operation; PAIR } } ;
code {CAR; UNIT; SWAP; PAIR } } ;
DIP{PUSH string ""}; PUSH tez "0.00"; DIP{PUSH string ""}; PUSH tez "0.00";
PUSH string "abcdefg"; TRANSFER_TOKENS; PUSH string "abcdefg"; TRANSFER_TOKENS;
DIP{DROP}; UNIT; PAIR}; DIP{DROP}; NIL operation; SWAP; CONS; UNIT; SWAP; PAIR};

View File

@ -1,15 +1,8 @@
parameter (pair signature (pair string nat));
# NONE if user wants to get the value
# SOME (signed hash of the string, string)
parameter (option (pair signature (pair string nat)));
return string;
storage (pair (pair key nat) string); storage (pair (pair key nat) string);
code { DUP; CAR; DIP{CDR; DUP}; code { DUP; CAR; DIP{CDR; DUP};
IF_NONE { AMOUNT; PUSH tez "1.00"; # The fee I'm charging for queries SWAP; DIP{DUP}; CAAR; DIP{DUP; CAR; DIP{CDR; H}; PAIR};
CMPLE; IF {} {FAIL}; CHECK_SIGNATURE;
CDR; PAIR} IF { CDR; DUP; DIP{CAR; DIP{CAAR}}; CDR; PUSH nat 1; ADD;
{ SWAP; DIP{DUP}; CAAR; DIP{DUP; CAR; DIP{CDR; H}; PAIR}; DIP{SWAP}; SWAP; PAIR; PAIR; NIL operation; PAIR}
CHECK_SIGNATURE; {FAIL}}
IF { CDR; DUP; DIP{CAR; DIP{CAAR}}; CDR; PUSH nat 1; ADD;
DIP{SWAP}; SWAP; PAIR; PAIR; PUSH string ""; PAIR}
{FAIL}}}

View File

@ -1,5 +1,5 @@
parameter key_hash; parameter key_hash;
return unit;
storage unit; storage unit;
code {DIP{UNIT}; CAR; IMPLICIT_ACCOUNT; code {DIP{UNIT}; CAR; IMPLICIT_ACCOUNT;
PUSH tez "100.00"; UNIT; TRANSFER_TOKENS; PAIR} PUSH tez "100.00"; UNIT; TRANSFER_TOKENS;
NIL operation; SWAP; CONS; PAIR}

View File

@ -1,4 +1,3 @@
parameter (pair timestamp timestamp); parameter (pair timestamp timestamp);
return int; storage int;
storage unit; code { CAR; DUP; CAR; DIP{CDR}; SUB; NIL operation; PAIR }
code { CAR; DUP; CAR; DIP{CDR}; SUB; UNIT; SWAP; PAIR }

View File

@ -1,9 +1,9 @@
parameter (or string (pair string (lambda unit string))); parameter (or string (pair string (lambda unit string)));
return string; storage (pair string (map string (lambda unit string)));
storage (map string (lambda unit string)); code { DUP; DIP{CDDR}; CAR; # Unpack stack
code { DUP; DIP{CDR}; CAR; # Unpack stack
IF_LEFT { DIP{DUP}; GET; # Get lambda if it exists IF_LEFT { DIP{DUP}; GET; # Get lambda if it exists
IF_NONE {FAIL} {}; # Fail if it doesn't IF_NONE {FAIL} {}; # Fail if it doesn't
UNIT; EXEC } # Execute the lambda UNIT; EXEC } # Execute the lambda
{ DUP; CAR; DIP {CDR; SOME}; UPDATE; PUSH string ""}; # Update the storage { DUP; CAR; DIP {CDR; SOME}; UPDATE; PUSH string ""}; # Update the storage
PAIR} # Calling convention PAIR;
NIL operation; PAIR} # Calling convention

View File

@ -1,5 +1,3 @@
parameter unit; parameter unit;
storage unit; storage unit;
return unit; code {CDR; NIL operation; PAIR}
code {}

View File

@ -1,7 +1,6 @@
storage unit; storage (map string string);
return (map string string);
parameter unit; parameter unit;
code {DROP; code {DROP;
EMPTY_MAP string string; EMPTY_MAP string string;
PUSH string "world"; SOME; PUSH string "hello"; UPDATE; PUSH string "world"; SOME; PUSH string "hello"; UPDATE;
UNIT; SWAP; PAIR}; NIL operation; PAIR};

View File

@ -1,6 +1,5 @@
parameter string; parameter string;
return string; storage string;
storage unit;
code {CAR; code {CAR;
LAMBDA string string {PUSH string "_abc"; SWAP; CONCAT}; LAMBDA string string {PUSH string "_abc"; SWAP; CONCAT};
SWAP; EXEC; UNIT; SWAP; PAIR}; SWAP; EXEC; NIL operation; PAIR};

View File

@ -1,6 +1,5 @@
parameter unit; parameter unit;
storage unit;
code code
{ # This contract will never accept a incoming transaction { # This contract will never accept a incoming transaction
FAIL}; FAIL};
return unit;
storage unit;

View File

@ -1,5 +1,6 @@
# Fail if the amount transferred is less than 10 # Fail if the amount transferred is less than 10
parameter unit; parameter unit;
storage unit; storage unit;
return unit; code { DROP;
code {AMOUNT; PUSH tez "10"; CMPGT; IF {FAIL} {}} AMOUNT; PUSH tez "10"; CMPGT; IF {FAIL} {};
UNIT; NIL operation; PAIR}

View File

@ -1,4 +1,3 @@
parameter (list nat); parameter (list nat);
return nat; storage nat;
storage unit; code{CAR; IF_CONS {DIP{DROP}} {FAIL}; NIL operation; PAIR};
code{CAR; IF_CONS {DIP{DROP}} {FAIL}; UNIT; SWAP; PAIR};

View File

@ -1,4 +1,3 @@
parameter string; parameter string;
storage (map string string); storage (pair (option string) (map string string));
return (option string); code {DUP; CAR; DIP{CDDR; DUP}; GET; PAIR; NIL operation; PAIR};
code {DUP; CAR; DIP{CDR; DUP}; GET; PAIR};

View File

@ -1,7 +1,5 @@
parameter unit ; parameter unit ;
code storage int ;
{ # This contract stops accepting transactions after N incoming transactions code { # This contract stops accepting transactions after N incoming transactions
CDR ; DUP ; PUSH int 0 ; CMPLT; IF {PUSH int -1 ; ADD} {FAIL}; CDR ; DUP ; PUSH int 0 ; CMPLT; IF {PUSH int -1 ; ADD} {FAIL};
UNIT; PAIR} ; NIL operation ; PAIR} ;
return unit ;
storage int

View File

@ -1,4 +1,3 @@
parameter (pair tez (pair timestamp int)) ; parameter (pair tez (pair timestamp int)) ;
return string ; storage string ;
storage unit ; code { CAR ; H ; NIL operation ; PAIR }
code { CAR ; H ; UNIT ; SWAP ; PAIR }

View File

@ -1,4 +1,3 @@
parameter key; parameter key;
return key_hash; storage (option key_hash);
storage unit; code {CAR; HASH_KEY; SOME ;NIL operation; PAIR}
code {CAR; HASH_KEY; DIP{UNIT}; PAIR}

View File

@ -1,4 +1,3 @@
parameter string; parameter string;
return string; storage string;
storage unit; code {CAR; H; NIL operation; PAIR};
code {CAR; H; UNIT; SWAP; PAIR};

View File

@ -1,5 +1,3 @@
parameter string; parameter string;
return string; storage string;
storage unit; code {CAR; NIL operation; PAIR};
code {};

View File

@ -1,4 +1,3 @@
parameter bool; parameter bool;
storage unit; storage (option bool);
return bool; code {CAR; IF {PUSH bool True} {PUSH bool False}; SOME; NIL operation; PAIR};
code {CAR; IF {PUSH bool True} {PUSH bool False}; UNIT; SWAP; PAIR};

View File

@ -1,4 +1,3 @@
parameter (option string); parameter (option string);
return string; storage string;
storage unit; code { CAR; IF_SOME {} {PUSH string ""}; NIL operation; PAIR}
code { CAR; IF_SOME {} {PUSH string ""}; UNIT; SWAP; PAIR}

View File

@ -1,4 +1,3 @@
parameter unit; parameter unit;
storage unit; storage unit;
return unit; code { DROP; PUSH bool True; LOOP {PUSH bool True}; UNIT; NIL operation; PAIR }
code { DROP; PUSH bool True; LOOP {PUSH bool True}; UNIT; UNIT; PAIR }

View File

@ -1,7 +1,5 @@
parameter (list int); parameter (list int);
return (list int); storage (list int);
storage unit;
code { CAR; # Access list code { CAR; # Access list
# Insert procedure # Insert procedure
LAMBDA (pair int (list int)) LAMBDA (pair int (list int))
@ -23,5 +21,5 @@ code { CAR; # Access list
{DUP; CAR; DIP{CDR}; CONS}; {DUP; CAR; DIP{CDR}; CONS};
REDUCE}; REDUCE};
NIL int; SWAP; DIP{SWAP}; # Accumulator for reverse onto NIL int; SWAP; DIP{SWAP}; # Accumulator for reverse onto
REDUCE; # Execute reverse onto REDUCE; # Execute reverse onto
UNIT; SWAP; PAIR} # Calling convention NIL operation; PAIR} # Calling convention

View File

@ -1,9 +1,5 @@
# NONE if user wants to get the value # (signed hash of the string, string)
# SOME (signed hash of the string, string)
parameter (option (pair signature int)); parameter (option (pair signature int));
return int;
# The key used to update the contract
# The data
storage (pair key int); storage (pair key int);
code {DUP; DUP; CAR; code {DUP; DUP; CAR;
IF_NONE {PUSH tez "1.00"; # Fee pattern from July 26 IF_NONE {PUSH tez "1.00"; # Fee pattern from July 26
@ -18,4 +14,4 @@ code {DUP; DUP; CAR;
# Revert the update. This could be replaced with FAIL # Revert the update. This could be replaced with FAIL
{DROP; DUP; CDR; DIP{CDDR}}}; {DROP; DUP; CDR; DIP{CDDR}}};
# Cleanup # Cleanup
SWAP; PAIR} DIP{DROP}; NIL operation; PAIR}

View File

@ -1,11 +1,11 @@
parameter key_hash; parameter key_hash;
storage (pair timestamp (pair tez key_hash)); storage (pair timestamp (pair tez key_hash));
return unit;
code { DUP; CDAR; code { DUP; CDAR;
# If the time is more than 2 weeks, any amount makes you king # If the time is more than 2 weeks, any amount makes you king
NOW; CMPGT; NOW; CMPGT;
# User becomes king of tez # User becomes king of tez
IF { CAR; AMOUNT; PAIR; NOW; PUSH int 604800; ADD; PAIR } IF { CAR; AMOUNT; PAIR; NOW; PUSH int 604800; ADD; PAIR;
NIL operation }
# Check balance to see if user has paid enough to become the new king # Check balance to see if user has paid enough to become the new king
{ DUP; CDDAR; AMOUNT; CMPLT; { DUP; CDDAR; AMOUNT; CMPLT;
IF { FAIL } # user has not paid out IF { FAIL } # user has not paid out
@ -13,6 +13,7 @@ code { DUP; CDAR;
# New storage # New storage
DIP{ AMOUNT; PAIR; NOW; PUSH int 604800; ADD; PAIR }; DIP{ AMOUNT; PAIR; NOW; PUSH int 604800; ADD; PAIR };
# Pay funds to old king # Pay funds to old king
IMPLICIT_ACCOUNT; AMOUNT; UNIT; TRANSFER_TOKENS; DROP }}; IMPLICIT_ACCOUNT; AMOUNT; UNIT; TRANSFER_TOKENS;
NIL operation; SWAP; CONS}};
# Cleanup # Cleanup
UNIT; PAIR }; PAIR };

View File

@ -1,4 +1,3 @@
parameter (list string); parameter (list string);
return (list string); storage (list string);
storage unit; code {CAR; NIL operation; PAIR}
code {}

View File

@ -1,4 +1,3 @@
parameter (list string); parameter (list string);
return (list string); storage (list string);
storage unit; code {CAR; LAMBDA string string {}; MAP; NIL operation; PAIR}
code {CAR; LAMBDA string string {}; MAP; UNIT; SWAP; PAIR}

View File

@ -1,6 +1,5 @@
parameter (list int); parameter (list int);
storage unit; storage int;
return int;
code { CAR; PUSH int 1; SWAP; code { CAR; PUSH int 1; SWAP;
ITER { MUL }; ITER { MUL };
UNIT; SWAP; PAIR} NIL operation; PAIR}

View File

@ -1,6 +1,5 @@
parameter (list string); parameter (list string);
return string; storage string;
storage unit;
code { CAR; PUSH string ""; SWAP; code { CAR; PUSH string ""; SWAP;
ITER { CONCAT }; ITER { CONCAT };
UNIT; SWAP; PAIR} NIL operation; PAIR}

View File

@ -1,6 +1,5 @@
parameter (list int); parameter (list int);
return (list int); storage (list int);
storage unit;
code { CAR; PUSH int 0; SWAP; code { CAR; PUSH int 0; SWAP;
MAP { DIP{DUP}; ADD; DIP{PUSH int 1; ADD}}; MAP { DIP{DUP}; ADD; DIP{PUSH int 1; ADD}};
UNIT; SWAP; PAIR; DIP{DROP}} NIL operation; PAIR; DIP{DROP}}

View File

@ -1,9 +1,8 @@
parameter unit; parameter unit;
storage (list (contract unit unit)); storage (list (contract unit));
return unit; code { CDR; DUP;
code { CDR; PUSH bool True; # Setup loop DIP {NIL operation}; PUSH bool True; # Setup loop
LOOP {IF_CONS { PUSH tez "1.00"; UNIT; TRANSFER_TOKENS; # Make transfer LOOP {IF_CONS { PUSH tez "1.00"; UNIT; TRANSFER_TOKENS; # Make transfer
DROP; PUSH bool True} # Setup for next round of loop SWAP; DIP {CONS}; PUSH bool True} # Setup for next round of loop
{ NIL (contract unit unit); PUSH bool False}}; # Data to satisfy types and end loop { NIL (contract unit); PUSH bool False}}; # Data to satisfy types and end loop
UNIT; PAIR}; # Calling convention DROP; PAIR}; # Calling convention

View File

@ -1,6 +1,5 @@
parameter unit; parameter unit;
storage (pair timestamp (pair tez (contract unit unit))); storage (pair timestamp (pair tez (contract unit)));
return unit;
code { CDR; # Ignore the parameter code { CDR; # Ignore the parameter
DUP; # Duplicate the storage DUP; # Duplicate the storage
CAR; # Get the timestamp CAR; # Get the timestamp
@ -14,5 +13,6 @@ code { CDR; # Ignore the parameter
CAR; # Get the amount of the transfer on top of the stack CAR; # Get the amount of the transfer on top of the stack
DIP{CDR}; # Put the contract underneath it DIP{CDR}; # Put the contract underneath it
UNIT; # Put the contract's argument type on top of the stack UNIT; # Put the contract's argument type on top of the stack
TRANSFER_TOKENS; # Make the transfer TRANSFER_TOKENS; # Emit the transfer
NIL operation; SWAP; CONS;# Make a singleton list of internal operations
PAIR} # Pair up to meet the calling convention PAIR} # Pair up to meet the calling convention

View File

@ -1,8 +1,7 @@
parameter (list string); parameter (list string);
return (list string); storage (list string);
storage unit;
code { CAR; NIL string; SWAP; PAIR; LEFT (list string); code { CAR; NIL string; SWAP; PAIR; LEFT (list string);
LOOP_LEFT { DUP; CAR; DIP{CDR}; LOOP_LEFT { DUP; CAR; DIP{CDR};
IF_CONS { SWAP; DIP{CONS}; PAIR; LEFT (list string) } IF_CONS { SWAP; DIP{CONS}; PAIR; LEFT (list string) }
{ RIGHT (pair (list string) (list string)) }; }; { RIGHT (pair (list string) (list string)) }; };
UNIT; SWAP; PAIR } NIL operation; PAIR }

View File

@ -1,6 +1,6 @@
return unit;
parameter unit; parameter unit;
storage unit; storage (pair @truc unit unit);
code { PUSH unit Unit ; code { DROP; UNIT ; UNIT ; PAIR ; UNIT ;
DUUP @truc ; DUUP @truc ;
DROP ; DROP } DIP { DROP ; DROP } ;
NIL operation ; PAIR }

View File

@ -1,4 +1,4 @@
parameter unit; parameter unit;
storage (pair (pair nat (pair nat (pair (pair (pair nat tez) nat) nat))) nat); storage (pair (pair nat (pair nat (pair (pair (pair nat tez) nat) nat))) nat);
return unit; code { MAP_CDADDAADR { PUSH tez "1.00" ; ADD } ;
code { MAP_CDADDAADR { PUSH tez "1.00" ; ADD } }; NIL operation ; SWAP; SET_CAR };

View File

@ -1,4 +1,3 @@
parameter bool; parameter bool;
storage (pair bool nat); storage (pair bool nat);
return unit; code { DUP; CAR; DIP{CDR}; SWAP; MAP_CAR { AND }; NIL operation; PAIR };
code { DUP; CAR; DIP{CDR}; SWAP; MAP_CAR { AND } ; UNIT; PAIR };

View File

@ -1,4 +1,3 @@
parameter (map nat nat); parameter (map nat nat);
return (map nat nat); storage (map nat nat);
storage unit; code { CAR ; NIL operation ; PAIR }
code {}

View File

@ -1,7 +1,6 @@
parameter (map int int); parameter (map int int);
return (pair int int); storage (pair int int);
storage unit;
code { CAR; PUSH int 0; DUP; PAIR; SWAP; code { CAR; PUSH int 0; DUP; PAIR; SWAP;
ITER { DIP {DUP; CAR; DIP{CDR}}; DUP; # Last instr ITER { DIP {DUP; CAR; DIP{CDR}}; DUP; # Last instr
DIP{CAR; ADD}; SWAP; DIP{CDR; ADD}; PAIR }; DIP{CAR; ADD}; SWAP; DIP{CDR; ADD}; PAIR };
UNIT; SWAP; PAIR} NIL operation; PAIR}

View File

@ -1,4 +1,3 @@
parameter (map string nat); parameter (map string nat);
return nat; storage nat;
storage unit; code {CAR; SIZE; NIL operation; PAIR}
code {CAR; SIZE; UNIT; SWAP; PAIR}

View File

@ -1,10 +1,9 @@
parameter (list int); parameter (list int);
storage unit; storage (option int);
return (option int);
code {CAR; DIP{NONE int}; code {CAR; DIP{NONE int};
LAMBDA LAMBDA
(pair int (option int)) (pair int (option int))
(option int) (option int)
{DUP; DUP; CAR; SWAP; CDR; {DUP; DUP; CAR; SWAP; CDR;
IF_NONE {DIP{DROP}; SOME} {CMPGT; IF {CDR} {CAR; SOME}}}; IF_NONE {DIP{DROP}; SOME} {CMPGT; IF {CDR} {CAR; SOME}}};
REDUCE; UNIT; SWAP; PAIR}; REDUCE; NIL operation; PAIR};

View File

@ -1,13 +1,11 @@
parameter (pair int int); parameter (pair int int);
return int; storage int;
storage unit;
code { CAR; # Ignore the storage code { CAR; # Ignore the storage
DUP; # Duplicate so we can get both the numbers passed as parameters DUP; # Duplicate so we can get both the numbers passed as parameters
DUP; # Second dup so we can access the lesser number DUP; # Second dup so we can access the lesser number
CAR; DIP{CDR}; # Unpack the numbers on top of the stack CAR; DIP{CDR}; # Unpack the numbers on top of the stack
CMPLT; # Compare the two numbers, placing a boolean on top of the stack CMPLT; # Compare the two numbers, placing a boolean on top of the stack
IF {CAR} {CDR}; # Access the first number if the boolean was true IF {CAR} {CDR}; # Access the first number if the boolean was true
UNIT; # Push storage value NIL operation; # Return no op
SWAP; # Correct order for calling convention pair
PAIR} # Pair the numbers satisfying the calling convention PAIR} # Pair the numbers satisfying the calling convention

View File

@ -1,4 +1,3 @@
parameter unit; parameter unit;
code {};
return unit;
storage unit; storage unit;
code {CDR; NIL operation; PAIR};

View File

@ -1,4 +1,3 @@
parameter bool; parameter bool;
return bool; storage (option bool);
storage unit; code {CAR; NOT; SOME; NIL operation; PAIR};
code {CAR; NOT; UNIT; SWAP; PAIR};

View File

@ -1,5 +1,3 @@
parameter (pair bool bool); parameter (pair bool bool);
return bool; storage (option bool);
storage unit; code {CAR; DUP; CAR; SWAP; CDR; OR; SOME; NIL operation; PAIR};
code {CAR; DUP; CAR; SWAP; CDR; OR;
UNIT; SWAP; PAIR};

View File

@ -1,9 +1,8 @@
storage unit ;
parameter nat ; parameter nat ;
return (list (contract unit unit)) ; storage (list (contract unit)) ;
code code
{ CAR ; DUP ; PUSH nat 0 ; CMPNEQ ; { CAR ; DUP ; PUSH nat 0 ; CMPNEQ ;
DIIP { NIL (contract unit unit) } ; DIIP { NIL (contract unit) } ;
LOOP LOOP
{ PUSH tez "5.00" ; { PUSH tez "5.00" ;
PUSH bool True ; # delegatable PUSH bool True ; # delegatable
@ -14,4 +13,4 @@ code
PUSH nat 1 ; SWAP ; SUB ; ABS ; PUSH nat 1 ; SWAP ; SUB ; ABS ;
DUP ; PUSH nat 0 ; CMPNEQ } ; DUP ; PUSH nat 0 ; CMPNEQ } ;
DROP ; DROP ;
UNIT ; SWAP ; PAIR } NIL operation ; PAIR }

View File

@ -1,4 +1,3 @@
parameter (pair bool bool); parameter (pair bool bool);
return (pair bool bool); storage (option (pair bool bool));
storage unit; code {CAR; SOME; NIL operation; PAIR}
code {}

View File

@ -1,4 +1,4 @@
parameter unit; parameter unit;
return unit;
storage unit; storage unit;
code { UNIT; UNIT; UNIT; UNIT; UNIT; PAIAAIAIAIR @name; DROP} code { UNIT; UNIT; UNIT; UNIT; UNIT; PAIAAIAIAIR @name; DROP;
CDR; NIL operation; PAIR}

View File

@ -1,26 +0,0 @@
parameter (or (pair string (pair tez (contract unit unit))) nat);
return unit;
storage (pair (contract nat (pair nat bool)) (pair nat (map nat (pair string (pair tez (contract unit unit))))));
code { DUP; DIP{CDR}; CAR; # Get the input while preserving the output
IF_LEFT { DIP{ DUP; CAR; SWAP; CDR; DUP; CAR; DIP{CDR}};
SOME; SWAP; DUP; DIP{UPDATE}; # Add the element to the map
PUSH nat 1; ADD; PAIR; SWAP; # Add 1 to the index
PAIR; UNIT; PAIR} # Cleanup and finish
# Check our other contract to see if the transaction is allowed
{ DIP{DUP; CAR}; PUSH tez "0.00"; SWAP; TRANSFER_TOKENS;
# Arrange the stack
DUP; CDR;
IF { CAR; DUP; DIIP{DUP; CDDR; DUP};
DIP{ GET; # Get the value of the data
IF_NONE {FAIL} {}; # This should not happen
SWAP;
NONE (pair string (pair tez (contract unit unit)))};
UPDATE; # Delete the element
SWAP;
# More stack arranging
DIP{ SWAP; DUP; CAR; DIP{CDR}};
DIP{DIP{CAR; PAIR}; PAIR};
DUP; CDAR;
DIP{CDDR}; UNIT; TRANSFER_TOKENS; # Make the transfer
PAIR}
{ FAIL }}}

View File

@ -1,7 +1,6 @@
storage (pair (map nat (pair bool bool)) (pair key key)); storage (pair bool (pair (map nat (pair bool bool)) (pair key key)));
return bool;
parameter (or nat (pair signature nat)); parameter (or nat (pair signature nat));
code { DUP; CAR; DIP{CDR}; # Stack rangling code { DUP; CAR; DIP{CDDR}; # Stack rangling
IF_LEFT { DIP{DUP; CAR}; GET; # Get the value stored for that index IF_LEFT { DIP{DUP; CAR}; GET; # Get the value stored for that index
IF_NONE { PUSH bool False} # If not referenced, reject IF_NONE { PUSH bool False} # If not referenced, reject
{ DUP; CAR; DIP{CDR}; AND}; { DUP; CAR; DIP{CDR}; AND};
@ -21,4 +20,5 @@ code { DUP; CAR; DIP{CDR}; # Stack rangling
CAR; PUSH bool True; SWAP; PAIR; SOME; SWAP} CAR; PUSH bool True; SWAP; PAIR; SOME; SWAP}
{FAIL}}; {FAIL}};
# Update the stored value and finish off # Update the stored value and finish off
UPDATE; PAIR; PUSH bool False; PAIR}} UPDATE; PAIR; PUSH bool False; PAIR};
NIL operation; PAIR }

View File

@ -1,17 +0,0 @@
parameter unit;
storage (option
(pair (pair (contract unit unit) (contract unit unit))
(pair (pair timestamp (contract (option (pair signature int)) int))
(pair tez int))));
return unit;
code { CDR; IF_NONE {FAIL} {}; # Check if settlement has already ocurred
DUP; CDAAR; NOW; CMPLT; IF {FAIL} {}; # Check the timestamp
DUP; CDADR; DIP{SOME}; PUSH tez "1.01"; NONE (pair signature int);
TRANSFER_TOKENS; DIP{IF_NONE{FAIL} {}};
DIP{DUP; CDDR; DUP; CDR}; CMPGT;
SWAP;
DIP{ IF {CAAR} {CADR};
DIP{ NONE (pair (pair (contract unit unit) (contract unit unit))
(pair (pair timestamp (contract (option (pair signature int)) int))
(pair tez int)))}};
CAR; UNIT; TRANSFER_TOKENS; PAIR}

View File

@ -1,9 +1,8 @@
parameter (option string); parameter (option string);
storage (pair (pair nat nat) (map nat string)); storage (pair (option string) (pair (pair nat nat) (map nat string)));
return (option string);
code { DUP; CAR; code { DUP; CAR;
# Retrieving an element # Retrieving an element
IF_NONE { CDR; DUP; CAR; DIP{CDR; DUP}; DUP; IF_NONE { CDDR; DUP; CAR; DIP{CDR; DUP}; DUP;
CAR; SWAP; DIP{GET}; # Check if an element is available CAR; SWAP; DIP{GET}; # Check if an element is available
SWAP; SWAP;
# Put NONE on stack and finish # Put NONE on stack and finish
@ -15,10 +14,11 @@ code { DUP; CAR;
DUP; CAR; PUSH nat 1; ADD; DIP{ CDR }; PAIR; PAIR}; DUP; CAR; PUSH nat 1; ADD; DIP{ CDR }; PAIR; PAIR};
PAIR }} PAIR }}
# Arrange the stack # Arrange the stack
{ DIP{DUP; CDAR; DIP{CDDR}; DUP}; SWAP; CAR; { DIP{DUP; CDDAR; DIP{CDDDR}; DUP}; SWAP; CAR;
# Add the element to the map # Add the element to the map
DIP{ SOME; SWAP; CDR; DUP; DIP{UPDATE}; DIP{ SOME; SWAP; CDR; DUP; DIP{UPDATE};
# Increment the second number # Increment the second number
PUSH nat 1; ADD}; PUSH nat 1; ADD};
# Cleanup and finish # Cleanup and finish
PAIR; PAIR; NONE string; PAIR }} PAIR; PAIR; NONE string; PAIR };
NIL operation; PAIR}

View File

@ -1,7 +1,6 @@
parameter (pair (lambda int int) (list int)); parameter (pair (lambda int int) (list int));
return (list int); storage (list int);
storage unit;
code { DIP{NIL int}; code { DIP{NIL int};
CAR; CAR;
DUP; DUP;
@ -19,4 +18,4 @@ code { DIP{NIL int};
(list int) (list int)
{DUP; CAR; DIP{CDR}; CONS}; {DUP; CAR; DIP{CDR}; CONS};
REDUCE; # Correct list order REDUCE; # Correct list order
UNIT; SWAP; PAIR} # Calling convention NIL operation; PAIR} # Calling convention

View File

@ -1,6 +1,7 @@
parameter unit; parameter unit;
storage (pair (contract unit unit) (contract unit unit)); storage (pair (contract unit) (contract unit));
return unit;
code { CDR; DUP; CAR; PUSH tez "5.00"; UNIT; code { CDR; DUP; CAR; PUSH tez "5.00"; UNIT;
TRANSFER_TOKENS; DROP; DUP; CDR; TRANSFER_TOKENS;
PUSH tez "5.00"; UNIT; TRANSFER_TOKENS; PAIR }; DIP {DUP; CDR;
PUSH tez "5.00"; UNIT; TRANSFER_TOKENS};
DIIP{NIL operation};DIP{CONS};CONS;PAIR};

View File

@ -1,4 +1,3 @@
parameter unit; parameter unit;
code {CAR; PUSH nat 300; PAIR}; storage (option nat);
return nat; code {DROP; PUSH nat 300; SOME; NIL operation; PAIR};
storage unit;

View File

@ -1,8 +1,7 @@
parameter (list string); parameter (list string);
storage unit; storage (list string);
return (list string);
code { CAR; NIL string; SWAP; code { CAR; NIL string; SWAP;
LAMBDA (pair string (list string)) LAMBDA (pair string (list string))
(list string) (list string)
{DUP; CAR; DIP{CDR}; CONS}; {DUP; CAR; DIP{CDR}; CONS};
REDUCE; UNIT; SWAP; PAIR}; REDUCE; NIL operation; PAIR};

View File

@ -1,6 +1,5 @@
parameter (list string); parameter (list string);
return (list string); storage (list string);
storage unit;
code { CAR; NIL string; SWAP; PUSH bool True; code { CAR; NIL string; SWAP; PUSH bool True;
LOOP { IF_CONS {SWAP; DIP{CONS}; PUSH bool True} {NIL string; PUSH bool False}}; LOOP { IF_CONS {SWAP; DIP{CONS}; PUSH bool True} {NIL string; PUSH bool False}};
DROP; UNIT; SWAP; PAIR} DROP; NIL operation; PAIR}

View File

@ -1,4 +1,3 @@
parameter unit ; parameter unit ;
storage (contract unit unit) ; storage (contract unit) ;
return unit ; code { DROP ; SELF ; NIL operation ; PAIR }
code { MAP_CDR { DROP ; SELF } }

View File

@ -1,6 +1,5 @@
parameter tez; parameter tez;
storage (pair (pair nat (pair nat (pair (pair (pair nat tez) nat) nat))) nat); storage (pair (pair nat (pair nat (pair (pair (pair nat tez) nat) nat))) nat);
return unit;
code { DUP ; CAR ; SWAP ; CDR ; code { DUP ; CAR ; SWAP ; CDR ;
SET_CADDAADR @annot ; SET_CADDAADR @annot ;
UNIT ; PAIR }; NIL operation ; PAIR };

View File

@ -1,4 +1,3 @@
parameter string; parameter string;
storage (pair string nat); storage (pair string nat);
return (pair string nat); code { DUP; CDR; DIP{CAR}; SET_CAR @hello; NIL operation; PAIR };
code { DUP; CDR; DIP{CAR}; SET_CAR @hello; DUP; PAIR };

Some files were not shown because too many files have changed in this diff Show More