Skip to content

Commit

Permalink
get_field_states
Browse files Browse the repository at this point in the history
  • Loading branch information
pause125 committed Jun 5, 2024
1 parent 649977c commit b88a252
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
19 changes: 14 additions & 5 deletions crates/rooch-rpc-api/src/api/rooch_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use crate::jsonrpc_types::transaction_view::{TransactionFilterView, TransactionW
use crate::jsonrpc_types::{
AccessPathView, AnnotatedFunctionResultView, BalanceInfoPageView, BytesView, EventOptions,
EventPageView, ExecuteTransactionResponseView, FunctionCallView, H256View,
IndexerEventPageView, IndexerObjectStatePageView, ObjectIDVecView, ObjectIDView,
ObjectStateFilterView, ObjectStateView, QueryOptions, StateOptions, StatePageView, StateView,
StrView, StructTagView, TransactionWithInfoPageView, TxOptions,
IndexerEventPageView, IndexerObjectStatePageView, KeyStateView, ObjectIDVecView, ObjectIDView,
ObjectStateFilterView, ObjectStateView, QueryOptions, SimpleKeyStateView, StateOptions,
StatePageView, StateView, StrView, StructTagView, TransactionWithInfoPageView, TxOptions,
};
use jsonrpsee::core::RpcResult;
use jsonrpsee::proc_macros::rpc;
Expand Down Expand Up @@ -76,9 +76,18 @@ pub trait RoochAPI {
state_option: Option<StateOptions>,
) -> RpcResult<Vec<Option<ObjectStateView>>>;

/// Get Object Fields via ObjectID and field keys.
#[method(name = "getFieldStates")]
async fn get_field_states(
&self,
object_id: ObjectIDView,
field_key: Vec<SimpleKeyStateView>,
state_option: Option<StateOptions>,
) -> RpcResult<Vec<Option<StateView>>>;

/// List Object Fields via ObjectID.
#[method(name = "listObjectFields")]
async fn list_object_fields(
#[method(name = "listFieldStates")]
async fn list_field_states(
&self,
object_id: ObjectIDView,
cursor: Option<String>,
Expand Down
13 changes: 12 additions & 1 deletion crates/rooch-rpc-server/src/server/rooch_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use rooch_rpc_api::jsonrpc_types::transaction_view::TransactionFilterView;
use rooch_rpc_api::jsonrpc_types::{
account_view::BalanceInfoView, IndexerEventPageView, IndexerObjectStatePageView,
IndexerObjectStateView, KeyStateView, ObjectIDVecView, ObjectStateFilterView, ObjectStateView,
QueryOptions, StateKVView, StateOptions, TxOptions,
QueryOptions, SimpleKeyStateView, StateKVView, StateOptions, TxOptions,
};
use rooch_rpc_api::jsonrpc_types::{
event_view::{EventFilterView, EventView, IndexerEventView},
Expand Down Expand Up @@ -343,6 +343,17 @@ impl RoochAPIServer for RoochServer {
Ok(objects_view)
}

async fn get_field_states(
&self,
object_id: ObjectIDView,
field_key: Vec<SimpleKeyStateView>,
state_option: Option<StateOptions>,
) -> RpcResult<Vec<Option<StateView>>> {
let key_states = field_key.into_iter().map(KeyState::from).collect();
let access_path_view =
AccessPathView::from(AccessPath::fields(object_id.into(), key_states));
}

async fn get_events_by_event_handle(
&self,
event_handle_type: StructTagView,
Expand Down

0 comments on commit b88a252

Please sign in to comment.