Skip to content

[Backend] sorobanService.decodeAddress uses 'addr.contractId() as any' cast #638

@ogazboiz

Description

@ogazboiz

Join the discussion on Telegram

Why this matters

backend/src/services/sorobanService.ts line 36:

return StrKey.encodeContract(Buffer.from(addr.contractId() as any));

And the identical pattern in backend/src/workers/soroban-event-worker.ts line 55. The as any cast hides a real type mismatch between the SDK's Hash opaque and Node's Buffer. The SDK exposes proper helpers — StrKey.encodeContract accepts the hash buffer directly in recent SDK versions, or the buffer can be obtained without any via Buffer.from(hash.value as Uint8Array) or hash.value as Uint8Array.

Acceptance criteria

  • Remove the as any in both files and use the correct typed source for the contract hash bytes
  • Build passes; runtime decoding still produces a valid C... address (the existing decode test should cover this)

Files to touch

  • backend/src/services/sorobanService.ts (line 36)
  • backend/src/workers/soroban-event-worker.ts (line 55)

Out of scope

  • Replacing the manual decoders with the SDK's higher-level scValToNative

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasksgood first issueGood for newcomersrefactorRefactoring existing code

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions