Skip to content

Commit

Permalink
runtime: add convenience methods to get chain / network name
Browse files Browse the repository at this point in the history
  • Loading branch information
kamirr authored and scx1332 committed Sep 29, 2023
1 parent eda7198 commit c484442
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions crates/erc20_payment_lib/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::path::Path;

use crate::error::{ErrorBag, PaymentError};

use crate::setup::{ExtraOptionsForTesting, PaymentSetup};
use crate::setup::{ChainSetup, ExtraOptionsForTesting, PaymentSetup};

use crate::config::{self, Config};
use secp256k1::SecretKey;
Expand Down Expand Up @@ -345,7 +345,7 @@ pub struct PaymentRuntime {
pub runtime_handle: JoinHandle<()>,
pub setup: PaymentSetup,
pub shared_state: Arc<Mutex<SharedState>>,
pub conn: SqlitePool,
conn: SqlitePool,
status_tracker: StatusTracker,
config: Config,
}
Expand Down Expand Up @@ -519,7 +519,16 @@ impl PaymentRuntime {
pub async fn get_status(&self) -> Vec<StatusProperty> {
self.status_tracker.get_status().await
}

pub fn get_chain(&self, chain_id: i64) -> Option<&ChainSetup> {
self.setup.chain_setup.get(&chain_id)
}

pub fn network_name(&self, chain_id: i64) -> Option<&str> {
self.get_chain(chain_id).map(|chain| chain.network.as_str())
}
}

pub async fn remove_last_unsent_transactions(
conn: SqlitePool,
) -> Result<Option<i64>, PaymentError> {
Expand Down

0 comments on commit c484442

Please sign in to comment.