OpenZeppelin / OpenZeppelin/ui-builder

refactor(adapter-stellar): extract shared Soroban RPC server factory

Open
#339 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
48
Forks
23
Avg merge
3h 1m
Merged PRs (30d)
10

Description

Summary

The Stellar adapter (packages/adapter-stellar/) has 7 independent RPC/network client creation sites, with 5 near-identical getSorobanRpcServer implementations copy-pasted across files. This is a DRY violation that also causes inconsistent behavior — some call sites skip userRpcConfigService and allowHttp, meaning they won't respect user RPC overrides or work on localhost.

Duplication Map

# File Uses userRpcConfigService? allowHttp?
1 transaction/sender.ts Yes Yes
2 transaction/eoa.ts Yes Yes
3 transaction/relayer.ts No Yes
4 query/handler.ts Yes Yes
5 contract/type.ts Yes Yes
6 access-control/onchain-reader.ts No No
7 contract/loader.ts No (different client type) N/A

Sites 1, 2, 4, 5 are virtually identical. Site 3 (relayer) and site 6 (access-control) skip userRpcConfigService, which means user RPC overrides are silently ignored. Site 6 also skips allowHttp, breaking localhost development.

Proposed Solution

  1. Create a shared createSorobanRpcServer(networkConfig) utility (e.g. in configuration/rpc.ts or a new utils/soroban-client.ts) that:

    • Resolves RPC URL via userRpcConfigService with fallback to networkConfig.sorobanRpcUrl
    • Applies allowHttp for localhost URLs
    • Returns StellarRpc.Server
  2. Replace all 6 Server creation sites with the shared utility

  3. Align relayer.ts and access-control/onchain-reader.ts to use userRpcConfigService (bug fix)

Context

This was identified while doing the same refactor on the EVM adapter (createEvmPublicClient utility in utils/public-client.ts on branch 011-evm-access-control). The EVM side is already consolidated.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the six Stellar RPC Server creation sites listed in transaction/sender.ts, transaction/eoa.ts, transaction/relayer.ts, query/handler.ts, contract/type.ts, and access-control/onchain-reader.ts. Read the existing EVM createEvmPublicClient utility in utils/public-client.ts and inspect the userRpcConfigService and networkConfig usage. Done means the six sites use one shared factory, including user RPC overrides and localhost allowHttp behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
blockchain
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.