Closed neekolas closed 10 months ago
Yes, exactly! We had no problems with the content, because we did not see any content types that we can't serialise to json and read back. (We used text, json and base64 encoded stuff.) But you are right, nothing permits the users to create a content type that is not serialisable.
this has been implemented
Is your feature request related to a problem?
When retrieving messages from the SDK it is difficult to serialize them.
There are two problems that make serialization of
DecodedMessage
objects difficult:any
type, and may not be serializable. XMTP does not put any constraints onto the output of a codec. User defined codecs may return classes, functions, or any other data type.Conversation
it originated in for convenienceDescribe the solution to the problem
We should create a
message.toBytes()
method that serializes to aUint8Array
and aDecodedMessage.fromBytes(data)
static method for deserialization.To accomplish this we need to make two changes to the SDK.
DecodedMessage
class, so that the original bytes can be stored in the serialized version anddecodeContent
can be re-run against the raw bytes as part of deserialization.ConversationReference
objectsThe good news is that 2 will be coming as part of v8 of the JS SDK as part of the migration to the Keystore. 1 is a straightforward change.
Describe the uses cases for the feature
Additional details
/cc @tg44