Skip to content

Commit

Permalink
fix(authority-claimer): remove AuthConfig (duplicate from TxSigningCo…
Browse files Browse the repository at this point in the history
…nfig)
  • Loading branch information
renan061 committed Nov 14, 2023
1 parent 10fdf6d commit bff88b6
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 131 deletions.
102 changes: 0 additions & 102 deletions offchain/authority-claimer/src/auth.rs

This file was deleted.

14 changes: 3 additions & 11 deletions offchain/authority-claimer/src/config/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ use snafu::ResultExt;
use std::{fs, str::FromStr};
use types::blockchain_config::BlockchainCLIConfig;

use crate::auth::{AuthConfig, AuthEnvCLIConfig};
use crate::config::{
error::{
AuthSnafu, AuthorityClaimerConfigError, BlockchainSnafu,
InvalidRegionSnafu, MnemonicFileSnafu, TxManagerSnafu,
TxSigningConfigError, TxSigningSnafu,
AuthorityClaimerConfigError, BlockchainSnafu, InvalidRegionSnafu,
MnemonicFileSnafu, TxManagerSnafu, TxSigningConfigError,
TxSigningSnafu,
},
AuthorityClaimerConfig, BlockchainConfig, TxSigningConfig,
};
Expand All @@ -43,9 +42,6 @@ pub(crate) struct AuthorityClaimerCLI {
#[command(flatten)]
pub log_config: LogEnvCliConfig,

#[command(flatten)]
pub auth_config: AuthEnvCLIConfig,

#[command(flatten)]
pub blockchain_config: BlockchainCLIConfig,
}
Expand All @@ -66,9 +62,6 @@ impl TryFrom<AuthorityClaimerCLI> for AuthorityClaimerConfig {

let log_config = LogConfig::initialize(cli_config.log_config);

let auth_config = AuthConfig::initialize(cli_config.auth_config)
.context(AuthSnafu)?;

let blockchain_config =
BlockchainConfig::try_from(cli_config.blockchain_config)
.context(BlockchainSnafu)?;
Expand All @@ -79,7 +72,6 @@ impl TryFrom<AuthorityClaimerCLI> for AuthorityClaimerConfig {
tx_manager_priority: Priority::Normal,
broker_config,
log_config,
auth_config,
blockchain_config,
})
}
Expand Down
5 changes: 0 additions & 5 deletions offchain/authority-claimer/src/config/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use rusoto_core::region::ParseRegionError;
use snafu::Snafu;
use types::blockchain_config::BlockchainConfigError;

use crate::auth::AuthError;

#[derive(Debug, Snafu)]
#[snafu(visibility(pub(crate)))]
pub enum AuthorityClaimerConfigError {
Expand All @@ -17,9 +15,6 @@ pub enum AuthorityClaimerConfigError {
#[snafu(display("TxSigning configuration error"))]
TxSigningError { source: TxSigningConfigError },

#[snafu(display("Auth configuration error"))]
AuthError { source: AuthError },

#[snafu(display("Blockchain configuration error"))]
BlockchainError { source: BlockchainConfigError },
}
Expand Down
3 changes: 0 additions & 3 deletions offchain/authority-claimer/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ use rollups_events::BrokerConfig;
use rusoto_core::Region;
use types::blockchain_config::BlockchainConfig;

use crate::auth::AuthConfig;

#[derive(Debug, Clone)]
pub struct Config {
pub authority_claimer_config: AuthorityClaimerConfig,
Expand All @@ -27,7 +25,6 @@ pub struct AuthorityClaimerConfig {
pub tx_manager_config: TxManagerConfig,
pub tx_signing_config: TxSigningConfig,
pub tx_manager_priority: Priority,
pub auth_config: AuthConfig,
pub broker_config: BrokerConfig,
pub log_config: LogConfig,
pub blockchain_config: BlockchainConfig,
Expand Down
1 change: 0 additions & 1 deletion offchain/authority-claimer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

pub mod auth;
pub mod checker;
pub mod claimer;
pub mod config;
Expand Down
2 changes: 1 addition & 1 deletion offchain/authority-claimer/src/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl DefaultTransactionSender {
let chain: Chain = (&config.tx_manager_config).into();

let conditional_signer =
ConditionalSigner::new(chain.id, &config.auth_config)
ConditionalSigner::new(chain.id, &config.tx_signing_config)
.await
.context(SignerSnafu)?;

Expand Down
16 changes: 8 additions & 8 deletions offchain/authority-claimer/src/signer/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use ethers::{
};
use snafu::{ResultExt, Snafu};

use crate::{auth::AuthConfig, signer::aws_signer::AwsSigner};
use crate::{config::TxSigningConfig, signer::aws_signer::AwsSigner};

/// The `ConditionalSigner` is implementing conditional dispatch (instead of
/// dynamic dispatch) by hand for objects that implement the `Sender` trait.
Expand All @@ -40,10 +40,10 @@ pub enum ConditionalSignerError {
impl ConditionalSigner {
pub async fn new(
chain_id: u64,
auth_config: &AuthConfig,
tx_signing_config: &TxSigningConfig,
) -> Result<Self, ConditionalSignerError> {
match auth_config.clone() {
AuthConfig::Mnemonic {
match tx_signing_config.clone() {
TxSigningConfig::Mnemonic {
mnemonic,
account_index,
} => {
Expand All @@ -58,7 +58,7 @@ impl ConditionalSigner {
.with_chain_id(chain_id);
Ok(ConditionalSigner::LocalWallet(wallet))
}
AuthConfig::Aws { key_id, region } => {
TxSigningConfig::Aws { key_id, region } => {
AwsSigner::new(key_id, chain_id, region)
.await
.map(ConditionalSigner::AwsSigner)
Expand Down Expand Up @@ -154,7 +154,7 @@ mod tests {
};
use ethers_signers::Signer;

use crate::{auth::AuthConfig, signer::ConditionalSigner};
use crate::{config::TxSigningConfig, signer::ConditionalSigner};

// --------------------------------------------------------------------------------------------
// new
Expand Down Expand Up @@ -190,11 +190,11 @@ mod tests {
"indoor dish desk flag debris potato excuse depart ticket judge file exit";

async fn local_wallet_conditional_signer() -> ConditionalSigner {
let auth_config = AuthConfig::Mnemonic {
let tx_signing_config = TxSigningConfig::Mnemonic {
mnemonic: MNEMONIC.to_string(),
account_index: Some(1),
};
ConditionalSigner::new(CHAIN_ID, &auth_config)
ConditionalSigner::new(CHAIN_ID, &tx_signing_config)
.await
.unwrap()
}
Expand Down

0 comments on commit bff88b6

Please sign in to comment.