multiversx / mx-sdk-js-core

MultiversX SDK for interacting with the MultiversX blockchain (in general) and Smart Contracts (in particular).
https://multiversx.github.io/mx-sdk-js-core/
Other
58 stars 37 forks source link

Rewrite "TypeExpressionParser" #344

Closed andreibancioiu closed 5 months ago

andreibancioiu commented 10 months ago

Current implementation is hard to adjust and maintain.

andreibancioiu commented 10 months ago

Bad handling of repeated types within multi types:

it("should parse multi (2)", () => {
    const type = parser.parse("multi<u8, utf-8 string, u8, utf-8 string, u8, utf-8 string>");

    assert.deepEqual(type.toJSON(), {
        "name": "multi",
        "typeParameters": [
            {
                "name": "u8",
                "typeParameters": []
            },
            {
                "name": "utf-8 string",
                "typeParameters": []
            },
            {
                "name": "u8",
                "typeParameters": []
            },
            {
                "name": "utf-8 string",
                "typeParameters": []
            }
        ]
    });
});

See:

private nodeToType(name: string, node: any): Type {
        if (name.charAt(name.length - 1) === "1") { name = name.slice(0, -1); }
        ...
andreibancioiu commented 5 months ago

Will be fixed by: https://github.com/multiversx/mx-sdk-js-core/pull/398.

andreibancioiu commented 5 months ago

Fixed in v13.