Skip to content

Commit

Permalink
fix: rename receipts config
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Sep 16, 2024
1 parent ceeb53f commit 5edb1bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
16 changes: 6 additions & 10 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ pub struct Config {
/// Target for indexer fees paid per request
#[serde(deserialize_with = "deserialize_not_nan_f64")]
pub query_fees_target: NotNan<f64>,
/// Scalar TAP config (receipt signing)
pub scalar: Scalar,
pub receipts: Receipts,
}

/// Deserialize a `NotNan<f64>` from a `f64` and return an error if the value is NaN.
Expand Down Expand Up @@ -171,21 +170,18 @@ impl From<KafkaConfig> for rdkafka::config::ClientConfig {
}
}

/// Scalar TAP config (receipt signing).
///
/// See [`Config`]'s [`scalar`](struct.Config.html#structfield.scalar).
#[serde_as]
#[derive(Debug, Deserialize)]
pub struct Scalar {
/// Scalar TAP verifier contract chain
pub struct Receipts {
/// TAP verifier contract chain
pub chain_id: U256,
/// Secret key for legacy voucher signing
/// Secret key for legacy voucher signing (Scalar)
#[serde_as(as = "Option<HiddenSecretKey>")]
pub legacy_signer: Option<Hidden<SecretKey>>,
/// Secret key for voucher signing
/// TAP signer key
#[serde_as(as = "HiddenSecretKey")]
pub signer: Hidden<SecretKey>,
/// Scalar TAP verifier contract address
/// TAP verifier contract address
pub verifier: Address,
}

Expand Down
12 changes: 6 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async fn main() {
.unwrap();
let conf = config::load_from_file(&conf_path).expect("Failed to load config");

let signer_address = Wallet::from_bytes(conf.scalar.signer.0.as_ref())
let signer_address = Wallet::from_bytes(conf.receipts.signer.0.as_ref())
.expect("failed to prepare receipt wallet");
let tap_signer = Address::from(signer_address.address().0);

Expand Down Expand Up @@ -119,15 +119,15 @@ async fn main() {
network.wait_until_ready().await;

let legacy_signer: &'static SecretKey = Box::leak(Box::new(
conf.scalar
conf.receipts
.legacy_signer
.map(|s| s.0)
.unwrap_or(conf.scalar.signer.0),
.unwrap_or(conf.receipts.signer.0),
));
let receipt_signer: &'static ReceiptSigner = Box::leak(Box::new(ReceiptSigner::new(
conf.scalar.signer.0,
conf.scalar.chain_id,
conf.scalar.verifier,
conf.receipts.signer.0,
conf.receipts.chain_id,
conf.receipts.verifier,
legacy_signer,
)));

Expand Down

0 comments on commit 5edb1bb

Please sign in to comment.