diff --git a/basic_bank/src/main.leo b/basic_bank/src/main.leo index 8258d4b..1693e98 100644 --- a/basic_bank/src/main.leo +++ b/basic_bank/src/main.leo @@ -47,7 +47,7 @@ program basic_bank.aleo { // - `hash` : The hash of the token owner. // - `amount`: The amount of tokens that were deposited. finalize deposit(hash: field, amount: u64) { - let balance: u64 = Mapping::get_or_init(balances, hash, 0u64); + let balance: u64 = Mapping::get_or_use(balances, hash, 0u64); Mapping::set(balances, hash, amount + balance); } @@ -75,7 +75,7 @@ program basic_bank.aleo { // - `hash` : The hash of the token owner. // - `amount`: The amount of tokens that were withdrawn. finalize withdraw(hash: field, amount: u64) { - let balance: u64 = Mapping::get_or_init(balances, hash, 0u64); + let balance: u64 = Mapping::get_or_use(balances, hash, 0u64); Mapping::set(balances, hash, balance - amount); } diff --git a/token/src/main.leo b/token/src/main.leo index 9daf53d..58a02cd 100644 --- a/token/src/main.leo +++ b/token/src/main.leo @@ -23,7 +23,7 @@ program token.aleo { // Increments `account[receiver]` by `amount`. // If `account[receiver]` does not exist, it will be created. // If `account[receiver] + amount` overflows, `mint_public` is reverted. - let receiver_amount: u64 = Mapping::get_or_init(account, receiver, 0u64); + let receiver_amount: u64 = Mapping::get_or_use(account, receiver, 0u64); Mapping::set(account, receiver, receiver_amount + amount); } @@ -45,13 +45,13 @@ program token.aleo { // Decrements `account[sender]` by `amount`. // If `account[sender]` does not exist, it will be created. // If `account[sender] - amount` underflows, `transfer_public` is reverted. - let sender_amount: u64 = Mapping::get_or_init(account, sender, 0u64); + let sender_amount: u64 = Mapping::get_or_use(account, sender, 0u64); Mapping::set(account, sender, sender_amount - amount); // Increments `account[receiver]` by `amount`. // If `account[receiver]` does not exist, it will be created. // If `account[receiver] + amount` overflows, `transfer_public` is reverted. - let receiver_amount: u64 = Mapping::get_or_init(account, receiver, 0u64); + let receiver_amount: u64 = Mapping::get_or_use(account, receiver, 0u64); Mapping::set(account, receiver, receiver_amount + amount); } @@ -101,7 +101,7 @@ program token.aleo { // 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. - let receiver_amount: u64 = Mapping::get_or_init(account, receiver, 0u64); + let receiver_amount: u64 = Mapping::get_or_use(account, receiver, 0u64); Mapping::set(account, receiver, receiver_amount + amount); } @@ -123,7 +123,7 @@ program token.aleo { // 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. - let sender_amount: u64 = Mapping::get_or_init(account, sender, 0u64); + let sender_amount: u64 = Mapping::get_or_use(account, sender, 0u64); Mapping::set(account, sender, sender_amount - amount); } } diff --git a/vote/src/main.leo b/vote/src/main.leo index 6e504bf..7b1a002 100644 --- a/vote/src/main.leo +++ b/vote/src/main.leo @@ -64,7 +64,7 @@ program vote.aleo { } // Create a new ticket on a proposal in the "tickets" mapping. finalize new_ticket(public pid: field) { - let vote: u64 = Mapping::get_or_init(tickets, pid, 0u64); + let vote: u64 = Mapping::get_or_use(tickets, pid, 0u64); Mapping::set(tickets, pid, vote + 1u64); } @@ -75,7 +75,7 @@ program vote.aleo { } finalize agree(public pid: field) { // Publicly increment the number of agree votes. - let agree_vote: u64 = Mapping::get_or_init(agree_votes, pid, 0u64); + let agree_vote: u64 = Mapping::get_or_use(agree_votes, pid, 0u64); Mapping::set(agree_votes, pid, agree_vote + 1u64); } @@ -86,7 +86,7 @@ program vote.aleo { } finalize disagree(pid: field) { // Publicly increment the number of disagree votes. - let disagree_vote: u64 = Mapping::get_or_init(disagree_votes, pid, 0u64); + let disagree_vote: u64 = Mapping::get_or_use(disagree_votes, pid, 0u64); Mapping::set(disagree_votes, pid, disagree_vote + 1u64); } }