-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use single library for SSZ, bls-to-execution-change and presigned-exi…
…t-message (#54) * Make bls-to-execution-change command work * [STACKED] Command to generate presigned exit message (#55) * Command to generate presigned exit message * Docs for presigned-exit-message * Code review feedback * Add support for sending signed payloads to beacon node * Add note on backwards compatibility policy * Unify regex usage * Adjustments for single payload cmds - Fix presigned-exit-message format & beacon node sending - Rename Operator traits -> validator - Rename operator module -> operations * Fix README
- Loading branch information
Showing
26 changed files
with
1,673 additions
and
880 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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,44 @@ | ||
#[derive(Debug)] | ||
pub enum BeaconNodeError { | ||
InvalidBeaconNodeURI, | ||
ClientConfigurationError, | ||
NodeCommunicationError, | ||
Non200Response, | ||
} | ||
|
||
/// A trait for types that can be sent to beacon node as-is | ||
/// without transformations | ||
pub trait BeaconNodeExportable { | ||
/// Export an entity as JSON | ||
fn export(&self) -> serde_json::Value; | ||
|
||
/// The path at beacon node where to send data | ||
fn beacon_node_path(&self) -> String; | ||
|
||
/// Send the JSON payload to beacon node | ||
fn send_beacon_payload(&self, beacon_node_uri: url::Url) -> Result<(), BeaconNodeError> { | ||
let reqwc = reqwest::blocking::Client::builder() | ||
.build() | ||
.map_err(|_| BeaconNodeError::ClientConfigurationError)?; | ||
let joined_url = beacon_node_uri | ||
.join(&self.beacon_node_path()) | ||
.map_err(|_| BeaconNodeError::InvalidBeaconNodeURI)?; | ||
let resp = reqwc | ||
.post(joined_url) | ||
.header("Content-Type", "application/json") | ||
.body(self.export().to_string()) | ||
.send(); | ||
|
||
match resp { | ||
Ok(response) => { | ||
let code = response.status().as_u16(); | ||
if code != 200 { | ||
Err(BeaconNodeError::Non200Response) | ||
} else { | ||
Ok(()) | ||
} | ||
} | ||
Err(_) => Err(BeaconNodeError::NodeCommunicationError), | ||
} | ||
} | ||
} |
Oops, something went wrong.