Skip to content

Commit f476e02

Browse files
committed
Remove to/from json methods on typestates
Now that we have proper session peristance in [0.24](https://github.com/payjoin/rust-payjoin/releases/tag/payjoin-0.24.0) we should remove these one off to from json method as to descourage devs from creating their own peristance strategies. Resolves payjoin#834
1 parent d802c9d commit f476e02

File tree

5 files changed

+0
-37
lines changed

5 files changed

+0
-37
lines changed

payjoin-ffi/python/test/test_payjoin_integration_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ async def test_integration_v2_to_v2(self):
151151
sender_persister = InMemorySenderPersister(1)
152152
session = self.create_receiver_context(receiver_address, directory, ohttp_keys, recv_persister)
153153
process_response = await self.process_receiver_proposal(ReceiveSession.INITIALIZED(session), recv_persister, ohttp_relay)
154-
print(f"session: {session.to_json()}")
155154
self.assertIsNone(process_response)
156155

157156
# **********************

payjoin-ffi/src/receive/mod.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -232,18 +232,6 @@ impl Initialized {
232232
.pj_uri()
233233
.into()
234234
}
235-
236-
pub fn to_json(&self) -> Result<String, SerdeJsonError> {
237-
serde_json::to_string(&self.0).map_err(Into::into)
238-
}
239-
240-
pub fn from_json(json: &str) -> Result<Self, SerdeJsonError> {
241-
serde_json::from_str::<payjoin::receive::v2::Receiver<payjoin::receive::v2::Initialized>>(
242-
json,
243-
)
244-
.map_err(Into::into)
245-
.map(Into::into)
246-
}
247235
}
248236

249237
#[derive(Clone)]

payjoin-ffi/src/receive/uni.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,6 @@ impl Initialized {
285285
pub fn process_res(&self, body: &[u8], context: Arc<ClientResponse>) -> InitializedTransition {
286286
InitializedTransition(self.0.process_res(body, &context))
287287
}
288-
289-
pub fn to_json(&self) -> Result<String, SerdeJsonError> { self.0.to_json() }
290-
291-
#[uniffi::constructor]
292-
pub fn from_json(json: &str) -> Result<Self, SerdeJsonError> {
293-
super::Initialized::from_json(json).map(Into::into)
294-
}
295288
}
296289

297290
#[derive(uniffi::Record)]

payjoin-ffi/src/send/mod.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,6 @@ impl WithReplyKey {
236236
self.clone().0.process_response(response, post_ctx.into()),
237237
))))
238238
}
239-
240-
pub fn to_json(&self) -> Result<String, SerdeJsonError> {
241-
serde_json::to_string(&self.0).map_err(Into::into)
242-
}
243-
244-
pub fn from_json(json: &str) -> Result<Self, SerdeJsonError> {
245-
serde_json::from_str::<payjoin::send::v2::Sender<payjoin::send::v2::WithReplyKey>>(json)
246-
.map_err(Into::into)
247-
.map(Into::into)
248-
}
249239
}
250240

251241
/// Data required for validation of response.

payjoin-ffi/src/send/uni.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,6 @@ impl WithReplyKey {
254254
let post_ctx = guard.take().expect("Value should not be taken");
255255
WithReplyKeyTransition(self.0.process_response(response, post_ctx.into()))
256256
}
257-
258-
pub fn to_json(&self) -> Result<String, SerdeJsonError> { self.0.to_json() }
259-
260-
#[uniffi::constructor]
261-
pub fn from_json(json: &str) -> Result<Self, SerdeJsonError> {
262-
super::WithReplyKey::from_json(json).map(Into::into)
263-
}
264257
}
265258

266259
#[derive(uniffi::Record)]

0 commit comments

Comments
 (0)