Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNIP-12 enum type encoding fails to include referenced types except when used alone #1287

Closed
xJonathanLEI opened this issue Jan 1, 2025 · 0 comments · Fixed by #1289
Closed
Labels
Type: bug Something isn't working

Comments

@xJonathanLEI
Copy link
Contributor

xJonathanLEI commented Jan 1, 2025

Describe the bug

When encoding an enum type that uses another user-defined type as an array, the referenced type fails to be included in the encoded signature.

Edit: After looking into the problematic code I realized this is the case not just for when using as array. It happens as long as contains is not exactly (DEPENDENCY_TYPE). So the reproducer below would still trigger the issue even if (Child*) is changed to something like (u128,Child).

To Reproduce

Run this code:

import { typedData, TypedDataRevision } from "starknet";

console.log(
  typedData.encodeType(
    {
      Parent: [{ name: "variant", type: "(Child*)" }],
      Child: [{ name: "test", type: "u128" }],
    },
    "Parent",
    TypedDataRevision.ACTIVE,
  ),
);

and it prints:

"Parent"("variant":("Child*"))

Expected behavior

The correct encoding would instead be:

"Parent"("variant":("Child*"))"Child"("test":"u128")

since Child is indeed used by Parent.

Screenshots

N/A

Desktop (please complete the following information):

  • Node version: v20.17.0
  • Starknet.js version: v6.20.3

Additional context

N/A

@xJonathanLEI xJonathanLEI added the Type: bug Something isn't working label Jan 1, 2025
@xJonathanLEI xJonathanLEI changed the title SNIP-12 enum type encoding fails to include referenced types when using as array SNIP-12 enum type encoding fails to include referenced types except when used alone Jan 1, 2025
@penovicp penovicp closed this as completed Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants