Skip to content

Commit

Permalink
add new andpoint view_state_paginated
Browse files Browse the repository at this point in the history
  • Loading branch information
kobayurii committed Dec 15, 2023
1 parent 302a775 commit 5ef0f65
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rpc-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ async fn main() -> anyhow::Result<()> {
let rpc = Server::new()
.with_data(Data::new(state))
.with_method("query", modules::queries::methods::query)
.with_method(
"view_state_paginated",
modules::state::methods::view_state_paginated,
)
.with_method("block", modules::blocks::methods::block)
.with_method(
"EXPERIMENTAL_changes",
Expand Down
1 change: 1 addition & 0 deletions rpc-server/src/modules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ pub mod network;
pub mod queries;
pub mod receipts;
pub mod transactions;
pub mod state;
27 changes: 27 additions & 0 deletions rpc-server/src/modules/state/methods.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use crate::config::ServerContext;
use crate::errors::RPCError;
use jsonrpc_v2::{Data, Params};

#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub struct RpcViewStatePaginatedRequest {
#[serde(flatten)]
pub block_reference: near_primitives::types::BlockReference,
pub next_page: Option<String>,
}

#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub struct RpcQueryResponse {
#[serde(flatten)]
pub kind: near_jsonrpc_primitives::types::query::QueryResponseKind,
pub block_height: near_primitives::types::BlockHeight,
pub block_hash: near_primitives::hash::CryptoHash,
pub next_page: Option<String>,
}

pub async fn view_state_paginated(
data: Data<ServerContext>,
Params(params): Params<RpcViewStatePaginatedRequest>,
) -> Result<RpcQueryResponse, RPCError> {
println!("{:?}", params);
todo!()
}
1 change: 1 addition & 0 deletions rpc-server/src/modules/state/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod methods;

0 comments on commit 5ef0f65

Please sign in to comment.