Skip to content

Commit 7f155da

Browse files
committed
pindexer: implement override for hardcoded values in app views
1 parent a655851 commit 7f155da

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed
+7-17
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,23 @@
1-
use std::str::FromStr;
2-
31
pub trait IndexerExt: Sized {
4-
fn with_default_penumbra_app_views(self) -> Self;
2+
fn with_default_penumbra_app_views(self, options: &crate::Options) -> Self;
53
}
64

75
impl IndexerExt for cometindex::Indexer {
8-
fn with_default_penumbra_app_views(self) -> Self {
6+
fn with_default_penumbra_app_views(self, options: &crate::Options) -> Self {
97
self.with_index(Box::new(crate::block::Block {}))
108
.with_index(Box::new(crate::stake::ValidatorSet {}))
119
.with_index(Box::new(crate::stake::Slashings {}))
1210
.with_index(Box::new(crate::stake::DelegationTxs {}))
1311
.with_index(Box::new(crate::stake::UndelegationTxs {}))
1412
.with_index(Box::new(crate::governance::GovernanceProposals {}))
1513
.with_index(Box::new(crate::dex_ex::Component::new(
16-
penumbra_sdk_asset::asset::Id::from_str(
17-
// USDC
18-
"passet1w6e7fvgxsy6ccy3m8q0eqcuyw6mh3yzqu3uq9h58nu8m8mku359spvulf6",
19-
)
20-
.expect("should be able to parse passet"),
21-
1000.0 * 1_000_000.0,
14+
options.indexing_denom,
15+
options.dex_ex_min_liquidity as f64,
2216
)))
2317
.with_index(Box::new(crate::supply::Component::new()))
2418
.with_index(Box::new(crate::ibc::Component::new()))
25-
.with_index(Box::new(crate::insights::Component::new(
26-
penumbra_sdk_asset::asset::Id::from_str(
27-
// USDC
28-
"passet1w6e7fvgxsy6ccy3m8q0eqcuyw6mh3yzqu3uq9h58nu8m8mku359spvulf6",
29-
)
30-
.ok(),
31-
)))
19+
.with_index(Box::new(crate::insights::Component::new(Some(
20+
options.indexing_denom,
21+
))))
3222
}
3323
}

crates/bin/pindexer/src/lib.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
pub use cometindex::{opt::Options, AppView, ContextualizedEvent, Indexer, PgPool, PgTransaction};
1+
pub use cometindex::{AppView, ContextualizedEvent, Indexer, PgPool, PgTransaction};
22

33
mod indexer_ext;
44
pub use indexer_ext::IndexerExt;
5+
use penumbra_asset::asset;
56
pub mod block;
67
pub mod dex_ex;
78
pub mod ibc;
@@ -11,3 +12,18 @@ pub mod stake;
1112
pub mod supply;
1213

1314
pub mod governance;
15+
16+
#[derive(clap::Parser, Clone, Debug)]
17+
pub struct Options {
18+
#[clap(flatten)]
19+
pub cometindex: cometindex::opt::Options,
20+
/// The denom to use for indexing related components, of the form passet1...
21+
#[clap(
22+
long,
23+
default_value = "passet1w6e7fvgxsy6ccy3m8q0eqcuyw6mh3yzqu3uq9h58nu8m8mku359spvulf6"
24+
)]
25+
pub indexing_denom: asset::Id,
26+
/// The minimum liquidity for the indexing denom in the dex explorer app view.
27+
#[clap(long, default_value = "100000000")]
28+
pub dex_ex_min_liquidity: u128,
29+
}

crates/bin/pindexer/src/main.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ use pindexer::{Indexer, IndexerExt as _, Options};
44

55
#[tokio::main]
66
async fn main() -> Result<()> {
7-
Indexer::new(Options::parse())
7+
let opts = Options::parse();
8+
Indexer::new(opts.cometindex.clone())
89
.with_default_tracing()
9-
.with_default_penumbra_app_views()
10+
.with_default_penumbra_app_views(&opts)
1011
.run()
1112
.await?;
1213

0 commit comments

Comments
 (0)