Michelson: switch string tez constants to int mutez constants
This commit is contained in:
parent
ffec060a6f
commit
702896f420
@ -1,11 +1,11 @@
|
||||
# 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;
|
||||
|
@ -1,5 +1,5 @@
|
||||
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
|
||||
|
@ -1,5 +1,5 @@
|
||||
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
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 }
|
||||
|
@ -1,3 +1,3 @@
|
||||
parameter unit;
|
||||
storage tez;
|
||||
storage mutez;
|
||||
code {DROP; BALANCE; NIL operation; PAIR};
|
||||
|
@ -1,4 +1,4 @@
|
||||
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 } } }
|
@ -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 } };
|
||||
|
@ -1,5 +1,5 @@
|
||||
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
|
||||
|
@ -1,3 +1,3 @@
|
||||
parameter (pair tez (pair timestamp int)) ;
|
||||
parameter (pair mutez (pair timestamp int)) ;
|
||||
storage string ;
|
||||
code { CAR ; H ; NIL operation ; PAIR }
|
@ -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}}
|
||||
|
@ -1,9 +1,9 @@
|
||||
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
|
||||
|
@ -1,5 +1,5 @@
|
||||
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
|
||||
|
@ -1,4 +1,4 @@
|
||||
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
|
||||
|
@ -1,7 +1,7 @@
|
||||
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};
|
||||
|
@ -1,7 +1,7 @@
|
||||
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 ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
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;
|
||||
|
@ -1,5 +1,5 @@
|
||||
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};
|
||||
|
@ -1,3 +1,3 @@
|
||||
parameter unit;
|
||||
storage tez;
|
||||
storage mutez;
|
||||
code { DROP; AMOUNT; NIL operation; PAIR };
|
||||
|
@ -1,5 +1,5 @@
|
||||
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
|
||||
|
@ -42,7 +42,7 @@ let comparable_type_size : type t. t comparable_ty -> int = function
|
||||
| Int_key -> 1
|
||||
| Nat_key -> 1
|
||||
| String_key -> 1
|
||||
| Tez_key -> 1
|
||||
| Mutez_key -> 1
|
||||
| Bool_key -> 1
|
||||
| Key_hash_key -> 1
|
||||
| Timestamp_key -> 1
|
||||
@ -54,7 +54,7 @@ let rec type_size : type t. t ty -> int = function
|
||||
| Nat_t -> 1
|
||||
| Signature_t -> 1
|
||||
| String_t -> 1
|
||||
| Tez_t -> 1
|
||||
| Mutez_t -> 1
|
||||
| Key_hash_t -> 1
|
||||
| Key_t -> 1
|
||||
| Timestamp_t -> 1
|
||||
@ -322,7 +322,7 @@ let namespace = function
|
||||
| T_set
|
||||
| T_signature
|
||||
| T_string
|
||||
| T_tez
|
||||
| T_mutez
|
||||
| T_timestamp
|
||||
| T_unit
|
||||
| T_operation
|
||||
@ -358,7 +358,7 @@ let compare_comparable
|
||||
= fun kind x y -> match kind with
|
||||
| String_key -> Compare.String.compare x y
|
||||
| Bool_key -> Compare.Bool.compare x y
|
||||
| Tez_key -> Tez.compare x y
|
||||
| Mutez_key -> Tez.compare x y
|
||||
| Key_hash_key -> Signature.Public_key_hash.compare x y
|
||||
| Int_key ->
|
||||
let res = (Script_int.compare x y) in
|
||||
@ -495,7 +495,7 @@ let ty_of_comparable_ty
|
||||
| Int_key -> Int_t
|
||||
| Nat_key -> Nat_t
|
||||
| String_key -> String_t
|
||||
| Tez_key -> Tez_t
|
||||
| Mutez_key -> Mutez_t
|
||||
| Bool_key -> Bool_t
|
||||
| Key_hash_key -> Key_hash_t
|
||||
| Timestamp_key -> Timestamp_t
|
||||
@ -506,7 +506,7 @@ let unparse_comparable_ty
|
||||
| Int_key -> Prim (-1, T_int, [], None)
|
||||
| Nat_key -> Prim (-1, T_nat, [], None)
|
||||
| String_key -> Prim (-1, T_string, [], None)
|
||||
| Tez_key -> Prim (-1, T_tez, [], None)
|
||||
| Mutez_key -> Prim (-1, T_mutez, [], None)
|
||||
| Bool_key -> Prim (-1, T_bool, [], None)
|
||||
| Key_hash_key -> Prim (-1, T_key_hash, [], None)
|
||||
| Timestamp_key -> Prim (-1, T_timestamp, [], None)
|
||||
@ -519,7 +519,7 @@ let rec unparse_ty
|
||||
| Int_t -> Prim (-1, T_int, [], annot)
|
||||
| Nat_t -> Prim (-1, T_nat, [], annot)
|
||||
| String_t -> Prim (-1, T_string, [], annot)
|
||||
| Tez_t -> Prim (-1, T_tez, [], annot)
|
||||
| Mutez_t -> Prim (-1, T_mutez, [], annot)
|
||||
| Bool_t -> Prim (-1, T_bool, [], annot)
|
||||
| Key_hash_t -> Prim (-1, T_key_hash, [], annot)
|
||||
| Key_t -> Prim (-1, T_key, [], annot)
|
||||
@ -604,9 +604,9 @@ let rec unparse_data
|
||||
MBytes.to_hex
|
||||
(Data_encoding.Binary.to_bytes_exn Signature.encoding s) in
|
||||
(String (-1, text), gas)
|
||||
| Tez_t, v ->
|
||||
| Mutez_t, v ->
|
||||
Gas.consume ctxt Unparse_costs.tez >|? fun gas ->
|
||||
(String (-1, Tez.to_string v), gas)
|
||||
(Int (-1, Z.of_int64 (Tez.to_mutez v)), gas)
|
||||
| Key_t, k ->
|
||||
Gas.consume ctxt Unparse_costs.key >|? fun gas ->
|
||||
(String (-1, Signature.Public_key.to_b58check k), gas)
|
||||
@ -686,7 +686,7 @@ let comparable_ty_eq
|
||||
| Int_key, Int_key -> Ok Eq
|
||||
| Nat_key, Nat_key -> Ok Eq
|
||||
| String_key, String_key -> Ok Eq
|
||||
| Tez_key, Tez_key -> Ok Eq
|
||||
| Mutez_key, Mutez_key -> Ok Eq
|
||||
| Bool_key, Bool_key -> Ok Eq
|
||||
| Key_hash_key, Key_hash_key -> Ok Eq
|
||||
| Timestamp_key, Timestamp_key -> Ok Eq
|
||||
@ -704,7 +704,7 @@ let rec ty_eq
|
||||
| Key_hash_t, Key_hash_t -> Ok Eq
|
||||
| String_t, String_t -> Ok Eq
|
||||
| Signature_t, Signature_t -> Ok Eq
|
||||
| Tez_t, Tez_t -> Ok Eq
|
||||
| Mutez_t, Mutez_t -> Ok Eq
|
||||
| Timestamp_t, Timestamp_t -> Ok Eq
|
||||
| Address_t, Address_t -> Ok Eq
|
||||
| Bool_t, Bool_t -> Ok Eq
|
||||
@ -783,7 +783,7 @@ let merge_comparable_types
|
||||
| Int_key, Int_key -> ta
|
||||
| Nat_key, Nat_key -> ta
|
||||
| String_key, String_key -> ta
|
||||
| Tez_key, Tez_key -> ta
|
||||
| Mutez_key, Mutez_key -> ta
|
||||
| Bool_key, Bool_key -> ta
|
||||
| Key_hash_key, Key_hash_key -> ta
|
||||
| Timestamp_key, Timestamp_key -> ta
|
||||
@ -816,7 +816,7 @@ let merge_types :
|
||||
| Key_hash_t, Key_hash_t -> ok Key_hash_t
|
||||
| String_t, String_t -> ok String_t
|
||||
| Signature_t, Signature_t -> ok Signature_t
|
||||
| Tez_t, Tez_t -> ok Tez_t
|
||||
| Mutez_t, Mutez_t -> ok Mutez_t
|
||||
| Timestamp_t, Timestamp_t -> ok Timestamp_t
|
||||
| Address_t, Address_t -> ok Address_t
|
||||
| Bool_t, Bool_t -> ok Bool_t
|
||||
@ -921,13 +921,13 @@ let rec parse_comparable_ty
|
||||
| Prim (_, T_int, [], _) -> ok (Ex_comparable_ty Int_key)
|
||||
| Prim (_, T_nat, [], _) -> ok (Ex_comparable_ty Nat_key)
|
||||
| Prim (_, T_string, [], _) -> ok (Ex_comparable_ty String_key)
|
||||
| Prim (_, T_tez, [], _) -> ok (Ex_comparable_ty Tez_key)
|
||||
| Prim (_, T_mutez, [], _) -> ok (Ex_comparable_ty Mutez_key)
|
||||
| Prim (_, T_bool, [], _) -> ok (Ex_comparable_ty Bool_key)
|
||||
| Prim (_, T_key_hash, [], _) -> ok (Ex_comparable_ty Key_hash_key)
|
||||
| Prim (_, T_timestamp, [], _) -> ok (Ex_comparable_ty Timestamp_key)
|
||||
| Prim (_, T_address, [], _) -> ok (Ex_comparable_ty Address_key)
|
||||
| Prim (loc, (T_int | T_nat
|
||||
| T_string | T_tez | T_bool
|
||||
| T_string | T_mutez | T_bool
|
||||
| T_key | T_address | T_timestamp as prim), l, _) ->
|
||||
error (Invalid_arity (loc, prim, 0, List.length l))
|
||||
| Prim (loc, (T_pair | T_or | T_set | T_map
|
||||
@ -938,7 +938,7 @@ let rec parse_comparable_ty
|
||||
| expr ->
|
||||
error @@ unexpected expr [] Type_namespace
|
||||
[ T_int ; T_nat ;
|
||||
T_string ; T_tez ; T_bool ;
|
||||
T_string ; T_mutez ; T_bool ;
|
||||
T_key ; T_key_hash ; T_timestamp ]
|
||||
|
||||
and parse_ty
|
||||
@ -968,8 +968,8 @@ and parse_ty
|
||||
ok (Ex_ty Nat_t, annot)
|
||||
| Prim (_, T_string, [], annot) ->
|
||||
ok (Ex_ty String_t, annot)
|
||||
| Prim (_, T_tez, [], annot) ->
|
||||
ok (Ex_ty Tez_t, annot)
|
||||
| Prim (_, T_mutez, [], annot) ->
|
||||
ok (Ex_ty Mutez_t, annot)
|
||||
| Prim (_, T_bool, [], annot) ->
|
||||
ok (Ex_ty Bool_t, annot)
|
||||
| Prim (_, T_key, [], annot) ->
|
||||
@ -1019,7 +1019,7 @@ and parse_ty
|
||||
error (Unexpected_big_map loc)
|
||||
| Prim (loc, (T_unit | T_signature
|
||||
| T_int | T_nat
|
||||
| T_string | T_tez | T_bool
|
||||
| T_string | T_mutez | T_bool
|
||||
| T_key | T_key_hash
|
||||
| T_timestamp | T_address as prim), l, _) ->
|
||||
error (Invalid_arity (loc, prim, 0, List.length l))
|
||||
@ -1033,7 +1033,7 @@ and parse_ty
|
||||
T_list ; T_option ; T_lambda ;
|
||||
T_unit ; T_signature ; T_contract ;
|
||||
T_int ; T_nat ; T_operation ;
|
||||
T_string ; T_tez ; T_bool ;
|
||||
T_string ; T_mutez ; T_bool ;
|
||||
T_key ; T_key_hash ; T_timestamp ]
|
||||
|
||||
let rec unparse_stack
|
||||
@ -1128,16 +1128,16 @@ let rec parse_data
|
||||
| Nat_t, expr ->
|
||||
traced (fail (Invalid_kind (location expr, [ Int_kind ], kind expr)))
|
||||
(* Tez amounts *)
|
||||
| Tez_t, String (_, v) ->
|
||||
| Mutez_t, Int (_, v) ->
|
||||
Lwt.return (Gas.consume ctxt Typecheck_costs.tez) >>=? fun ctxt ->
|
||||
begin try
|
||||
match Tez.of_string v with
|
||||
match Tez.of_mutez (Z.to_int64 v) with
|
||||
| None -> raise Exit
|
||||
| Some tez -> return (tez, ctxt)
|
||||
with _ ->
|
||||
fail @@ error ()
|
||||
end
|
||||
| Tez_t, expr ->
|
||||
| Mutez_t, expr ->
|
||||
traced (fail (Invalid_kind (location expr, [ String_kind ], kind expr)))
|
||||
(* Timestamps *)
|
||||
| Timestamp_t, (Int (_, v)) ->
|
||||
@ -1790,21 +1790,21 @@ and parse_instr
|
||||
(Item_t (String_t, rest, instr_annot))
|
||||
(* currency operations *)
|
||||
| Prim (loc, I_ADD, [], instr_annot),
|
||||
Item_t (Tez_t, Item_t (Tez_t, rest, _), _) ->
|
||||
Item_t (Mutez_t, Item_t (Mutez_t, rest, _), _) ->
|
||||
typed ctxt loc Add_tez
|
||||
(Item_t (Tez_t, rest, instr_annot))
|
||||
(Item_t (Mutez_t, rest, instr_annot))
|
||||
| Prim (loc, I_SUB, [], instr_annot),
|
||||
Item_t (Tez_t, Item_t (Tez_t, rest, _), _) ->
|
||||
Item_t (Mutez_t, Item_t (Mutez_t, rest, _), _) ->
|
||||
typed ctxt loc Sub_tez
|
||||
(Item_t (Tez_t, rest, instr_annot))
|
||||
(Item_t (Mutez_t, rest, instr_annot))
|
||||
| Prim (loc, I_MUL, [], instr_annot),
|
||||
Item_t (Tez_t, Item_t (Nat_t, rest, _), _) ->
|
||||
Item_t (Mutez_t, Item_t (Nat_t, rest, _), _) ->
|
||||
typed ctxt loc Mul_teznat
|
||||
(Item_t (Tez_t, rest, instr_annot))
|
||||
(Item_t (Mutez_t, rest, instr_annot))
|
||||
| Prim (loc, I_MUL, [], instr_annot),
|
||||
Item_t (Nat_t, Item_t (Tez_t, rest, _), _) ->
|
||||
Item_t (Nat_t, Item_t (Mutez_t, rest, _), _) ->
|
||||
typed ctxt loc Mul_nattez
|
||||
(Item_t (Tez_t, rest, instr_annot))
|
||||
(Item_t (Mutez_t, rest, instr_annot))
|
||||
(* boolean operations *)
|
||||
| Prim (loc, I_OR, [], instr_annot),
|
||||
Item_t (Bool_t, Item_t (Bool_t, rest, _), _) ->
|
||||
@ -1896,13 +1896,13 @@ and parse_instr
|
||||
typed ctxt loc Mul_natnat
|
||||
(Item_t (Nat_t, rest, instr_annot))
|
||||
| Prim (loc, I_EDIV, [], instr_annot),
|
||||
Item_t (Tez_t, Item_t (Nat_t, rest, _), _) ->
|
||||
Item_t (Mutez_t, Item_t (Nat_t, rest, _), _) ->
|
||||
typed ctxt loc Ediv_teznat
|
||||
(Item_t (Option_t (Pair_t ((Tez_t, None), (Tez_t, None))), rest, instr_annot))
|
||||
(Item_t (Option_t (Pair_t ((Mutez_t, None), (Mutez_t, None))), rest, instr_annot))
|
||||
| Prim (loc, I_EDIV, [], instr_annot),
|
||||
Item_t (Tez_t, Item_t (Tez_t, rest, _), _) ->
|
||||
Item_t (Mutez_t, Item_t (Mutez_t, rest, _), _) ->
|
||||
typed ctxt loc Ediv_tez
|
||||
(Item_t (Option_t (Pair_t ((Nat_t, None), (Tez_t, None))), rest, instr_annot))
|
||||
(Item_t (Option_t (Pair_t ((Nat_t, None), (Mutez_t, None))), rest, instr_annot))
|
||||
| Prim (loc, I_EDIV, [], instr_annot),
|
||||
Item_t (Int_t, Item_t (Int_t, rest, _), _) ->
|
||||
typed ctxt loc Ediv_intint
|
||||
@ -1969,8 +1969,8 @@ and parse_instr
|
||||
typed ctxt loc (Compare String_key)
|
||||
(Item_t (Int_t, rest, instr_annot))
|
||||
| Prim (loc, I_COMPARE, [], instr_annot),
|
||||
Item_t (Tez_t, Item_t (Tez_t, rest, _), _) ->
|
||||
typed ctxt loc (Compare Tez_key)
|
||||
Item_t (Mutez_t, Item_t (Mutez_t, rest, _), _) ->
|
||||
typed ctxt loc (Compare Mutez_key)
|
||||
(Item_t (Int_t, rest, instr_annot))
|
||||
| Prim (loc, I_COMPARE, [], instr_annot),
|
||||
Item_t (Key_hash_t, Item_t (Key_hash_t, rest, _), _) ->
|
||||
@ -2030,7 +2030,7 @@ and parse_instr
|
||||
(Item_t (Option_t Key_hash_t, rest, instr_annot))
|
||||
| Prim (loc, I_TRANSFER_TOKENS, [], instr_annot),
|
||||
Item_t (p, Item_t
|
||||
(Tez_t, Item_t
|
||||
(Mutez_t, Item_t
|
||||
(Contract_t cp, rest, _), _), _) ->
|
||||
check_item_ty p cp loc I_TRANSFER_TOKENS 1 4 >>=? fun Eq ->
|
||||
typed ctxt loc Transfer_tokens (Item_t (Operation_t, rest, instr_annot))
|
||||
@ -2042,7 +2042,7 @@ and parse_instr
|
||||
(Key_hash_t, Item_t
|
||||
(Option_t Key_hash_t, Item_t
|
||||
(Bool_t, Item_t
|
||||
(Tez_t, rest, _), _), _), _) ->
|
||||
(Mutez_t, rest, _), _), _), _) ->
|
||||
typed ctxt loc Create_account
|
||||
(Item_t (Operation_t, Item_t (Address_t, rest, None), instr_annot))
|
||||
| Prim (loc, I_IMPLICIT_ACCOUNT, [], instr_annot),
|
||||
@ -2055,7 +2055,7 @@ and parse_instr
|
||||
(Option_t Key_hash_t, Item_t
|
||||
(Bool_t, Item_t
|
||||
(Bool_t, Item_t
|
||||
(Tez_t, Item_t
|
||||
(Mutez_t, Item_t
|
||||
(ginit, rest, _), _), _), _), _), _) ->
|
||||
fail_unexpected_annot seq_loc annot >>=? fun () ->
|
||||
let cannonical_code = fst @@ Micheline.extract_locations code in
|
||||
@ -2087,11 +2087,11 @@ and parse_instr
|
||||
| Prim (loc, I_AMOUNT, [], instr_annot),
|
||||
stack ->
|
||||
typed ctxt loc Amount
|
||||
(Item_t (Tez_t, stack, instr_annot))
|
||||
(Item_t (Mutez_t, stack, instr_annot))
|
||||
| Prim (loc, I_BALANCE, [], instr_annot),
|
||||
stack ->
|
||||
typed ctxt loc Balance
|
||||
(Item_t (Tez_t, stack, instr_annot))
|
||||
(Item_t (Mutez_t, stack, instr_annot))
|
||||
| Prim (loc, I_HASH_KEY, [], instr_annot),
|
||||
Item_t (Key_t, rest, _) ->
|
||||
typed ctxt loc Hash_key
|
||||
|
@ -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
|
||||
|
@ -1,11 +1,11 @@
|
||||
# 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;
|
||||
|
@ -1,5 +1,5 @@
|
||||
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
|
||||
|
@ -1,5 +1,5 @@
|
||||
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
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 }
|
||||
|
@ -1,3 +1,3 @@
|
||||
parameter unit;
|
||||
storage tez;
|
||||
storage mutez;
|
||||
code {DROP; BALANCE; NIL operation; PAIR};
|
||||
|
@ -1,4 +1,4 @@
|
||||
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 } } }
|
@ -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 } };
|
||||
|
@ -1,5 +1,5 @@
|
||||
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}
|
||||
|
@ -1,3 +1,3 @@
|
||||
parameter (pair tez (pair timestamp int)) ;
|
||||
parameter (pair mutez (pair timestamp int)) ;
|
||||
storage string ;
|
||||
code { CAR ; H ; NIL operation ; PAIR }
|
@ -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}}
|
||||
|
@ -1,9 +1,9 @@
|
||||
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
|
||||
|
@ -1,5 +1,5 @@
|
||||
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
|
||||
|
@ -1,4 +1,4 @@
|
||||
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
|
||||
|
@ -1,7 +1,7 @@
|
||||
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};
|
||||
|
@ -1,5 +1,5 @@
|
||||
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;
|
||||
|
@ -1,5 +1,5 @@
|
||||
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};
|
||||
|
@ -1,3 +1,3 @@
|
||||
parameter unit;
|
||||
storage tez;
|
||||
storage mutez;
|
||||
code { DROP; AMOUNT; NIL operation; PAIR };
|
||||
|
@ -1,5 +1,5 @@
|
||||
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};
|
||||
|
@ -313,18 +313,18 @@ let test_example () =
|
||||
|
||||
let bootstrap_0 = List.nth Account.bootstrap_accounts 0 in
|
||||
get_balance_res bootstrap_0 sb >>=?? fun _balance ->
|
||||
let amount = Proto_alpha.Alpha_context.Tez.to_string @@ Cast.cents_of_int Script.init_amount in
|
||||
let amount = string_of_int (Script.init_amount * 10000) in
|
||||
(* Get the current balance of the contract *)
|
||||
test_output ~location: __LOC__ "balance" "\"111\"" "Unit" ("\"" ^ amount ^ "\"") >>=? fun _ ->
|
||||
test_output ~location: __LOC__ "balance" "111000000" "Unit" amount >>=? fun _ ->
|
||||
|
||||
(* Test comparisons on tez { EQ ; GT ; LT ; GE ; LE } *)
|
||||
test_output ~location: __LOC__ "compare" "{}" "(Pair \"1.00\" \"2.00\")" "{ False ; False ; True ; False ; True }" >>=? fun _ ->
|
||||
test_output ~location: __LOC__ "compare" "{}" "(Pair \"2.00\" \"1.00\")" "{ False ; True ; False ; True ; False }" >>=? fun _ ->
|
||||
test_output ~location: __LOC__ "compare" "{}" "(Pair \"2.37\" \"2.37\")" "{ True ; False ; False ; True ; True }" >>=? fun _ ->
|
||||
test_output ~location: __LOC__ "compare" "{}" "(Pair 1000000 2000000)" "{ False ; False ; True ; False ; True }" >>=? fun _ ->
|
||||
test_output ~location: __LOC__ "compare" "{}" "(Pair 2000000 1000000)" "{ False ; True ; False ; True ; False }" >>=? fun _ ->
|
||||
test_output ~location: __LOC__ "compare" "{}" "(Pair 2370000 2370000)" "{ True ; False ; False ; True ; True }" >>=? fun _ ->
|
||||
|
||||
(* Test addition and subtraction on tez *)
|
||||
test_output ~location: __LOC__ "tez_add_sub" "None" "(Pair \"2\" \"1\")" "(Some (Pair \"3\" \"1\"))" >>=? fun _ ->
|
||||
test_output ~location: __LOC__ "tez_add_sub" "None" "(Pair \"2.31\" \"1.01\")" "(Some (Pair \"3.32\" \"1.3\"))" >>=? fun _ ->
|
||||
test_output ~location: __LOC__ "tez_add_sub" "None" "(Pair 2000000 1000000)" "(Some (Pair 3000000 1000000))" >>=? fun _ ->
|
||||
test_output ~location: __LOC__ "tez_add_sub" "None" "(Pair 2310000 1010000)" "(Some (Pair 3320000 1300000))" >>=? fun _ ->
|
||||
|
||||
(* Test get first element of list *)
|
||||
test_output ~location: __LOC__ "first" "111" "{ 1 ; 2 ; 3 ; 4 }" "1" >>=? fun _ ->
|
||||
@ -404,9 +404,9 @@ let test_example () =
|
||||
test_output ~location: __LOC__ "set_cdr" "(Pair \"hello\" 500)" "3" "(Pair \"hello\" 3)" >>=? fun _ ->
|
||||
test_output ~location: __LOC__ "set_cdr" "(Pair \"hello\" 7)" "100" "(Pair \"hello\" 100)" >>=? fun _ ->
|
||||
|
||||
test_storage ~location: __LOC__ "set_caddaadr" "(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)" >>=? fun _ ->
|
||||
test_storage ~location: __LOC__ "set_caddaadr" "(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)" >>=? fun _ ->
|
||||
|
||||
test_storage ~location: __LOC__ "map_caddaadr" "(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)" >>=? fun _ ->
|
||||
test_storage ~location: __LOC__ "map_caddaadr" "(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 0) 4) 5))) 6)" "Unit" "(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 1000000) 4) 5))) 6)" >>=? fun _ ->
|
||||
|
||||
(* Did the given key sign the string? (key is bootstrap1) *)
|
||||
test_success ~location: __LOC__ "check_signature" "(Pair \"1f19f8f37e80d96797b019f30d23ede6a26a0f698220f942103a3401f047623746e51a9c6e77e269b5df9593994ab96b001aae0f73728a2259187cb640b61e01\" \"hello\")" "\"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav\"" >>=? fun _ ->
|
||||
|
Loading…
Reference in New Issue
Block a user