fisco_bcos_service/
lib.rs

1pub mod web3;
2pub mod account;
3pub mod abi;
4pub mod transaction;
5pub mod helpers;
6pub mod tassl;
7pub mod config;
8pub mod precompiled;
9pub mod event;
10pub mod channel;
11pub use ethabi;
12pub use serde_json;
13
14pub use config::create_config_with_file;
15pub use web3::service::create_service_with_config as create_web3_service_with_config;
16
17use web3::service::{
18    Service as Web3Service,
19    ServiceError as Web3ServiceError,
20};
21
22use event::event_service::EventService;
23
24///
25/// 根据配置文件创建 web3 service 服务实例。
26///
27/// 完整配置文件格式如下所示:
28///
29/// ```json
30/// {
31///    "service_type": "rpc",
32///    "node": {
33///        "host": "127.0.0.1",
34///        "port": 8545
35///    },
36///    "account": "./accounts/alice.pem",
37///    "contract":  {
38///        "solc": "./bin/solc-0.4.25",
39///        "source": "./contracts",
40///        "output": "./contracts/.output"
41///    },
42///    "authentication": {
43///        "ca_cert": "./authentication/gm/gmca.crt",
44///        "sign_cert": "./authentication/gm/gmsdk.crt",
45///        "sign_key": "./authentication/gm/gmsdk.key",
46///        "enc_key": "./authentication/gm/gmensdk.key",
47///        "enc_cert": "./authentication/gm/gmensdk.crt"
48///    },
49///    "sm_crypto": false,
50///    "group_id": 1,
51///    "chain_id": 1,
52///    "timeout_seconds": 10
53/// }
54/// ```
55///
56pub fn create_web3_service(config_file_path: &str) -> Result<Web3Service, Web3ServiceError>  {
57    let config = create_config_with_file(config_file_path)?;
58    create_web3_service_with_config(&config)
59}
60
61///
62/// 根据配置文件创建 event service 服务实例。
63///
64/// 完整配置文件格式如下所示:
65///
66/// ```json
67/// {
68///    "service_type": "rpc",
69///    "node": {
70///        "host": "127.0.0.1",
71///        "port": 8545
72///    },
73///    "account": "./accounts/alice.pem",
74///    "contract":  {
75///        "solc": "./bin/solc-0.4.25",
76///        "source": "./contracts",
77///        "output": "./contracts/.output"
78///    },
79///    "authentication": {
80///        "ca_cert": "./authentication/gm/gmca.crt",
81///        "sign_cert": "./authentication/gm/gmsdk.crt",
82///        "sign_key": "./authentication/gm/gmsdk.key",
83///        "enc_key": "./authentication/gm/gmensdk.key",
84///        "enc_cert": "./authentication/gm/gmensdk.crt"
85///    },
86///    "sm_crypto": false,
87///    "group_id": 1,
88///    "chain_id": 1,
89///    "timeout_seconds": 10
90/// }
91/// ```
92///
93pub fn create_event_service(config_file_path: &str) -> Result<EventService, std::io::Error> {
94    let config = create_config_with_file(&config_file_path)?;
95    Ok(EventService::new(&config))
96}