Skip to content

Commit

Permalink
fix: build requests with Jws
Browse files Browse the repository at this point in the history
  • Loading branch information
dav1do committed Jun 19, 2024
1 parent 0c52e8e commit 18d8d08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/api.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{jws::Jws, query::FilterQuery};
use ceramic_event::{
unvalidated::signed, Base64String, Base64UrlString, MultiBase32String, MultiBase36String,
StreamId, StreamIdType,
Base64String, Base64UrlString, MultiBase32String, MultiBase36String, StreamId, StreamIdType,
};
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -39,7 +38,7 @@ pub struct BlockData<T: Serialize> {
pub data: Option<T>,
/// Signature for block
#[serde(skip_serializing_if = "Option::is_none")]
pub jws: Option<signed::Envelope>,
pub jws: Option<Jws>,
/// IPFS Linked Block
#[serde(skip_serializing_if = "Option::is_none")]
pub linked_block: Option<Base64String>,
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ impl<S: Signer + Sync> CeramicHttpClient<S> {
.build();
let event = Event::from_payload(commit.into(), &self.signer)?;
let controllers: Vec<_> = vec![controller];
let jws = Jws::builder(&self.signer).build_for_cid(&event.payload_cid())?;
let data = Base64String::from(event.encode_payload()?);
let model = Base64String::from(PARENT_STREAM_ID.to_vec());
let (envelope, _payload) = event.into_parts();

Ok(api::CreateRequest {
r#type: StreamIdType::Model,
Expand All @@ -115,7 +115,7 @@ impl<S: Signer + Sync> CeramicHttpClient<S> {
model,
},
linked_block: Some(data.clone()),
jws: Some(envelope),
jws: Some(jws),
data: Some(data),
cacao_block: None,
},
Expand Down Expand Up @@ -215,7 +215,7 @@ impl<S: Signer + Sync> CeramicHttpClient<S> {
let event = Event::from_payload(commit.into(), &self.signer)?;
let controllers: Vec<_> = vec![controller];
let data = Base64String::from(event.encode_payload()?);
let (envelope, _payload) = event.into_parts();
let jws = Jws::builder(&self.signer).build_for_cid(&event.payload_cid())?;

Ok(api::CreateRequest {
r#type: StreamIdType::ModelInstanceDocument,
Expand All @@ -226,7 +226,7 @@ impl<S: Signer + Sync> CeramicHttpClient<S> {
model,
},
linked_block: Some(data.clone()),
jws: Some(envelope),
jws: Some(jws),
data: Some(data),
cacao_block: None,
},
Expand Down Expand Up @@ -257,7 +257,7 @@ impl<S: Signer + Sync> CeramicHttpClient<S> {
let controllers: Vec<_> = vec![controller];
let data = Base64String::from(event.encode_payload()?);
let stream = MultiBase36String::try_from(&get.stream_id)?;
let (envelope, _payload) = event.into_parts();
let jws = Jws::builder(&self.signer).build_for_cid(&event.payload_cid())?;
Ok(api::UpdateRequest {
r#type: StreamIdType::ModelInstanceDocument,
block: api::BlockData {
Expand All @@ -267,7 +267,7 @@ impl<S: Signer + Sync> CeramicHttpClient<S> {
model,
},
linked_block: Some(data.clone()),
jws: Some(envelope),
jws: Some(jws),
data: Some(data),
cacao_block: None,
},
Expand Down

0 comments on commit 18d8d08

Please sign in to comment.