Skip to content

Commit

Permalink
Merge pull request #367 from near/develop
Browse files Browse the repository at this point in the history
Develop -> main
  • Loading branch information
kobayurii authored Oct 18, 2024
2 parents 9d6d10c + a82b8d5 commit 23a570d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion rpc-server/src/modules/state/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub async fn view_state_paginated(
block.block_height,
request_data.next_page_token,
)
.await;
.await?;

Ok(crate::modules::state::RpcViewStatePaginatedResponse {
values: state_values.values,
Expand Down
35 changes: 19 additions & 16 deletions rpc-server/src/modules/state/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,31 @@ pub async fn get_state_from_db_paginated(
account_id: &near_primitives::types::AccountId,
block_height: near_primitives::types::BlockHeight,
page_token: database::PageToken,
) -> crate::modules::state::PageStateValues {
) -> Result<crate::modules::state::PageStateValues, near_jsonrpc::primitives::errors::RpcError> {
tracing::debug!(
"`get_state_from_db_paginated` call. AccountId {}, block {}, page_token {:?}",
account_id,
block_height,
page_token,
);
if let Ok((values, next_page_token)) = db_manager

let (values, next_page_token) = db_manager
.get_state_by_page(account_id, block_height, page_token, "view_state_paginated")
.await
{
crate::modules::state::PageStateValues {
values: values
.into_iter()
.map(|(k, v)| near_primitives::views::StateItem {
key: k.into(),
value: v.into(),
})
.collect(),
next_page_token,
}
} else {
crate::modules::state::PageStateValues::default()
}
.map_err(|err| {
near_jsonrpc::primitives::errors::RpcError::new_internal_error(
Some(serde_json::Value::String(err.to_string())),
"Failed to get page state from DB. Please try again!".to_string(),
)
})?;
Ok(crate::modules::state::PageStateValues {
values: values
.into_iter()
.map(|(k, v)| near_primitives::views::StateItem {
key: k.into(),
value: v.into(),
})
.collect(),
next_page_token,
})
}

0 comments on commit 23a570d

Please sign in to comment.