near / borsh-js

TypeScript/JavaScript implementation of Binary Object Representation Serializer for Hashing
Apache License 2.0
112 stars 38 forks source link

How to deserialize enum? #73

Closed kayac-chang closed 10 months ago

kayac-chang commented 11 months ago

In the readme, the documentation mentions about enum.

{ enum: [{ className1: { struct: {...} } }, { className2: { struct: {...} } }, ... ] } - an enum. The variants of the enum are described by the className1, className2, etc. fields. The variants are structs.

But the current implementation seems not correct. https://github.com/near/borsh-js/blob/93a633dfa76d8577b3cb6f5c1a906dfa3b9b63a2/borsh-ts/deserialize.ts#L82

ailisp commented 10 months ago

Hi @kayac-chang ! Thanks for reporting, the readme is outdated, we've just updated readme.