Skip to content

Commit

Permalink
Merge branch '2.0' into feat/dyn-secret-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandcoats authored Sep 13, 2023
2 parents 54da871 + 456398f commit 25c0626
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
10 changes: 2 additions & 8 deletions sdk/src/client/node_api/core/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl ClientInner {
let block_dto = BlockDto::from(block);

let response = self
.post_request_json::<SubmitBlockResponse>(PATH, serde_json::to_value(block_dto)?)
.post_request::<SubmitBlockResponse>(PATH, serde_json::to_value(block_dto)?)
.await?;

Ok(response.block_id)
Expand All @@ -167,14 +167,8 @@ impl ClientInner {
pub async fn post_block_raw(&self, block: &Block) -> Result<BlockId> {
const PATH: &str = "api/core/v3/blocks";

let timeout = self.get_timeout().await;

// TODO add Client::post_request_bytes
let response = self
.node_manager
.read()
.await
.post_request_bytes::<SubmitBlockResponse>(PATH, timeout, &block.pack_to_vec())
.post_request_bytes::<SubmitBlockResponse>(PATH, &block.pack_to_vec())
.await?;

Ok(response.block_id)
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/client/node_api/plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl ClientInner {

match req_method {
Ok(Method::GET) => self.get_request(&path, None, false, false).await,
Ok(Method::POST) => self.post_request_json(&path, request_object.into()).await,
Ok(Method::POST) => self.post_request(&path, request_object.into()).await,
_ => Err(crate::client::Error::Node(
crate::client::node_api::error::Error::NotSupported(method.to_string()),
)),
Expand Down
14 changes: 11 additions & 3 deletions sdk/src/client/node_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,17 @@ impl ClientInner {
request.await
}

pub(crate) async fn post_request_json<T: DeserializeOwned>(&self, path: &str, json: Value) -> Result<T> {
pub(crate) async fn post_request<T: DeserializeOwned>(&self, path: &str, json: Value) -> Result<T> {
let node_manager = self.node_manager.read().await;
let request = node_manager.post_request_json(path, self.get_timeout().await, json);
let request = node_manager.post_request(path, self.get_timeout().await, json);
#[cfg(not(target_family = "wasm"))]
let request = request.rate_limit(&self.request_pool);
request.await
}

pub(crate) async fn post_request_bytes<T: DeserializeOwned>(&self, path: &str, body: &[u8]) -> Result<T> {
let node_manager = self.node_manager.read().await;
let request = node_manager.post_request_bytes(path, self.get_timeout().await, body);
#[cfg(not(target_family = "wasm"))]
let request = request.rate_limit(&self.request_pool);
request.await
Expand Down Expand Up @@ -340,7 +348,7 @@ impl NodeManager {
Err(error.unwrap())
}

pub(crate) async fn post_request_json<T: DeserializeOwned>(
pub(crate) async fn post_request<T: DeserializeOwned>(
&self,
path: &str,
timeout: Duration,
Expand Down

0 comments on commit 25c0626

Please sign in to comment.