Michelson: allow CREATE_CONTRACT to set the spendable flag

This commit is contained in:
Milo Davis 2017-07-13 18:17:11 +02:00 committed by Benjamin Canou
parent 98424be5be
commit 110e0206e7
3 changed files with 13 additions and 12 deletions

View File

@ -459,8 +459,8 @@ let rec interp
let contract = Contract.default_contract key in
logged_return (Item ((Unit_t, Unit_t, contract), rest), qta - 1, ctxt)
| Create_contract (g, p, r),
Item (manager, Item (delegate, Item (delegatable, Item (credit,
Item (Lam (_, code), Item (init, rest)))))) ->
Item (manager, Item (delegate, Item (spendable, Item (delegatable, Item (credit,
Item (Lam (_, code), Item (init, rest))))))) ->
let code, storage =
{ code; arg_type = unparse_ty p; ret_type = unparse_ty r; storage_type = unparse_ty g },
{ storage = unparse_data g init; storage_type = unparse_ty g } in
@ -470,7 +470,7 @@ let rec interp
origination
~manager ~delegate ~balance
~script:({ code ; storage }, (dummy_code_fee, dummy_storage_fee))
~spendable:true ~delegatable
~spendable ~delegatable
>>=? fun (ctxt, contract, origination) ->
logged_return ~origination (Item ((p, r, contract), rest), qta - 1, ctxt)
| Balance, rest ->

View File

@ -1273,12 +1273,13 @@ and parse_instr
(Key_t, Item_t
(Option_t Key_t, Item_t
(Bool_t, Item_t
(Tez_t, Item_t
(Lambda_t (Pair_t (Pair_t (Tez_t, p), gp),
Pair_t (r, gr)), Item_t
(ginit, rest)))))) ->
check_item_ty gp gr loc "CREATE_CONTRACT" 5 6 >>=? fun (Eq _) ->
check_item_ty ginit gp loc "CREATE_CONTRACT" 6 6 >>=? fun (Eq _) ->
(Bool_t, Item_t
(Tez_t, Item_t
(Lambda_t (Pair_t (Pair_t (Tez_t, p), gp),
Pair_t (r, gr)), Item_t
(ginit, rest))))))) ->
check_item_ty gp gr loc "CREATE_CONTRACT" 5 7 >>=? fun (Eq _) ->
check_item_ty ginit gp loc "CREATE_CONTRACT" 6 7 >>=? fun (Eq _) ->
return (typed loc (Create_contract (gp, p, r),
Item_t (Contract_t (p, r), rest)))
| Prim (loc, "NOW", []),
@ -1352,7 +1353,7 @@ and parse_instr
fail (Bad_stack (loc, name, 3, stack))
| Prim (loc, "CREATE_CONTRACT", []),
stack ->
fail (Bad_stack (loc, "CREATE_CONTRACT", 6, stack))
fail (Bad_stack (loc, "CREATE_CONTRACT", 7, stack))
| Prim (loc, "CREATE_ACCOUNT", []),
stack ->
fail (Bad_stack (loc, "CREATE_ACCOUNT", 4, stack))

View File

@ -269,8 +269,8 @@ and ('bef, 'aft) instr =
(unit, unit) typed_contract * 'rest) instr
| Default_account : (public_key_hash * 'rest, (unit, unit) typed_contract * 'rest) instr
| Create_contract : 'g ty * 'p ty * 'r ty ->
(public_key_hash * (public_key_hash option * (bool * (Tez.t *
(((Tez.t * 'p) * 'g, 'r * 'g) lambda * ('g * 'rest))))),
(public_key_hash * (public_key_hash option * (bool * (bool * (Tez.t *
(((Tez.t * 'p) * 'g, 'r * 'g) lambda * ('g * 'rest)))))),
('p, 'r) typed_contract * 'rest) instr
| Now :
('rest, Timestamp.t * 'rest) instr