Skip to content

Commit c3f1ce2

Browse files
authored
Remove to/from json methods on typestates (payjoin#835)
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 custom peristance strategies. Resolves payjoin#834
2 parents c2ae434 + f476e02 commit c3f1ce2

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
@@ -238,18 +238,6 @@ impl Initialized {
238238
.pj_uri()
239239
.into()
240240
}
241-
242-
pub fn to_json(&self) -> Result<String, SerdeJsonError> {
243-
serde_json::to_string(&self.0).map_err(Into::into)
244-
}
245-
246-
pub fn from_json(json: &str) -> Result<Self, SerdeJsonError> {
247-
serde_json::from_str::<payjoin::receive::v2::Receiver<payjoin::receive::v2::Initialized>>(
248-
json,
249-
)
250-
.map_err(Into::into)
251-
.map(Into::into)
252-
}
253241
}
254242

255243
#[derive(Clone)]

payjoin-ffi/src/receive/uni.rs

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

298291
#[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)