Closed marcus-pousette closed 10 months ago
Any update on this? Would be great to serialize enums like this.
I think our decision is to have a JS compatible borsh, so TS decorators won't fit our goal. But that's not to say it's not a good approach. For new comers who use TS, @marcus-pousette implemented https://github.com/dao-xyz/borsh-ts is a great library that you can consider. If you also need to use borsh in JS, then near/borsh-js is for you.
closing this PR since a different approach was maintained, and anyway the use of enums has been simplified.
Why?
Changes:
Todos (maybe):
See tests for all examples, but just a few examples:
Enum, variant at instruction "slot" 1.
Nested Schema generation for structs
Option
Explicit serialization order of fields
Please let me know (quite quickly) if you want these kinds of ergonomics in the library. If so, and you are actively working on this repository, I will put some more time this week into this PR.