From 62ed0039575bfe8b9bab6bb83d74bf648ba28862 Mon Sep 17 00:00:00 2001 From: Benjamin Canou Date: Mon, 20 Mar 2017 15:15:39 +0100 Subject: [PATCH] Alpha: remove assets. --- .../embedded/alpha/client_proto_rpcs.ml | 7 --- .../embedded/alpha/client_proto_rpcs.mli | 16 ----- src/proto/alpha/TEZOS_PROTOCOL | 1 - src/proto/alpha/apply.ml | 4 -- src/proto/alpha/asset_repr.ml | 61 ------------------- src/proto/alpha/asset_repr.mli | 22 ------- src/proto/alpha/contract_storage.ml | 19 ------ src/proto/alpha/contract_storage.mli | 4 -- src/proto/alpha/operation_repr.ml | 20 +----- src/proto/alpha/operation_repr.mli | 4 -- src/proto/alpha/services.ml | 19 ++---- src/proto/alpha/services_registration.ml | 4 +- src/proto/alpha/storage.ml | 11 ---- src/proto/alpha/storage.mli | 5 -- src/proto/alpha/tezos_context.ml | 2 - src/proto/alpha/tezos_context.mli | 19 ------ 16 files changed, 7 insertions(+), 211 deletions(-) delete mode 100644 src/proto/alpha/asset_repr.ml delete mode 100644 src/proto/alpha/asset_repr.mli diff --git a/src/client/embedded/alpha/client_proto_rpcs.ml b/src/client/embedded/alpha/client_proto_rpcs.ml index 1de8c01c0..fb8ebdad5 100644 --- a/src/client/embedded/alpha/client_proto_rpcs.ml +++ b/src/client/embedded/alpha/client_proto_rpcs.ml @@ -109,7 +109,6 @@ module Context = struct spendable: bool ; delegate: bool * public_key_hash option ; script: Script.t option ; - assets: Asset.Map.t ; counter: int32 ; } let get cctxt b c = @@ -128,8 +127,6 @@ module Context = struct call_error_service2 cctxt Services.Context.Contract.delegatable b c () let script cctxt b c = call_error_service2 cctxt Services.Context.Contract.script b c () - let assets cctxt b c = - call_error_service2 cctxt Services.Context.Contract.assets b c () end end @@ -212,10 +209,6 @@ module Helpers = struct delegatable ; credit = balance } ] - let issuance cctxt - block ~net ~source ?sourcePubKey ~counter ~assetType ~quantity ~fee ()= - operations cctxt block ~net ~source ?sourcePubKey ~counter ~fee - Tezos_context.[Issuance { asset = assetType ; amount = quantity }] let delegation cctxt block ~net ~source ?sourcePubKey ~counter ~fee delegate = operations cctxt block ~net ~source ?sourcePubKey ~counter ~fee diff --git a/src/client/embedded/alpha/client_proto_rpcs.mli b/src/client/embedded/alpha/client_proto_rpcs.mli index f405333a2..a1b5ead37 100644 --- a/src/client/embedded/alpha/client_proto_rpcs.mli +++ b/src/client/embedded/alpha/client_proto_rpcs.mli @@ -92,7 +92,6 @@ module Context : sig spendable: bool ; delegate: bool * public_key_hash option ; script: Script.t option ; - assets: Asset.Map.t ; counter: int32 ; } val get: @@ -125,10 +124,6 @@ module Context : sig val script: Client_commands.context -> block -> Contract.t -> Script.t option tzresult Lwt.t - val assets: - Client_commands.context -> - block -> Contract.t -> - Asset.Map.t tzresult Lwt.t end end @@ -227,17 +222,6 @@ module Helpers : sig fee:Tez.t-> unit -> MBytes.t tzresult Lwt.t - val issuance: - Client_commands.context -> - block -> - net:Updater.Net_id.t -> - source:Contract.t -> - ?sourcePubKey:public_key -> - counter:int32 -> - assetType:(Asset.t * public_key_hash) -> - quantity:Tez.t -> - fee:Tez.t -> - unit -> MBytes.t tzresult Lwt.t val delegation: Client_commands.context -> block -> diff --git a/src/proto/alpha/TEZOS_PROTOCOL b/src/proto/alpha/TEZOS_PROTOCOL index ed12b35cc..f64af7ce2 100644 --- a/src/proto/alpha/TEZOS_PROTOCOL +++ b/src/proto/alpha/TEZOS_PROTOCOL @@ -19,7 +19,6 @@ "Script_repr", "Contract_repr", "Roll_repr", - "Asset_repr", "Vote_repr", "Operation_repr", "Block_repr", diff --git a/src/proto/alpha/apply.ml b/src/proto/alpha/apply.ml index b15d8be7d..a1504d9c7 100644 --- a/src/proto/alpha/apply.ml +++ b/src/proto/alpha/apply.ml @@ -93,10 +93,6 @@ let apply_manager_operation_content ctxt origination_nonce accept_failing_script ?script ~spendable ~delegatable >>=? fun (ctxt, _, origination_nonce) -> return (ctxt, origination_nonce) - | Issuance { asset = (asset, key); amount } -> - Contract.issue ctxt source asset key amount >>=? fun ctxt -> - return (ctxt, origination_nonce) - (* TODO: pay for the storage diff *) | Delegation delegate -> Contract.set_delegate ctxt source delegate >>=? fun ctxt -> return (ctxt, origination_nonce) diff --git a/src/proto/alpha/asset_repr.ml b/src/proto/alpha/asset_repr.ml deleted file mode 100644 index ac288a660..000000000 --- a/src/proto/alpha/asset_repr.ml +++ /dev/null @@ -1,61 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2016. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -type t = int32 -type asset = t -let of_int32 i = i -let to_int32 i = i - -let encoding = - let open Data_encoding in - describe - ~title: "Asset type" - ~description: "A type of asset" - (conv to_int32 of_int32 int32) - - -module Map = struct - module Raw = Map.Make(struct - type t = asset * Ed25519.Public_key_hash.t - let compare (a1, pk1) (a2, pk2) = - if Compare.Int32.(a1 = a2) then - Ed25519.Public_key_hash.compare pk1 pk2 - else - Compare.Int32.compare a1 a2 - end) - type t = Tez_repr.tez Raw.t - let empty = Raw.empty - let add map asset key quantity = - let previous_quantity = - try Raw.find (asset, key) map - with Not_found -> Tez_repr.zero in - Tez_repr.(previous_quantity +? quantity) >>? fun total -> - ok (Raw.add (asset, key) total map) - - let of_tuple_list_exn tl = - List.fold_left - (fun map (key, qty) -> Raw.add key qty map) - Raw.empty tl - - -let encoding = - let open Data_encoding in - describe - ~title: "Assets" - ~description: "A list of assets held in the contract" - (conv - Raw.bindings - (Json.wrap_error of_tuple_list_exn) - (list - (tup2 - (tup2 encoding Ed25519.Public_key_hash.encoding) - Tez_repr.encoding))) - -end - diff --git a/src/proto/alpha/asset_repr.mli b/src/proto/alpha/asset_repr.mli deleted file mode 100644 index 6bdd30efc..000000000 --- a/src/proto/alpha/asset_repr.mli +++ /dev/null @@ -1,22 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2016. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* All rights reserved. No warranty, explicit or implicit, provided. *) -(* *) -(**************************************************************************) - -type t -type asset = t - -val encoding: asset Data_encoding.t -val of_int32 : int32 -> asset - -module Map : sig - type t - val empty: t - val add: - t -> asset -> Ed25519.Public_key_hash.t -> Tez_repr.tez -> t tzresult - val encoding: t Data_encoding.t -end diff --git a/src/proto/alpha/contract_storage.ml b/src/proto/alpha/contract_storage.ml index 13ebd4713..59a25dc35 100644 --- a/src/proto/alpha/contract_storage.ml +++ b/src/proto/alpha/contract_storage.ml @@ -155,7 +155,6 @@ let create_base c contract ~balance ~manager ~delegate ?script ~spendable ~deleg end >>=? fun c -> Storage.Contract.Spendable.init c contract spendable >>=? fun c -> Storage.Contract.Delegatable.init c contract delegatable >>=? fun c -> - Storage.Contract.Assets.init c contract Asset_repr.Map.empty >>=? fun c -> Storage.Contract.Counter.init c contract counter >>=? fun c -> (match script with | Some ({ Script_repr.code ; storage }, (code_fees, storage_fees)) -> @@ -266,15 +265,6 @@ let get_balance c contract = end | Some v -> return v -let get_assets c contract = - Storage.Contract.Assets.get_option c contract >>=? function - | None -> begin - match Contract_repr.is_default contract with - | Some _ -> return Asset_repr.Map.empty - | None -> failwith "get_assets" - end - | Some a -> return a - let is_delegatable c contract = Storage.Contract.Delegatable.get_option c contract >>=? function | None -> begin @@ -362,15 +352,6 @@ let credit c contract amount = Storage.Contract.Balance.set c contract balance >>=? fun c -> Roll_storage.Contract.add_amount c contract amount -let issue c contract asset key quantity = - Storage.Contract.Assets.get_option c contract >>=? function - | None -> - Lwt.return (Asset_repr.Map.add Asset_repr.Map.empty asset key quantity) >>=? - Storage.Contract.Assets.set c contract - | Some assets -> - Lwt.return (Asset_repr.Map.add assets asset key quantity) >>=? - Storage.Contract.Assets.set c contract - let spend c contract amount = Storage.Contract.Spendable.get c contract >>=? fun spendable -> if not spendable diff --git a/src/proto/alpha/contract_storage.mli b/src/proto/alpha/contract_storage.mli index 7e4101345..57a841b30 100644 --- a/src/proto/alpha/contract_storage.mli +++ b/src/proto/alpha/contract_storage.mli @@ -34,7 +34,6 @@ val is_spendable : Storage.t -> Contract_repr.t -> bool tzresult Lwt.t val get_manager: Storage.t -> Contract_repr.t -> Ed25519.Public_key_hash.t tzresult Lwt.t val get_delegate_opt: Storage.t -> Contract_repr.t -> Ed25519.Public_key_hash.t option tzresult Lwt.t val get_balance: Storage.t -> Contract_repr.t -> Tez_repr.t tzresult Lwt.t -val get_assets: Storage.t -> Contract_repr.t -> Asset_repr.Map.t tzresult Lwt.t val get_counter: Storage.t -> Contract_repr.t -> int32 tzresult Lwt.t val get_script: Storage.t -> Contract_repr.t -> Script_repr.t option tzresult Lwt.t @@ -52,9 +51,6 @@ val spend : Storage.t -> Contract_repr.t -> Tez_repr.t -> Storage.t tzresult Lwt (** decrease_balance even if the contract is not spendable *) val spend_from_script : Storage.t -> Contract_repr.t -> Tez_repr.t -> Storage.t tzresult Lwt.t -val issue : - Storage.t -> Contract_repr.t -> Asset_repr.t -> Ed25519.Public_key_hash.t -> Tez_repr.t -> Storage.t tzresult Lwt.t - val originate : Storage.t -> Contract_repr.origination_nonce -> diff --git a/src/proto/alpha/operation_repr.ml b/src/proto/alpha/operation_repr.ml index c4bdf50be..824465a30 100644 --- a/src/proto/alpha/operation_repr.ml +++ b/src/proto/alpha/operation_repr.ml @@ -58,10 +58,6 @@ and manager_operation = delegatable: bool ; credit: Tez_repr.tez ; } - | Issuance of { - asset: Asset_repr.asset * Ed25519.Public_key_hash.t ; - amount: Tez_repr.tez ; - } | Delegation of Ed25519.Public_key_hash.t option and delegate_operation = @@ -131,19 +127,6 @@ module Encoding = struct Origination {manager ; credit ; spendable ; delegatable ; delegate ; script }) - let issuance_encoding = - (obj3 - (req "kind" (constant "issuance")) - (req "asset" (tup2 Asset_repr.encoding Ed25519.Public_key_hash.encoding)) - (req "quantity" Tez_repr.encoding)) - - let issuance_case tag = - case ~tag issuance_encoding - (function - | Issuance { asset ; amount } -> Some ((), asset, amount) - | _ -> None) - (fun ((), asset, amount) -> Issuance { asset ; amount }) - let delegation_encoding = (obj2 (req "kind" (constant "delegation")) @@ -164,8 +147,7 @@ module Encoding = struct (list (union ~tag_size:`Uint8 [ transaction_case 0 ; origination_case 1 ; - issuance_case 2 ; - delegation_case 3 ; + delegation_case 2 ; ])))) let manager_kind_case tag = diff --git a/src/proto/alpha/operation_repr.mli b/src/proto/alpha/operation_repr.mli index 9d2e6d9f8..918af3da0 100644 --- a/src/proto/alpha/operation_repr.mli +++ b/src/proto/alpha/operation_repr.mli @@ -58,10 +58,6 @@ and manager_operation = delegatable: bool ; credit: Tez_repr.tez ; } - | Issuance of { - asset: Asset_repr.t * Ed25519.Public_key_hash.t ; - amount: Tez_repr.tez ; - } | Delegation of Ed25519.Public_key_hash.t option and delegate_operation = diff --git a/src/proto/alpha/services.ml b/src/proto/alpha/services.ml index b39e16604..03f97c580 100644 --- a/src/proto/alpha/services.ml +++ b/src/proto/alpha/services.ml @@ -256,20 +256,12 @@ module Context = struct ~output: (wrap_tzerror (option Script.encoding)) RPC.Path.(custom_root / "context" / "contracts" /: Contract.arg / "script") - let assets custom_root = - RPC.service - ~description: "Access the assets of the contract." - ~input: empty - ~output: (wrap_tzerror Asset.Map.encoding) - RPC.Path.(custom_root / "context" / "contracts" /: Contract.arg / "assets") - type info = { manager: public_key_hash ; balance: Tez.t ; spendable: bool ; delegate: bool * public_key_hash option ; script: Script.t option ; - assets: Asset.Map.t ; counter: int32 ; } @@ -280,11 +272,11 @@ module Context = struct ~output: (wrap_tzerror @@ conv - (fun {manager;balance;spendable;delegate;script;assets;counter} -> - (manager,balance,spendable,delegate,script,assets,counter)) - (fun (manager,balance,spendable,delegate,script,assets,counter) -> - {manager;balance;spendable;delegate;script;assets;counter}) @@ - obj7 + (fun {manager;balance;spendable;delegate;script;counter} -> + (manager,balance,spendable,delegate,script,counter)) + (fun (manager,balance,spendable,delegate,script,counter) -> + {manager;balance;spendable;delegate;script;counter}) @@ + obj6 (req "manager" Ed25519.Public_key_hash.encoding) (req "balance" Tez.encoding) (req "spendable" bool) @@ -292,7 +284,6 @@ module Context = struct (req "setable" bool) (opt "value" Ed25519.Public_key_hash.encoding)) (opt "script" Script.encoding) - (req "assets" Asset.Map.encoding) (req "counter" int32)) RPC.Path.(custom_root / "context" / "contracts" /: Contract.arg) diff --git a/src/proto/alpha/services_registration.ml b/src/proto/alpha/services_registration.ml index c2bcc8cf3..e2675e647 100644 --- a/src/proto/alpha/services_registration.ml +++ b/src/proto/alpha/services_registration.ml @@ -153,7 +153,6 @@ let () = register2' Services.Context.Contract.spendable Contract.is_spendable ; register2' Services.Context.Contract.delegatable Contract.is_delegatable ; register2' Services.Context.Contract.script Contract.get_script ; - register2' Services.Context.Contract.assets Contract.get_assets ; register2' Services.Context.Contract.get (fun ctxt contract -> Contract.get_balance ctxt contract >>=? fun balance -> Contract.get_manager ctxt contract >>=? fun manager -> @@ -162,10 +161,9 @@ let () = Contract.is_delegatable ctxt contract >>=? fun delegatable -> Contract.is_spendable ctxt contract >>=? fun spendable -> Contract.get_script ctxt contract >>=? fun script -> - Contract.get_assets ctxt contract >>=? fun assets -> return { Services.Context.Contract.manager ; balance ; spendable ; delegate = (delegatable, delegate) ; - script ; assets ; counter }) ; + script ; counter }) ; () (*-- Helpers -----------------------------------------------------------------*) diff --git a/src/proto/alpha/storage.ml b/src/proto/alpha/storage.ml index 77c85a175..7f65834d7 100644 --- a/src/proto/alpha/storage.ml +++ b/src/proto/alpha/storage.ml @@ -108,7 +108,6 @@ module Key = struct let roll_list c = contract_store c ["roll_list"] let change c = contract_store c ["change"] let balance c = contract_store c ["balance"] - let assets c = contract_store c ["assets"] let manager c = contract_store c ["manager"] let spendable c = contract_store c ["spendable"] let delegatable c = contract_store c ["delegatable"] @@ -250,16 +249,6 @@ module Contract = struct let encoding = Tez_repr.encoding end) - module Assets = - Make_indexed_data_storage( - struct - type key = Contract_repr.t - type value = Asset_repr.Map.t - let name = "contract assets" - let key = Key.Contract.assets - let encoding = Asset_repr.Map.encoding - end) - module Manager = Make_indexed_data_storage(struct type key = Contract_repr.t diff --git a/src/proto/alpha/storage.mli b/src/proto/alpha/storage.mli index fbe29cd8f..7ff2503ae 100644 --- a/src/proto/alpha/storage.mli +++ b/src/proto/alpha/storage.mli @@ -132,11 +132,6 @@ module Contract : sig and type value = Tez_repr.t and type context := t - module Assets : Indexed_data_storage - with type key = Contract_repr.t - and type value = Asset_repr.Map.t - and type context := t - (** The manager of a contract *) module Manager : Indexed_data_storage with type key = Contract_repr.t diff --git a/src/proto/alpha/tezos_context.ml b/src/proto/alpha/tezos_context.ml index 41577693b..02810f9a1 100644 --- a/src/proto/alpha/tezos_context.ml +++ b/src/proto/alpha/tezos_context.ml @@ -108,8 +108,6 @@ module Fitness = struct end -module Asset = Asset_repr - let init = Init_storage.may_initialize let finalize ?commit_message c = diff --git a/src/proto/alpha/tezos_context.mli b/src/proto/alpha/tezos_context.mli index c806f2520..2280b9d98 100644 --- a/src/proto/alpha/tezos_context.mli +++ b/src/proto/alpha/tezos_context.mli @@ -148,16 +148,6 @@ module Script : sig end -module Asset : sig - type t - type asset = t - val encoding: asset Data_encoding.t - module Map : sig - type t - val encoding: t Data_encoding.t - end -end - module Bootstrap : sig type account = { public_key_hash: public_key_hash ; @@ -346,8 +336,6 @@ module Contract : sig val get_counter: context -> contract -> int32 tzresult Lwt.t val get_balance: context -> contract -> Tez.t tzresult Lwt.t - val get_assets: - context -> contract -> Asset.Map.t tzresult Lwt.t val set_delegate: context -> contract -> public_key_hash option -> context tzresult Lwt.t @@ -373,9 +361,6 @@ module Contract : sig val credit: context -> contract -> Tez.t -> context tzresult Lwt.t - val issue: - context -> contract -> - Asset.t -> public_key_hash -> Tez.t -> context tzresult Lwt.t val update_script_storage_and_fees: context -> contract -> Tez.t -> Script.expr -> context tzresult Lwt.t @@ -483,10 +468,6 @@ and manager_operation = delegatable: bool ; credit: Tez.t ; } - | Issuance of { - asset: Asset.t * public_key_hash ; - amount: Tez.t ; - } | Delegation of public_key_hash option and delegate_operation =