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

feat(frontend): fallback of token address for mapping Solana instructions #5061

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

AntonioVentilii
Copy link
Collaborator

Motivation

It is useful to have a fallback for the token address when mapping a Token program instruction. So we use the destination mint info as fallback, in the same way we use the source one.

@AntonioVentilii AntonioVentilii requested a review from a team as a code owner March 6, 2025 21:46
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR introduces a fallback mechanism for mapping Solana Token program instructions by using the destination mint info if the source info is unavailable. Key changes include:

  • Fetching the destination account info as a fallback in token mapping functions.
  • Updating the token mapping functions in sol-instructions.utils.ts to incorporate the fallback.
  • Changing the SolMappedTransaction interface in sol-transaction.ts by making the "value" property required instead of optional.

Reviewed Changes

File Description
src/frontend/src/sol/utils/sol-instructions.utils.ts Implements fallback logic by unconditionally fetching destination account info and then using it when source info is unavailable.
src/frontend/src/sol/types/sol-transaction.ts Updates the "value" property type in the SolMappedTransaction interface to ensure it is always defined.

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

@AntonioVentilii AntonioVentilii requested a review from Copilot March 6, 2025 23:26

Choose a reason for hiding this comment

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

PR Overview

This PR introduces a fallback mechanism for mapping Solana token program instructions by using the destination mint info when the source is unavailable.

  • Updated token parsing logic in sol-instructions.utils.ts to handle both source and destination cases
  • Modified the SolMappedTransaction interface in sol-transaction.ts to ensure value is always defined

Reviewed Changes

File Description
src/frontend/src/sol/utils/sol-instructions.utils.ts Refactored token info extraction and added fallback logic using destination info
src/frontend/src/sol/types/sol-transaction.ts Updated the type of value in SolMappedTransaction from bigint

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

src/frontend/src/sol/utils/sol-instructions.utils.ts:135

  • [nitpick] The variable 'info' is used for both source and destination extraction. Consider renaming it to a more descriptive name (e.g., sourceInfo or destInfo) to improve clarity.
parsed: { info }

src/frontend/src/sol/types/sol-transaction.ts:70

  • Changing the type of 'value' from 'bigint | undefined' to 'bigint' might introduce issues if there are scenarios where 'value' can be undefined. Please ensure that 'value' is always assigned a valid bigint.
value: bigint;
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.

1 participant