Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
- name: Install rustfmt for nightly
run: rustup component add --toolchain nightly rustfmt

- name: Install clippy for nightly
run: rustup component add --toolchain nightly clippy

- name: Install llvm-tools-preview for stable
run: rustup component add llvm-tools-preview --toolchain stable-x86_64-unknown-linux-gnu

Expand Down
Binary file modified ideal-metadata/ideal.scale
Binary file not shown.
5 changes: 1 addition & 4 deletions indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ edition = "2021"

[dependencies]
ideal-metadata = { path = "../ideal-metadata" }
acuity-index-substrate = { git = "https://github.com/ideal-lab5/idn-acuity-index-substrate", version = "=0.6.2" }
acuity-index-substrate = { git = "https://github.com/ideal-lab5/idn-acuity-index-substrate" }
byte-unit = "4.0.19"
clap = { version = "4.5.1", features = ["derive"] }
clap-verbosity-flag = "2.2.0"
serde = { version = "1.0.130", features = ["derive"] }
serde_json = "1.0.68"
sled = "0.34.7"
subxt = "0.35.3"
tokio = { version = "1.35.1", features = ["full"] }
tracing = "0.1.40"
tracing-log = "0.2.0"
zerocopy = "0.7.32"
hex = "0.4.3"
hex-literal = "0.4.1"
lazy_static = "1.4.0"
96 changes: 93 additions & 3 deletions indexer/src/ideal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use ideal_metadata::ideal_metadata::{
runtime_types::{
frame_system::pallet::Event as SystemEvent,
pallet_balances::pallet::Event as BalancesEvent,
// Add other relevant event imports for your ideal network
// IDN-specific pallet events
pallet_idn_manager::pallet::Event as IdnManagerEvent,
},
Event,
};
Expand All @@ -16,7 +17,7 @@ use acuity_index_substrate::*;
pub struct IdealIndexer;

impl acuity_index_substrate::shared::RuntimeIndexer for IdealIndexer {
type RuntimeConfig = subxt::PolkadotConfig; // You might need to adjust this based on your chain's configuration
type RuntimeConfig = subxt::PolkadotConfig;
type ChainKey = ChainKey;

fn get_name() -> &'static str {
Expand Down Expand Up @@ -48,7 +49,96 @@ impl acuity_index_substrate::shared::RuntimeIndexer for IdealIndexer {
Event::Balances(event) => {
index_balances_event![BalancesEvent, event, indexer, block_number, event_index]
},
// Add other event handlers as needed
// IDN-specific event handlers
Event::IdnManager(event) => {
match event {
IdnManagerEvent::SubscriptionCreated { sub_id } => {
// Convert H256 to u32 for the subscription ID (taking first 4 bytes)
let id_u32 =
u32::from_le_bytes([sub_id[0], sub_id[1], sub_id[2], sub_id[3]]);
indexer.index_event(
Key::Substrate(SubstrateKey::SubscriptionId(id_u32)),
block_number,
event_index,
)?;
1
},
IdnManagerEvent::SubscriptionTerminated { sub_id } => {
let id_u32 =
u32::from_le_bytes([sub_id[0], sub_id[1], sub_id[2], sub_id[3]]);
indexer.index_event(
Key::Substrate(SubstrateKey::SubscriptionId(id_u32)),
block_number,
event_index,
)?;
1
},
IdnManagerEvent::SubscriptionPaused { sub_id } => {
let id_u32 =
u32::from_le_bytes([sub_id[0], sub_id[1], sub_id[2], sub_id[3]]);
indexer.index_event(
Key::Substrate(SubstrateKey::SubscriptionId(id_u32)),
block_number,
event_index,
)?;
1
},
IdnManagerEvent::SubscriptionUpdated { sub_id } => {
let id_u32 =
u32::from_le_bytes([sub_id[0], sub_id[1], sub_id[2], sub_id[3]]);
indexer.index_event(
Key::Substrate(SubstrateKey::SubscriptionId(id_u32)),
block_number,
event_index,
)?;
1
},
IdnManagerEvent::SubscriptionReactivated { sub_id } => {
let id_u32 =
u32::from_le_bytes([sub_id[0], sub_id[1], sub_id[2], sub_id[3]]);
indexer.index_event(
Key::Substrate(SubstrateKey::SubscriptionId(id_u32)),
block_number,
event_index,
)?;
1
},
IdnManagerEvent::RandomnessDistributed { sub_id } => {
let id_u32 =
u32::from_le_bytes([sub_id[0], sub_id[1], sub_id[2], sub_id[3]]);
indexer.index_event(
Key::Substrate(SubstrateKey::SubscriptionId(id_u32)),
block_number,
event_index,
)?;
1
},
IdnManagerEvent::FeesCollected { sub_id, .. } => {
let id_u32 =
u32::from_le_bytes([sub_id[0], sub_id[1], sub_id[2], sub_id[3]]);
indexer.index_event(
Key::Substrate(SubstrateKey::SubscriptionId(id_u32)),
block_number,
event_index,
)?;
1
},
IdnManagerEvent::SubQuoted { .. } => {
// This event doesn't have a subscription ID to index by
0
},
IdnManagerEvent::SubscriptionDistributed { sub_id } => {
let id_u32 =
u32::from_le_bytes([sub_id[0], sub_id[1], sub_id[2], sub_id[3]]);
indexer.index_event(
Key::Substrate(SubstrateKey::SubscriptionId(id_u32)),
block_number,
event_index,
)?;
1
},
}
},
_ => 0,
})
}
Expand Down
7 changes: 3 additions & 4 deletions indexer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ mod tests;

mod config;
mod ideal;
mod pallets;

use ideal::IdealIndexer;

Expand Down Expand Up @@ -64,9 +63,9 @@ impl IndexTrees for ChainTrees {
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, Hash)]
#[serde(tag = "type", content = "value")]
pub enum ChainKey {
AccountId(Bytes32), // For balance events
BlockHash(Bytes32), // For system events
ExtrinsicHash(Bytes32), // For transaction events
AccountId(Bytes32),
BlockHash(Bytes32),
ExtrinsicHash(Bytes32),
}

impl IndexKey for ChainKey {
Expand Down
Loading
Loading