Skip to content

fix(svm): Decode SvmSpoke events from a Uint8Array, not a Buffer - #1509

Merged
pxrl merged 1 commit into
pxrl/svm2from
droplet/T90K0AL22-C0BHMM63D9Q-1786373009-391839
Aug 10, 2026
Merged

pxrl merged 1 commit into
pxrl/svm2from
droplet/T90K0AL22-C0BHMM63D9Q-1786373009-391839

Conversation

@droplet-rl

Copy link
Copy Markdown
Contributor

Fixes the two SvmCpiEventsClient (integration) failures on #1508.

decodeEvent passed a Buffer to the codama decoders. They populate byte-array fields by slicing their input, and Buffer.prototype.slice returns a Buffer — so depositId, inputAmount, messageHash etc. came back as Buffers rather than the Uint8Array the generated types promise. Buffer.toString() utf8-decodes instead of joining bytes, which is what the assertions tripped on:

- ^@^@^@ ... ^@	TM-oM-?M-=          // Buffer
+ 0,0,0, ... ,0,9,84,144           // Uint8Array

Decode with @solana/kit's base64 encoder (returns a plain Uint8Array) and skip the discriminator via the decoder's offset argument instead of slicing.

Verified locally against a local validator: Solana.SvmCpiEventsClient.Integration, Solana.EventData and Solana.SvmCpiEventsClient.ForgedEvent.unit all pass, and the full suite is green.

🤖 Generated with Claude Code

The codama decoders populate byte-array fields by slicing their input.
Slicing a Buffer yields a Buffer, so every fixed-size byte field
(depositId, inputAmount/outputAmount, messageHash) came back as a Buffer
rather than the Uint8Array the generated types promise, and Buffer's
toString() utf8-decodes instead of joining the bytes.

Feed the decoder the Uint8Array produced by @solana/kit's base64 encoder
and skip the discriminator via the decoder's offset argument.

Co-Authored-By: Claude <noreply@anthropic.com>
@pxrl
pxrl merged commit 95e5f6a into pxrl/svm2 Aug 10, 2026
4 checks passed
@pxrl
pxrl deleted the droplet/T90K0AL22-C0BHMM63D9Q-1786373009-391839 branch August 10, 2026 15:09
@droplet-rl

Copy link
Copy Markdown
Contributor Author

Thanks for the review — nothing to address: the approval had no body and no inline comments, and you merged it (95e5f6a) 18s later. All four CI checks were green on 4ff5f13. No code changes made.

@droplet-rl

Copy link
Copy Markdown
Contributor Author

🔎 View trace

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.

2 participants