Skip to content

Commit db61bac

Browse files
committed
chain/ethereum: wrapper for Block
1 parent 85cf80d commit db61bac

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

chain/ethereum/src/trigger.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use graph::data::subgraph::API_VERSION_0_0_6;
66
use graph::data::subgraph::API_VERSION_0_0_7;
77
use graph::data_source::common::DeclaredCall;
88
use graph::prelude::web3::types::Address;
9-
use graph::prelude::web3::types::Block;
109
use graph::prelude::web3::types::Log;
1110
use graph::prelude::web3::types::Transaction;
1211
use graph::prelude::web3::types::TransactionReceipt;
@@ -17,6 +16,7 @@ use graph::prelude::web3::types::U256;
1716
use graph::prelude::web3::types::U64;
1817
use graph::prelude::BlockNumber;
1918
use graph::prelude::BlockPtr;
19+
use graph::prelude::LightEthereumBlock;
2020
use graph::prelude::{CheapClone, EthereumCall};
2121
use graph::runtime::asc_new;
2222
use graph::runtime::gas::GasCounter;
@@ -37,9 +37,6 @@ use crate::runtime::abi::AscEthereumTransaction_0_0_1;
3737
use crate::runtime::abi::AscEthereumTransaction_0_0_2;
3838
use crate::runtime::abi::AscEthereumTransaction_0_0_6;
3939

40-
// ETHDEP: This should be defined in only one place.
41-
type LightEthereumBlock = Block<Transaction>;
42-
4340
static U256_DEFAULT: U256 = U256::zero();
4441

4542
pub enum MappingTrigger {
@@ -412,11 +409,11 @@ impl TriggerData for EthereumTrigger {
412409
/// Ethereum block data.
413410
#[derive(Clone, Debug)]
414411
pub struct EthereumBlockData<'a> {
415-
block: &'a Block<Transaction>,
412+
block: &'a LightEthereumBlock,
416413
}
417414

418-
impl<'a> From<&'a Block<Transaction>> for EthereumBlockData<'a> {
419-
fn from(block: &'a Block<Transaction>) -> EthereumBlockData<'a> {
415+
impl<'a> From<&'a LightEthereumBlock> for EthereumBlockData<'a> {
416+
fn from(block: &'a LightEthereumBlock) -> EthereumBlockData<'a> {
420417
EthereumBlockData { block }
421418
}
422419
}
@@ -550,7 +547,7 @@ pub struct EthereumEventData<'a> {
550547

551548
impl<'a> EthereumEventData<'a> {
552549
pub fn new(
553-
block: &'a Block<Transaction>,
550+
block: &'a LightEthereumBlock,
554551
tx: &'a Transaction,
555552
log: &'a Log,
556553
params: &'a [abi::DynSolParam],
@@ -598,7 +595,7 @@ pub struct EthereumCallData<'a> {
598595

599596
impl<'a> EthereumCallData<'a> {
600597
fn new(
601-
block: &'a Block<Transaction>,
598+
block: &'a LightEthereumBlock,
602599
transaction: &'a Transaction,
603600
call: &'a EthereumCall,
604601
inputs: &'a [abi::DynSolParam],

graph/src/components/ethereum/types.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use alloy::rpc::types::trace::parity::{Action, LocalizedTransactionTrace, TraceOutput};
22
use serde::{Deserialize, Serialize};
33
use std::{convert::TryFrom, sync::Arc};
4-
use web3::types::{Address, Block, Bytes, Log, Transaction, TransactionReceipt, H256, U256, U64};
4+
use web3::types::{Address, Bytes, Log, Transaction, TransactionReceipt, H256, U256, U64};
55

66
use crate::{
77
alloy_todo,
@@ -12,7 +12,10 @@ use crate::{
1212
util::conversions::{alloy_bytes_to_web3_bytes, alloy_u256_to_web3_u256, u64_to_web3_u256},
1313
};
1414

15-
pub type LightEthereumBlock = Block<Transaction>;
15+
#[allow(dead_code)]
16+
pub struct Block(web3::types::Block<Transaction>);
17+
18+
pub type LightEthereumBlock = web3::types::Block<Transaction>;
1619
pub type LightEthereumBlockAlloy = AlloyBlock;
1720

1821
pub trait LightEthereumBlockExt {

0 commit comments

Comments
 (0)