cashubtc / cashu-ts

A TypeScript library for building Cashu wallets
MIT License
55 stars 31 forks source link

Proofs Class adds friction #49

Closed Egge21M closed 1 year ago

Egge21M commented 1 year ago

Some of the methods on CashuWallet expect or return proofs as Class. While I understand that OOP leads to cleaner code, it makes working (and especially storing proofs more difficult as those instances are not serializable. So in order to store proofs I have to extract data out of the instance and if I want to work with previously stored ones, I have to create new instances from the data.

BilligsterUser commented 1 year ago

would this help?

https://github.com/cashubtc/cashu-ts/pull/50/files

Egge21M commented 1 year ago

Yeah, it would at definitely save some code. However after retrieving serialized proofs from store, I would still have to create new Proof instances for every one of them, before passing them to for example payLnInvoice.

There is only a single method on Proof, which is a utility for base64 encoding. I don't think the value gained from having this utility on the class itself, does not weigh up the friction it provides when working with the data. If it could be outsourced, Proofs as class would no longer be necessary and could exist as regular typed objects.

gandlafbtc commented 1 year ago

Interesting, i never had that issue.

That being said, it would probably make sense to put this method elsewhere. not even sure where this is needed at all, maybe we can jsut remove it, since we've moved to other token format