-
Notifications
You must be signed in to change notification settings - Fork 3
/
lib.rs
39 lines (37 loc) · 1.46 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
extern crate alloc;
use fuel_indexer_utils::prelude::*;
#[indexer(manifest = "spark_indexer.manifest.yaml")]
pub mod compolabs_index_mod {
fn handle_block(block: BlockData) {
let height = block.height;
let txs = block.transactions.len();
info!("🧱 Block height: {height} | transacrions: {txs}");
for transaction in block.transactions.iter() {
match transaction.status {
fuel::TransactionStatus::Success { .. } => {
info!("✅ transaction {:?}", transaction)
}
_ => (),
}
}
}
fn handle_order_slot(data: ProxySendFundsToPredicateParams) {
//TODO validate the proxy contract
// const PROXY: &str = "0x8924a38ac11879670de1d0898c373beb1e35dca974c4cab8a70819322f6bd9c4";
info!("✨ Order slot {:#?}", data);
let order = OrderData {
// https://docs.rs/fuel-indexer-utils/0.18.5/fuel_indexer_utils/prelude/fn.id8.html
id: id8(data.predicate_root),
predicate_root: data.predicate_root,
asset0: data.asset_0,
asset1: data.asset_1,
maker: data.maker,
min_fulfill_amount0: data.min_fulfill_amount_0,
price: data.price,
asset0_decimals: data.asset_0_decimals.into(),
asset1_decimals: data.asset_1_decimals.into(),
price_decimals: data.price_decimals.into(),
};
order.save();
}
}