Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RPC] Merge the state API and refactor event API #984

Merged
merged 5 commits into from
Oct 16, 2023
Merged

Conversation

jolestar
Copy link
Contributor

@jolestar jolestar commented Oct 16, 2023

Summary

Merge the state API and refactor event API

  1. Merge rooch_getAnnotatedStates to rooch_getStates, and add StateOptions as an argument.
  2. Merge rooch_listAnnotatedStates to rooch_listStates, and add StateOptions as an argument.
  3. Refactor event API, add EventOptions as argument. Follow refactor event RPC to make a pure event #983
  4. Rename move_value in Response to decoded_value.
curl --location 'http://localhost:50051' \
--header 'Content-Type: application/json' \
--data '{
    "id": 101,
    "jsonrpc": "2.0",
    "method": "rooch_getEventsByEventHandle",
    "params": [
        "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081::event_test::WithdrawEvent", null, "5", {"decode":true}
    ]
}'
{
   "id" : 101,
   "jsonrpc" : "2.0",
   "result" : {
      "data" : [
         {
            "decoded_event_data" : {
               "abilities" : 0,
               "type" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081::event_test::WithdrawEvent",
               "value" : {
                  "addr" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081",
                  "amount" : "10"
               }
            },
            "event_data" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef10810a00000000000000",
            "event_id" : {
               "event_handle_id" : "0xccc2dc0d116f37a1d8cca72f6ea6fc938c652309e40ea30c3f8bbd57913438ee",
               "event_seq" : 0
            },
            "event_index" : 0,
            "type_tag" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081::event_test::WithdrawEvent"
         },
         {
            "decoded_event_data" : {
               "abilities" : 0,
               "type" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081::event_test::WithdrawEvent",
               "value" : {
                  "addr" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081",
                  "amount" : "10"
               }
            },
            "event_data" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef10810a00000000000000",
            "event_id" : {
               "event_handle_id" : "0xccc2dc0d116f37a1d8cca72f6ea6fc938c652309e40ea30c3f8bbd57913438ee",
               "event_seq" : 1
            },
            "event_index" : 0,
            "type_tag" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081::event_test::WithdrawEvent"
         },
         {
            "decoded_event_data" : {
               "abilities" : 0,
               "type" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081::event_test::WithdrawEvent",
               "value" : {
                  "addr" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081",
                  "amount" : "10"
               }
            },
            "event_data" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef10810a00000000000000",
            "event_id" : {
               "event_handle_id" : "0xccc2dc0d116f37a1d8cca72f6ea6fc938c652309e40ea30c3f8bbd57913438ee",
               "event_seq" : 2
            },
            "event_index" : 0,
            "type_tag" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081::event_test::WithdrawEvent"
         },
         {
            "decoded_event_data" : {
               "abilities" : 0,
               "type" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081::event_test::WithdrawEvent",
               "value" : {
                  "addr" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081",
                  "amount" : "10"
               }
            },
            "event_data" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef10810a00000000000000",
            "event_id" : {
               "event_handle_id" : "0xccc2dc0d116f37a1d8cca72f6ea6fc938c652309e40ea30c3f8bbd57913438ee",
               "event_seq" : 3
            },
            "event_index" : 0,
            "type_tag" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081::event_test::WithdrawEvent"
         },
         {
            "decoded_event_data" : {
               "abilities" : 0,
               "type" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081::event_test::WithdrawEvent",
               "value" : {
                  "addr" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081",
                  "amount" : "10"
               }
            },
            "event_data" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef10810a00000000000000",
            "event_id" : {
               "event_handle_id" : "0xccc2dc0d116f37a1d8cca72f6ea6fc938c652309e40ea30c3f8bbd57913438ee",
               "event_seq" : 4
            },
            "event_index" : 0,
            "type_tag" : "0x5078ae74bac281e65fc446b467a843b186904a1b2d435f367030fc755eef1081::event_test::WithdrawEvent"
         }
      ],
      "has_next_page" : true,
      "next_cursor" : 4
   }
}
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"rooch_listStates","params":["/resource/0x3", null, null, {"decode":true}],"id":67}' http://localhost:50051
{
   "id" : 67,
   "jsonrpc" : "2.0",
   "result" : {
      "data" : [
         {
            "decoded_value" : {
               "abilities" : 8,
               "type" : "0x3::ethereum_light_client::BlockStore",
               "value" : {
                  "blocks" : {
                     "abilities" : 4,
                     "type" : "0x2::table::Table<u64, 0x3::ethereum_light_client::BlockHeader>",
                     "value" : {
                        "handle" : "0x74d9dc1bc2e8942ab789832be8e30bf688f8aeaa9e6cd8007bb554a3645b030a"
                     }
                  }
               }
            },
            "value" : "0x74d9dc1bc2e8942ab789832be8e30bf688f8aeaa9e6cd8007bb554a3645b030a",
            "value_type" : "0x3::ethereum_light_client::BlockStore"
         },
         {
            "decoded_value" : {
               "abilities" : 8,
               "type" : "0x3::timestamp::CurrentTimeMicroseconds",
               "value" : {
                  "microseconds" : "0"
               }
            },
            "value" : "0x0000000000000000",
            "value_type" : "0x3::timestamp::CurrentTimeMicroseconds"
         },
         {
            "decoded_value" : {
               "abilities" : 8,
               "type" : "0x3::coin::CoinInfos",
               "value" : {
                  "coin_infos" : {
                     "abilities" : 4,
                     "type" : "0x2::table::Table<0x1::string::String, 0x3::coin::CoinInfo>",
                     "value" : {
                        "handle" : "0xdf6fe655ba10fa00aba344ce49239a69739d03ad6afe40ef7af60882ea93ec2e"
                     }
                  }
               }
            },
            "value" : "0xdf6fe655ba10fa00aba344ce49239a69739d03ad6afe40ef7af60882ea93ec2e",
            "value_type" : "0x3::coin::CoinInfos"
         },
         {
            "decoded_value" : {
               "abilities" : 12,
               "type" : "0x3::account::Account",
               "value" : {
                  "sequence_number" : "0"
               }
            },
            "value" : "0x0000000000000000",
            "value_type" : "0x3::account::Account"
         },
         {
            "decoded_value" : {
               "abilities" : 8,
               "type" : "0x3::account_authentication::AuthenticationKeys",
               "value" : {
                  "authentication_keys" : {
                     "abilities" : 4,
                     "type" : "0x2::type_table::TypeTable",
                     "value" : {
                        "handle" : "0x00ce0f32b6aea4109a7ec1b9748eccc5194ff034b91228df33d0fe948888a986"
                     }
                  }
               }
            },
            "value" : "0x00ce0f32b6aea4109a7ec1b9748eccc5194ff034b91228df33d0fe948888a986",
            "value_type" : "0x3::account_authentication::AuthenticationKeys"
         },
         {
            "decoded_value" : {
               "abilities" : 8,
               "type" : "0x3::address_mapping::AddressMapping",
               "value" : {
                  "mapping" : {
                     "abilities" : 4,
                     "type" : "0x2::table::Table<0x3::multichain_address::MultiChainAddress, address>",
                     "value" : {
                        "handle" : "0x5977156e94db7e32dd7431e57d9ffce9d3ee5b766e344d4a719639465d21df8c"
                     }
                  }
               }
            },
            "value" : "0x5977156e94db7e32dd7431e57d9ffce9d3ee5b766e344d4a719639465d21df8c",
            "value_type" : "0x3::address_mapping::AddressMapping"
         },
         {
            "decoded_value" : {
               "abilities" : 12,
               "type" : "0x3::transaction_fee::TransactionFeePool",
               "value" : {
                  "fee" : {
                     "abilities" : 14,
                     "type" : "0x2::object_ref::ObjectRef<0x3::coin_store::CoinStore>",
                     "value" : {
                        "id" : "0x01695ca98c64c40be429f1b12b563a1cd446decc4d62775571f767deaf179b70"
                     }
                  }
               }
            },
            "value" : "0x01695ca98c64c40be429f1b12b563a1cd446decc4d62775571f767deaf179b70",
            "value_type" : "0x3::transaction_fee::TransactionFeePool"
         },
         {
            "decoded_value" : {
               "abilities" : 8,
               "type" : "0x3::auth_validator_registry::ValidatorRegistry",
               "value" : {
                  "validator_num" : "2",
                  "validators" : {
                     "abilities" : 4,
                     "type" : "0x2::table::Table<u64, 0x3::auth_validator::AuthValidator>",
                     "value" : {
                        "handle" : "0x6530cc0697d8b41ce6e20215a963e4512275ad44aaf759aa42e2c99decf5ed7b"
                     }
                  },
                  "validators_with_type" : {
                     "abilities" : 4,
                     "type" : "0x2::type_table::TypeTable",
                     "value" : {
                        "handle" : "0x5eeedeef6e8c9c6a4c3a9a3e368cbe02cf9560c3bd29af923f556443ac43d6eb"
                     }
                  }
               }
            },
            "value" : "0x02000000000000006530cc0697d8b41ce6e20215a963e4512275ad44aaf759aa42e2c99decf5ed7b5eeedeef6e8c9c6a4c3a9a3e368cbe02cf9560c3bd29af923f556443ac43d6eb",
            "value_type" : "0x3::auth_validator_registry::ValidatorRegistry"
         },
         {
            "decoded_value" : {
               "abilities" : 15,
               "type" : "0x3::chain_id::ChainID",
               "value" : {
                  "id" : "20230104"
               }
            },
            "value" : "0xd8af340100000000",
            "value_type" : "0x3::chain_id::ChainID"
         },
         {
            "decoded_value" : {
               "abilities" : 8,
               "type" : "0x3::account_coin_store::AutoAcceptCoins",
               "value" : {
                  "auto_accept_coins" : {
                     "abilities" : 4,
                     "type" : "0x2::table::Table<address, bool>",
                     "value" : {
                        "handle" : "0x07335190afdd98dc7187c5c810b0f947d0088bb975fc98d07fd23a4709f5f279"
                     }
                  }
               }
            },
            "value" : "0x07335190afdd98dc7187c5c810b0f947d0088bb975fc98d07fd23a4709f5f279",
            "value_type" : "0x3::account_coin_store::AutoAcceptCoins"
         },
         {
            "decoded_value" : {
               "abilities" : 8,
               "type" : "0x3::account_coin_store::CoinStores",
               "value" : {
                  "coin_stores" : {
                     "abilities" : 4,
                     "type" : "0x2::table::Table<0x1::string::String, 0x2::object_ref::ObjectRef<0x3::coin_store::CoinStore>>",
                     "value" : {
                        "handle" : "0x7e4cac7418d5e570a68389f8c5479c652157e4ab6cd86e79cde3784f71746096"
                     }
                  }
               }
            },
            "value" : "0x7e4cac7418d5e570a68389f8c5479c652157e4ab6cd86e79cde3784f71746096",
            "value_type" : "0x3::account_coin_store::CoinStores"
         }
      ],
      "has_next_page" : false,
      "next_cursor" : "0x60303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030333a3a6163636f756e745f636f696e5f73746f72653a3a436f696e53746f726573"
   }
}

@vercel
Copy link

vercel bot commented Oct 16, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
rooch ⬜️ Ignored (Inspect) Visit Preview Oct 16, 2023 5:04pm

@jolestar jolestar merged commit b020423 into main Oct 16, 2023
4 checks passed
@jolestar jolestar deleted the merge_state_api branch October 16, 2023 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Review] RPC return AnnotatedStruct as default and provide option by argument
2 participants