Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix fmt for examples
  • Loading branch information
lean-apple committed Nov 4, 2022
commit fc26b9254d6119dfa99a45676ca22e651a85bdfd
12 changes: 4 additions & 8 deletions examples/erc1155/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ mod erc1155 {

// Given that TokenId is a `u128` the likelihood of this overflowing is pretty slim.
self.token_id_nonce += 1;
self.balances
.insert(&(caller, self.token_id_nonce), &value);
self.balances.insert(&(caller, self.token_id_nonce), &value);

// Emit transfer event but with mint semantics
self.env().emit_event(TransferSingle {
Expand All @@ -288,8 +287,7 @@ mod erc1155 {
ensure!(token_id <= self.token_id_nonce, Error::UnexistentToken);

let caller = self.env().caller();
self.balances
.insert(&(caller, token_id), &value);
self.balances.insert(&(caller, token_id), &value);

// Emit transfer event but with mint semantics
self.env().emit_event(TransferSingle {
Expand Down Expand Up @@ -323,13 +321,11 @@ mod erc1155 {
.get(&(from, token_id))
.expect("Caller should have ensured that `from` holds `token_id`.");
sender_balance -= value;
self.balances
.insert(&(from, token_id), &sender_balance);
self.balances.insert(&(from, token_id), &sender_balance);

let mut recipient_balance = self.balances.get(&(to, token_id)).unwrap_or(0);
recipient_balance += value;
self.balances
.insert(&(to, token_id), &recipient_balance);
self.balances.insert(&(to, token_id), &recipient_balance);

let caller = self.env().caller();
self.env().emit_event(TransferSingle {
Expand Down
6 changes: 2 additions & 4 deletions examples/erc20/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ mod erc20 {
#[ink(message)]
pub fn approve(&mut self, spender: AccountId, value: Balance) -> Result<()> {
let owner = self.env().caller();
self.allowances
.insert((&owner, &spender), &value);
self.allowances.insert((&owner, &spender), &value);
self.env().emit_event(Approval {
owner,
spender,
Expand Down Expand Up @@ -202,8 +201,7 @@ mod erc20 {
return Err(Error::InsufficientBalance)
}

self.balances
.insert(from, &(from_balance - value));
self.balances.insert(from, &(from_balance - value));
let to_balance = self.balance_of_impl(to);
self.balances.insert(to, &(to_balance + value));
self.env().emit_event(Transfer {
Expand Down
3 changes: 1 addition & 2 deletions examples/erc721/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ mod erc721 {
});

if approved {
self.operator_approvals
.insert((&caller, &to), &());
self.operator_approvals.insert((&caller, &to), &());
} else {
self.operator_approvals.remove((&caller, &to));
}
Expand Down
6 changes: 2 additions & 4 deletions examples/multisig/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,7 @@ mod multisig {
if new_confirmation {
count += 1;
self.confirmations.insert(&key, &());
self.confirmation_count
.insert(&transaction, &count);
self.confirmation_count.insert(&transaction, &count);
}
let status = {
if count >= self.requirement {
Expand Down Expand Up @@ -664,8 +663,7 @@ mod multisig {
self.confirmations.remove(&key);
let mut count = self.confirmation_count.get(&trans_id).unwrap_or(0);
count -= 1;
self.confirmation_count
.insert(&trans_id, &count);
self.confirmation_count.insert(&trans_id, &count);
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions examples/trait-erc20/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ mod erc20 {
#[ink(message)]
fn approve(&mut self, spender: AccountId, value: Balance) -> Result<()> {
let owner = self.env().caller();
self.allowances
.insert((&owner, &spender), &value);
self.allowances.insert((&owner, &spender), &value);
self.env().emit_event(Approval {
owner,
spender,
Expand Down Expand Up @@ -243,8 +242,7 @@ mod erc20 {
return Err(Error::InsufficientBalance)
}

self.balances
.insert(from, &(from_balance - value));
self.balances.insert(from, &(from_balance - value));
let to_balance = self.balance_of_impl(to);
self.balances.insert(to, &(to_balance + value));
self.env().emit_event(Transfer {
Expand Down