Skip to content

SNIP-12 Incorrect type for enum #1343

Open
@sgc-code

Description

@sgc-code

Describe the bug
Regarding SNIP-12.
When calculating the encodetype of an object that includes an enum, type of the parameter is not enum as expected

To Reproduce
It can be reproduced with the following types:

{
  StarknetDomain: [
    { name: "name", type: "shortstring" },
    { name: "version", type: "shortstring" },
    { name: "chainId", type: "shortstring" },
    { name: "revision", type: "shortstring" },
  ],
 Object: [{ name: "e", type: "enum", contains: "MyEnum" }],
 MyEnum: [{ name: "Variant 1", type: "()" }]
}

Expected behavior

Object encodeType is calculated as
"Object"("e":"MyEnum")"MyEnum"("Variant 1"())

but it should be
"Object"("e":"enum")"MyEnum"("Variant 1"())

Note that this is similar to the merkle tree where the type is correctly encoded

Screenshots

Desktop (please complete the following information):
Node version: 18
Starknet.js version: v6.23.1 (latest)

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions