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

js-legacy: Fix decoding when optional authority is not provided #70

Closed

Conversation

Danver97
Copy link

@joncinque This PR fixes #68 only for Token 2022 (this repo). The original issue solana-labs#7549 actually affects Token 2022 and SPL Token contract.

@joncinque joncinque changed the title Fix #68 js-legacy: Fix decoding when optional authority is not provided Jan 13, 2025
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I don't think this is the right approach unfortunately. buffer-layout has a method for showing that a type must use a concrete instance in order to determine the layout size, which is by overriding getSpan. We've done something incorrect by not returning an error from getSpan for COptionPublicKeyLayout.

I tried to do the full fix at #71 -- will that fix your issue?

Comment on lines +43 to +45
return option === 0 ? COptionPublicKeyLayout.spanWhenNull : 1 + COptionPublicKeyLayout.spanWithValue;
}
return 1 + this.publicKeyLayout.span;
return 1 + COptionPublicKeyLayout.spanWithValue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are incorrect since spanWithValue already includes the additional byte

@joncinque
Copy link
Contributor

Closing since this was fixed with #71

@joncinque joncinque closed this Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

js-legacy: InitializeMint without FreezeAuthority breaks decodeInitializeMintInstruction
2 participants