OpenZeppelin / OpenZeppelin/ui-builder
refactor(adapter-stellar): extract shared Soroban RPC server factory
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
-
Create a shared
createSorobanRpcServer(networkConfig)utility (e.g. inconfiguration/rpc.tsor a newutils/soroban-client.ts) that:- Resolves RPC URL via
userRpcConfigServicewith fallback tonetworkConfig.sorobanRpcUrl - Applies
allowHttpfor localhost URLs - Returns
StellarRpc.Server
- Resolves RPC URL via
-
Replace all 6
Servercreation sites with the shared utility -
Align
relayer.tsandaccess-control/onchain-reader.tsto useuserRpcConfigService(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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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