Skip to content

fix(parsers): encode full @solana/kit transaction to resolve KMS 500 errors (#397)#398

Open
Soham-ent wants to merge 1 commit into
phantom:mainfrom
Soham-ent:fix/solana-kit-serialization
Open

fix(parsers): encode full @solana/kit transaction to resolve KMS 500 errors (#397)#398
Soham-ent wants to merge 1 commit into
phantom:mainfrom
Soham-ent:fix/solana-kit-serialization

Conversation

@Soham-ent
Copy link
Copy Markdown

@Soham-ent Soham-ent commented May 28, 2026

Closes #397.

Root cause: I found that the parseSolanaTransactionToBase64Url was sending only transaction.messageBytes for @solana/kit transactions. The KMS backend expects the canonical Solana wire format: a compact-u16 signature count prefix followed by the message. Sending bare message bytes causes the backend deserializer to read the message header as a signature count, producing a malformed parse and an unhandled 500.

Fix: Replaced transaction.messageBytes with getTransactionEncoder().encode(transaction) to produce the correct wire format, matching the behaviour of the existing @solana/web3.js path. Added Jest mocks to bypass strict encoder validation in unit tests.

Summary by CodeRabbit

Release Notes

  • Tests

    • Enhanced test suite with comprehensive coverage for Solana transaction parsing, including multiple transaction formats, encoding methods, and various serialization options.
  • Refactor

    • Updated transaction encoding implementation to use standardized wire format encoding for improved consistency and compatibility.

Review Change Stack

@phantom-autopilot
Copy link
Copy Markdown

Task created — intent: multi-review, workspace provisioning started. https://autopilot-orchestrator.tools.phantom.dev/tasks/85353c5b-7880-5c1f-8940-a8992d6cb3d5

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c206c861-2d4f-45b4-98c5-e467b4b2f5b9

📥 Commits

Reviewing files that changed from the base of the PR and between 872944c and 264dd67.

📒 Files selected for processing (2)
  • packages/parsers/src/index.ts
  • packages/parsers/src/parsers.test.ts

📝 Walkthrough

Walkthrough

Updated Solana transaction parsing for @solana/kit to use canonical wire format encoding via getTransactionEncoder().encode() instead of messageBytes. Tests now mock the encoder for deterministic validation and cover additional input formats. EVM, Sui, and Bitcoin parsers remain unchanged.

Changes

Solana Canonical Wire Format Encoding

Layer / File(s) Summary
Solana canonical wire format encoding implementation
packages/parsers/src/index.ts
Modified parseSolanaTransactionToBase64Url to base64url-encode the output of getTransactionEncoder().encode(transaction) for @solana/kit inputs instead of encoding messageBytes. Other Solana input branches (web3.js serialize, Uint8Array, base64 string) remain unchanged.
Module structure and unchanged parser logic
packages/parsers/src/index.ts
Module imports, exports, and public interfaces remain the same. EVM, Sui, Bitcoin, and Solana web3.js parsers, along with the Solana kit-to-web3.js conversion utility, retain their original logic aside from non-semantic formatting.
Test validation of Solana canonical encoding and expanded coverage
packages/parsers/src/parsers.test.ts
Added module mock for @solana/transactions encoder to return deterministic byte output. Updated @solana/kit test to validate mocked encoder output. Expanded test cases for parsing raw Uint8Array and base64-string inputs. Tightened assertions on serialize call arguments for legacy and versioned web3.js transactions.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description explains the root cause, fix, and testing approach, but is missing a changeset addition confirmation and README update confirmation as specified in the template. Confirm whether a changeset was added via 'yarn changeset' and whether README files were updated if package interfaces changed.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing Solana @solana/kit transaction encoding to resolve KMS 500 errors, which directly matches the PR's primary objective.
Linked Issues check ✅ Passed The PR directly addresses issue #397 by fixing the serialization issue where only messageBytes were sent instead of the canonical Solana wire format with signature count prefix.
Out of Scope Changes check ✅ Passed Changes are limited to updating Solana transaction encoding in parsers and related tests, all directly aligned with resolving the KMS 500 error issue.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: one or more packages not found in the registry.


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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

@phantom-autopilot
Copy link
Copy Markdown

PR opened by agent

Execution log

https://github.com/phantom/phantom-connect-sdk*[newref]refs/pull/398

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

signTransaction Internal Server Error

1 participant