Skip to content

Commit

Permalink
sui-graphql-client: return Result<Page> instead of Result<Option<Page…
Browse files Browse the repository at this point in the history
…>> (#44)
  • Loading branch information
stefan-mysten authored Oct 25, 2024
1 parent 24207a2 commit 9eed43e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
8 changes: 4 additions & 4 deletions crates/sui-graphql-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ impl Client {
&self,
address: Address,
pagination_filter: PaginationFilter<'a>,
) -> Result<Option<Page<DynamicFieldOutput>>, Error> {
) -> Result<Page<DynamicFieldOutput>, Error> {
let (after, before, first, last) = self.pagination_filter(pagination_filter);
let operation = DynamicFieldsOwnerQuery::build(DynamicFieldConnectionArgs {
address,
Expand All @@ -751,18 +751,18 @@ impl Client {
}

let Some(DynamicFieldsOwnerQuery { owner: Some(dfs) }) = response.data else {
return Ok(Some(Page::new_empty()));
return Ok(Page::new_empty());
};

Ok(Some(Page::new(
Ok(Page::new(
dfs.dynamic_fields.page_info,
dfs.dynamic_fields
.nodes
.into_iter()
.map(TryInto::try_into)
.collect::<Result<Vec<_>, Error>>()
.map_err(|e| Error::msg(format!("{:?}", e)))?,
)))
))
}

// ===========================================================================
Expand Down
15 changes: 0 additions & 15 deletions crates/sui-graphql-client/src/query_types/dynamic_fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,3 @@ impl TryFrom<DynamicField> for DynamicFieldOutput {
})
}
}

// impl From<DynamicField> for DynamicFieldOutput {
// fn from(val: DynamicField) -> DynamicFieldOutput {
// DynamicFieldOutput {
// name: crate::DynamicFieldName {
// type_: TypeTag::from_str(val.name.as_ref().unwrap().type_.as_str()),
// bcs: base64ct::Base64::decode_vec(val.name.as_ref().unwrap().bcs.0.as_ref())
// .unwrap(),
// json: val.name.as_ref().unwrap().json.clone(),
// },
// value_as_json: val.field_value_json(),
// value: val.value.and_then(|x| x.type_bcs()),
// }
// }
// }

0 comments on commit 9eed43e

Please sign in to comment.