Skip to content

Commit

Permalink
refactor: config args
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Jan 11, 2024
1 parent c1c152c commit 779ce5e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
7 changes: 0 additions & 7 deletions subfile-exchange/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,6 @@ pub struct DownloaderArgs {
help = "Blockchain provider endpoint"
)]
pub provider: String,
#[clap(
long,
value_name = "chain_id",
env = "CHAIN_ID",
help = "Protocol network's Chain ID"
)]
pub chain_id: u64,
#[clap(
long,
value_name = "verifier",
Expand Down
13 changes: 11 additions & 2 deletions subfile-exchange/src/subfile_client/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use alloy_primitives::{Address, U256};
use bytes::Bytes;

use ethers::providers::{Http, Middleware, Provider};
use http::header::{AUTHORIZATION, CONTENT_RANGE};
use rand::seq::SliceRandom;
use reqwest::Client;
Expand Down Expand Up @@ -57,13 +58,21 @@ impl SubfileDownloader {
.expect("Read subfile");

let wallet = build_wallet(&args.mnemonic).expect("Mnemonic build wallet");
//TODO: Factor away from client, Transactions could be a separate entity
let signing_key = wallet.signer().to_bytes();
let secp256k1_private_key =
SecretKey::from_slice(&signing_key).expect("Private key from wallet");
let provider = Provider::<Http>::try_from(&args.provider).expect("Connect to the provider");
//TODO: migrate ethers type to alloy
let chain_id = U256::from(
provider
.get_chainid()
.await
.expect("Get chain id from provider")
.as_u128(),
);
let receipt_signer = ReceiptSigner::new(
secp256k1_private_key,
U256::from(args.chain_id),
chain_id,
Address::from_str(&args.verifier).expect("Parse verifier"),
)
.await;
Expand Down
1 change: 0 additions & 1 deletion subfile-exchange/tests/file_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ mod tests {
"http://localhost:5677".to_string(),
]
.to_vec(),
chain_id: 421614,
verifier: String::from("0xfC24cE7a4428A6B89B52645243662A02BA734ECF"),
mnemonic: String::from(
"sheriff obscure trick beauty army fat wink legal flee leader section suit",
Expand Down

0 comments on commit 779ce5e

Please sign in to comment.