mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-24 02:42:21 +03:00
Update examples to use async before finalize
This commit is contained in:
parent
7a859e7b63
commit
bf50384dd5
@ -28,7 +28,7 @@ function deposit(token: Token, amount: u64) -> Token {
|
||||
|
||||
let hash: field = BHP256::hash(token.owner);
|
||||
|
||||
finalize(hash, amount);
|
||||
async finalize(hash, amount);
|
||||
|
||||
return remaining;
|
||||
}
|
||||
@ -50,7 +50,7 @@ function withdraw(recipient: address, amount: u64, rate: u64, periods: u64) -> T
|
||||
amount: total,
|
||||
};
|
||||
|
||||
finalize(hash, amount);
|
||||
async finalize(hash, amount);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
@ -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) {
|
||||
@ -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) {
|
||||
@ -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;
|
||||
@ -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;
|
||||
|
@ -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 {
|
||||
@ -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,
|
||||
@ -80,7 +80,7 @@ finalize new_ticket(public pid: field) {
|
||||
// Vote to agree with a proposal.
|
||||
@program
|
||||
function agree(ticket: Ticket) {// Privately cast the vote.
|
||||
finalize(ticket.pid);
|
||||
async finalize(ticket.pid);
|
||||
}
|
||||
finalize agree(public pid: field) {// Publicly increment the number of agree votes.
|
||||
increment(agree_votes, pid, 1u64);
|
||||
@ -89,7 +89,7 @@ finalize agree(public pid: field) {// Publicly increment the number of agree vot
|
||||
// Vote to disagree with a proposal.
|
||||
@program
|
||||
function disagree(ticket: Ticket) {// Privately cast the vote.
|
||||
finalize(ticket.pid);
|
||||
async finalize(ticket.pid);
|
||||
}
|
||||
finalize disagree(pid: field) {// Publicly increment the number of disagree votes.
|
||||
increment(disagree_votes, pid, 1u64);
|
||||
|
Loading…
Reference in New Issue
Block a user