Skip to content

Commit

Permalink
fix: fix get log filter with address (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
driftluo authored Feb 23, 2022
1 parent 0c51878 commit 03aade0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion core/api/src/jsonrpc/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,19 @@ impl<Adapter: APIAdapter + 'static> AxonJsonRpcServer for JsonRpcImpl<Adapter> {
position: BlockPosition,
topics: &[H256],
logs: &mut Vec<Web3Log>,
address: Option<&H160>,
) -> RpcResult<()> {
let extend_logs = |logs: &mut Vec<Web3Log>, receipts: Vec<Option<Receipt>>| {
let mut index = 0;
for receipt in receipts.into_iter().flatten() {
let log_len = receipt.logs.len();
from_receipt_to_web3_log(index, topics, receipt, logs);
match address {
Some(s) if s == &receipt.sender => {
from_receipt_to_web3_log(index, topics, receipt, logs)
}
None => from_receipt_to_web3_log(index, topics, receipt, logs),
_ => (),
}
index += log_len;
}
};
Expand Down Expand Up @@ -449,6 +456,7 @@ impl<Adapter: APIAdapter + 'static> AxonJsonRpcServer for JsonRpcImpl<Adapter> {
BlockPosition::Hash(hash),
&topics,
&mut all_logs,
filter.address.as_ref(),
)
.await?;
}
Expand Down Expand Up @@ -488,6 +496,7 @@ impl<Adapter: APIAdapter + 'static> AxonJsonRpcServer for JsonRpcImpl<Adapter> {
BlockPosition::Num(n),
&topics,
&mut all_logs,
filter.address.as_ref(),
)
.await?;
}
Expand All @@ -499,6 +508,7 @@ impl<Adapter: APIAdapter + 'static> AxonJsonRpcServer for JsonRpcImpl<Adapter> {
BlockPosition::Block(latest_block),
&topics,
&mut all_logs,
filter.address.as_ref(),
)
.await?;
}
Expand Down
2 changes: 1 addition & 1 deletion protocol/src/types/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl Hex {
}

pub fn as_string_trim0x(&self) -> String {
(&self.0[2..]).to_owned()
(self.0[2..]).to_owned()
}

pub fn as_bytes(&self) -> Bytes {
Expand Down

0 comments on commit 03aade0

Please sign in to comment.