Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add iterator to BlobTransactionSidecar #1256

Conversation

DoTheBestToGetTheBest
Copy link
Contributor

@DoTheBestToGetTheBest DoTheBestToGetTheBest commented Sep 7, 2024

closes #1255

crates/eips/src/eip4844/sidecar.rs Outdated Show resolved Hide resolved
crates/eips/src/eip4844/sidecar.rs Outdated Show resolved Hide resolved
crates/eips/src/eip4844/sidecar.rs Outdated Show resolved Hide resolved
crates/eips/src/eip4844/sidecar.rs Outdated Show resolved Hide resolved
@DoTheBestToGetTheBest
Copy link
Contributor Author

hey matts thanks for the reivew, made all changes you requested!

Comment on lines +395 to +403
#[cfg(feature = "serde")]
fn parse_u64_string<'de, T, D>(de: D) -> Result<T, D::Error>
where
D: serde::Deserializer<'de>,
T: FromStr,
<T as FromStr>::Err: core::fmt::Display,
{
String::deserialize(de)?.parse().map_err(serde::de::Error::custom)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just alloy-serde::quantity

#[cfg(test)]
mod tests {
use super::*;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines +52 to +64
impl BlobTransactionSidecar {
/// Creates an iterator
pub fn iter(&self) -> impl Iterator<Item = BlobTransactionSidecarItem> + '_ {
self.blobs.iter().zip(&self.commitments).zip(&self.proofs).enumerate().map(
|(index, ((blob, commitment), proof))| BlobTransactionSidecarItem {
index,
blob: *blob,
kzg_commitment: *commitment,
kzg_proof: *proof,
},
)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be an IntoIter impl instead

Comment on lines +11 to +29
#[cfg(feature = "kzg")]
use crate::BlockNumHash;
#[cfg(feature = "serde")]
use alloc::string::String;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

#[cfg(feature = "kzg")]
use alloy_primitives::FixedBytes;
use alloy_primitives::{bytes::BufMut, B256};
use alloy_rlp::{Decodable, Encodable};
#[cfg(feature = "kzg")]
use c_kzg::KzgProof;
#[cfg(feature = "serde")]
use core::str::FromStr;
#[cfg(feature = "serde")]
use serde::Deserialize;
#[cfg(feature = "kzg")]
use sha2::{Digest, Sha256};
#[cfg(feature = "kzg")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none of these should be necessary, this makes it very hard to read.

please use full paths instead, this way no import is required

@DaniPopes
Copy link
Member

Superseded by #1334

@DaniPopes DaniPopes closed this Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Add iterator to BlobTransactionSidecar
3 participants