Michelson: rename DEFAULT_ACCOUNT to IMPLICIT_ACCOUNT

This commit is contained in:
Benjamin Canou 2018-04-04 10:13:59 +02:00 committed by Grégoire Henry
parent bceb91289a
commit 676a64b81f
20 changed files with 32 additions and 32 deletions

View File

@ -1468,7 +1468,7 @@ recursive call (the contract just fails if the boolean is true).
:: 'S -> tez : 'S :: 'S -> tez : 'S
- ``DEFAULT_ACCOUNT``: Return a default contract with the given - ``IMPLICIT_ACCOUNT``: Return a default contract with the given
public/private key pair. Any funds deposited in this contract can public/private key pair. Any funds deposited in this contract can
immediately be spent by the holder of the private key. This contract immediately be spent by the holder of the private key. This contract
cannot execute Michelson code and will always exist on the cannot execute Michelson code and will always exist on the
@ -2452,7 +2452,7 @@ XII - Full grammar
| TRANSFER_TOKENS | TRANSFER_TOKENS
| CREATE_ACCOUNT | CREATE_ACCOUNT
| CREATE_CONTRACT | CREATE_CONTRACT
| DEFAULT_ACCOUNT | IMPLICIT_ACCOUNT
| NOW | NOW
| AMOUNT | AMOUNT
| BALANCE | BALANCE

View File

@ -768,7 +768,7 @@ If `DO-NOT-OVERWRITE' is non-nil, the existing contents of the buffer are mainta
(michelson-suggest-reorderable '("ADD" "SUB" "MUL") 'tez 'nat) (michelson-suggest-reorderable '("ADD" "SUB" "MUL") 'tez 'nat)
(michelson-suggest-literals "EDIV" 'tez 'nat) (michelson-suggest-literals "EDIV" 'tez 'nat)
(michelson-suggest-literals "EDIV" 'tez 'tez) (michelson-suggest-literals "EDIV" 'tez 'tez)
(michelson-suggest-literals "DEFAULT_ACCOUNT" 'key) (michelson-suggest-literals "IMPLICIT_ACCOUNT" 'key)
(michelson-suggest-depth "SWAP" 2) (michelson-suggest-depth "SWAP" 2)
(michelson-suggest-depth '("DROP" "H") 1) (michelson-suggest-depth '("DROP" "H") 1)
(michelson-suggest-literals "CHECK_SIGNATURE" 'key '(pair signature string)) (michelson-suggest-literals "CHECK_SIGNATURE" 'key '(pair signature string))

View File

@ -1,7 +1,7 @@
# This is a very simple accounts system. # This is a very simple accounts system.
# (Left key) initializes or deposits into an account # (Left key) initializes or deposits into an account
# (Right key (pair tez (signed tez))) withdraws tez amount to a # (Right key (pair tez (signed tez))) withdraws tez amount to a
# DEFAULT_ACCOUNT created from the key if the balance is available # IMPLICIT_ACCOUNT created from the key if the balance is available
# and the key is correctly signed # and the key is correctly signed
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
@ -38,5 +38,5 @@ 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; DEFAULT_ACCOUNT }; UNIT; TRANSFER_TOKENS; DIP{ CAR; HASH_KEY; IMPLICIT_ACCOUNT }; UNIT; TRANSFER_TOKENS;
PAIR }}}} PAIR }}}}

View File

@ -5,5 +5,5 @@ code { DUP; CDAR; DUP; NOW; CMPGT; IF {FAIL} {}; SWAP; # Check if auction has en
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; DEFAULT_ACCOUNT}; UNIT; TRANSFER_TOKENS; # Make refund DIP{CDR; IMPLICIT_ACCOUNT}; UNIT; TRANSFER_TOKENS; # Make refund
PAIR} # Calling convention PAIR} # Calling convention

View File

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

View File

@ -13,6 +13,6 @@ 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
DEFAULT_ACCOUNT; AMOUNT; UNIT; TRANSFER_TOKENS; DROP }}; IMPLICIT_ACCOUNT; AMOUNT; UNIT; TRANSFER_TOKENS; DROP }};
# Cleanup # Cleanup
UNIT; PAIR }; UNIT; PAIR };

View File

@ -1,7 +1,7 @@
parameter key_hash; parameter key_hash;
return unit; return unit;
storage unit; storage unit;
code { CAR; DEFAULT_ACCOUNT; # Create an account for the recipient of the funds 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 DIP{UNIT}; # Push a value of the storage type below the contract
PUSH tez "1.00"; # The person can have a ꜩ PUSH tez "1.00"; # The person can have a ꜩ
UNIT; # Push the contract's argument type UNIT; # Push the contract's argument type

View File

@ -393,7 +393,7 @@ init_with_transfer $contract_dir/create_contract.tz $key2 \
bake_after $client transfer 0 from bootstrap1 to create_contract -arg '"tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"' bake_after $client transfer 0 from bootstrap1 to create_contract -arg '"tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"'
assert_storage_contains create_contract '"abcdefg"' assert_storage_contains create_contract '"abcdefg"'
# Test DEFAULT_ACCOUNT # Test IMPLICIT_ACCOUNT
init_with_transfer $contract_dir/default_account.tz $key1 \ init_with_transfer $contract_dir/default_account.tz $key1 \
Unit 1,000 bootstrap1 Unit 1,000 bootstrap1
bake_after $client transfer 0 from bootstrap1 to default_account -arg "\"$BOOTSTRAP4_IDENTITY\"" bake_after $client transfer 0 from bootstrap1 to default_account -arg "\"$BOOTSTRAP4_IDENTITY\""

View File

@ -186,7 +186,7 @@ module Script : sig
| I_CONS | I_CONS
| I_CREATE_ACCOUNT | I_CREATE_ACCOUNT
| I_CREATE_CONTRACT | I_CREATE_CONTRACT
| I_DEFAULT_ACCOUNT | I_IMPLICIT_ACCOUNT
| I_DIP | I_DIP
| I_DROP | I_DROP
| I_DUP | I_DUP

View File

@ -41,7 +41,7 @@ type prim =
| I_CONS | I_CONS
| I_CREATE_ACCOUNT | I_CREATE_ACCOUNT
| I_CREATE_CONTRACT | I_CREATE_CONTRACT
| I_DEFAULT_ACCOUNT | I_IMPLICIT_ACCOUNT
| I_DIP | I_DIP
| I_DROP | I_DROP
| I_DUP | I_DUP
@ -162,7 +162,7 @@ let string_of_prim = function
| I_CONS -> "CONS" | I_CONS -> "CONS"
| I_CREATE_ACCOUNT -> "CREATE_ACCOUNT" | I_CREATE_ACCOUNT -> "CREATE_ACCOUNT"
| I_CREATE_CONTRACT -> "CREATE_CONTRACT" | I_CREATE_CONTRACT -> "CREATE_CONTRACT"
| I_DEFAULT_ACCOUNT -> "DEFAULT_ACCOUNT" | I_IMPLICIT_ACCOUNT -> "IMPLICIT_ACCOUNT"
| I_DIP -> "DIP" | I_DIP -> "DIP"
| I_DROP -> "DROP" | I_DROP -> "DROP"
| I_DUP -> "DUP" | I_DUP -> "DUP"
@ -264,7 +264,7 @@ let prim_of_string = function
| "CONS" -> ok I_CONS | "CONS" -> ok I_CONS
| "CREATE_ACCOUNT" -> ok I_CREATE_ACCOUNT | "CREATE_ACCOUNT" -> ok I_CREATE_ACCOUNT
| "CREATE_CONTRACT" -> ok I_CREATE_CONTRACT | "CREATE_CONTRACT" -> ok I_CREATE_CONTRACT
| "DEFAULT_ACCOUNT" -> ok I_DEFAULT_ACCOUNT | "IMPLICIT_ACCOUNT" -> ok I_IMPLICIT_ACCOUNT
| "DIP" -> ok I_DIP | "DIP" -> ok I_DIP
| "DROP" -> ok I_DROP | "DROP" -> ok I_DROP
| "DUP" -> ok I_DUP | "DUP" -> ok I_DUP
@ -410,7 +410,7 @@ let prim_encoding =
("CONS", I_CONS) ; ("CONS", I_CONS) ;
("CREATE_ACCOUNT", I_CREATE_ACCOUNT) ; ("CREATE_ACCOUNT", I_CREATE_ACCOUNT) ;
("CREATE_CONTRACT", I_CREATE_CONTRACT) ; ("CREATE_CONTRACT", I_CREATE_CONTRACT) ;
("DEFAULT_ACCOUNT", I_DEFAULT_ACCOUNT) ; ("IMPLICIT_ACCOUNT", I_IMPLICIT_ACCOUNT) ;
("DIP", I_DIP) ; ("DIP", I_DIP) ;
("DROP", I_DROP) ; ("DROP", I_DROP) ;
("DUP", I_DUP) ; ("DUP", I_DUP) ;

View File

@ -39,7 +39,7 @@ type prim =
| I_CONS | I_CONS
| I_CREATE_ACCOUNT | I_CREATE_ACCOUNT
| I_CREATE_CONTRACT | I_CREATE_CONTRACT
| I_DEFAULT_ACCOUNT | I_IMPLICIT_ACCOUNT
| I_DIP | I_DIP
| I_DROP | I_DROP
| I_DUP | I_DUP

View File

@ -744,7 +744,7 @@ let rec interp
?script:None ~spendable:true ~delegatable >>=? fun (ctxt, contract, origination) -> ?script:None ~spendable:true ~delegatable >>=? fun (ctxt, contract, origination) ->
Fees.origination_burn ctxt ~source contract >>=? fun ctxt -> Fees.origination_burn ctxt ~source contract >>=? fun ctxt ->
logged_return ~origination (Item ((Unit_t, Unit_t, contract), rest), ctxt) logged_return ~origination (Item ((Unit_t, Unit_t, contract), rest), ctxt)
| Default_account, Item (key, rest) -> | Implicit_account, Item (key, rest) ->
Lwt.return (Gas.consume ctxt Interp_costs.implicit_account) >>=? fun ctxt -> Lwt.return (Gas.consume ctxt Interp_costs.implicit_account) >>=? fun ctxt ->
let contract = Contract.implicit_contract key in let contract = Contract.implicit_contract key in
logged_return (Item ((Unit_t, Unit_t, contract), rest), ctxt) logged_return (Item ((Unit_t, Unit_t, contract), rest), ctxt)

View File

@ -193,7 +193,7 @@ let number_of_generated_growing_types : type b a. (b, a) instr -> int = function
| Manager -> 0 | Manager -> 0
| Transfer_tokens _ -> 1 | Transfer_tokens _ -> 1
| Create_account -> 0 | Create_account -> 0
| Default_account -> 0 | Implicit_account -> 0
| Create_contract _ -> 1 | Create_contract _ -> 1
| Create_contract_literal _ -> 1 | Create_contract_literal _ -> 1
| Now -> 0 | Now -> 0
@ -248,7 +248,7 @@ let namespace = function
| I_CONS | I_CONS
| I_CREATE_ACCOUNT | I_CREATE_ACCOUNT
| I_CREATE_CONTRACT | I_CREATE_CONTRACT
| I_DEFAULT_ACCOUNT | I_IMPLICIT_ACCOUNT
| I_DIP | I_DIP
| I_DROP | I_DROP
| I_DUP | I_DUP
@ -1963,9 +1963,9 @@ and parse_instr
(Tez_t, rest, _), _), _), _) -> (Tez_t, rest, _), _), _), _) ->
typed ctxt loc Create_account typed ctxt loc Create_account
(Item_t (Contract_t (Unit_t, Unit_t), rest, instr_annot)) (Item_t (Contract_t (Unit_t, Unit_t), rest, instr_annot))
| Prim (loc, I_DEFAULT_ACCOUNT, [], instr_annot), | Prim (loc, I_IMPLICIT_ACCOUNT, [], instr_annot),
Item_t (Key_hash_t, rest, _) -> Item_t (Key_hash_t, rest, _) ->
typed ctxt loc Default_account typed ctxt loc Implicit_account
(Item_t (Contract_t (Unit_t, Unit_t), rest, instr_annot)) (Item_t (Contract_t (Unit_t, Unit_t), rest, instr_annot))
| Prim (loc, I_CREATE_CONTRACT, [], instr_annot), | Prim (loc, I_CREATE_CONTRACT, [], instr_annot),
Item_t Item_t
@ -2071,7 +2071,7 @@ and parse_instr
| I_LT | I_GT | I_LE | I_GE | I_LT | I_GT | I_LE | I_GE
| I_MANAGER | I_TRANSFER_TOKENS | I_CREATE_ACCOUNT | I_MANAGER | I_TRANSFER_TOKENS | I_CREATE_ACCOUNT
| I_CREATE_CONTRACT | I_NOW | I_CREATE_CONTRACT | I_NOW
| I_DEFAULT_ACCOUNT | I_AMOUNT | I_BALANCE | I_IMPLICIT_ACCOUNT | I_AMOUNT | I_BALANCE
| I_CHECK_SIGNATURE | I_HASH_KEY | I_CHECK_SIGNATURE | I_HASH_KEY
| I_H | I_STEPS_TO_QUOTA | I_H | I_STEPS_TO_QUOTA
as name), (_ :: _ as l), _), _ -> as name), (_ :: _ as l), _), _ ->
@ -2114,7 +2114,7 @@ and parse_instr
fail (Bad_stack (loc, I_TRANSFER_TOKENS, 3, stack)) fail (Bad_stack (loc, I_TRANSFER_TOKENS, 3, stack))
| Prim (loc, (I_DROP | I_DUP | I_CAR | I_CDR | I_SOME | I_H | I_DIP | Prim (loc, (I_DROP | I_DUP | I_CAR | I_CDR | I_SOME | I_H | I_DIP
| I_IF_NONE | I_LEFT | I_RIGHT | I_IF_LEFT | I_IF | I_IF_NONE | I_LEFT | I_RIGHT | I_IF_LEFT | I_IF
| I_LOOP | I_IF_CONS | I_MANAGER | I_DEFAULT_ACCOUNT | I_LOOP | I_IF_CONS | I_MANAGER | I_IMPLICIT_ACCOUNT
| I_NEG | I_ABS | I_INT | I_NOT | I_NEG | I_ABS | I_INT | I_NOT
| I_EQ | I_NEQ | I_LT | I_GT | I_LE | I_GE as name), _, _), | I_EQ | I_NEQ | I_LT | I_GT | I_LE | I_GE as name), _, _),
stack -> stack ->
@ -2141,7 +2141,7 @@ and parse_instr
I_LT ; I_GT ; I_LE ; I_GE ; I_LT ; I_GT ; I_LE ; I_GE ;
I_MANAGER ; I_TRANSFER_TOKENS ; I_CREATE_ACCOUNT ; I_MANAGER ; I_TRANSFER_TOKENS ; I_CREATE_ACCOUNT ;
I_CREATE_CONTRACT ; I_NOW ; I_AMOUNT ; I_BALANCE ; I_CREATE_CONTRACT ; I_NOW ; I_AMOUNT ; I_BALANCE ;
I_DEFAULT_ACCOUNT ; I_CHECK_SIGNATURE ; I_H ; I_HASH_KEY ; I_IMPLICIT_ACCOUNT ; I_CHECK_SIGNATURE ; I_H ; I_HASH_KEY ;
I_STEPS_TO_QUOTA ; I_STEPS_TO_QUOTA ;
I_PUSH ; I_NONE ; I_LEFT ; I_RIGHT ; I_NIL ; I_PUSH ; I_NONE ; I_LEFT ; I_RIGHT ; I_NIL ;
I_EMPTY_SET ; I_DIP ; I_LOOP ; I_EMPTY_SET ; I_DIP ; I_LOOP ;

View File

@ -322,7 +322,7 @@ and ('bef, 'aft) instr =
| Create_account : | Create_account :
(public_key_hash * (public_key_hash option * (bool * (Tez.t * 'rest))), (public_key_hash * (public_key_hash option * (bool * (Tez.t * 'rest))),
(unit, unit) typed_contract * 'rest) instr (unit, unit) typed_contract * 'rest) instr
| Default_account : | Implicit_account :
(public_key_hash * 'rest, (unit, unit) typed_contract * 'rest) instr (public_key_hash * 'rest, (unit, unit) typed_contract * 'rest) instr
| Create_contract : 'g ty * 'p ty * 'r ty -> | Create_contract : 'g ty * 'p ty * 'r ty ->
(public_key_hash * (public_key_hash option * (bool * (bool * (Tez.t * (public_key_hash * (public_key_hash option * (bool * (bool * (Tez.t *

View File

@ -1,7 +1,7 @@
# This is a very simple accounts system. # This is a very simple accounts system.
# (Left key) initializes or deposits into an account # (Left key) initializes or deposits into an account
# (Right key (pair tez (signed tez))) withdraws tez amount to a # (Right key (pair tez (signed tez))) withdraws tez amount to a
# DEFAULT_ACCOUNT created from the key if the balance is available # IMPLICIT_ACCOUNT created from the key if the balance is available
# and the key is correctly signed # and the key is correctly signed
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
@ -38,5 +38,5 @@ 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; DEFAULT_ACCOUNT }; UNIT; TRANSFER_TOKENS; DIP{ CAR; HASH_KEY; IMPLICIT_ACCOUNT }; UNIT; TRANSFER_TOKENS;
PAIR }}}} PAIR }}}}

View File

@ -5,5 +5,5 @@ code { DUP; CDAR; DUP; NOW; CMPGT; IF {FAIL} {}; SWAP; # Check if auction has en
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; DEFAULT_ACCOUNT}; UNIT; TRANSFER_TOKENS; # Make refund DIP{CDR; IMPLICIT_ACCOUNT}; UNIT; TRANSFER_TOKENS; # Make refund
PAIR} # Calling convention PAIR} # Calling convention

View File

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

View File

@ -13,6 +13,6 @@ 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
DEFAULT_ACCOUNT; AMOUNT; UNIT; TRANSFER_TOKENS; DROP }}; IMPLICIT_ACCOUNT; AMOUNT; UNIT; TRANSFER_TOKENS; DROP }};
# Cleanup # Cleanup
UNIT; PAIR }; UNIT; PAIR };

View File

@ -1,7 +1,7 @@
parameter key_hash; parameter key_hash;
return unit; return unit;
storage unit; storage unit;
code { CAR; DEFAULT_ACCOUNT; # Create an account for the recipient of the funds 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 DIP{UNIT}; # Push a value of the storage type below the contract
PUSH tez "1.00"; # The person can have a ꜩ PUSH tez "1.00"; # The person can have a ꜩ
UNIT; # Push the contract's argument type UNIT; # Push the contract's argument type

View File

@ -439,7 +439,7 @@ let test_example () =
Script.execute_code_pred ~tc sb script (parse_param "\"abc\"") >>=?? fun (_, ret, _, _, _) -> Script.execute_code_pred ~tc sb script (parse_param "\"abc\"") >>=?? fun (_, ret, _, _, _) ->
Assert.equal_string ~msg: __LOC__ "\"abc\"" @@ string_of_canon ret ; Assert.equal_string ~msg: __LOC__ "\"abc\"" @@ string_of_canon ret ;
(* Test DEFAULT_ACCOUNT *) (* Test IMPLICIT_ACCOUNT *)
let account = Account.new_account () in let account = Account.new_account () in
let b_str = quote @@ Signature.Public_key_hash.to_b58check account.hpub in let b_str = quote @@ Signature.Public_key_hash.to_b58check account.hpub in
test_contract ~tc "default_account" "Unit" b_str >>=? fun (_cs, tc) -> test_contract ~tc "default_account" "Unit" b_str >>=? fun (_cs, tc) ->