Skip to content

Commit

Permalink
Merge pull request #12 from gear-foundation/lm-fix-fmt
Browse files Browse the repository at this point in the history
fixed fmt
  • Loading branch information
MedovTimur authored Jul 30, 2024
2 parents d705a98 + 2be20d2 commit d0bf47a
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 50 deletions.
99 changes: 62 additions & 37 deletions extended-vft/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extended-vft/app/src/services/extended_vft/funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn burn(
} else {
balances.remove(&from);
}

*total_supply = new_total_supply;
Ok(true)
}
16 changes: 4 additions & 12 deletions vft-service/src/funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub fn approve(
spender: ActorId,
value: U256,
) -> bool {

if owner == spender {
return false;
}
Expand All @@ -24,17 +23,14 @@ pub fn approve(
if value.is_zero() {
return allowances.remove(&key).is_some();
}

let prev = allowances.insert(key, value);

prev.map(|v| v != value).unwrap_or(true)
}

pub fn balance_of(balances: &BalancesMap, owner: ActorId) -> U256 {
balances
.get(&owner)
.cloned()
.unwrap_or_default()
balances.get(&owner).cloned().unwrap_or_default()
}

pub fn transfer(
Expand All @@ -55,13 +51,12 @@ pub fn transfer(
.checked_add(value)
.ok_or(Error::NumericOverflow)?;


if !new_from.is_zero() {
balances.insert(from, new_from);
} else {
balances.remove(&from);
}

balances.insert(to, new_to);

Ok(true)
Expand Down Expand Up @@ -606,10 +601,7 @@ mod tests {
}

pub fn balances_map<const N: usize>(content: [(ActorId, U256); N]) -> BalancesMap {
content
.into_iter()
.map(|(k, v)| (k, v))
.collect()
content.into_iter().map(|(k, v)| (k, v)).collect()
}

pub fn alice() -> ActorId {
Expand Down

0 comments on commit d0bf47a

Please sign in to comment.