New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to decode logs from the Envio indexer response? #1308
Comments
It looks like somehow I need to create a use std::path::PathBuf;
use fuels::{
test_helpers::{launch_custom_provider_and_get_wallets, WalletsConfig},
tx::Receipt,
};
use orderbook::orderbook_utils::{OrderChangeEvent, Orderbook};
use src20_sdk::token_utils::{deploy_token_contract, Asset};
#[tokio::test]
async fn indexer_parse_test() {
let path =
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/indexer_test/indexer_data.json");
let addresses_json = std::fs::read_to_string(path).unwrap();
let data: serde_json::Value = serde_json::from_str(&addresses_json).unwrap();
let receipts_str = data["data"][0]["receipts"].as_str().unwrap();
let wallets_config = WalletsConfig::new(Some(5), Some(1), Some(1_000_000_000));
let wallets = launch_custom_provider_and_get_wallets(wallets_config, None, None)
.await
.unwrap();
let admin = &wallets[0];
let token_contract = deploy_token_contract(&admin).await;
let btc = Asset::new(admin.clone(), token_contract.contract_id().into(), "BTC");
let token_contract = deploy_token_contract(&admin).await;
let usdc = Asset::new(admin.clone(), token_contract.contract_id().into(), "USDC");
let orderbook = Orderbook::deploy(&admin, usdc.asset_id, usdc.decimals, 9).await;
let res = orderbook
._create_market(btc.asset_id, btc.decimals as u32)
.await
.unwrap();
let receipts: &[Receipt] = serde_json::from_str(&receipts_str).unwrap();
let res = res
.log_decoder
.decode_logs_with_type::<OrderChangeEvent>(receipts);
} |
Alexander from the indexer team told me we should be able to do something with the ProgramABI type and its logged_types field; they did something like that for V1 of the indexer — https://github.com/FuelLabs/fuel-indexer/blob/develop/packages/fuel-indexer-macros/src/indexer.rs#L48-L61 https://github.com/FuelLabs/fuel-indexer/blob/develop/packages/fuel-indexer-macros/src/indexer.rs let mut decoded_type_snippets = HashSet::new();
let mut decoded_log_match_arms = HashSet::new();
let mut decoded_type_fields = HashSet::new();
let mut abi_dispatchers = Vec::new();
let funcs = abi.clone().functions;
let abi_types: Vec[TypeDeclaration](https://app.slack.com/client/T04L3KML1PZ/TypeDeclaration) = abi
.clone()
.types
.iter()
.map(|t| strip_callpath_from_type_field(t.clone()))
.collect();
let abi_log_types = abi.clone().logged_types.unwrap_or_default();
let abi_msg_types = abi.clone().messages_types.unwrap_or_default(); |
Should I use this to decode the data? |
https://github.com/FuelLabs/fuels-rs/blob/master/packages%2Ffuels%2Ftests%2Flogs.rs This possibly can help |
Hi guys,I'm trying to use Envio indexer in the Spark app
Envio Allows you to send a POST request to "http://fuel.hypersync.xyz/query" and get a response with info
Request body
Response
Can you help me please to get my Events from here
Additional info
Orderbook contract: 0x1ad65e67c522dc0355f17792417aeb3269b5adc84ba13549b94b98b2db34c1e0
Orderbook repo: https://github.com/compolabs/orderbook-contract
Envio docs: https://github.com/enviodev/hypersync-fuel-docs
Envio rust SDK(install apnproto and libcapnp-dev before use): https://docs.rs/skar-client-fuel/0.0.1/skar_client_fuel/struct.Client.html
The text was updated successfully, but these errors were encountered: