-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from chainbound/feat/sidecar/commitments-api
Implement new commitments-API
- Loading branch information
Showing
19 changed files
with
1,050 additions
and
635 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub struct JsonPayload { | ||
/// The JSON-RPC version string. MUST be "2.0". | ||
pub jsonrpc: String, | ||
/// The method string. | ||
pub method: String, | ||
/// Optional ID. | ||
pub id: Option<serde_json::Value>, | ||
/// The parameters object. | ||
pub params: Vec<serde_json::Value>, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub struct JsonResponse { | ||
pub jsonrpc: String, | ||
/// Optional ID. Must be serialized as `null` if not present. | ||
pub id: Option<serde_json::Value>, | ||
#[serde(skip_serializing_if = "serde_json::Value::is_null", default)] | ||
pub result: serde_json::Value, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub error: Option<JsonError>, | ||
} | ||
|
||
impl Default for JsonResponse { | ||
fn default() -> Self { | ||
Self { | ||
jsonrpc: "2.0".to_string(), | ||
id: None, | ||
result: serde_json::Value::Null, | ||
error: None, | ||
} | ||
} | ||
} | ||
|
||
impl JsonResponse { | ||
pub fn from_error(code: i32, message: String) -> Self { | ||
Self { | ||
jsonrpc: "2.0".to_string(), | ||
id: None, | ||
result: serde_json::Value::Null, | ||
error: Some(JsonError { code, message }), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub struct JsonError { | ||
pub code: i32, | ||
pub message: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/// JSON-RPC helper types and functions. | ||
mod jsonrpc; | ||
/// The commitments-API JSON-RPC server implementation. | ||
pub mod server; | ||
/// The commitments-API specification and errors. | ||
pub mod spec; |
Oops, something went wrong.