Skip to content

feat: typed Soroban contract integration layer - #45

Open
TomikeDS wants to merge 1 commit into
Proof-Stell:mainfrom
TomikeDS:fix/typed-soroban-client
Open

feat: typed Soroban contract integration layer#45
TomikeDS wants to merge 1 commit into
Proof-Stell:mainfrom
TomikeDS:fix/typed-soroban-client

Conversation

@TomikeDS

Copy link
Copy Markdown

Description

Adds a typed Soroban contract integration layer to src/lib/stellar.ts with Zod runtime validation, exponential backoff retry, request timeout, and structured error classes.

Closes #13

Key Changes

  • Typed contract methods: verifyDocument, getDocumentStatus, registerDocument, revokeDocument — each with Zod schema validation of RPC responses
  • Retry with exponential backoff: 3 retries on transient (5xx) errors, no retry on 4xx or validation failures
  • Request timeout: Configurable per-call timeout (default 30s) with AbortController cancellation
  • Error classes: SorobanRpcError and SorobanTimeoutError with structured codes/statuses
  • Zod schemas: verificationResultSchema, documentStatusSchema, registerResultSchema, revokeResultSchema for runtime response validation

Testing

  • 23 unit tests covering error classes, Zod schemas, RPC call behavior, retry logic, schema validation, typed contract methods, and service properties
  • npm run test — all new tests pass (2 pre-existing failures in api-validation.test.ts unrelated to this change)
  • npm run build — only pre-existing import.meta.vitest type error in errorHandler.ts

Type of Change

  • New feature (non-breaking change which adds functionality)

…nd runtime validation

Adds typed contract methods (verifyDocument, getDocumentStatus,
registerDocument, revokeDocument) with Zod schema validation,
exponential backoff retry, request timeout, and structured error
classes. Closes Proof-Stell#13.
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.

Build a typed Soroban contract integration layer

1 participant