mesg-foundation / js-sdk

Javascript mono-repo with all the tools to interact with MESG
https://mesg.com
4 stars 4 forks source link

Improve encoder by checking toJSON exist #25

Closed NicolasMahe closed 4 years ago

NicolasMahe commented 5 years ago

Let's not start to specify how to encode every special type. The lib should check if the function toJSON is implemented and call it if it is. Otherwise, maybe simple call JSON.stringify?

Function to improve: https://github.com/mesg-foundation/mesg-js/blob/d0844fde085d3b797f076a56152a867c7dc3ac4f/src/util/encoder.ts#L3-L30

Originally posted by @NicolasMahe in https://github.com/mesg-foundation/mesg-js/pull/116/files#r309583299

NicolasMahe commented 5 years ago

Let's also take a look at the decode functions to see if we can do a similar reversed system.

antho1404 commented 4 years ago

Issue migrated to liteflow-labs/liteflow-js#66