Skip to content

Commit 46db4bf

Browse files
Jannis PohlmannfordN
authored andcommitted
graph, runtime/wasm: Add block size to EthereumBlockData
1 parent 901f98b commit 46db4bf

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

graph/src/components/ethereum/types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub struct EthereumBlockData {
3131
pub timestamp: U256,
3232
pub difficulty: U256,
3333
pub total_difficulty: U256,
34+
pub size: Option<U256>,
3435
}
3536

3637
impl<'a, T> From<&'a Block<T>> for EthereumBlockData {
@@ -49,6 +50,7 @@ impl<'a, T> From<&'a Block<T>> for EthereumBlockData {
4950
timestamp: block.timestamp,
5051
difficulty: block.difficulty,
5152
total_difficulty: block.total_difficulty,
53+
size: block.size,
5254
}
5355
}
5456
}

runtime/wasm/src/asc_abi/class.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ pub(crate) struct AscEthereumBlock {
415415
pub timestamp: AscPtr<AscBigInt>,
416416
pub difficulty: AscPtr<AscBigInt>,
417417
pub total_difficulty: AscPtr<AscBigInt>,
418+
pub size: AscPtr<AscBigInt>,
418419
}
419420

420421
impl AscType for AscEthereumBlock {}

runtime/wasm/src/to_from/external.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ impl ToAscObj<AscEthereumBlock> for EthereumBlockData {
263263
timestamp: heap.asc_new(&BigInt::from_unsigned_u256(&self.timestamp)),
264264
difficulty: heap.asc_new(&BigInt::from_unsigned_u256(&self.difficulty)),
265265
total_difficulty: heap.asc_new(&BigInt::from_unsigned_u256(&self.total_difficulty)),
266+
size: self
267+
.size
268+
.map(|size| heap.asc_new(&BigInt::from_unsigned_u256(&size)))
269+
.unwrap_or_else(|| AscPtr::null()),
266270
}
267271
}
268272
}

0 commit comments

Comments
 (0)