Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use async keyword before finalize statement. #8

Merged
merged 3 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 92 additions & 26 deletions basic_bank/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,36 @@ echo "
######## STEP 1: Initialize 100 tokens for aleo1zeklp...v46ngg ########
######## ########
######## ----------------------------------------- ########
######## | BANK | aleo1zeklp...v46ngg | ########
######## | ACTION | AMOUNT | ########
######## ----------------------------------------- ########
######## ----------------------------------------- ########
######## | Start Balance | 0 | ########
######## | Issuing | 100 | ########
######## ----------------------------------------- ########
######## | Periods | 0 | ########
######## | Depositing | 0 | ########
######## ----------------------------------------- ########
######## | Interest Rate | 12.34% | ########
######## | Withdrawing | 0 | ########
######## ----------------------------------------- ########
######## ########
######## ----------------------------------------- ########
######## | Issuing | 100 | ########
######## | WALLET | aleo1zeklp...v46ngg | ########
######## ----------------------------------------- ########
######## | Depositing | 0 | ########
######## ----------------------------------------- ########
######## | Balance | 100 | ########
######## ----------------------------------------- ########
######## | Withdrawing | 0 | ########
######## ########
######## ----------------------------------------- ########
######## | BANK | aleo1zeklp...v46ngg | ########
######## ----------------------------------------- ########
######## ----------------------------------------- ########
######## | Balance | 0 | ########
######## ----------------------------------------- ########
######## | Final Balance | 100 | ########
######## | Periods | 0 | ########
######## ----------------------------------------- ########
######## | Interest Rate | 12.34% | ########
######## ----------------------------------------- ########
######## ########
######## ----------------------------------------- ########
######## | TOTAL BALANCE | 100 | ########
######## ----------------------------------------- ########
######## ########
###############################################################################
Expand All @@ -76,28 +87,39 @@ echo "{
echo "
###############################################################################
######## ########
######## STEP 2: aleo1zeklp...v46ngg deposits 50 tokens ########
######## STEP 2: aleo1zeklp...v46ngg deposits 50 tokens ########
######## ########
######## ----------------------------------------- ########
######## | BANK | aleo1zeklp...v46ngg | ########
######## | ACTION | AMOUNT | ########
######## ----------------------------------------- ########
######## ----------------------------------------- ########
######## | Start Balance | 100 | ########
######## | Issuing | 0 | ########
######## ----------------------------------------- ########
######## | Periods | 0 | ########
######## | Depositing | 50 | ########
######## ----------------------------------------- ########
######## | Interest Rate | 12.34% | ########
######## | Withdrawing | 0 | ########
######## ----------------------------------------- ########
######## ########
######## ----------------------------------------- ########
######## | Issuing | 0 | ########
######## | WALLET | aleo1zeklp...v46ngg | ########
######## ----------------------------------------- ########
######## | Depositing | 50 | ########
######## ----------------------------------------- ########
######## | Balance | 50 | ########
######## ----------------------------------------- ########
######## | Withdrawing | 0 | ########
######## ########
######## ----------------------------------------- ########
######## | BANK | aleo1zeklp...v46ngg | ########
######## ----------------------------------------- ########
######## ----------------------------------------- ########
######## | Final Balance | 150 | ########
######## | Balance | 50 | ########
######## ----------------------------------------- ########
######## | Periods | 0 | ########
######## ----------------------------------------- ########
######## | Interest Rate | 12.34% | ########
######## ----------------------------------------- ########
######## ########
######## ----------------------------------------- ########
######## | TOTAL BALANCE | 100 | ########
######## ----------------------------------------- ########
######## ########
###############################################################################
Expand All @@ -112,7 +134,40 @@ leo run deposit "{
echo "
###############################################################################
######## ########
######## STEP 3: Wait 15 periods ########
######## STEP 3: Wait 15 periods ########
######## ########
######## ----------------------------------------- ########
######## | ACTION | AMOUNT | ########
######## ----------------------------------------- ########
######## ----------------------------------------- ########
######## | Issuing | 0 | ########
######## ----------------------------------------- ########
######## | Depositing | 0 | ########
######## ----------------------------------------- ########
######## | Withdrawing | 0 | ########
######## ----------------------------------------- ########
######## ########
######## ----------------------------------------- ########
######## | WALLET | aleo1zeklp...v46ngg | ########
######## ----------------------------------------- ########
######## ----------------------------------------- ########
######## | Balance | 50 | ########
######## ----------------------------------------- ########
######## ########
######## ----------------------------------------- ########
######## | BANK | aleo1zeklp...v46ngg | ########
######## ----------------------------------------- ########
######## ----------------------------------------- ########
######## | Balance | 266 | ########
######## ----------------------------------------- ########
######## | Periods | 15 | ########
######## ----------------------------------------- ########
######## | Interest Rate | 12.34% | ########
######## ----------------------------------------- ########
######## ########
######## ----------------------------------------- ########
######## | TOTAL BALANCE | 316 | ########
######## ----------------------------------------- ########
######## ########
###############################################################################
"
Expand All @@ -136,25 +191,36 @@ echo "
######## STEP 4: Withdraw tokens of aleo1zeklp...v46ngg w/ interest ########
######## ########
######## ----------------------------------------- ########
######## | BANK | aleo1zeklp...v46ngg | ########
######## | ACTION | AMOUNT | ########
######## ----------------------------------------- ########
######## ----------------------------------------- ########
######## | Start Balance | 266 | ########
######## | Issuing | 0 | ########
######## ----------------------------------------- ########
######## | Periods | 15 | ########
######## | Depositing | 0 | ########
######## ----------------------------------------- ########
######## | Interest Rate | 12.34% | ########
######## | Withdrawing | 266 | ########
######## ----------------------------------------- ########
######## ########
######## ----------------------------------------- ########
######## | Issuing | 0 | ########
######## | WALLET | aleo1zeklp...v46ngg | ########
######## ----------------------------------------- ########
######## | Depositing | 0 | ########
######## ----------------------------------------- ########
######## | Balance | 316 | ########
######## ----------------------------------------- ########
######## | Withdrawing | 266 | ########
######## ########
######## ----------------------------------------- ########
######## | BANK | aleo1zeklp...v46ngg | ########
######## ----------------------------------------- ########
######## ----------------------------------------- ########
######## | Balance | 0 | ########
######## ----------------------------------------- ########
######## | Periods | 15 | ########
######## ----------------------------------------- ########
######## | Interest Rate | 12.34% | ########
######## ----------------------------------------- ########
######## ########
######## ----------------------------------------- ########
######## | Final Balance | 0 | ########
######## | TOTAL BALANCE | 316 | ########
######## ----------------------------------------- ########
######## ########
###############################################################################
Expand Down
4 changes: 2 additions & 2 deletions basic_bank/src/main.leo
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function deposit(token: Token, amount: u64) -> Token {
// Compute the hash of the token owner.
let hash: field = BHP256::hash(token.owner);

finalize(hash, amount);
async finalize(hash, amount);

return remaining;
}
Expand Down Expand Up @@ -75,7 +75,7 @@ function withdraw(recipient: address, amount: u64, rate: u64, periods: u64) -> T
amount: total,
};

finalize(hash, amount);
async finalize(hash, amount);

return token;
}
Expand Down
8 changes: 4 additions & 4 deletions token/src/main.leo
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ record token {
@program
function mint_public(public receiver: address, public amount: u64) {
// Mint the tokens publicly by invoking the computation on-chain.
finalize(receiver, amount);
async finalize(receiver, amount);
}

finalize mint_public(public receiver: address, public amount: u64) {
Expand All @@ -41,7 +41,7 @@ function mint_private(receiver: address, amount: u64) -> token {
@program
function transfer_public(public receiver: address, public amount: u64) {
// Transfer the tokens publicly, by invoking the computation on-chain.
finalize(self.caller, receiver, amount);
async finalize(self.caller, receiver, amount);
}

finalize transfer_public(public sender: address, public receiver: address, public amount: u64) {
Expand Down Expand Up @@ -98,7 +98,7 @@ function transfer_private_to_public(sender: token, public receiver: address, pub
};

// Increment the token amount publicly for the token receiver.
finalize(receiver, amount);
async finalize(receiver, amount);

// Output the sender's change record.
return remaining;
Expand All @@ -123,7 +123,7 @@ function transfer_public_to_private(public receiver: address, public amount: u64
};

// Decrement the token amount of the caller publicly.
finalize(self.caller, amount);
async finalize(self.caller, amount);

// Output the receiver's record.
return transferred;
Expand Down
8 changes: 4 additions & 4 deletions vote/src/main.leo
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function propose(public info: ProposalInfo) -> Proposal {
let id: field = BHP256::hash(info.title);

// Finalize the proposal id.
finalize(id);
async finalize(id);

// Return a new record for the proposal.
return Proposal {
Expand All @@ -64,7 +64,7 @@ function new_ticket(
public voter: address,
) -> Ticket {
// Finalize the proposal id for the ticket.
finalize(pid);
async finalize(pid);

return Ticket {
owner: voter,
Expand All @@ -81,7 +81,7 @@ finalize new_ticket(public pid: field) {
@program
function agree(ticket: Ticket) {
// Finalize this vote.
finalize(ticket.pid);
async finalize(ticket.pid);
}
finalize agree(public pid: field) {
// Publicly increment the number of agree votes.
Expand All @@ -92,7 +92,7 @@ finalize agree(public pid: field) {
@program
function disagree(ticket: Ticket) {
// Finalize this vote.
finalize(ticket.pid);
async finalize(ticket.pid);
}
finalize disagree(pid: field) {
// Publicly increment the number of disagree votes.
Expand Down