-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add payload parsing to hyperlane Rest API #13
Add payload parsing to hyperlane Rest API #13
Conversation
c3731c7
to
dc7eb43
Compare
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.
👍
let mut results = Vec::new(); | ||
|
||
tx.events | ||
.iter() | ||
.filter(|e| e.key == Self::EVENT_KEY) | ||
.try_for_each(|e| -> ChainResult<()> { | ||
let (indexed_msg, meta) = self.process_event(tx, e, tx.batch_number, batch_hash)?; | ||
info!( | ||
"Processed {} event : {:?} - Meta: {:?}", | ||
Self::EVENT_KEY, | ||
indexed_msg, | ||
meta | ||
); | ||
results.push((indexed_msg, meta)); | ||
Ok(()) | ||
})?; | ||
Ok(results) |
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.
So, would something like the below code work?
Removed the intermediate results vector and used collect() to create the result vector directly from the iterator. Would it be a bit faster to avoid pushing each element to a vector?
let mut results = Vec::new(); | |
tx.events | |
.iter() | |
.filter(|e| e.key == Self::EVENT_KEY) | |
.try_for_each(|e| -> ChainResult<()> { | |
let (indexed_msg, meta) = self.process_event(tx, e, tx.batch_number, batch_hash)?; | |
info!( | |
"Processed {} event : {:?} - Meta: {:?}", | |
Self::EVENT_KEY, | |
indexed_msg, | |
meta | |
); | |
results.push((indexed_msg, meta)); | |
Ok(()) | |
})?; | |
Ok(results) | |
tx.events | |
.iter() | |
.filter(|e| e.key == Self::EVENT_KEY) | |
.map(|e| { | |
let (indexed_msg, meta) = self.process_event(tx, e, tx.batch_number, batch_hash)?; | |
info!( | |
"Processed {} event: {:?} - Meta: {:?}", | |
Self::EVENT_KEY, | |
indexed_msg, | |
meta | |
); | |
Ok((indexed_msg, meta)) | |
}) | |
.collect() |
let thingy = self.decode_event(event)?; | ||
|
||
let meta = LogMeta { | ||
address: batch_hash, //TODO!!! this is wrong |
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.
Why it's wrong?
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.
Still IDK why it's wrong 😸 Maybe it should be explained in the comment?
rust/main/chains/hyperlane-sovereign/src/provider/rest_client.rs
Outdated
Show resolved
Hide resolved
rust/main/chains/hyperlane-sovereign/src/provider/rest_client.rs
Outdated
Show resolved
Hide resolved
rust/main/chains/hyperlane-sovereign/src/provider/rest_client.rs
Outdated
Show resolved
Hide resolved
rust/main/chains/hyperlane-sovereign/src/provider/rest_client.rs
Outdated
Show resolved
Hide resolved
rust/main/chains/hyperlane-sovereign/src/provider/rest_client.rs
Outdated
Show resolved
Hide resolved
aac93e2
to
172e04c
Compare
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.
👍
let thingy = self.decode_event(event)?; | ||
|
||
let meta = LogMeta { | ||
address: batch_hash, //TODO!!! this is wrong |
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.
Still IDK why it's wrong 😸 Maybe it should be explained in the comment?
rust/main/chains/hyperlane-sovereign/src/provider/rest_client.rs
Outdated
Show resolved
Hide resolved
Please make sure all public structs and functions are properly documented. |
d5017b3
to
cf6c6c0
Compare
9ed826d
to
27a8b6e
Compare
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.
Let's merge it! 👍
// // /modules/bank/tokens/{token_id}/balances/{address} | ||
// let query = format!("/modules/bank/tokens/{}/balances/{}", token_id, address); | ||
|
||
// #[derive(Clone, Debug, Deserialize)] | ||
// struct Data { | ||
// _amount: Option<u128>, | ||
// _token_id: Option<String>, | ||
// } | ||
|
||
// let response = self | ||
// .http_get(&query) | ||
// .await | ||
// .map_err(|e| ChainCommunicationError::CustomError(format!("HTTP Get Error: {}", e)))?; | ||
// let response: Schema<Data> = serde_json::from_slice(&response)?; | ||
|
||
// let response = U256::from(response); |
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.
Maybe delete those comments?
27a8b6e
to
b75175d
Compare
b75175d
to
9945b9d
Compare
Description
Added rest_client.rs to project to interact with Sovereign rollup.
(PR will be squashed before merge)
Drive-by changes
No
Related issues
NA
Backward compatibility
Yes
Testing
Extensive manual testing. Used for all demo and dev purposes.