Skip to content

Commit

Permalink
fix: derive oracle address from private key
Browse files Browse the repository at this point in the history
Signed-off-by: Tomás Migone <[email protected]>
  • Loading branch information
tmigone committed Feb 6, 2024
1 parent e44d409 commit 4c20560
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions availability-oracle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ wasmparser = "0.74.0"
multibase = "0.8.0"
moka = { version = "0.8", features = ["future"] }
graphql-parser = "0.4.0"
secp256k1 = "0.20.3"
15 changes: 4 additions & 11 deletions availability-oracle/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod util;

use common::prelude::*;
use common::prometheus;
use common::web3::signing::Key;
use contract::*;
use ipfs::*;
use manifest::{Abi, DataSource, Manifest, Mapping};
Expand All @@ -18,6 +19,7 @@ use structopt::StructOpt;
use tiny_cid::Cid;
use tokio::time::MissedTickBehavior;
use util::bytes32_to_cid_v0;
use secp256k1::key::SecretKey;

fn parse_secs(secs: &str) -> Result<Duration, Error> {
Ok(Duration::from_secs(u64::from_str(secs)?))
Expand Down Expand Up @@ -94,15 +96,6 @@ struct Config {
)]
contracts: Option<common::contracts::ContractConfig>,

#[structopt(
short,
long,
env = "ORACLE_ADDRESS",
required_unless("dry-run"),
help = "The address used by by the oracle to sign transactions"
)]
oracle: Option<Address>,

#[structopt(
long,
env = "ORACLE_SIGNING_KEY",
Expand Down Expand Up @@ -151,10 +144,10 @@ async fn run(logger: Logger, config: Config) -> Result<()> {
let subgraph = NetworkSubgraphImpl::new(logger.clone(), config.subgraph);
let contract: Box<dyn RewardsManager> = match config.dry_run {
false => {
let signing_key = &config.signing_key.unwrap().parse()?;
let signing_key: &SecretKey = &config.signing_key.unwrap().parse()?;
let contracts_config = config.contracts.unwrap();
let web3_context =
Web3Context::new(&contracts_config.url, config.oracle.unwrap(), signing_key)?;
Web3Context::new(&contracts_config.url, signing_key.address(), signing_key)?;
let contracts = Contracts::new(contracts_config, web3_context);
Box::new(RewardsManagerContract::new(contracts))
}
Expand Down

0 comments on commit 4c20560

Please sign in to comment.