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

SDK Crash On Voyage When Invoking PublicKeyOf for Username "aa" #100

Open
sarvalabs-prakhar opened this issue Nov 25, 2024 · 3 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@sarvalabs-prakhar
Copy link
Member

Description

When invoking the PublicKeyOf method for a specific username, the SDK crashes with the error:
data.startsWith is not a function.

This occurs while running a logic invoke for the logic ID:
0x0800002d6a50f8211797e168014c6be6949235418aaab01eac26074dcbdc86a50355d9

image

Steps to Reproduce

  1. Use the SDK to run a logic invoke with the following logic ID: 0x0800002d6a50f8211797e168014c6be6949235418aaab01eac26074dcbdc86a50355d9
  2. Attempt to invoke PublicKeyOf for the username "aa"
  3. Observe that the SDK crashes and throws the error: data.startsWith is not a function
@sarvalabs-harshrastogi
Copy link
Member

sarvalabs-harshrastogi commented Nov 26, 2024

@sarvalabs-prakhar The serialization issue occurs because the current implementation inadvertently trims the hexadecimal prefix when serializing a string argument, and the encodeArguments method was not correctly spreading the arguments. As a result, the system attempted to encode an array as a string, causing unexpected encoding behavior.

@sarvalabs-harshrastogi
Copy link
Member

sarvalabs-harshrastogi commented Nov 26, 2024

The type validation utility isHex() has a flaw with type safety. The current implementation of the regex test inadvertently coerces non-string inputs to strings during type checking, which leads to incorrect validation results.
Specifically, when an array like ["aa"] is passed to isHex(), JavaScript's type coercion mechanism converts the array to the string "aa" before regex evaluation. This means the method returns true for array inputs that should be considered invalid hex values.

console.log(['aa'].toString()); // Outputs: "aa"
isHex(["aa"]); // Incorrectly returns true

@sarvalabs-harshrastogi sarvalabs-harshrastogi added the bug Something isn't working label Nov 26, 2024
@sarvalabs-harshrastogi
Copy link
Member

@sarvalabs-prakhar Prefer to docs for usage encodeArguments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants