near / borsh-js

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

Type is not strict when serialize `u64` or `u128` #81

Open hanakannzashi opened 9 months ago

hanakannzashi commented 9 months ago

When schema is u64 or u128, the input value type can be number, bigint, string, boolean. But when schema is u8, u16, u32, the input value type can only be number, they are not consistent, that is strange.

I think we should make input value type be strict when serialize u64 or u128, I mean ONLY allow bigint. Alternatively, we should make input type NOT be strict when serialize u8, u16, u32, I mean allow number, bigint, string and boolean

gagdiez commented 8 months ago

While I agree with the simplicity from the theoretical point of view, the reality is that I've seen people always use number for number, but the same people would use BN.js or strings for big values.

To be honest, I think we would break more things that we would fix by doing this (thought I might be wrong)