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. 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
-
Replace all 6 Server creation sites with the shared utility
-
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.
Summary
The Stellar adapter (
packages/adapter-stellar/) has 7 independent RPC/network client creation sites, with 5 near-identicalgetSorobanRpcServerimplementations copy-pasted across files. This is a DRY violation that also causes inconsistent behavior — some call sites skipuserRpcConfigServiceandallowHttp, meaning they won't respect user RPC overrides or work on localhost.Duplication Map
userRpcConfigService?allowHttp?transaction/sender.tstransaction/eoa.tstransaction/relayer.tsquery/handler.tscontract/type.tsaccess-control/onchain-reader.tscontract/loader.tsSites 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 skipsallowHttp, breaking localhost development.Proposed Solution
Create a shared
createSorobanRpcServer(networkConfig)utility (e.g. inconfiguration/rpc.tsor a newutils/soroban-client.ts) that:userRpcConfigServicewith fallback tonetworkConfig.sorobanRpcUrlallowHttpfor localhost URLsStellarRpc.ServerReplace all 6
Servercreation sites with the shared utilityAlign
relayer.tsandaccess-control/onchain-reader.tsto useuserRpcConfigService(bug fix)Context
This was identified while doing the same refactor on the EVM adapter (
createEvmPublicClientutility inutils/public-client.tson branch011-evm-access-control). The EVM side is already consolidated.