Skip to content

Commit

Permalink
fix queryObjectStates response bug (#1760)
Browse files Browse the repository at this point in the history
* fix IndexerObjectStateView value

* generate rpc schema
  • Loading branch information
pause125 authored May 29, 2024
1 parent 5b1f2c5 commit d2cf9f3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crates/rooch-open-rpc-spec/schemas/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@
"value": {
"anyOf": [
{
"$ref": "#/components/schemas/AnnotatedMoveValueView"
"$ref": "#/components/schemas/AnnotatedMoveStructView"
},
{
"type": "null"
Expand Down
12 changes: 6 additions & 6 deletions crates/rooch-rpc-api/src/jsonrpc_types/state_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

use super::{
AnnotatedMoveValueView, BytesView, H256View, RoochAddressView, StrView, StructTagView,
TypeTagView,
AnnotatedMoveStructView, AnnotatedMoveValueView, BytesView, H256View, RoochAddressView,
StrView, StructTagView, TypeTagView,
};
use anyhow::Result;

Expand All @@ -13,7 +13,7 @@ use moveos_types::state::{
};
use moveos_types::state_resolver::StateKV;
use moveos_types::{
moveos_std::object::ObjectID,
moveos_std::object::{AnnotatedObject, ObjectID},
state::{AnnotatedState, State, StateChangeSet, TableTypeInfo},
};
use rooch_types::address::RoochAddress;
Expand Down Expand Up @@ -375,7 +375,7 @@ pub struct IndexerObjectStateView {
pub object_id: ObjectID,
pub owner: RoochAddressView,
pub flag: u8,
pub value: Option<AnnotatedMoveValueView>,
pub value: Option<AnnotatedMoveStructView>,
pub object_type: StructTagView,
pub state_root: H256View,
pub size: u64,
Expand All @@ -388,14 +388,14 @@ pub struct IndexerObjectStateView {

impl IndexerObjectStateView {
pub fn new_from_object_state(
annotated_state: Option<AnnotatedState>,
annotated_state: Option<AnnotatedObject>,
state: IndexerObjectState,
) -> IndexerObjectStateView {
IndexerObjectStateView {
object_id: state.object_id,
owner: state.owner.into(),
flag: state.flag,
value: annotated_state.map(|v| AnnotatedMoveValueView::from(v.decoded_value)),
value: annotated_state.map(|v| AnnotatedMoveStructView::from(v.value)),
object_type: state.object_type.into(),
state_root: state.state_root.into(),
size: state.size,
Expand Down
15 changes: 13 additions & 2 deletions crates/rooch-rpc-server/src/server/rooch_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,15 +626,26 @@ impl RoochAPIServer for RoochServer {
!valid_display_field_views.is_empty(),
"display fields should not be empty"
);
(Some(s), valid_display_field_views.pop().unwrap())
let annotated_obj = s.into_annotated_object().expect("should be object");
(
Some(annotated_obj),
valid_display_field_views.pop().unwrap(),
)
}
None => (None, None),
})
.collect::<Vec<_>>()
} else {
annotated_states
.into_iter()
.map(|s| (s, None))
.map(|s| {
let obj = s.map(|annotated_s| {
annotated_s
.into_annotated_object()
.expect("should be object")
});
(obj, None)
})
.collect::<Vec<_>>()
};

Expand Down
4 changes: 3 additions & 1 deletion frameworks/moveos-stdlib/sources/evm.move
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

// Evm Precompiled Contracts https://www.evm.codes/precompiled?fork=cancun
module moveos_std::evm {
use std::vector;
use moveos_std::hash;

#[test_only]
use std::vector;

const ErrorEcRecoverFailed: u64 = 1;
const ErrorModexpFailed: u64 = 5;
const ErrorEcAddFailed: u64 = 6;
Expand Down

0 comments on commit d2cf9f3

Please sign in to comment.