Create a workspace and make clippy happy.

This commit is contained in:
kayibal
2024-03-14 00:19:54 +00:00
parent e62cc13c0b
commit 425628ae97
11 changed files with 222 additions and 1345 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -4,8 +4,8 @@ version = "0.1.0"
edition = "2021"
[dependencies]
substreams-ethereum = "0.9.9"
substreams = "0.5"
prost = "0.11"
hex = "0.4.3"
substreams-ethereum.workspace = true
substreams.workspace = true
prost.workspace = true
hex.workspace = true
itertools = "0.12.0"

View File

@@ -1,13 +0,0 @@
reorder_imports = true
imports_granularity = "Crate"
use_small_heuristics = "Max"
comment_width = 100
wrap_comments = true
binop_separator = "Back"
trailing_comma = "Vertical"
trailing_semicolon = false
use_field_init_shorthand = true
chain_width = 40
ignore = [
"src/pb",
]

View File

@@ -63,6 +63,8 @@ pub fn store_balance_changes(deltas: BlockBalanceDeltas, store: impl StoreAdd<Bi
});
}
type TxAggregatedBalances = HashMap<Vec<u8>, (Transaction, HashMap<Vec<u8>, BalanceChange>)>;
/// Aggregates absolute balances per transaction and token.
///
/// ## Arguments
@@ -82,7 +84,7 @@ pub fn store_balance_changes(deltas: BlockBalanceDeltas, store: impl StoreAdd<Bi
pub fn aggregate_balances_changes(
balance_store: StoreDeltas,
deltas: BlockBalanceDeltas,
) -> HashMap<Vec<u8>, (Transaction, HashMap<Vec<u8>, BalanceChange>)> {
) -> TxAggregatedBalances {
balance_store
.deltas
.into_iter()
@@ -207,9 +209,9 @@ mod tests {
let token_1 = hex::decode("babe00").unwrap();
let t0_key =
format!("{}:{}", String::from_utf8(comp_id.clone()).unwrap(), hex::encode(&token_0));
format!("{}:{}", String::from_utf8(comp_id.clone()).unwrap(), hex::encode(token_0));
let t1_key =
format!("{}:{}", String::from_utf8(comp_id.clone()).unwrap(), hex::encode(&token_1));
format!("{}:{}", String::from_utf8(comp_id.clone()).unwrap(), hex::encode(token_1));
StoreDeltas {
deltas: vec![
StoreDelta {
@@ -283,12 +285,12 @@ mod tests {
let res_0 = store.get_last(format!(
"{}:{}",
String::from_utf8(comp_id.clone()).unwrap(),
hex::encode(&token_0)
hex::encode(token_0)
));
let res_1 = store.get_last(format!(
"{}:{}",
String::from_utf8(comp_id.clone()).unwrap(),
hex::encode(&token_1)
hex::encode(token_1)
));
assert_eq!(res_0, Some(BigInt::from_str("+999").unwrap()));

View File

@@ -49,11 +49,7 @@ impl InterimContractChange {
balance: vec![],
code: vec![],
slots: Default::default(),
change: if creation {
tycho::ChangeType::Creation.into()
} else {
tycho::ChangeType::Update.into()
},
change: if creation { tycho::ChangeType::Creation } else { tycho::ChangeType::Update },
}
}
}

View File

@@ -7,9 +7,11 @@ use std::rc::Rc;
use substreams::prelude::{BigInt, StoreDelete, StoreGet, StoreNew};
use substreams::store::StoreAdd;
type BigIntStore = HashMap<String, Vec<(u64, BigInt)>>;
#[derive(Debug, Clone)]
pub struct MockStore {
data: Rc<RefCell<HashMap<String, Vec<(u64, BigInt)>>>>,
data: Rc<RefCell<BigIntStore>>,
}
impl StoreDelete for MockStore {