From 2be20d2e27c159dff2d13e8eb7387a9f490a088c Mon Sep 17 00:00:00 2001 From: LouiseMedova Date: Tue, 30 Jul 2024 10:58:56 +0300 Subject: [PATCH] fixed fmt --- extended-vft/Cargo.lock | 99 ++++++++++++------- .../app/src/services/extended_vft/funcs.rs | 2 +- vft-service/src/funcs.rs | 16 +-- 3 files changed, 67 insertions(+), 50 deletions(-) diff --git a/extended-vft/Cargo.lock b/extended-vft/Cargo.lock index df46907..1854434 100644 --- a/extended-vft/Cargo.lock +++ b/extended-vft/Cargo.lock @@ -101,7 +101,7 @@ dependencies = [ "getrandom 0.2.15", "once_cell", "version_check", - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -893,9 +893,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" [[package]] name = "cfg-expr" @@ -4535,9 +4535,12 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f" +dependencies = [ + "zerocopy 0.6.6", +] [[package]] name = "precomputed-hash" @@ -5078,8 +5081,8 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "sails-client-gen" -version = "0.1.1" -source = "git+https://github.com/gear-tech/sails#310008ad1e89f654fd8c3cc437e630c373c95ce0" +version = "0.2.0" +source = "git+https://github.com/gear-tech/sails#0de2c9e1b5c2d309d7e4495897c38870513819b3" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -5090,8 +5093,8 @@ dependencies = [ [[package]] name = "sails-idl-gen" -version = "0.1.1" -source = "git+https://github.com/gear-tech/sails#310008ad1e89f654fd8c3cc437e630c373c95ce0" +version = "0.2.0" +source = "git+https://github.com/gear-tech/sails#0de2c9e1b5c2d309d7e4495897c38870513819b3" dependencies = [ "convert_case 0.6.0", "handlebars", @@ -5104,8 +5107,8 @@ dependencies = [ [[package]] name = "sails-idl-parser" -version = "0.1.1" -source = "git+https://github.com/gear-tech/sails#310008ad1e89f654fd8c3cc437e630c373c95ce0" +version = "0.2.0" +source = "git+https://github.com/gear-tech/sails#0de2c9e1b5c2d309d7e4495897c38870513819b3" dependencies = [ "lalrpop", "lalrpop-util", @@ -5115,8 +5118,8 @@ dependencies = [ [[package]] name = "sails-macros" -version = "0.1.1" -source = "git+https://github.com/gear-tech/sails#310008ad1e89f654fd8c3cc437e630c373c95ce0" +version = "0.2.0" +source = "git+https://github.com/gear-tech/sails#0de2c9e1b5c2d309d7e4495897c38870513819b3" dependencies = [ "proc-macro-error", "sails-macros-core", @@ -5124,8 +5127,8 @@ dependencies = [ [[package]] name = "sails-macros-core" -version = "0.1.1" -source = "git+https://github.com/gear-tech/sails#310008ad1e89f654fd8c3cc437e630c373c95ce0" +version = "0.2.0" +source = "git+https://github.com/gear-tech/sails#0de2c9e1b5c2d309d7e4495897c38870513819b3" dependencies = [ "const_format", "convert_case 0.6.0", @@ -5138,8 +5141,8 @@ dependencies = [ [[package]] name = "sails-rs" -version = "0.1.1" -source = "git+https://github.com/gear-tech/sails#310008ad1e89f654fd8c3cc437e630c373c95ce0" +version = "0.2.0" +source = "git+https://github.com/gear-tech/sails#0de2c9e1b5c2d309d7e4495897c38870513819b3" dependencies = [ "futures", "gclient", @@ -5476,20 +5479,21 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] [[package]] name = "serde_spanned" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] @@ -6629,9 +6633,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.1" +version = "1.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d040ac2b29ab03b09d4129c2f5bbd012a3ac2f79d38ff506a4bf8dd34b0eac8a" +checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" dependencies = [ "backtrace", "bytes", @@ -6691,21 +6695,21 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac2caab0bf757388c6c0ae23b3293fdb463fee59434529014f85e3263b995c28" +checksum = "81967dd0dd2c1ab0bc3468bd7caecc32b8a4aa47d0c8c695d8c2b2108168d62c" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.16", + "toml_edit 0.22.17", ] [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db" dependencies = [ "serde", ] @@ -6734,15 +6738,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.16" +version = "0.22.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788" +checksum = "8d9f8729f5aea9562aac1cc0441f5d6de3cff1ee0c5d67293eeca5eb36ee7c16" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.15", + "winnow 0.6.16", ] [[package]] @@ -7013,14 +7017,14 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vft-service" version = "0.1.0" -source = "git+https://github.com/gear-foundation/standards#1767c1ea39dacb1811c40f510b3700a4f5041493" +source = "git+https://github.com/gear-foundation/standards#d705a98c1529420e158289bcdff9d1492967e22f" dependencies = [ "gstd", "log", @@ -7977,9 +7981,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.15" +version = "0.6.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "557404e450152cd6795bb558bca69e43c585055f4606e3bcae5894fc6dac9ba0" +checksum = "b480ae9340fc261e6be3e95a1ba86d54ae3f9171132a73ce8d4bbaf68339507c" dependencies = [ "memchr", ] @@ -7999,13 +8003,34 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff4524214bc4629eba08d78ceb1d6507070cc0bcbbed23af74e19e6e924a24cf" +[[package]] +name = "zerocopy" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" +dependencies = [ + "byteorder", + "zerocopy-derive 0.6.6", +] + [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "zerocopy-derive", + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy-derive" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", ] [[package]] diff --git a/extended-vft/app/src/services/extended_vft/funcs.rs b/extended-vft/app/src/services/extended_vft/funcs.rs index 39379a0..39d4f4d 100644 --- a/extended-vft/app/src/services/extended_vft/funcs.rs +++ b/extended-vft/app/src/services/extended_vft/funcs.rs @@ -48,7 +48,7 @@ pub fn burn( } else { balances.remove(&from); } - + *total_supply = new_total_supply; Ok(true) } diff --git a/vft-service/src/funcs.rs b/vft-service/src/funcs.rs index b6e8f87..a5b49f9 100644 --- a/vft-service/src/funcs.rs +++ b/vft-service/src/funcs.rs @@ -14,7 +14,6 @@ pub fn approve( spender: ActorId, value: U256, ) -> bool { - if owner == spender { return false; } @@ -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( @@ -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) @@ -606,10 +601,7 @@ mod tests { } pub fn balances_map(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 {