-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: logger implementation for event feeder like cosmos icon eth substrate #130
Merged
shanithkk
merged 15 commits into
aurras-runtime-lite-dev
from
AV-273-Logger-implementation-for-Event-Feeder-like-Cosmos-icon-eth-substrate
May 6, 2024
Merged
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b4b500c
chore: add logger for the event feed
Prathiksha-Nataraja 43b3d94
chore: logger for eventfeed
Prathiksha-Nataraja 113b483
chore: remove unwanted imports
Prathiksha-Nataraja 2bd4504
chore: remove unwanted imports
Prathiksha-Nataraja 3586f9b
chore: implement logger
Prathiksha-Nataraja d1054bb
chore: code formating
Prathiksha-Nataraja 13be368
chore: remove commented code
Prathiksha-Nataraja fb3266b
Merge branch 'aurras-runtime-lite-dev' into AV-273-Logger-implementat…
Prathiksha-Nataraja e3ea116
chore: fix code
Prathiksha-Nataraja 3d961b3
Merge branch 'aurras-runtime-lite-dev' into AV-273-Logger-implementat…
Prathiksha-Nataraja 2bc9066
chore: log block number in substrate
shanithkk ff65aba
chore: remove unused imports
Prathiksha-Nataraja e69e551
Merge branch 'aurras-runtime-lite-dev' into AV-273-Logger-implementat…
Prathiksha-Nataraja ac0264d
chore: fixed code
Prathiksha-Nataraja c286fbe
chore: update code by removing the created file after the test
Prathiksha-Nataraja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
use super::*; | ||
use runtime::{logger::CoreLogger, Logger}; | ||
|
||
pub struct EthFeed { | ||
eth_service: Provider<Ws>, | ||
events: Vec<(String, H256)>, | ||
contracts: Vec<String>, | ||
logger: CoreLogger, | ||
} | ||
|
||
impl EthFeed { | ||
pub async fn new(config: ChainConfig) -> Result<EthFeed> { | ||
pub async fn new(config: ChainConfig, logger: CoreLogger) -> Result<EthFeed> { | ||
let events = config | ||
.event_filter | ||
.split(';') | ||
|
@@ -27,6 +30,7 @@ impl EthFeed { | |
eth_service: client, | ||
events, | ||
contracts, | ||
logger, | ||
}; | ||
|
||
Ok(eth_feed) | ||
|
@@ -47,6 +51,10 @@ impl EthFeed { | |
let filter = Filter::new().from_block(last_block - 25).events(events); | ||
|
||
let mut stream = client.subscribe_logs(&filter).await?; | ||
self.logger.info(&format!( | ||
"Subscribed to events with the filter : {:?}", | ||
filter | ||
)); | ||
|
||
while let Some(log) = stream.next().await { | ||
if self.contracts.is_empty() || self.contracts.contains(&format!("{:?}", &log.address)) | ||
|
@@ -72,6 +80,10 @@ impl EthFeed { | |
let tx_receipt = client.get_transaction_receipt(tx_hash).await; | ||
|
||
if let Ok(Some(tx_receipt)) = tx_receipt { | ||
self.logger.info(&format!( | ||
"Received trabsaction receipt for the tx_hash : {:?}", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typographical error "transaction" |
||
tx_hash | ||
)); | ||
let mut logs = Vec::<Value>::new(); | ||
|
||
for log in tx_receipt.logs.iter() { | ||
|
@@ -80,6 +92,8 @@ impl EthFeed { | |
{ | ||
for evt in self.events.iter() { | ||
if log.topics[0] == evt.1 { | ||
self.logger | ||
.info(&format!("Matched event : {:?}", evt.0.clone())); | ||
logs.push( | ||
serde_json::to_value( | ||
FeederEvent { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code clean up