Skip to content

Commit

Permalink
Merge pull request #65 from originalworks/add-ipfs-files-to-ddex
Browse files Browse the repository at this point in the history
Add pinning IPFS image files and include CID in ddex
  • Loading branch information
cezary-stroczynski authored Oct 9, 2024
2 parents fb03763 + 0637e38 commit ae9b1ea
Show file tree
Hide file tree
Showing 17 changed files with 747 additions and 19 deletions.
3 changes: 2 additions & 1 deletion ow_data_provider_cli/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.env
/target/
/target/
/output_files/
151 changes: 147 additions & 4 deletions ow_data_provider_cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions ow_data_provider_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ version = "0.1.0"
edition = "2021"

[dependencies]
reqwest = { version = "0.12.8", features = ["stream", "multipart", "json"] }
alloy = { version = "0.3.6", features = ["full"] }
c-kzg = "1.0.3"
dotenvy = "0.15.7"
ow_blob_codec = "0.1.1"
tokio = { version = "1.40.0", features = ["full"] }
tokio-util = "0.7.12"
serde = "1.0.210"
infer = "0.16.0"
quick-xml = "0.36.2"
6 changes: 3 additions & 3 deletions ow_data_provider_cli/src/blob.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{errors::OwDataProviderCliError, Config};
use crate::{constants::OUTPUT_FILES_DIR, errors::OwDataProviderCliError};
use alloy::consensus::BlobTransactionSidecar;
use c_kzg::{ethereum_kzg_settings, Blob, KzgCommitment, KzgProof};
use std::error::Error;
Expand All @@ -9,8 +9,8 @@ pub struct BlobTransactionData {
}

impl BlobTransactionData {
pub fn build(config: &Config) -> Result<Self, Box<dyn Error>> {
let blob: [u8; 131072] = ow_blob_codec::blob_from_dir(&config.folder_path)?;
pub fn build() -> Result<Self, Box<dyn Error>> {
let blob: [u8; 131072] = ow_blob_codec::blob_from_dir(OUTPUT_FILES_DIR)?;

let kzg_blob = Blob::new(blob);

Expand Down
5 changes: 5 additions & 0 deletions ow_data_provider_cli/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
use alloy::primitives::{address, Address};

pub const DDEX_SEQUENCER_ADDRESS: Address = address!("B965D10739e19a9158e7f713720B0145D996E370");
pub const IPFS_API_BASE_URL: &str = "http://localhost:5001";
pub const IPFS_API_ADD_FILE: &str = "/api/v0/add";
pub const OUTPUT_FILES_DIR: &str = "./output_files";
pub const IPFS_CIDS_ROOT_TAG: &str = "MessageHeader";
pub const IMAGE_FILE_CID_TAG: &str = "ImageIpfsCid";
12 changes: 12 additions & 0 deletions ow_data_provider_cli/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ pub enum OwDataProviderCliError {
MissingEnvVar(String),
MissingCliArg(String),
InvalidBlobProof(),
SourcePathIsNotDir(String),
EmptySourcePathFolder(String),
ErrorReadingFile(String),
}

impl fmt::Display for OwDataProviderCliError {
Expand All @@ -20,6 +23,15 @@ impl fmt::Display for OwDataProviderCliError {
Self::InvalidBlobProof() => {
write!(f, "c_kzg error during proof validation")
}
Self::SourcePathIsNotDir(path) => {
write!(f, "Provided folder_path is not a directory: {}", path)
}
Self::EmptySourcePathFolder(path) => {
write!(f, "Folder under provided folder_path is empty: {}", path)
}
Self::ErrorReadingFile(file_path) => {
write!(f, "Error while reading file from: {}", file_path)
}
}
}
}
Expand Down
Loading

0 comments on commit ae9b1ea

Please sign in to comment.