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
- Define
TransactionParams interface in client.ts and replace submit(tx: unknown) with submit(tx: TransactionParams).
- Change
InvokeParams.args from unknown[] to SorobanScVal[] | unknown[] with JSDoc explaining the Soroban XDR types.
- Change
ContractEvent.value from unknown to JsonValue (a recursive type representing JSON-serialisable values).
Acceptance Criteria
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.
Problem
Three issues affect the developer experience when using the library in a TypeScript strict-mode project.
1.
SorokitClientinterfacesubmit(tx: unknown)accepts any value — loses type safetytransaction.submitacceptstx: unknownwhich means TypeScript cannot catch incorrect payload shapes at the call site. A typedTransactionParamsinterface replacingunknownwould catch errors at compile time.2.
InvokeParams.argstyped asunknown[]— callers cannot express Soroban XDR typesargs?: unknown[]is too permissive. Callers passingscValobjects from@stellar/stellar-sdkhave no type-safe way to declare them. AScVal[]or a union type would enable type checking at the Soroban call site.3.
ContractEvent.valuetyped asunknown— JSON.stringify result cannot be typedevent.value: unknownmeansJSON.stringify(event.value, null, 2)inEventRowworks at runtime but has no type-level structure. A brandedJsonValuetype orRecord<string, unknown>would at least constrain the shape and enable smarter rendering decisions.Solution
TransactionParamsinterface inclient.tsand replacesubmit(tx: unknown)withsubmit(tx: TransactionParams).InvokeParams.argsfromunknown[]toSorobanScVal[] | unknown[]with JSDoc explaining the Soroban XDR types.ContractEvent.valuefromunknowntoJsonValue(a recursive type representing JSON-serialisable values).Acceptance Criteria
TransactionParamsinterface defined and used inSorokitClientInvokeParams.argsJSDoc explains Soroban XDR typesContractEvent.valuetyped asJsonValuetsc --noEmitpasses with no new errorsnpm run buildpasses