Skip to content

ENG-2376: make solana tx building work#518

Merged
Philippoes merged 2 commits into
mainfrom
make-solana-work-again
May 20, 2026
Merged

ENG-2376: make solana tx building work#518
Philippoes merged 2 commits into
mainfrom
make-solana-work-again

Conversation

@jdomingos
Copy link
Copy Markdown
Contributor

@jdomingos jdomingos commented May 19, 2026

Added

Description of new functionality, feature, or content that has been added in this pull request.

Changed

Updated the Solana connector to make transaction decoding deterministic and safer:

getSolanaTxDecodingCandidates() now chooses one encoding path:
hex only when the input is valid hex (including 0x...)
otherwise base64 only
This prevents hex payloads from also being (incorrectly) retried as base64.
Also tightened tests for this behavior:

Added assertion that a 0x hex input produces exactly one candidate, with encoding "hex".
Kept validation coverage for base64, error messaging, and adapter pass-through.
Verified with pnpm lint and the connector test file (all passing).

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced Solana transaction processing to robustly support multiple encoding formats (base64 and hexadecimal) with significantly improved error messages that provide better diagnostic context and clarity when transaction decoding fails.
  • Tests

    • Added comprehensive test coverage validating transaction decoding across various payload formats, different encoding scenarios, and error handling edge cases.

Review Change Stack

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 19, 2026

⚠️ No Changeset found

Latest commit: e6e01bc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

📝 Walkthrough

Walkthrough

This PR introduces shared Solana transaction decoding utilities that normalize raw transaction strings and attempt multiple encoding candidates (hex and base64), replacing inline deserialization logic in the connector's sendTransaction method. A comprehensive test suite validates encoding normalization, candidate detection, error handling, and the full connector integration.

Changes

Solana Transaction Deserialization Utilities

Layer / File(s) Summary
Core decoding utilities and candidates
packages/widget/src/providers/misc/solana-connector.ts
New helpers getSolanaTxDecodingCandidates() and deserializeSolanaTransaction() build and process decoding candidates (hex and base64), attempting VersionedTransaction deserialization first and falling back to legacy Transaction, with consolidated error messaging when all candidates fail.
Connector sendTransaction integration
packages/widget/src/providers/misc/solana-connector.ts
The connector's sendTransaction method replaces prior inlined base64/hex buffer detection and deserialization with a single call to deserializeSolanaTransaction().
Test infrastructure and decoding candidate validation
packages/widget/tests/use-cases/solana-connector.test.ts
Test helper createConnectorForTest() constructs a mocked connector instance; suite validates that padded base64, unpadded base64, and hex payloads with 0x prefix decode into correct buffers with appropriate encoding labels.
Error handling and integration tests
packages/widget/tests/use-cases/solana-connector.test.ts
Tests confirm that invalid payloads produce error messages combining encoding context and deserialization failure details for both transaction formats, and that successful deserialization passes the transaction object to the wallet adapter's sendTransaction.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 A decoder hops through candidates with care,
Base64 and hex both handled fair,
When none will work, the errors unite,
In messages clear, shining bright,
Solana txns now flow just right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description partially follows the template structure but contains incomplete sections with placeholder text under 'Added'. Replace the placeholder text under 'Added' with a concrete description of the new functionality (getSolanaTxDecodingCandidates and deserializeSolanaTransaction functions and their test coverage).
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title references a ticket (ENG-2376) and broadly mentions making Solana tx building work, which aligns with the changeset's focus on Solana connector improvements, but lacks specificity about the key implementation changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch make-solana-work-again

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/widget/src/providers/misc/solana-connector.ts`:
- Around line 39-55: The current logic pushes both a hex DecodingCandidate and
an unconditional base64 candidate, causing hex inputs
(normalizedTx/withoutHexPrefix detected by isHexString) to also be reinterpreted
as base64; change the branch so that when isHexString(withoutHexPrefix) is true
you push only the hex candidate into candidates and skip adding the base64
candidate, and add a unit test asserting that an input starting with "0x" yields
exactly one candidate (encoding "hex") and no base64 fallback; update
references: normalizedTx, withoutHexPrefix, isHexString, DecodingCandidate, and
the candidates array.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7b2c23f9-f16a-4b2e-b9fb-fd254c1fc2d2

📥 Commits

Reviewing files that changed from the base of the PR and between 0b60e3e and 496d6ea.

📒 Files selected for processing (2)
  • packages/widget/src/providers/misc/solana-connector.ts
  • packages/widget/tests/use-cases/solana-connector.test.ts

Comment thread packages/widget/src/providers/misc/solana-connector.ts Outdated
@aws-amplify-eu-central-1
Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-518.d2ribjy8evqo6h.amplifyapp.com

@aws-amplify-eu-central-1
Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-518.df4xyoi0xyeak.amplifyapp.com

@Philippoes Philippoes merged commit 823a809 into main May 20, 2026
7 checks passed
@Philippoes Philippoes deleted the make-solana-work-again branch May 20, 2026 15:08
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.

3 participants