From 9c76ddcfc6948ccd6d51944579a091ebfce1b1b3 Mon Sep 17 00:00:00 2001 From: Lucas Randazzo Date: Mon, 15 May 2023 14:28:22 +0200 Subject: [PATCH] Proto: keep total_supply up to date --- src/proto_alpha/lib_protocol/token.ml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/proto_alpha/lib_protocol/token.ml b/src/proto_alpha/lib_protocol/token.ml index 0da01148dc1b..6b8d63054d3f 100644 --- a/src/proto_alpha/lib_protocol/token.ml +++ b/src/proto_alpha/lib_protocol/token.ml @@ -98,7 +98,10 @@ let credit ctxt receiver amount origin = | `Sc_rollup_refutation_punishments -> Sc_rollup_refutation_punishments | `Burned -> Burned in - return (ctxt, sink) + Storage.Contract.Total_supply.get ctxt >>=? fun old_total_supply -> + Tez_repr.(old_total_supply -? amount) >>?= fun new_total_supply -> + Storage.Contract.Total_supply.update ctxt new_total_supply + >|=? fun ctxt -> (ctxt, sink) | #container as container -> ( match container with | `Contract receiver -> @@ -146,7 +149,10 @@ let spend ctxt giver amount origin = | `Tx_rollup_rejection_rewards -> Tx_rollup_rejection_rewards | `Sc_rollup_refutation_rewards -> Sc_rollup_refutation_rewards in - return (ctxt, src) + Storage.Contract.Total_supply.get ctxt >>=? fun old_total_supply -> + Tez_repr.(old_total_supply +? amount) >>?= fun new_total_supply -> + Storage.Contract.Total_supply.update ctxt new_total_supply + >|=? fun ctxt -> (ctxt, src) | #container as container -> ( match container with | `Contract giver -> -- GitLab