From 307dcca8e9b3c62beda008d344beabb3f18e918d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?O=C4=9Fuz=20Utku=20Y=C4=B1ld=C4=B1z?=
 <76889160+oguzutku1745@users.noreply.github.com>
Date: Wed, 3 Jul 2024 02:35:58 +0300
Subject: [PATCH] Updated token example for testnet-beta

---
 token/src/main.leo | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/token/src/main.leo b/token/src/main.leo
index 58a02cd..c7dd5ce 100644
--- a/token/src/main.leo
+++ b/token/src/main.leo
@@ -14,12 +14,12 @@ program token.aleo {
     /* Mint */
 
     // The function `mint_public` issues the specified token amount for the token receiver publicly on the network.
-    transition mint_public(public receiver: address, public amount: u64) {
+    async transition mint_public(public receiver: address, public amount: u64) -> Future {
         // Mint the tokens publicly by invoking the computation on-chain.
-        return then finalize(receiver, amount);
+        return mint_public_state(receiver, amount);
     }
 
-    finalize mint_public(public receiver: address, public amount: u64) {
+    async function mint_public_state(public receiver: address, public amount: u64) {
         // Increments `account[receiver]` by `amount`.
         // If `account[receiver]` does not exist, it will be created.
         // If `account[receiver] + amount` overflows, `mint_public` is reverted.
@@ -36,12 +36,12 @@ program token.aleo {
     }
 
     /* Transfer */
-    transition transfer_public(public receiver: address, public amount: u64) {
+    async transition transfer_public(public receiver: address, public amount: u64) -> Future {
         // Transfer the tokens publicly, by invoking the computation on-chain.
-        return then finalize(self.caller, receiver, amount);
+        return transfer_public_tokens(self.caller, receiver, amount);
     }
 
-    finalize transfer_public(public sender: address, public receiver: address, public amount: u64) {
+    async function transfer_public_tokens(public sender: address, public receiver: address, public amount: u64) {
         // Decrements `account[sender]` by `amount`.
         // If `account[sender]` does not exist, it will be created.
         // If `account[sender] - amount` underflows, `transfer_public` is reverted.
@@ -80,7 +80,7 @@ program token.aleo {
 
     // The function `transfer_private_to_public` turns a specified token amount from a token record into public tokens for the specified receiver.
     // This function preserves privacy for the sender's record, however it publicly reveals the token receiver and the token amount.
-    transition transfer_private_to_public(sender: token, public receiver: address, public amount: u64) -> token {
+    async transition transfer_private_to_public(sender: token, public receiver: address, public amount: u64) -> (token, Future) {
         // Checks the given token record has a sufficient token amount.
         // This `sub` operation is safe, and the proof will fail if an underflow occurs.
         // `difference` holds the change amount for the caller.
@@ -94,10 +94,10 @@ program token.aleo {
 
         // Output the sender's change record.
         // Increment the token amount publicly for the token receiver.
-        return remaining then finalize(receiver, amount);
+        return (remaining, transfer_from_private_to_public(receiver, amount));
     }
 
-    finalize transfer_private_to_public(public receiver: address, public amount: u64) {
+    async function transfer_from_private_to_public(public receiver: address, public amount: u64) {
         // Increments `account[receiver]` by `amount`.
         // If `account[receiver]` does not exist, it will be created.
         // If `account[receiver] + amount` overflows, `transfer_private_to_public` is reverted.
@@ -107,7 +107,7 @@ program token.aleo {
 
     // The function `transfer_public_to_private` turns a specified token amount from `account` into a token record for the specified receiver.
     // This function preserves privacy for the receiver's record, however it publicly reveals the caller and the specified token amount.
-    transition transfer_public_to_private(public receiver: address, public amount: u64) -> token {
+    async transition transfer_public_to_private(public receiver: address, public amount: u64) -> (token, Future) {
         // Produces a token record for the token receiver.
         let transferred: token = token {
             owner: receiver,
@@ -116,10 +116,10 @@ program token.aleo {
 
         // Output the receiver's record.
         // Decrement the token amount of the caller publicly.
-        return transferred then finalize(self.caller, amount);
+        return (transferred, transfer_from_public_to_private(self.caller, amount));
     }
 
-    finalize transfer_public_to_private(public sender: address, public amount: u64) {
+    async function transfer_from_public_to_private(public sender: address, public amount: u64) {
         // Decrements `account[sender]` by `amount`.
         // If `account[sender]` does not exist, it will be created.
         // If `account[sender] - amount` underflows, `transfer_public_to_private` is reverted.