Skip to content

Commit 4c20560

Browse files
committed
fix: derive oracle address from private key
Signed-off-by: Tomás Migone <[email protected]>
1 parent e44d409 commit 4c20560

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

availability-oracle/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ wasmparser = "0.74.0"
2626
multibase = "0.8.0"
2727
moka = { version = "0.8", features = ["future"] }
2828
graphql-parser = "0.4.0"
29+
secp256k1 = "0.20.3"

availability-oracle/src/main.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mod util;
77

88
use common::prelude::*;
99
use common::prometheus;
10+
use common::web3::signing::Key;
1011
use contract::*;
1112
use ipfs::*;
1213
use manifest::{Abi, DataSource, Manifest, Mapping};
@@ -18,6 +19,7 @@ use structopt::StructOpt;
1819
use tiny_cid::Cid;
1920
use tokio::time::MissedTickBehavior;
2021
use util::bytes32_to_cid_v0;
22+
use secp256k1::key::SecretKey;
2123

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

97-
#[structopt(
98-
short,
99-
long,
100-
env = "ORACLE_ADDRESS",
101-
required_unless("dry-run"),
102-
help = "The address used by by the oracle to sign transactions"
103-
)]
104-
oracle: Option<Address>,
105-
10699
#[structopt(
107100
long,
108101
env = "ORACLE_SIGNING_KEY",
@@ -151,10 +144,10 @@ async fn run(logger: Logger, config: Config) -> Result<()> {
151144
let subgraph = NetworkSubgraphImpl::new(logger.clone(), config.subgraph);
152145
let contract: Box<dyn RewardsManager> = match config.dry_run {
153146
false => {
154-
let signing_key = &config.signing_key.unwrap().parse()?;
147+
let signing_key: &SecretKey = &config.signing_key.unwrap().parse()?;
155148
let contracts_config = config.contracts.unwrap();
156149
let web3_context =
157-
Web3Context::new(&contracts_config.url, config.oracle.unwrap(), signing_key)?;
150+
Web3Context::new(&contracts_config.url, signing_key.address(), signing_key)?;
158151
let contracts = Contracts::new(contracts_config, web3_context);
159152
Box::new(RewardsManagerContract::new(contracts))
160153
}

0 commit comments

Comments
 (0)