Commit 702896f4 authored by Benjamin Canou's avatar Benjamin Canou Committed by Grégoire Henry

Michelson: switch string tez constants to int mutez constants

parent ffec060a
# This is a very simple accounts system.
# (Left key) initializes or deposits into an account
# (Right key (pair tez (signed tez))) withdraws tez amount to a
# (Right key (pair mutez (signed mutez))) withdraws mutez amount to a
# IMPLICIT_ACCOUNT created from the key if the balance is available
# and the key is correctly signed
parameter (or key_hash (pair key (pair tez signature)));
parameter (or key_hash (pair key (pair mutez signature)));
# Maps the key to the balance they have stored
storage (map key_hash tez);
storage (map key_hash mutez);
code { DUP; CAR;
# Deposit into account
IF_LEFT { DUP; DIIP{ CDR; DUP };
......@@ -30,8 +30,8 @@ code { DUP; CAR;
IF { FAIL }
{ SUB; DIP{ DUP; DIP{ SWAP }}; DUP;
# Delete account if balance is 0
PUSH tez "0.00"; CMPEQ;
IF { DROP; NONE tez }
PUSH mutez 0; CMPEQ;
IF { DROP; NONE mutez }
# Otherwise update storage with new balance
{ SOME };
SWAP; CAR; HASH_KEY; UPDATE;
......
parameter unit;
storage tez; # How much you have to send me
storage mutez; # How much you have to send me
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
IF {FAIL} # Reject the person
......
parameter key_hash;
storage (pair timestamp (pair tez key_hash));
storage (pair timestamp (pair mutez key_hash));
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; AMOUNT; CMPLE; IF {FAIL} {}; # Check to make sure that the new amount is greater
......
parameter unit;
storage (pair timestamp (pair (contract unit) (contract unit)));
code { CDR; DUP; CAR; NOW; CMPLT; IF {FAIL} {};
DUP; CDAR; PUSH tez "100"; UNIT; TRANSFER_TOKENS; SWAP;
DUP; CDDR; PUSH tez "100"; UNIT; TRANSFER_TOKENS; DIP {SWAP} ;
DUP; CDAR; PUSH mutez 100000000; UNIT; TRANSFER_TOKENS; SWAP;
DUP; CDDR; PUSH mutez 100000000; UNIT; TRANSFER_TOKENS; DIP {SWAP} ;
NIL operation ; SWAP ; CONS ; SWAP ; CONS ; PAIR }
parameter unit;
storage tez;
storage mutez;
code {DROP; BALANCE; NIL operation; PAIR};
parameter (pair tez tez);
parameter (pair mutez mutez);
storage (list bool);
code {CAR; DUP; DUP; DUP; DUP; DIIIIIP {NIL bool};
DIIIIP {DUP; CAR; DIP {CDR}; COMPARE; LE; CONS};
......
......@@ -11,6 +11,6 @@ code { UNPAIR ;
IF_NONE
{ NIL operation ; PAIR }
{ DUP ; DIP { PUSH nat 1 ; ADD ; MUL @storage } ; SWAP;
DIP { DIP { SELF; PUSH tez "0" } ;
DIP { DIP { SELF; PUSH mutez 0 } ;
TRANSFER_TOKENS ; NIL operation ; SWAP ; CONS } ;
SWAP ; PAIR } } }
\ No newline at end of file
......@@ -2,9 +2,9 @@ parameter (or key_hash address) ;
storage (option (contract unit)) ;
code { CAR;
IF_LEFT
{ DIP { PUSH tez "100.00" ; PUSH bool False ; NONE key_hash };
{ DIP { PUSH mutez 100000000 ; PUSH bool False ; NONE key_hash };
CREATE_ACCOUNT ;
DIP { RIGHT key_hash ; DIP { SELF ; PUSH tez "0" } ; TRANSFER_TOKENS ;
DIP { RIGHT key_hash ; DIP { SELF ; PUSH mutez 0 } ; TRANSFER_TOKENS ;
NIL operation ; SWAP ; CONS } ;
CONS ; NONE (contract unit) ; SWAP ; PAIR }
{ SELF ; ADDRESS ; SOURCE ; IFCMPNEQ { FAIL } {} ;
......
......@@ -3,16 +3,16 @@ storage unit;
code { CAR;
IF_LEFT
{ DIP { PUSH string "dummy";
PUSH tez "100.00" ; PUSH bool False ;
PUSH mutez 100000000 ; PUSH bool False ;
PUSH bool False ; NONE key_hash } ;
CREATE_CONTRACT
{ parameter string ;
storage string ;
code { CAR ; NIL operation ; PAIR } } ;
DIP { RIGHT key_hash ; DIP { SELF ; PUSH tez "0" } ; TRANSFER_TOKENS ;
DIP { RIGHT key_hash ; DIP { SELF ; PUSH mutez 0 } ; TRANSFER_TOKENS ;
NIL operation ; SWAP ; CONS } ;
CONS ; UNIT ; SWAP ; PAIR }
{ SELF ; ADDRESS ; SOURCE ; IFCMPNEQ { FAIL } {} ;
CONTRACT string ; IF_SOME {} { FAIL } ;
PUSH tez "0.00" ; PUSH string "abcdefg" ; TRANSFER_TOKENS ;
PUSH mutez 0 ; PUSH string "abcdefg" ; TRANSFER_TOKENS ;
NIL operation; SWAP; CONS ; UNIT ; SWAP ; PAIR } };
parameter key_hash;
storage unit;
code {DIP{UNIT}; CAR; IMPLICIT_ACCOUNT;
PUSH tez "100.00"; UNIT; TRANSFER_TOKENS;
PUSH mutez 100000000; UNIT; TRANSFER_TOKENS;
NIL operation; SWAP; CONS; PAIR}
......@@ -2,5 +2,5 @@
parameter unit;
storage unit;
code { DROP;
AMOUNT; PUSH tez "10"; CMPGT; IF {FAIL} {};
AMOUNT; PUSH mutez 10000000; CMPGT; IF {FAIL} {};
UNIT; NIL operation; PAIR}
......@@ -2,11 +2,11 @@ parameter
(or string nat) ;
storage
(pair
(pair nat (pair tez tez)) # counter from_buyer from_seller
(pair nat (pair mutez mutez)) # counter from_buyer from_seller
(pair
(pair nat (pair timestamp timestamp)) # Q T Z
(pair
(pair tez tez) # K C
(pair mutez mutez) # K C
(pair
(pair (contract unit) (contract unit)) # B S
(contract unit))))) ; # W
......@@ -40,12 +40,12 @@ code
{ FAIL } } # (Right _)
{ # After Z + 24
# if balance is emptied, just fail
BALANCE ; PUSH tez "0" ; IFCMPEQ { FAIL } {} ;
BALANCE ; PUSH mutez 0 ; IFCMPEQ { FAIL } {} ;
# test if the required amount is reached
DUP ; CDDAAR ; # Q
DIP { DUP ; CDDDADR } ; MUL ; # C
PUSH nat 2 ; MUL ;
PUSH tez "1.00" ; ADD ;
PUSH mutez 1000000 ; ADD ;
BALANCE ; COMPARE ; LT ; # balance < 2 * (Q * C) + 1
IF { # refund the parties
CDR ; DUP ; CADAR ; # amount versed by the buyer
......
parameter (pair tez (pair timestamp int)) ;
parameter (pair mutez (pair timestamp int)) ;
storage string ;
code { CAR ; H ; NIL operation ; PAIR }
\ No newline at end of file
......@@ -2,7 +2,7 @@
parameter (option (pair signature int));
storage (pair key int);
code {DUP; DUP; CAR;
IF_NONE {PUSH tez "1.00"; # Fee pattern from July 26
IF_NONE {PUSH mutez 1000000; # Fee pattern from July 26
AMOUNT; CMPLE; IF {FAIL} {};
# Provide the data
CDR; DIP {CDDR}}
......
parameter key_hash;
storage (pair timestamp (pair tez key_hash));
storage (pair timestamp (pair mutez key_hash));
code { DUP; CDAR;
# If the time is more than 2 weeks, any amount makes you king
NOW; CMPGT;
# User becomes king of tez
# User becomes king of mutez
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
......
......@@ -2,7 +2,7 @@ parameter unit;
storage (list (contract unit));
code { CDR; DUP;
DIP {NIL operation}; PUSH bool True; # Setup loop
LOOP {IF_CONS { PUSH tez "1.00"; UNIT; TRANSFER_TOKENS; # Make transfer
LOOP {IF_CONS { PUSH mutez 1000000; UNIT; TRANSFER_TOKENS; # Make transfer
SWAP; DIP {CONS}; PUSH bool True} # Setup for next round of loop
{ NIL (contract unit); PUSH bool False}}; # Data to satisfy types and end loop
DROP; PAIR}; # Calling convention
parameter unit;
storage (pair timestamp (pair tez (contract unit)));
storage (pair timestamp (pair mutez (contract unit)));
code { CDR; # Ignore the parameter
DUP; # Duplicate the storage
CAR; # Get the timestamp
......
parameter unit;
storage (pair (pair nat (pair nat (pair (pair (pair nat tez) nat) nat))) nat);
code { MAP_CDADDAADR { PUSH tez "1.00" ; ADD } ;
storage (pair (pair nat (pair nat (pair (pair (pair nat mutez) nat) nat))) nat);
code { MAP_CDADDAADR { PUSH mutez 1000000 ; ADD } ;
NIL operation ; SWAP; SET_CAR };
......@@ -4,7 +4,7 @@ code
{ DUP ; CAR ; PUSH nat 0 ; CMPNEQ ;
DIP { DUP ; CAR ; DIP { CDR ; NIL operation } } ;
LOOP
{ PUSH tez "5.00" ;
{ PUSH mutez 5000000 ;
PUSH bool True ; # delegatable
NONE key_hash ; # delegate
PUSH key_hash "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" ; # manager
......
parameter unit;
storage (pair (contract unit) (contract unit));
code { CDR; DUP; CAR; PUSH tez "5.00"; UNIT;
code { CDR; DUP; CAR; PUSH mutez 5000000; UNIT;
TRANSFER_TOKENS;
DIP {DUP; CDR;
PUSH tez "5.00"; UNIT; TRANSFER_TOKENS};
PUSH mutez 5000000; UNIT; TRANSFER_TOKENS};
DIIP{NIL operation};DIP{CONS};CONS;PAIR};
parameter unit ;
storage
(pair
(pair (timestamp @T) (tez @N))
(pair (timestamp @T) (mutez @N))
(pair (contract @A unit) (contract @B unit))) ;
code
{ CDR ; DUP ; CAAR ; # T
......
......@@ -5,7 +5,7 @@ storage
(pair
timestamp # T
(pair
(pair tez tez) # P N
(pair mutez mutez) # P N
(pair
(contract unit) # X
(pair (contract unit) (contract unit)))))) ; # A B
......@@ -18,8 +18,8 @@ code
NOW ;
COMPARE ; LT ;
IF { # Before timeout
# We compute ((1 + P) + N) tez for keeping the contract alive
PUSH tez "1.00" ;
# We compute ((1 + P) + N) mutez for keeping the contract alive
PUSH mutez 1000000 ;
DIP { DUP ; CDDDAAR } ; ADD ; # P
DIP { DUP ; CDDDADR } ; ADD ; # N
# We compare to the cumulated amount
......@@ -45,17 +45,17 @@ code
# We update the global
CDDR ; PUSH string "timeout" ; PAIR ;
# We try to transfer the fee to the broker
PUSH tez "1.00" ; BALANCE ; SUB ; # available
PUSH mutez 1000000 ; BALANCE ; SUB ; # available
DIP { DUP ; CDDAAR } ; # P
COMPARE ; LT ; # available < P
IF { PUSH tez "1.00" ; BALANCE ; SUB ; # available
IF { PUSH mutez 1000000 ; BALANCE ; SUB ; # available
DIP { DUP ; CDDDAR } ; # X
UNIT ; TRANSFER_TOKENS }
{ DUP ; CDDAAR ; # P
DIP { DUP ; CDDDAR } ; # X
UNIT ; TRANSFER_TOKENS } ;
# We transfer the rest to B
DIP { PUSH tez "1.00" ; BALANCE ; SUB ; # available
DIP { PUSH mutez 1000000 ; BALANCE ; SUB ; # available
DIP { DUP ; CDDDDDR } ; # B
UNIT ; TRANSFER_TOKENS } ;
NIL operation ; SWAP ; CONS ; SWAP ; CONS ;
......
parameter tez;
storage (pair (pair nat (pair nat (pair (pair (pair nat tez) nat) nat))) nat);
parameter mutez;
storage (pair (pair nat (pair nat (pair (pair (pair nat mutez) nat) nat))) nat);
code { DUP ; CAR ; SWAP ; CDR ;
SET_CADDAADR @annot ;
NIL operation ; PAIR };
......@@ -8,7 +8,7 @@ code { DUP;
IF { PUSH bool False} # End the loop
{ PUSH nat 1; SWAP; SUB; ABS; # Subtract 1. The ABS is to make it back into a nat
PUSH string "init"; # Storage type
PUSH tez "5.00"; # Strating balance
PUSH mutez 5000000; # Strating balance
PUSH bool False; DUP; # Not spendable or delegatable
NONE key_hash;
PUSH key_hash "tz1cxcwwnzENRdhe2Kb8ZdTrdNy4bFNyScx5";
......
......@@ -2,7 +2,7 @@ parameter key_hash;
storage unit;
code { CAR; IMPLICIT_ACCOUNT; # Create an account for the recipient of the funds
DIP{UNIT}; # Push a value of the storage type below the contract
PUSH tez "1.00"; # The person can have a ꜩ
PUSH mutez 1000000; # The person can have a ꜩ
UNIT; # Push the contract's argument type
TRANSFER_TOKENS; # Run the transfer
NIL operation; SWAP; CONS;
......
parameter (pair tez tez);
storage (option (pair tez tez));
parameter (pair mutez mutez);
storage (option (pair mutez mutez));
code {CAR; DUP; DUP; CAR; DIP{CDR}; ADD;
DIP{DUP; CAR; DIP{CDR}; SUB};
PAIR; SOME; NIL operation; PAIR};
parameter unit;
storage tez;
storage mutez;
code { DROP; AMOUNT; NIL operation; PAIR };
parameter (contract unit);
storage unit;
code { CAR; DIP{UNIT}; PUSH tez "100.00"; UNIT;
code { CAR; DIP{UNIT}; PUSH mutez 100000000; UNIT;
TRANSFER_TOKENS;
NIL operation; SWAP; CONS; PAIR};
......@@ -213,16 +213,16 @@ assert_storage $contract_dir/exec_concat.tz '"?"' '"test"' '"test_abc"'
assert_storage $contract_dir/steps_to_quota.tz 111 Unit 399992
# Get the current balance of the contract
assert_storage $contract_dir/balance.tz '"111"' Unit '"4,000,000"'
assert_storage $contract_dir/balance.tz '111' Unit '4000000000000'
# Test comparisons on tez { EQ ; GT ; LT ; GE ; LE }
assert_storage $contract_dir/compare.tz '{}' '(Pair "1.00" "2.00")' '{ False ; False ; True ; False ; True }'
assert_storage $contract_dir/compare.tz '{}' '(Pair "2.00" "1.00")' '{ False ; True ; False ; True ; False }'
assert_storage $contract_dir/compare.tz '{}' '(Pair "2.37" "2.37")' '{ True ; False ; False ; True ; True }'
assert_storage $contract_dir/compare.tz '{}' '(Pair 1000000 2000000)' '{ False ; False ; True ; False ; True }'
assert_storage $contract_dir/compare.tz '{}' '(Pair 2000000 1000000)' '{ False ; True ; False ; True ; False }'
assert_storage $contract_dir/compare.tz '{}' '(Pair 2370000 2370000)' '{ True ; False ; False ; True ; True }'
# Test addition and subtraction on tez
assert_storage $contract_dir/tez_add_sub.tz None '(Pair "2" "1")' '(Some (Pair "3" "1"))'
assert_storage $contract_dir/tez_add_sub.tz None '(Pair "2.31" "1.01")' '(Some (Pair "3.32" "1.3"))'
assert_storage $contract_dir/tez_add_sub.tz None '(Pair 2000000 1000000)' '(Some (Pair 3000000 1000000))'
assert_storage $contract_dir/tez_add_sub.tz None '(Pair 2310000 1010000)' '(Some (Pair 3320000 1300000))'
# Test get first element of list
assert_storage $contract_dir/first.tz '111' '{ 1 ; 2 ; 3 ; 4 }' '1'
......@@ -303,14 +303,14 @@ assert_storage $contract_dir/set_cdr.tz '(Pair "hello" 500)' '3' '(Pair "hello"
assert_storage $contract_dir/set_cdr.tz '(Pair "hello" 7)' '100' '(Pair "hello" 100)'
assert_storage $contract_dir/set_caddaadr.tz \
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 "0") 4) 5))) 6)' \
'"3"' \
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 "3") 4) 5))) 6)'
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 0) 4) 5))) 6)' \
'3000000' \
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 3000000) 4) 5))) 6)'
assert_storage $contract_dir/map_caddaadr.tz \
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 "0") 4) 5))) 6)' \
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 0) 4) 5))) 6)' \
'Unit' \
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 "1") 4) 5))) 6)'
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 1000000) 4) 5))) 6)'
# Did the given key sign the string? (key is bootstrap1)
assert_success $client run program $contract_dir/check_signature.tz \
......@@ -343,7 +343,7 @@ assert_storage_contains store_input '"abcdefg"'
bake_after $client transfer 100 from bootstrap1 to store_input -arg '"xyz"'
assert_storage_contains store_input '"xyz"'
init_with_transfer $contract_dir/transfer_amount.tz $key1 '"0"' "100" bootstrap1
init_with_transfer $contract_dir/transfer_amount.tz $key1 '0' "100" bootstrap1
bake_after $client transfer 500 from bootstrap1 to transfer_amount -arg Unit
assert_storage_contains transfer_amount 500
......@@ -443,14 +443,14 @@ assert_fails $client typecheck data '{ "A" ; "C" ; "B" }' against type '(set str
assert_fails $client typecheck data '{ "A" ; "B" ; "B" }' against type '(set string)'
# Test hash consistency between Michelson and the CLI
hash_result=`$client hash data '(Pair "22220.00" (Pair "2017-12-13T04:49:00Z" 034))' \
of type '(pair tez (pair timestamp int))' | grep expr`
hash_result=`$client hash data '(Pair 22220000000 (Pair "2017-12-13T04:49:00Z" 034))' \
of type '(pair mutez (pair timestamp int))' | grep expr`
assert_storage $contract_dir/hash_consistency_checker.tz '"?"' \
'(Pair "22220.00" (Pair "2017-12-13T04:49:00Z" 034))' "$hash_result"
'(Pair 22220000000 (Pair "2017-12-13T04:49:00Z" 034))' "$hash_result"
assert_storage $contract_dir/hash_consistency_checker.tz '"?"' \
'(Pair "22,220" (Pair "2017-12-13T04:49:00+00:00" 34))' "$hash_result"
'(Pair 22220000000 (Pair "2017-12-13T04:49:00+00:00" 34))' "$hash_result"
# Test for big maps
init_with_transfer $contract_dir/big_map_mem.tz $key1\
......
......@@ -261,7 +261,7 @@ module Script : sig
| T_set
| T_signature
| T_string
| T_tez
| T_mutez
| T_timestamp
| T_unit
| T_operation
......
......@@ -113,7 +113,7 @@ type prim =
| T_set
| T_signature
| T_string
| T_tez
| T_mutez
| T_timestamp
| T_unit
| T_operation
......@@ -238,7 +238,7 @@ let string_of_prim = function
| T_set -> "set"
| T_signature -> "signature"
| T_string -> "string"
| T_tez -> "tez"
| T_mutez -> "mutez"
| T_timestamp -> "timestamp"
| T_unit -> "unit"
| T_operation -> "operation"
......@@ -344,7 +344,7 @@ let prim_of_string = function
| "set" -> ok T_set
| "signature" -> ok T_signature
| "string" -> ok T_string
| "tez" -> ok T_tez
| "mutez" -> ok T_mutez
| "timestamp" -> ok T_timestamp
| "unit" -> ok T_unit
| "operation" -> ok T_operation
......@@ -494,7 +494,7 @@ let prim_encoding =
("set", T_set) ;
("signature", T_signature) ;
("string", T_string) ;
("tez", T_tez) ;
("mutez", T_mutez) ;
("timestamp", T_timestamp) ;
("unit", T_unit) ;
("operation", T_operation) ;
......
......@@ -111,7 +111,7 @@ type prim =
| T_set
| T_signature
| T_string
| T_tez
| T_mutez
| T_timestamp
| T_unit
| T_operation
......
......@@ -517,7 +517,7 @@ let rec interp
consume_gaz_comparison descr Compare.Bool.compare Interp_costs.compare_bool a b rest
| Compare String_key, Item (a, Item (b, rest)) ->
consume_gaz_comparison descr Compare.String.compare Interp_costs.compare_string a b rest
| Compare Tez_key, Item (a, Item (b, rest)) ->
| Compare Mutez_key, Item (a, Item (b, rest)) ->
consume_gaz_comparison descr Tez.compare Interp_costs.compare_tez a b rest
| Compare Int_key, Item (a, Item (b, rest)) ->
consume_gaz_comparison descr Script_int.compare Interp_costs.compare_int a b rest
......
......@@ -17,7 +17,7 @@ type 'ty comparable_ty =
| Int_key : (z num) comparable_ty
| Nat_key : (n num) comparable_ty
| String_key : string comparable_ty
| Tez_key : Tez.t comparable_ty
| Mutez_key : Tez.t comparable_ty
| Bool_key : bool comparable_ty
| Key_hash_key : public_key_hash comparable_ty
| Timestamp_key : Script_timestamp.t comparable_ty
......@@ -68,7 +68,7 @@ and 'ty ty =
| Nat_t : n num ty
| Signature_t : signature ty
| String_t : string ty
| Tez_t : Tez.t ty
| Mutez_t : Tez.t ty
| Key_hash_t : public_key_hash ty
| Key_t : public_key ty
| Timestamp_t : Script_timestamp.t ty
......
# This is a very simple accounts system.
# (Left key) initializes or deposits into an account
# (Right key (pair tez (signed tez))) withdraws tez amount to a
# (Right key (pair mutez (signed mutez))) withdraws mutez amount to a
# IMPLICIT_ACCOUNT created from the key if the balance is available
# and the key is correctly signed
parameter (or key_hash (pair key (pair tez signature)));
parameter (or key_hash (pair key (pair mutez signature)));
# Maps the key to the balance they have stored
storage (map key_hash tez);
storage (map key_hash mutez);
code { DUP; CAR;
# Deposit into account
IF_LEFT { DUP; DIIP{ CDR; DUP };
......@@ -30,8 +30,8 @@ code { DUP; CAR;
IF { FAIL }
{ SUB; DIP{ DUP; DIP{ SWAP }}; DUP;
# Delete account if balance is 0
PUSH tez "0.00"; CMPEQ;
IF { DROP; NONE tez }
PUSH mutez 0; CMPEQ;
IF { DROP; NONE mutez }
# Otherwise update storage with new balance
{ SOME };
SWAP; CAR; HASH_KEY; UPDATE;
......
parameter unit;
storage tez; # How much you have to send me
storage mutez; # How much you have to send me
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
IF {FAIL} # Reject the person
......
parameter key_hash;
storage (pair timestamp (pair tez key_hash));
storage (pair timestamp (pair mutez key_hash));
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; AMOUNT; CMPLE; IF {FAIL} {}; # Check to make sure that the new amount is greater
......
parameter unit;
storage (pair timestamp (pair (contract unit) (contract unit)));
code { CDR; DUP; CAR; NOW; CMPLT; IF {FAIL} {};
DUP; CDAR; PUSH tez "100"; UNIT; TRANSFER_TOKENS; SWAP;
DUP; CDDR; PUSH tez "100"; UNIT; TRANSFER_TOKENS; DIP {SWAP} ;
DUP; CDAR; PUSH mutez 100000000; UNIT; TRANSFER_TOKENS; SWAP;
DUP; CDDR; PUSH mutez 100000000; UNIT; TRANSFER_TOKENS; DIP {SWAP} ;
NIL operation ; SWAP ; CONS ; SWAP ; CONS ; PAIR }
parameter unit;
storage tez;
storage mutez;
code {DROP; BALANCE; NIL operation; PAIR};
parameter (pair tez tez);
parameter (pair mutez mutez);
storage (list bool);
code {CAR; DUP; DUP; DUP; DUP; DIIIIIP {NIL bool};
DIIIIP {DUP; CAR; DIP {CDR}; COMPARE; LE; CONS};
......
......@@ -11,6 +11,6 @@ code { UNPAIR ;
IF_NONE
{ NIL operation ; PAIR }
{ DUP ; DIP { PUSH nat 1 ; ADD ; MUL @storage } ; SWAP;
DIP { DIP { SELF; PUSH tez "0" } ;
DIP { DIP { SELF; PUSH mutez 0 } ;
TRANSFER_TOKENS ; NIL operation ; SWAP ; CONS } ;
SWAP ; PAIR } } }
\ No newline at end of file
......@@ -2,9 +2,9 @@ parameter (or key_hash address) ;
storage (option (contract unit)) ;
code { CAR;
IF_LEFT
{ DIP { PUSH tez "100.00" ; PUSH bool False ; NONE key_hash };
{ DIP { PUSH mutez 100000000 ; PUSH bool False ; NONE key_hash };
CREATE_ACCOUNT ;
DIP { RIGHT key_hash ; DIP { SELF ; PUSH tez "0" } ; TRANSFER_TOKENS ;
DIP { RIGHT key_hash ; DIP { SELF ; PUSH mutez 0 } ; TRANSFER_TOKENS ;
NIL operation ; SWAP ; CONS } ;
CONS ; NONE (contract unit) ; SWAP ; PAIR }
{ SELF ; ADDRESS ; SOURCE ; IFCMPNEQ { FAIL } {} ;
......
......@@ -3,16 +3,16 @@ storage unit;
code { CAR;
IF_LEFT
{ DIP { PUSH string "dummy";
PUSH tez "100.00" ; PUSH bool False ;
PUSH mutez 100000000 ; PUSH bool False ;
PUSH bool False ; NONE key_hash } ;
CREATE_CONTRACT
{ parameter string ;
storage string ;
code { CAR ; NIL operation ; PAIR } } ;
DIP { RIGHT key_hash ; DIP { SELF ; PUSH tez "0" } ; TRANSFER_TOKENS ;
DIP { RIGHT key_hash ; DIP { SELF ; PUSH mutez 0 } ; TRANSFER_TOKENS ;
NIL operation ; SWAP ; CONS } ;
CONS ; UNIT ; SWAP ; PAIR }
{ SELF ; ADDRESS ; SOURCE ; IFCMPNEQ { FAIL } {} ;
CONTRACT string ; IF_SOME {} { FAIL } ;
PUSH tez "0.00" ; PUSH string "abcdefg" ; TRANSFER_TOKENS ;
PUSH mutez 0 ; PUSH string "abcdefg" ; TRANSFER_TOKENS ;
NIL operation; SWAP; CONS ; UNIT ; SWAP ; PAIR } };
parameter key_hash;
storage unit;
code {DIP{UNIT}; CAR; IMPLICIT_ACCOUNT;
PUSH tez "100.00"; UNIT; TRANSFER_TOKENS;
PUSH mutez 100000000; UNIT; TRANSFER_TOKENS;
NIL operation; SWAP; CONS; PAIR}
......@@ -2,5 +2,5 @@
parameter unit;
storage unit;
code { DROP;
AMOUNT; PUSH tez "10"; CMPGT; IF {FAIL} {};
AMOUNT; PUSH mutez 10000000; CMPGT; IF {FAIL} {};
UNIT; NIL operation; PAIR}
parameter (pair tez (pair timestamp int)) ;
parameter (pair mutez (pair timestamp int)) ;
storage string ;
code { CAR ; H ; NIL operation ; PAIR }
\ No newline at end of file
......@@ -2,7 +2,7 @@
parameter (option (pair signature int));
storage (pair key int);
code {DUP; DUP; CAR;
IF_NONE {PUSH tez "1.00"; # Fee pattern from July 26
IF_NONE {PUSH mutez 1000000; # Fee pattern from July 26
AMOUNT; CMPLE; IF {FAIL} {};
# Provide the data
CDR; DIP {CDDR}}
......
parameter key_hash;
storage (pair timestamp (pair tez key_hash));
storage (pair timestamp (pair mutez key_hash));
code { DUP; CDAR;
# If the time is more than 2 weeks, any amount makes you king
NOW; CMPGT;
# User becomes king of tez
# User becomes king of mutez
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
......
......@@ -2,7 +2,7 @@ parameter unit;
storage (list (contract unit));
code { CDR; DUP;
DIP {NIL operation}; PUSH bool True; # Setup loop
LOOP {IF_CONS { PUSH tez "1.00"; UNIT; TRANSFER_TOKENS; # Make transfer
LOOP {IF_CONS { PUSH mutez 1000000; UNIT; TRANSFER_TOKENS; # Make transfer
SWAP; DIP {CONS}; PUSH bool True} # Setup for next round of loop
{ NIL (contract unit); PUSH bool False}}; # Data to satisfy types and end loop
DROP; PAIR}; # Calling convention
parameter unit;
storage (pair timestamp (pair tez (contract unit)));
storage (pair timestamp (pair mutez (contract unit)));
code { CDR; # Ignore the parameter
DUP; # Duplicate the storage
CAR; # Get the timestamp
......
parameter unit;
storage (pair (pair nat (pair nat (pair (pair (pair nat tez) nat) nat))) nat);
code { MAP_CDADDAADR { PUSH tez "1.00" ; ADD } ;
storage (pair (pair nat (pair nat (pair (pair (pair nat mutez) nat) nat))) nat);
code { MAP_CDADDAADR { PUSH mutez 1000000 ; ADD } ;
NIL operation ; SWAP; SET_CAR };
......@@ -4,7 +4,7 @@ code
{ DUP ; CAR ; PUSH nat 0 ; CMPNEQ ;
DIP { DUP ; CAR ; DIP { CDR ; NIL operation } } ;
LOOP
{ PUSH tez "5.00" ;
{ PUSH mutez 5000000 ;
PUSH bool True ; # delegatable
NONE key_hash ; # delegate
PUSH key_hash "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" ; # manager
......
parameter unit;
storage (pair (contract unit) (contract unit));
code { CDR; DUP; CAR; PUSH tez "5.00"; UNIT;
code { CDR; DUP; CAR; PUSH mutez 5000000; UNIT;
TRANSFER_TOKENS;
DIP {DUP; CDR;
PUSH tez "5.00"; UNIT; TRANSFER_TOKENS};
PUSH mutez 5000000; UNIT; TRANSFER_TOKENS};
DIIP{NIL operation};DIP{CONS};CONS;PAIR};
parameter tez;
storage (pair (pair nat (pair nat (pair (pair (pair nat tez) nat) nat))) nat);
parameter mutez;
storage (pair (pair nat (pair nat (pair (pair (pair nat mutez) nat) nat))) nat);
code { DUP ; CAR ; SWAP ; CDR ;
SET_CADDAADR @annot ;
NIL operation ; PAIR };
......@@ -8,7 +8,7 @@ code { DUP;
IF { PUSH bool False} # End the loop
{ PUSH nat 1; SWAP; SUB; ABS; # Subtract 1. The ABS is to make it back into a nat
PUSH string "init"; # Storage type
PUSH tez "5.00"; # Strating balance
PUSH mutez 5000000; # Strating balance
PUSH bool False; DUP; # Not spendable or delegatable
NONE key_hash;
PUSH key_hash "tz1cxcwwnzENRdhe2Kb8ZdTrdNy4bFNyScx5";
......
......@@ -2,7 +2,7 @@ parameter key_hash;
storage unit;
code { CAR; IMPLICIT_ACCOUNT; # Create an account for the recipient of the funds
DIP{UNIT}; # Push a value of the storage type below the contract
PUSH tez "1.00"; # The person can have a ꜩ
PUSH mutez 1000000; # The person can have a ꜩ
UNIT; # Push the contract's argument type
TRANSFER_TOKENS; # Run the transfer
NIL operation; SWAP; CONS;
......
parameter (pair tez tez);
storage (option (pair tez tez));
parameter (pair mutez mutez);
storage (option (pair mutez mutez));
code {CAR; DUP; DUP; CAR; DIP{CDR}; ADD;
DIP{DUP; CAR; DIP{CDR}; SUB};
PAIR; SOME; NIL operation; PAIR};
parameter unit;
storage tez;
storage mutez;
code { DROP; AMOUNT; NIL operation; PAIR };