Skip to content

Commit

Permalink
Types: AsRef<HashMap<>> to IntoIterator (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evalir committed Mar 28, 2023
1 parent 03c1a13 commit 8be41f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, ops::Deref};
use std::ops::Deref;

use ethers::{
signers::Signer,
Expand Down Expand Up @@ -224,13 +224,13 @@ impl SafeClient {
pub(crate) async fn filtered_msig_history(
&self,
safe_address: Address,
filters: impl AsRef<HashMap<&'static str, String>>,
filters: impl IntoIterator<Item = (&'static str, String)>,
) -> ClientResult<MsigHistoryResponse> {
json_get!(
&self.client,
MsigHistoryFilters::url(self.url(), safe_address),
MsigHistoryResponse,
filters.as_ref(),
filters,
)
.map(Option::unwrap)
}
Expand Down
10 changes: 3 additions & 7 deletions src/rpc/msig_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,6 @@ pub struct MsigHistoryFilters<'a> {
pub(crate) client: &'a SafeClient,
}

impl<'a> AsRef<HashMap<&'static str, String>> for MsigHistoryFilters<'a> {
fn as_ref(&self) -> &HashMap<&'static str, String> {
&self.filters
}
}

impl<'a> MsigHistoryFilters<'a> {
// TODO: `modified` filters
// TODO: Execution date & submission date
Expand All @@ -182,7 +176,9 @@ impl<'a> MsigHistoryFilters<'a> {

/// Dispatch the request to the API, querying txns from the specified safe
pub async fn query(self, safe_address: Address) -> ClientResult<MsigHistoryResponse> {
self.client.filtered_msig_history(safe_address, &self).await
self.client
.filtered_msig_history(safe_address, self.filters)
.await
}

/// Insert a KV pair into the internal mapping for later URL encoding
Expand Down

0 comments on commit 8be41f6

Please sign in to comment.