Closed enoldev closed 1 year ago
"to=dac17f958d2ee523a2206206994597c13d831ec7&from=46340b20830761efd32832a74d7169b29feb9758"
status != TransactionTraceStatus::Succeeded
let contract_address_as_vec = match Hex::decode(&contract_address) {
Ok(address) => address,
Err(error) => return Err(Error::Unexpected(error.to_string())),
};
Here for example a re-write of map_contract_events
with only:
#[substreams::handlers::map]
fn map_contract_events(contract_address: String, blk: Block) -> Result<Events, Error> {
// Not working today, needs to update `substreams-rs` to enable the conversion out of the box
let address = Hex::decode(&contract_address)
.with_context(|| anyhow!("invalid param address {}", contract_address))?;
Ok(Events {
events: blk
.logs()
.filter(|log_view| log_view.address() == address)
.map(|log_view| Event {
address: Hex::encode(log_view.address()),
topics: log_view.log.topics.iter().map(Hex::encode).collect(),
tx_hash: Hex::encode(log_view.receipt.transaction.hash),
})
.collect(),
})
}
Currently, there are three modules:
map_block_meta
,map_filter_transaction
andmap_contract_events
.I've included most of the information in the README.md, but I'd like to add a section in the docs with a step-by-step guide of the source code.