Update examples

This commit is contained in:
d0cd 2022-10-16 11:55:00 -07:00
parent c6fd32c032
commit 21a015ede4
3 changed files with 14 additions and 24 deletions

View File

@ -43,9 +43,7 @@ program basic_bank.aleo {
// Compute the hash of the token owner.
let hash: field = BHP256::hash(token.owner);
async finalize(hash, amount);
return remaining;
return remaining then finalize(hash, amount);
}
// Updates on-chain state by the amount of tokens deposited.
@ -73,9 +71,7 @@ program basic_bank.aleo {
amount: total,
};
async finalize(hash, amount);
return token;
return token then finalize(hash, amount);
}
// Updates on-chain state by the amount of tokens withdrawn.

View File

@ -17,7 +17,7 @@ program token.aleo {
// 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) {
// Mint the tokens publicly by invoking the computation on-chain.
async finalize(receiver, amount);
return then finalize(receiver, amount);
}
finalize mint_public(public receiver: address, public amount: u64) {
@ -39,7 +39,7 @@ program token.aleo {
/* Transfer */
transition transfer_public(public receiver: address, public amount: u64) {
// Transfer the tokens publicly, by invoking the computation on-chain.
async finalize(self.caller, receiver, amount);
return then finalize(self.caller, receiver, amount);
}
finalize transfer_public(public sender: address, public receiver: address, public amount: u64) {
@ -93,11 +93,9 @@ program token.aleo {
amount: difference,
};
// Increment the token amount publicly for the token receiver.
async finalize(receiver, amount);
// Output the sender's change record.
return remaining;
// Increment the token amount publicly for the token receiver.
return remaining then finalize(receiver, amount);
}
finalize transfer_private_to_public(public receiver: address, public amount: u64) {
@ -117,11 +115,9 @@ program token.aleo {
amount: amount,
};
// Decrement the token amount of the caller publicly.
async finalize(self.caller, amount);
// Output the receiver's record.
return transferred;
// Decrement the token amount of the caller publicly.
return transferred then finalize(self.caller, amount);
}
finalize transfer_public_to_private(public sender: address, public amount: u64) {

View File

@ -40,16 +40,15 @@ program vote.aleo {
// Generate a new proposal id.
let id: field = BHP256::hash(info.title);
// Finalize the proposal id.
async finalize(id);
// Return a new record for the proposal.
// Finalize the proposal id.
return Proposal {
owner: self.caller,
gates: 0u64,
id,
info,
};
} then finalize(id);
}
// Create a new proposal in the "tickets" mapping.
finalize propose(public id: field) {
@ -61,14 +60,13 @@ program vote.aleo {
public pid: field,
public voter: address,
) -> Ticket {
// Finalize the proposal id for the ticket.
async finalize(pid);
// Finalize the proposal id for the ticket.
return Ticket {
owner: voter,
gates: 0u64,
pid,
};
} then finalize(pid);
}
// Create a new ticket on a proposal in the "tickets" mapping.
finalize new_ticket(public pid: field) {
@ -78,7 +76,7 @@ program vote.aleo {
// Vote privately to agree with a proposal.
transition agree(ticket: Ticket) {
// Finalize this vote.
async finalize(ticket.pid);
return then finalize(ticket.pid);
}
finalize agree(public pid: field) {
// Publicly increment the number of agree votes.
@ -88,7 +86,7 @@ program vote.aleo {
// Vote privately to disagree with a proposal.
transition disagree(ticket: Ticket) {
// Finalize this vote.
async finalize(ticket.pid);
return then finalize(ticket.pid);
}
finalize disagree(pid: field) {
// Publicly increment the number of disagree votes.