Skip to content

fix(types): SorokitClient submit accepts unknown, InvokeParams args too permissive, ContractEvent value typed as unknown #201

Description

@k-deejah

Problem

Three issues affect the developer experience when using the library in a TypeScript strict-mode project.

1. SorokitClient interface submit(tx: unknown) accepts any value — loses type safety

transaction.submit accepts tx: unknown which means TypeScript cannot catch incorrect payload shapes at the call site. A typed TransactionParams interface replacing unknown would catch errors at compile time.

2. InvokeParams.args typed as unknown[] — callers cannot express Soroban XDR types

args?: unknown[] is too permissive. Callers passing scVal objects from @stellar/stellar-sdk have no type-safe way to declare them. A ScVal[] or a union type would enable type checking at the Soroban call site.

3. ContractEvent.value typed as unknown — JSON.stringify result cannot be typed

event.value: unknown means JSON.stringify(event.value, null, 2) in EventRow works at runtime but has no type-level structure. A branded JsonValue type or Record<string, unknown> would at least constrain the shape and enable smarter rendering decisions.

Solution

  1. Define TransactionParams interface in client.ts and replace submit(tx: unknown) with submit(tx: TransactionParams).
  2. Change InvokeParams.args from unknown[] to SorobanScVal[] | unknown[] with JSDoc explaining the Soroban XDR types.
  3. Change ContractEvent.value from unknown to JsonValue (a recursive type representing JSON-serialisable values).

Acceptance Criteria

  • TransactionParams interface defined and used in SorokitClient
  • InvokeParams.args JSDoc explains Soroban XDR types
  • ContractEvent.value typed as JsonValue
  • tsc --noEmit passes with no new errors
  • npm run build passes

Note for Contributors: Write a clear PR description. Show the TypeScript errors that disappear after the TransactionParams change and confirm the JsonValue type covers all serialisable JSON shapes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    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