From 996e5d3ce8a91be60620c082af7a466e56f34f99 Mon Sep 17 00:00:00 2001 From: Ritvik <91389059+raghav-rama@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:42:01 +0530 Subject: [PATCH 1/2] feat: add `burn_public` and `burn_private` transitions Signed-off-by: Ritvik <91389059+raghav-rama@users.noreply.github.com> --- token/src/main.leo | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/token/src/main.leo b/token/src/main.leo index 58a02cd..052a86b 100644 --- a/token/src/main.leo +++ b/token/src/main.leo @@ -1,5 +1,5 @@ // The `program` scope defines the data types, functions, and state associated with the `token` program. -program token.aleo { +program simple_token_1i3muyd.aleo { // On-chain storage of an `account` map, with `address` as the key, // and `u64` as the value. mapping account: address => u64; @@ -11,6 +11,25 @@ program token.aleo { amount: u64, } + /* Burn */ + transition burn_public(public receiver: address, public amount_to_burn: u64) { + return then finalize(receiver, amount_to_burn); + } + + finalize burn_public(public owner: address, amount_to_burn: u64) { + let amount: u64 = Mapping::get_or_use(account, owner, 0u64); + Mapping::set(account, owner, amount - amount_to_burn); + } + + transition burn_private(token_to_burn: token, amount: u64) -> token { + let difference: u64 = token_to_burn.amount - amount; + return token { + owner: token_to_burn.owner, + amount: difference, + }; + } + + /* Mint */ // The function `mint_public` issues the specified token amount for the token receiver publicly on the network. From b55c5922802d5d0404fb16da03977e84e0193211 Mon Sep 17 00:00:00 2001 From: Ritvik <91389059+raghav-rama@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:42:42 +0530 Subject: [PATCH 2/2] fix: minor fixes Signed-off-by: Ritvik <91389059+raghav-rama@users.noreply.github.com> --- token/src/main.leo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/token/src/main.leo b/token/src/main.leo index 052a86b..63c72c8 100644 --- a/token/src/main.leo +++ b/token/src/main.leo @@ -1,5 +1,5 @@ // The `program` scope defines the data types, functions, and state associated with the `token` program. -program simple_token_1i3muyd.aleo { +program token.aleo { // On-chain storage of an `account` map, with `address` as the key, // and `u64` as the value. mapping account: address => u64;