Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
74 changes: 74 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Rust

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Install Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: false

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

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

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler

- name: Install Rust dependencies
run: cargo fetch

- name: Build
run: cargo +nightly build --verbose

- name: Run cargo fmt
run: cargo +nightly fmt -- --check

- name: Run cargo clippy
run: cargo +nightly clippy -- -D warnings

- name: Install llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Install nextest
uses: taiki-e/install-action@nextest

- name: Run Tests
run: cargo +nightly llvm-cov --cobertura --output-path cobertura.xml nextest

- name: Generate Code Coverage Summary
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: cobertura.xml
badge: true
fail_below_min: false
thresholds: '70 85'
output: both
format: markdown

- name: Export Job Summary
run: echo "$(<code-coverage-results.md)" >> $GITHUB_STEP_SUMMARY
2 changes: 1 addition & 1 deletion indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ byte-unit = "4.0.19"
serde = { version = "1.0.162", features = ["derive"] }
zerocopy = "0.7.8"
tracing-log = "0.2.0"
acuity-index-substrate = { path = "../../idn-acuity-index-substrate" }
acuity-index-substrate = { git = "https://github.com/ideal-lab5/idn-acuity-index-substrate", version = "=0.6.2" }
86 changes: 43 additions & 43 deletions indexer/src/ideal.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use ideal_network_local_metadata::ideal_network_local_metadata::{
runtime_types::{
frame_system::pallet::Event as SystemEvent,
pallet_balances::pallet::Event as BalancesEvent,
// Add other relevant event imports for your ideal network
},
Event,
runtime_types::{
frame_system::pallet::Event as SystemEvent,
pallet_balances::pallet::Event as BalancesEvent,
// Add other relevant event imports for your ideal network
},
Event,
};

use crate::*;
Expand All @@ -14,41 +14,41 @@ use hex_literal::hex;
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 ChainKey = ChainKey;

fn get_name() -> &'static str {
"ideal"
}

fn get_genesis_hash() -> <Self::RuntimeConfig as subxt::Config>::Hash {
// Replace with your chain's genesis hash
hex!["af97825bf72091072a08b9dbff88d6664e2061bcb4e28a90f17bd85572d8f8ae"].into() // Temporary placeholder
}

fn get_versions() -> &'static [u32] {
&[0]
}

fn get_default_url() -> &'static str {
"ws://127.0.0.1:1234" // Replace with your actual endpoint
}

fn process_event(
indexer: &acuity_index_substrate::substrate::Indexer<Self>,
block_number: u32,
event_index: u16,
event: subxt::events::EventDetails<Self::RuntimeConfig>,
) -> Result<u32, IndexError> {
Ok(match event.as_root_event::<Event>()? {
Event::System(event) => {
index_system_event![SystemEvent, event, indexer, block_number, event_index]
}
Event::Balances(event) => {
index_balances_event![BalancesEvent, event, indexer, block_number, event_index]
}
// Add other event handlers as needed
_ => 0,
})
}
type RuntimeConfig = subxt::PolkadotConfig; // You might need to adjust this based on your chain's configuration
type ChainKey = ChainKey;

fn get_name() -> &'static str {
"ideal"
}

fn get_genesis_hash() -> <Self::RuntimeConfig as subxt::Config>::Hash {
// Replace with your chain's genesis hash
hex!["af97825bf72091072a08b9dbff88d6664e2061bcb4e28a90f17bd85572d8f8ae"].into() // Temporary placeholder
}

fn get_versions() -> &'static [u32] {
&[0]
}

fn get_default_url() -> &'static str {
"ws://127.0.0.1:1234" // Replace with your actual endpoint
}

fn process_event(
indexer: &acuity_index_substrate::substrate::Indexer<Self>,
block_number: u32,
event_index: u16,
event: subxt::events::EventDetails<Self::RuntimeConfig>,
) -> Result<u32, IndexError> {
Ok(match event.as_root_event::<Event>()? {
Event::System(event) => {
index_system_event![SystemEvent, event, indexer, block_number, event_index]
},
Event::Balances(event) => {
index_balances_event![BalancesEvent, event, indexer, block_number, event_index]
},
// Add other event handlers as needed
_ => 0,
})
}
}
Loading
Loading