Skip to content

Commit 160b4cc

Browse files
committed
public rpcclient
1 parent bf5ec6e commit 160b4cc

File tree

10 files changed

+1274
-235
lines changed

10 files changed

+1274
-235
lines changed

Cargo.lock

+1,167-185
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+19
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ members = [
77
"abi/resolver",
88
"abi/types",
99
"dev",
10+
"rpc/api",
1011
"types",
1112
"storage",
1213
"state/api",
@@ -52,6 +53,7 @@ default-members = [
5253
"abi/resolver",
5354
"abi/types",
5455
"dev",
56+
"rpc/api",
5557
"types",
5658
"storage",
5759
"state/api",
@@ -225,6 +227,7 @@ regex = "1.6.0"
225227
rocksdb = { default-features = false, features = ["lz4"], version = "0.21.0" }
226228
schemars = { git = "https://github.com/starcoinorg/schemars", rev = "a64c6ddf7ca4796e090208b1476de2e53772042f" }
227229
serde = { version = "1.0.130", features = ["derive"] }
230+
serde-helpers = { path = "commons/serde-helpers" }
228231
serde-generate = { git = "https://github.com/starcoinorg/serde-reflection", rev = "eb95fd4e3b67e08d71432b522c53833a0b855d80" }
229232
serde-reflection = { git = "https://github.com/starcoinorg/serde-reflection", rev = "eb95fd4e3b67e08d71432b522c53833a0b855d80" }
230233
serde_bytes = "0.11"
@@ -308,6 +311,22 @@ zeroize = "1.3.0"
308311
better_any = "0.1.1"
309312
paste = "1.0.7"
310313

314+
jsonrpc-client-transports = "18"
315+
jsonrpc-core = "18"
316+
jsonrpc-core-client = "18"
317+
jsonrpc-derive = "18"
318+
openrpc-derive = { git = "https://github.com/starcoinorg/openrpc-rs", rev = "1f2f7d3495e3bd3ef3b6fcf7c4e0602cad090d5e", features = [
319+
"jsonrpc",
320+
] }
321+
openrpc-schema = { git = "https://github.com/starcoinorg/openrpc-rs", rev = "1f2f7d3495e3bd3ef3b6fcf7c4e0602cad090d5e" }
322+
323+
jsonrpc-http-server = "18"
324+
jsonrpc-ipc-server = "18"
325+
jsonrpc-pubsub = "18"
326+
jsonrpc-server-utils = "18"
327+
jsonrpc-tcp-server = "18"
328+
jsonrpc-ws-server = "18"
329+
311330
[profile.release.package]
312331
starcoin-vm-runtime.debug = 1
313332

rpc/api/Cargo.toml

+1-21
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ path = "src/generate_schema.rs"
44

55
[dependencies]
66
anyhow = { workspace = true }
7-
async-trait = { workspace = true }
87
bytes = { workspace = true }
9-
bcs-ext = { workspace = true }
108
clap = { features = ["derive"], workspace = true }
119
futures = { workspace = true }
12-
hex = { workspace = true }
1310
jsonrpc-core = { features = ["arbitrary_precision"], workspace = true }
1411
jsonrpc-core-client = { features = [
1512
"http",
@@ -20,35 +17,18 @@ jsonrpc-core-client = { features = [
2017
], workspace = true }
2118
jsonrpc-derive = { workspace = true }
2219
jsonrpc-pubsub = { workspace = true }
23-
jsonrpc-server-utils = { workspace = true }
24-
network-api = { workspace = true }
25-
network-p2p-types = { workspace = true }
26-
network-types = { workspace = true }
2720
openrpc-derive = { workspace = true }
2821
openrpc-schema = { workspace = true }
2922
schemars = { workspace = true }
3023
serde = { features = ["derive"], workspace = true }
31-
serde-helpers = { workspace = true }
3224
serde_json = { features = ["arbitrary_precision"], workspace = true }
3325
starcoin-abi-decoder = { workspace = true }
3426
starcoin-abi-types = { workspace = true }
3527
starcoin-account-api = { workspace = true }
36-
starcoin-accumulator = { workspace = true }
37-
starcoin-chain-api = { workspace = true }
38-
starcoin-config = { workspace = true }
3928
starcoin-crypto = { workspace = true }
40-
starcoin-logger = { workspace = true }
41-
starcoin-resource-viewer = { workspace = true }
42-
starcoin-service-registry = { workspace = true }
43-
starcoin-state-api = { workspace = true }
44-
starcoin-sync-api = { workspace = true }
45-
starcoin-txpool-api = { workspace = true }
4629
starcoin-types = { workspace = true }
4730
starcoin-vm-types = { workspace = true }
48-
thiserror = { workspace = true }
49-
vm-status-translator = { workspace = true }
50-
move-core-types = { workspace = true }
51-
starcoin-dag = { workspace = true }
31+
5232

5333
[package]
5434
authors = { workspace = true }

rpc/api/src/account/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
// SPDX-License-Identifier: Apache-2
33

44
pub use self::gen_client::Client as AccountClient;
5-
use crate::types::{SignedMessageView, StrView, TransactionRequest};
65
use crate::FutureResult;
76
use openrpc_derive::openrpc;
87
use starcoin_account_api::AccountInfo;
98
use starcoin_types::account_address::AccountAddress;
109
use starcoin_types::sign_message::SigningMessage;
1110
use starcoin_types::transaction::{RawUserTransaction, SignedUserTransaction};
11+
use starcoin_types::view::{SignedMessageView, StrView, TransactionRequest};
1212
use starcoin_vm_types::token::token_code::TokenCode;
1313

1414
#[openrpc]

rpc/api/src/contract_api.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
pub use self::gen_client::Client as ContractClient;
2-
use crate::types::{
3-
AnnotatedMoveStructView, AnnotatedMoveValueView, ContractCall, DryRunOutputView,
4-
DryRunTransactionRequest, FunctionIdView, ModuleIdView, StrView, StructTagView,
5-
};
62
use crate::FutureResult;
73
use openrpc_derive::openrpc;
4+
use schemars::JsonSchema;
5+
use serde::{Deserialize, Serialize};
86
use starcoin_abi_decoder::DecodedMoveValue;
97
use starcoin_abi_types::{FunctionABI, ModuleABI, StructInstantiation};
8+
use starcoin_types::view::{
9+
AnnotatedMoveStructView, AnnotatedMoveValueView, DryRunOutputView, DryRunTransactionRequest,
10+
FunctionIdView, ModuleIdView, StrView, StructTagView, TransactionArgumentView, TypeTagView,
11+
};
1012
use starcoin_vm_types::account_address::AccountAddress;
1113
use starcoin_vm_types::language_storage::{ModuleId, StructTag};
1214
use starcoin_vm_types::transaction::authenticator::AccountPublicKey;
15+
16+
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
17+
pub struct ContractCall {
18+
pub function_id: FunctionIdView,
19+
pub type_args: Vec<TypeTagView>,
20+
pub args: Vec<TransactionArgumentView>,
21+
}
1322
#[openrpc]
1423
pub trait ContractApi {
1524
/// get code of module

rpc/api/src/generate_schema.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
use anyhow::Result;
22
use clap::Parser;
33
use starcoin_rpc_api::{
4-
account, chain, contract_api, debug, miner, network_manager, node, node_manager, state,
5-
sync_manager, txpool,
4+
account, /* chain ,*/ contract_api,
5+
/*debug, miner, network_manager, node, node_manager, */
6+
state,
7+
/* sync_manager, txpool, */
68
};
79
use std::fs::{create_dir_all, File};
810
use std::path::Path;
@@ -38,15 +40,17 @@ fn main() {
3840
data_dir
3941
},
4042
account,
41-
chain,
43+
/*
44+
chain, */
4245
contract_api,
46+
/*
4347
debug,
4448
miner,
4549
network_manager,
4650
node,
47-
node_manager,
48-
state,
49-
sync_manager,
50-
txpool
51+
node_manager, */
52+
state /*,
53+
sync_manager,
54+
txpool */
5155
);
5256
}

rpc/api/src/lib.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ pub type FutureResult<T> = BoxFuture<Result<T, Error>>;
77
pub use jsonrpc_core::Params;
88

99
pub mod account;
10-
pub mod chain;
10+
//pub mod chain;
1111
pub mod contract_api;
12-
pub mod debug;
12+
//pub mod debug;
1313
pub mod errors;
1414
pub mod metadata;
15-
pub mod miner;
16-
pub mod network_manager;
17-
pub mod node;
18-
pub mod node_manager;
15+
//pub mod miner;
16+
//pub mod network_manager;
17+
//pub mod node;
18+
//pub mod node_manager;
1919
pub mod pubsub;
20-
pub mod service;
20+
//pub mod service;
2121
pub mod state;
22-
pub mod sync_manager;
23-
#[cfg(test)]
24-
mod tests;
25-
pub mod txpool;
26-
pub mod types;
22+
// pub mod sync_manager;
23+
// #[cfg(test)]
24+
// mod tests;
25+
// pub mod txpool;
26+
//pub mod types;

rpc/api/src/pubsub/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ use jsonrpc_core::Result;
77
use jsonrpc_derive::rpc;
88
use jsonrpc_pubsub::{typed, SubscriptionId};
99

10-
use crate::types::pubsub;
10+
//use crate::types::pubsub;
1111

12+
/*
1213
/// Starcoin PUB-SUB rpc interface.
1314
/// Example:
1415
/// ```bash
@@ -43,3 +44,4 @@ pub trait StarcoinPubSub {
4344
)]
4445
fn unsubscribe(&self, meta: Option<Self::Metadata>, id: SubscriptionId) -> Result<bool>;
4546
}
47+
*/

rpc/api/src/state/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// SPDX-License-Identifier: Apache-2
33

44
pub use self::gen_client::Client as StateClient;
5-
use crate::types::{
6-
AccountStateSetView, CodeView, ListCodeView, ListResourceView, ResourceView,
7-
StateWithProofView, StateWithTableItemProofView, StrView, StructTagView, TableInfoView,
8-
};
95
use crate::FutureResult;
106
use bytes::Bytes;
117
use openrpc_derive::openrpc;
@@ -14,6 +10,10 @@ use serde::Deserialize;
1410
use serde::Serialize;
1511
use starcoin_crypto::HashValue;
1612
use starcoin_types::language_storage::{ModuleId, StructTag};
13+
use starcoin_types::view::{
14+
AccountStateSetView, CodeView, ListCodeView, ListResourceView, ResourceView,
15+
StateWithProofView, StateWithTableItemProofView, StrView, StructTagView, TableInfoView,
16+
};
1717
use starcoin_types::{account_address::AccountAddress, account_state::AccountState};
1818
use starcoin_vm_types::state_store::state_key::StateKey;
1919
use starcoin_vm_types::state_store::table::TableHandle;

types/src/view/mod.rs

+43
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,91 @@
44
pub type ByteCode = Vec<u8>;
55

66
pub mod account_state_set_view;
7+
pub use account_state_set_view::*;
78
pub mod accumulator_info_view;
9+
pub use accumulator_info_view::*;
810
pub mod accumulator_proof_view;
11+
pub use accumulator_proof_view::*;
912
pub mod annotated_move_struct_view;
13+
pub use annotated_move_struct_view::*;
1014
pub mod annotated_move_value_view;
15+
pub use annotated_move_value_view::*;
1116
pub mod arguments_view;
17+
pub use arguments_view::*;
1218
pub mod block_header_view;
19+
pub use block_header_view::*;
1320
pub mod block_info_view;
21+
pub use block_info_view::*;
1422
pub mod block_metadata_view;
23+
pub use block_metadata_view::*;
1524
pub mod block_transaction_view;
25+
pub use block_transaction_view::*;
1626
pub mod block_view;
27+
pub use block_view::*;
1728
pub mod byte_code_or_script_function;
29+
pub use byte_code_or_script_function::*;
1830
pub mod bytes_view;
31+
pub use bytes_view::*;
1932
pub mod chain_info_view;
33+
pub use chain_info_view::*;
2034
pub mod code_view;
35+
pub use code_view::*;
2136
pub mod decoded_script_view;
37+
pub use decoded_script_view::*;
2238
pub mod dry_run_output_view;
39+
pub use dry_run_output_view::*;
2340
pub mod event_with_proof_view;
41+
pub use event_with_proof_view::*;
2442
pub mod function_arg_type_view;
43+
pub use function_arg_type_view::*;
2544
pub mod minted_block_view;
45+
pub use minted_block_view::*;
2646
pub mod peer_info_view;
47+
pub use peer_info_view::*;
2748
pub mod raw_block_view;
49+
pub use raw_block_view::*;
2850
pub mod raw_user_transaction_view;
51+
pub use raw_user_transaction_view::*;
2952
pub mod resource_view;
53+
pub use resource_view::*;
3054
pub mod scripts_data;
55+
pub use scripts_data::*;
3156
pub mod signed_user_transaction_view;
57+
pub use signed_user_transaction_view::*;
3258
pub mod spare_merkle_proof_view;
59+
pub use spare_merkle_proof_view::*;
3360
pub mod state_key_view;
61+
pub use state_key_view::*;
3462
pub mod state_with_proof_view;
63+
pub use state_with_proof_view::*;
3564
pub mod state_with_table_item_proof_view;
65+
pub use state_with_table_item_proof_view::*;
3666
pub mod str_view;
67+
pub use str_view::*;
3768
pub mod table_info_view;
69+
pub use table_info_view::*;
3870
pub mod table_item_view;
71+
pub use table_item_view::*;
3972
pub mod transaction_event_response;
73+
pub use transaction_event_response::*;
4074
pub mod transaction_event_view;
75+
pub use transaction_event_view::*;
4176
pub mod transaction_info_view;
77+
pub use transaction_info_view::*;
4278
pub mod transaction_output_action;
79+
pub use transaction_output_action::*;
4380
pub mod transaction_output_table_item_action;
4481
pub mod transaction_output_view;
4582
pub mod transaction_payload_view;
4683
pub mod transaction_request;
84+
pub use transaction_request::*;
4785
pub mod transaction_status_view;
86+
pub use transaction_status_view::*;
4887
pub mod transaction_view;
88+
pub use transaction_view::*;
4989
pub mod transaction_with_proof;
90+
pub use transaction_with_proof::*;
5091
pub mod write_op_value_view;
92+
pub use write_op_value_view::*;
5193
pub mod write_op_view;
94+
pub use write_op_view::*;

0 commit comments

Comments
 (0)