perun-network / erdstall-ts-sdk

TypeScript client SDK to interact with Erdstall.
Apache License 2.0
5 stars 2 forks source link

Remove `BigInteger` & replace by `bigint` #40

Closed sebastianst closed 2 years ago

sebastianst commented 3 years ago

We can register our custom JSON serialization of bigint directly with TypedJSON's type mapping. ABI handling can probably also be set per type.

sebastianst commented 2 years ago

What might work even better is a custom property decorator like

function jsonBigIntMember(): PropertyDecorator {
    return jsonMember({
        deserializer: (json) => (json == null ? json : BigInt(json)),
        serializer: (value) => (value == null ? value : value.toString()),
    });
}

reference: https://github.com/JohnWeisz/TypedJSON/issues/156#issuecomment-768326459