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"
|
||||
| "MANAGER"
|
||||
| "TRANSFER_FUNDS"
|
||||
| "DEFAULT_ACCOUNT"
|
||||
| "CREATE_ACCOUNT"
|
||||
| "CREATE_CONTRACT"
|
||||
| "NOW"
|
||||
|
@ -1120,6 +1120,14 @@ for under/overflows.
|
||||
|
||||
:: '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
|
||||
|
||||
* `STEPS_TO_QUOTA`:
|
||||
|
@ -456,6 +456,9 @@ let rec interp
|
||||
~manager ~delegate ~balance
|
||||
?script:None ~spendable:true ~delegatable >>=? fun (ctxt, contract, origination) ->
|
||||
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),
|
||||
Item (manager, Item (delegate, Item (delegatable, Item (credit,
|
||||
Item (Lam (_, code), Item (init, rest)))))) ->
|
||||
|
@ -1247,6 +1247,10 @@ and parse_instr
|
||||
(Tez_t, rest)))) ->
|
||||
return (typed loc (Create_account,
|
||||
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", []),
|
||||
Item_t
|
||||
(Key_t, Item_t
|
||||
@ -1296,7 +1300,8 @@ and parse_instr
|
||||
| "COMPARE" | "EQ" | "NEQ"
|
||||
| "LT" | "GT" | "LE" | "GE"
|
||||
| "MANAGER" | "TRANSFER_TOKENS" | "CREATE_ACCOUNT"
|
||||
| "CREATE_CONTRACT" | "NOW" | "AMOUNT" | "BALANCE"
|
||||
| "CREATE_CONTRACT" | "NOW"
|
||||
| "DEFAULT_ACCOUNT" | "AMOUNT" | "BALANCE"
|
||||
| "CHECK_SIGNATURE" | "H" | "STEPS_TO_QUOTA"
|
||||
as name), (_ :: _ as 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))
|
||||
| Prim (loc, ("DROP" | "DUP" | "CAR" | "CDR" | "SOME" | "H" | "DIP"
|
||||
| "IF_NONE" | "LEFT" | "RIGHT" | "IF_LEFT" | "IF"
|
||||
| "LOOP" | "IF_CONS" | "MANAGER"
|
||||
| "LOOP" | "IF_CONS" | "MANAGER" | "DEFAULT_ACCOUNT"
|
||||
| "NEG" | "ABS" | "NOT"
|
||||
| "EQ" | "NEQ" | "LT" | "GT" | "LE" | "GE" as name), _),
|
||||
stack ->
|
||||
@ -1369,7 +1374,7 @@ and parse_instr
|
||||
"LT" ; "GT" ; "LE" ; "GE" ;
|
||||
"MANAGER" ; "TRANSFER_TOKENS" ; "CREATE_ACCOUNT" ;
|
||||
"CREATE_CONTRACT" ; "NOW" ; "AMOUNT" ; "BALANCE" ;
|
||||
"CHECK_SIGNATURE" ; "H" ; "STEPS_TO_QUOTA" ;
|
||||
"DEFAULT_ACCOUNT" ; "CHECK_SIGNATURE" ; "H" ; "STEPS_TO_QUOTA" ;
|
||||
"PUSH" ; "NONE" ; "LEFT" ; "RIGHT" ; "NIL" ;
|
||||
"EMPTY_SET" ; "DIP" ; "CHECKED_CAST" ; "CAST" ; "LOOP" ;
|
||||
"IF_NONE" ; "IF_LEFT" ; "IF_CONS" ;
|
||||
|
@ -267,6 +267,7 @@ and ('bef, 'aft) instr =
|
||||
| Create_account :
|
||||
(public_key_hash * (public_key_hash option * (bool * (Tez.t * 'rest))),
|
||||
(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))))),
|
||||
|
Loading…
Reference in New Issue
Block a user