Michelson: Adds DEFAULT_ACCOUNT instruction
This commit is contained in:
parent
b320d43259
commit
23c814c783
@ -169,6 +169,7 @@ with the following JSON script description.
|
|||||||
| "NANAN"
|
| "NANAN"
|
||||||
| "MANAGER"
|
| "MANAGER"
|
||||||
| "TRANSFER_FUNDS"
|
| "TRANSFER_FUNDS"
|
||||||
|
| "DEFAULT_ACCOUNT"
|
||||||
| "CREATE_ACCOUNT"
|
| "CREATE_ACCOUNT"
|
||||||
| "CREATE_CONTRACT"
|
| "CREATE_CONTRACT"
|
||||||
| "NOW"
|
| "NOW"
|
||||||
|
@ -1120,6 +1120,14 @@ for under/overflows.
|
|||||||
|
|
||||||
:: 'S -> tez :: 'S
|
:: 'S -> tez :: 'S
|
||||||
|
|
||||||
|
* `DEFAULT_ACCOUNT`:
|
||||||
|
Return a default contract with the given public/private key pair.
|
||||||
|
Any funds deposited in this contract can immediately be spent by the
|
||||||
|
holder of the private key. This contract cannot execute Michelson code
|
||||||
|
and will always exist on the blockchain.
|
||||||
|
|
||||||
|
:: key : 'S -> contract unit unit :: 'S
|
||||||
|
|
||||||
### Special operations
|
### Special operations
|
||||||
|
|
||||||
* `STEPS_TO_QUOTA`:
|
* `STEPS_TO_QUOTA`:
|
||||||
|
@ -456,6 +456,9 @@ let rec interp
|
|||||||
~manager ~delegate ~balance
|
~manager ~delegate ~balance
|
||||||
?script:None ~spendable:true ~delegatable >>=? fun (ctxt, contract, origination) ->
|
?script:None ~spendable:true ~delegatable >>=? fun (ctxt, contract, origination) ->
|
||||||
logged_return ~origination (Item ((Unit_t, Unit_t, contract), rest), qta - 1, ctxt)
|
logged_return ~origination (Item ((Unit_t, Unit_t, contract), rest), qta - 1, ctxt)
|
||||||
|
| Default_account, Item (key, rest) ->
|
||||||
|
let contract = Contract.default_contract key in
|
||||||
|
logged_return (Item ((Unit_t, Unit_t, contract), rest), qta - 1, ctxt)
|
||||||
| Create_contract (g, p, r),
|
| Create_contract (g, p, r),
|
||||||
Item (manager, Item (delegate, Item (delegatable, Item (credit,
|
Item (manager, Item (delegate, Item (delegatable, Item (credit,
|
||||||
Item (Lam (_, code), Item (init, rest)))))) ->
|
Item (Lam (_, code), Item (init, rest)))))) ->
|
||||||
|
@ -1247,6 +1247,10 @@ and parse_instr
|
|||||||
(Tez_t, rest)))) ->
|
(Tez_t, rest)))) ->
|
||||||
return (typed loc (Create_account,
|
return (typed loc (Create_account,
|
||||||
Item_t (Contract_t (Unit_t, Unit_t), rest)))
|
Item_t (Contract_t (Unit_t, Unit_t), rest)))
|
||||||
|
| Prim (loc, "DEFAULT_ACCOUNT", []),
|
||||||
|
Item_t (Key_t, rest) ->
|
||||||
|
return
|
||||||
|
(typed loc (Default_account, Item_t (Contract_t (Unit_t, Unit_t), rest)))
|
||||||
| Prim (loc, "CREATE_CONTRACT", []),
|
| Prim (loc, "CREATE_CONTRACT", []),
|
||||||
Item_t
|
Item_t
|
||||||
(Key_t, Item_t
|
(Key_t, Item_t
|
||||||
@ -1296,7 +1300,8 @@ and parse_instr
|
|||||||
| "COMPARE" | "EQ" | "NEQ"
|
| "COMPARE" | "EQ" | "NEQ"
|
||||||
| "LT" | "GT" | "LE" | "GE"
|
| "LT" | "GT" | "LE" | "GE"
|
||||||
| "MANAGER" | "TRANSFER_TOKENS" | "CREATE_ACCOUNT"
|
| "MANAGER" | "TRANSFER_TOKENS" | "CREATE_ACCOUNT"
|
||||||
| "CREATE_CONTRACT" | "NOW" | "AMOUNT" | "BALANCE"
|
| "CREATE_CONTRACT" | "NOW"
|
||||||
|
| "DEFAULT_ACCOUNT" | "AMOUNT" | "BALANCE"
|
||||||
| "CHECK_SIGNATURE" | "H" | "STEPS_TO_QUOTA"
|
| "CHECK_SIGNATURE" | "H" | "STEPS_TO_QUOTA"
|
||||||
as name), (_ :: _ as l)), _ ->
|
as name), (_ :: _ as l)), _ ->
|
||||||
fail (Invalid_arity (loc, name, 0, List.length l))
|
fail (Invalid_arity (loc, name, 0, List.length l))
|
||||||
@ -1339,7 +1344,7 @@ and parse_instr
|
|||||||
fail (Bad_stack (loc, "TRANSFER_TOKENS", 3, stack))
|
fail (Bad_stack (loc, "TRANSFER_TOKENS", 3, stack))
|
||||||
| Prim (loc, ("DROP" | "DUP" | "CAR" | "CDR" | "SOME" | "H" | "DIP"
|
| Prim (loc, ("DROP" | "DUP" | "CAR" | "CDR" | "SOME" | "H" | "DIP"
|
||||||
| "IF_NONE" | "LEFT" | "RIGHT" | "IF_LEFT" | "IF"
|
| "IF_NONE" | "LEFT" | "RIGHT" | "IF_LEFT" | "IF"
|
||||||
| "LOOP" | "IF_CONS" | "MANAGER"
|
| "LOOP" | "IF_CONS" | "MANAGER" | "DEFAULT_ACCOUNT"
|
||||||
| "NEG" | "ABS" | "NOT"
|
| "NEG" | "ABS" | "NOT"
|
||||||
| "EQ" | "NEQ" | "LT" | "GT" | "LE" | "GE" as name), _),
|
| "EQ" | "NEQ" | "LT" | "GT" | "LE" | "GE" as name), _),
|
||||||
stack ->
|
stack ->
|
||||||
@ -1369,7 +1374,7 @@ and parse_instr
|
|||||||
"LT" ; "GT" ; "LE" ; "GE" ;
|
"LT" ; "GT" ; "LE" ; "GE" ;
|
||||||
"MANAGER" ; "TRANSFER_TOKENS" ; "CREATE_ACCOUNT" ;
|
"MANAGER" ; "TRANSFER_TOKENS" ; "CREATE_ACCOUNT" ;
|
||||||
"CREATE_CONTRACT" ; "NOW" ; "AMOUNT" ; "BALANCE" ;
|
"CREATE_CONTRACT" ; "NOW" ; "AMOUNT" ; "BALANCE" ;
|
||||||
"CHECK_SIGNATURE" ; "H" ; "STEPS_TO_QUOTA" ;
|
"DEFAULT_ACCOUNT" ; "CHECK_SIGNATURE" ; "H" ; "STEPS_TO_QUOTA" ;
|
||||||
"PUSH" ; "NONE" ; "LEFT" ; "RIGHT" ; "NIL" ;
|
"PUSH" ; "NONE" ; "LEFT" ; "RIGHT" ; "NIL" ;
|
||||||
"EMPTY_SET" ; "DIP" ; "CHECKED_CAST" ; "CAST" ; "LOOP" ;
|
"EMPTY_SET" ; "DIP" ; "CHECKED_CAST" ; "CAST" ; "LOOP" ;
|
||||||
"IF_NONE" ; "IF_LEFT" ; "IF_CONS" ;
|
"IF_NONE" ; "IF_LEFT" ; "IF_CONS" ;
|
||||||
|
@ -267,6 +267,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 : (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 * (Tez.t *
|
(public_key_hash * (public_key_hash option * (bool * (Tez.t *
|
||||||
(((Tez.t * 'p) * 'g, 'r * 'g) lambda * ('g * 'rest))))),
|
(((Tez.t * 'p) * 'g, 'r * 'g) lambda * ('g * 'rest))))),
|
||||||
|
Loading…
Reference in New Issue
Block a user