From c6c41e57736127c9360019c2be1c8c82d9f0952d Mon Sep 17 00:00:00 2001 From: 0xMochan Date: Wed, 24 Jan 2024 16:24:41 -0500 Subject: [PATCH] fix: code clean w/ clippy --- substreams/ethereum-balancer/.DS_Store | Bin 6148 -> 0 bytes substreams/ethereum-balancer/src/lib.rs | 44 +++++++++++------------- 2 files changed, 20 insertions(+), 24 deletions(-) delete mode 100644 substreams/ethereum-balancer/.DS_Store diff --git a/substreams/ethereum-balancer/.DS_Store b/substreams/ethereum-balancer/.DS_Store deleted file mode 100644 index 269120cf9452a35d00e53e3bec5be96a2d24a57f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}(Pm5FWRMwgRLcK;meLYb8oSLKT-#$_s1|99UGErh&#j@dRGC=Qc0b&?|f)w)a@4<`1AW0jICs8Pt78c7WOXV~7Qcc{nmyVNm zZ*)qdBc(#`rQh?8gTbU*TRl)w+6$t=NGAmT07HJB1d*>MZ8eVkMCZE3QAO$2)~C~E zvsIVdySuZxoVJ>cy4-0sXR~T$ZDVuqNB1fmM(VdAQs5V-WyRtP++ruUBR}bf9zG$t zbLMMz6oo3fKr2mDgaj$*hZkFJUkzglhUH&3ub!dmbnJ&+xeIU4@BcjR=e_=ayzymj z))k3qEX)8izzlpY1NH>1EPd`{@aoI}Gw=l&pz}eZ5;_($gZk*eMwbAHB{XZnKGhPG zBP}`>GlS?s5hfMUqzYSN2$PO>Y2zG=nL(2d!WJLGt}JYYBJ}DwztrI%9E0341I)l% z28w1_qx=8x-}V37BpxvX%)qx|K$JRer;S^(ckA5d=&qHh=cptUml^z!@1LE~$g)Sj-Hf1%-bEG!5J^10Tx3GbB!IQvd(} diff --git a/substreams/ethereum-balancer/src/lib.rs b/substreams/ethereum-balancer/src/lib.rs index 25a4e4d..7a27d81 100644 --- a/substreams/ethereum-balancer/src/lib.rs +++ b/substreams/ethereum-balancer/src/lib.rs @@ -1,18 +1,15 @@ use std::collections::HashMap; use anyhow::Result; +use substreams::hex; use substreams::pb::substreams::StoreDeltas; -use substreams::store::{ - StoreAdd, StoreAddBigInt, StoreGet, StoreGetBigInt, StoreGetProto, StoreNew, - StoreSetIfNotExists, StoreSetIfNotExistsProto, -}; -use substreams::{hex, log}; +use substreams::store::{StoreAdd, StoreAddBigInt, StoreNew}; use substreams::key; use substreams::scalar::BigInt; -use substreams_ethereum::block_view::{CallView, LogView}; + use substreams_ethereum::pb::eth; -use substreams_ethereum::pb::eth::v2::{balance_change, Call, Log, TransactionTrace}; +use substreams_ethereum::pb::eth::v2::{Call, Log}; use substreams_ethereum::{Event, Function}; use itertools::Itertools; @@ -67,8 +64,8 @@ impl PartialEq for TransactionWrapper { /// fufill both the required details + any extra `Attributes` /// Ref: https://docs.balancer.fi/reference/contracts/deployment-addresses/mainnet.html fn pool_factory_map(pool_addr: &[u8], log: &Log, call: &Call) -> Option { - match pool_addr { - &hex!("897888115Ada5773E02aA29F775430BFB5F34c51") => { + match *pool_addr { + hex!("897888115Ada5773E02aA29F775430BFB5F34c51") => { let create_call = abi::weighted_pool_factory::functions::Create::match_and_decode(call)?; let pool_created = @@ -98,7 +95,7 @@ fn pool_factory_map(pool_addr: &[u8], log: &Log, call: &Call) -> Option { + hex!("DB8d758BCb971e482B2C45f7F8a7740283A1bd3A") => { let create_call = abi::composable_stable_pool_factory::functions::Create::match_and_decode(call)?; let pool_created = @@ -128,7 +125,7 @@ fn pool_factory_map(pool_addr: &[u8], log: &Log, call: &Call) -> Option { + hex!("813EE7a840CE909E7Fea2117A44a90b8063bd4fd") => { let create_call = abi::erc_linear_pool_factory::functions::Create::match_and_decode(call)?; let pool_created = @@ -160,7 +157,7 @@ fn pool_factory_map(pool_addr: &[u8], log: &Log, call: &Call) -> Option { + hex!("5F43FBa61f63Fa6bFF101a0A0458cEA917f6B347") => { let create_call = abi::euler_linear_pool_factory::functions::Create::match_and_decode(call)?; let pool_created = @@ -190,7 +187,7 @@ fn pool_factory_map(pool_addr: &[u8], log: &Log, call: &Call) -> Option { + hex!("39A79EB449Fc05C92c39aA6f0e9BfaC03BE8dE5B") => { let create_call = abi::gearbox_linear_pool_factory::functions::Create::match_and_decode(call)?; let pool_created = @@ -222,7 +219,7 @@ fn pool_factory_map(pool_addr: &[u8], log: &Log, call: &Call) -> Option { + // hex!("BF904F9F340745B4f0c4702c7B6Ab1e808eA6b93") => { // let create_call = abi::managed_pool_factory::functions::Create::match_and_decode(call)?; // let pool_created = // abi::managed_pool_factory::events::PoolCreated::match_and_decode(log)?; @@ -246,7 +243,7 @@ fn pool_factory_map(pool_addr: &[u8], log: &Log, call: &Call) -> Option { + hex!("4E11AEec21baF1660b1a46472963cB3DA7811C89") => { let create_call = abi::silo_linear_pool_factory::functions::Create::match_and_decode(call)?; let pool_created = @@ -276,7 +273,7 @@ fn pool_factory_map(pool_addr: &[u8], log: &Log, call: &Call) -> Option { + hex!("5F5222Ffa40F2AEd6380D022184D6ea67C776eE0") => { let create_call = abi::yearn_linear_pool_factory::functions::Create::match_and_decode(call)?; let pool_created = @@ -308,7 +305,7 @@ fn pool_factory_map(pool_addr: &[u8], log: &Log, call: &Call) -> Option { + hex!("A5bf2ddF098bb0Ef6d120C98217dD6B141c74EE0") => { let create_call = abi::weighted_pool_tokens_factory::functions::Create::match_and_decode(call)?; let pool_created = @@ -361,7 +358,7 @@ pub fn map_balance_deltas(block: eth::v2::Block) -> Result::into(log.receipt.transaction.index).clone(), + index: Into::::into(log.receipt.transaction.index), }), token: token.clone(), delta: delta.to_signed_bytes_be(), @@ -395,7 +392,7 @@ pub fn store_balance_changes(deltas: tycho::BalanceDeltas, store: StoreAddBigInt pub fn map_changes( block: eth::v2::Block, deltas: tycho::BalanceDeltas, - store: StoreDeltas, // Note, this map module is using the `deltas` mode for the store. + store: StoreDeltas, // Note, this map module is using the `deltas` mode for the store. ) -> Result { // Gather contract changes by indexing `PoolCreated` events and analysing the `Create` call // We store these as a hashmap by tx hash since we need to agg by tx hash later @@ -414,14 +411,14 @@ pub fn map_changes( hash: tx.hash.clone(), from: tx.from.clone(), to: tx.to.clone(), - index: Into::::into(tx.index).clone(), + index: Into::::into(tx.index), }), contract_changes: vec![], balance_changes: vec![], component_changes: vec![pool_factory_map( pool_factory_address, - &log, - &call.call, + log, + call.call, )?], }, )) @@ -487,8 +484,7 @@ pub fn map_changes( ts: block.timestamp_seconds(), }), changes: transaction_contract_changes - .into_iter() - .map(|(_, v)| v) + .into_values() .sorted_unstable_by_key(|tx_change| tx_change.tx.clone().unwrap().index) .collect::>(), })