Skip to content

Commit 4a31f26

Browse files
committed
[fix](network): Displayed ENS IDs
1 parent 2767d07 commit 4a31f26

File tree

1 file changed

+44
-8
lines changed

1 file changed

+44
-8
lines changed

src/network.rs

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,56 @@ impl<'a> Network<'a> {
115115
}
116116
IoEvent::GetBlock { number } => {
117117
let res = Self::get_block(self.endpoint, number).await;
118-
let mut app = self.app.lock().await;
119118
if let Ok(block) = res {
120-
app.pop_current_route();
121-
app.set_route(Route::new(RouteId::Block(block), ActiveBlock::Main));
119+
{
120+
let mut app = self.app.lock().await;
121+
app.pop_current_route();
122+
app.set_route(Route::new(
123+
RouteId::Block(block.to_owned()),
124+
ActiveBlock::Main,
125+
));
126+
}
127+
128+
if let Some(block) = block {
129+
let mut addresses = vec![];
130+
for transaction in block.block.transactions {
131+
addresses.push(transaction.from);
132+
if let Some(to) = transaction.to {
133+
addresses.push(to);
134+
}
135+
}
136+
137+
let _ = self.update_app_with_ens_ids(&addresses).await;
138+
}
122139
}
140+
let mut app = self.app.lock().await;
123141
app.is_loading = false;
124142
}
125143
IoEvent::GetBlockByHash { hash } => {
126144
let res = Self::get_block(self.endpoint, hash).await;
127-
let mut app = self.app.lock().await;
128-
if let Ok(some) = res {
129-
app.pop_current_route();
130-
app.set_route(Route::new(RouteId::Block(some), ActiveBlock::Main));
145+
if let Ok(block) = res {
146+
{
147+
let mut app = self.app.lock().await;
148+
app.pop_current_route();
149+
app.set_route(Route::new(
150+
RouteId::Block(block.to_owned()),
151+
ActiveBlock::Main,
152+
));
153+
}
154+
155+
if let Some(block) = block {
156+
let mut addresses = vec![];
157+
for transaction in block.block.transactions {
158+
addresses.push(transaction.from);
159+
if let Some(to) = transaction.to {
160+
addresses.push(to);
161+
}
162+
}
163+
164+
let _ = self.update_app_with_ens_ids(&addresses).await;
165+
}
131166
}
167+
let mut app = self.app.lock().await;
132168
app.is_loading = false;
133169
}
134170
IoEvent::GetTransactionWithReceipt { transaction_hash } => {
@@ -164,7 +200,7 @@ impl<'a> Network<'a> {
164200
Self::get_latest_transactions(self.endpoint, n),
165201
)
166202
.await
167-
.unwrap();
203+
.unwrap(); //TODO: remove unwrap
168204
let mut addresses = vec![];
169205
for transaction in &transactions {
170206
addresses.push(transaction.transaction.from);

0 commit comments

Comments
 (0)