-
Notifications
You must be signed in to change notification settings - Fork 12
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.