-
Notifications
You must be signed in to change notification settings - Fork 15
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
Build Client inside DaConfig #46
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9b7f1e2
update: added boilerplate build_da_client
heemankv 82a9137
build_da_client support for Ethereum
heemankv 241f32d
update: support for Ethereum - build_da_client
heemankv f90dc39
update: rename : build_da_client in DaConfig to build_client
heemankv f3aae1f
chore: linting fixes
heemankv 5d729f5
chore: rearrange env_utils functions
heemankv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,40 @@ | ||
use std::str::FromStr; | ||
use std::{env, path::Path}; | ||
|
||
use alloy::signers::wallet::LocalWallet; | ||
use alloy::{network::Ethereum, providers::ProviderBuilder, rpc::client::RpcClient}; | ||
use async_trait::async_trait; | ||
use c_kzg::KzgSettings; | ||
use da_client_interface::DaConfig; | ||
use url::Url; | ||
use utils::env_utils::get_env_var_or_panic; | ||
|
||
use crate::EthereumDaClient; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct EthereumDaConfig { | ||
pub rpc_url: String, | ||
pub memory_pages_contract: String, | ||
pub private_key: String, | ||
} | ||
|
||
impl DaConfig for EthereumDaConfig { | ||
#[async_trait] | ||
impl DaConfig<EthereumDaClient> for EthereumDaConfig { | ||
fn new_from_env() -> Self { | ||
Self { | ||
rpc_url: get_env_var_or_panic("ETHEREUM_RPC_URL"), | ||
memory_pages_contract: get_env_var_or_panic("MEMORY_PAGES_CONTRACT_ADDRESS"), | ||
private_key: get_env_var_or_panic("PRIVATE_KEY"), | ||
} | ||
} | ||
async fn build_client(&self) -> EthereumDaClient { | ||
let client = | ||
RpcClient::new_http(Url::from_str(self.rpc_url.as_str()).expect("Failed to parse ETHEREUM_RPC_URL")); | ||
let provider = ProviderBuilder::<_, Ethereum>::new().on_client(client); | ||
let wallet: LocalWallet = env::var("PK").expect("PK must be set").parse().expect("issue while parsing"); | ||
// let wallet: LocalWallet = config.private_key.as_str().parse(); | ||
let trusted_setup = KzgSettings::load_trusted_setup_file(Path::new("./trusted_setup.txt")) | ||
.expect("issue while loading the trusted setup"); | ||
EthereumDaClient { provider, wallet, trusted_setup } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.