Documentation
¶
Index ¶
Constants ¶
const ( // ChainsCacheName is the filename for the cached /api/chains response. ChainsCacheName = "chains.json" // ChainsCacheTTL is the TTL for chain cache entries. ChainsCacheTTL = 1 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
func CacheChains ¶
func CacheChains(data json.RawMessage) error
CacheChains writes chain data to the local cache.
func Resolve ¶
func Resolve(chainID string, flagValue string, cfg config.Config, chains []ChainInfo) (string, error)
Resolve returns the RPC endpoint URL for a given chain ID. Resolution order:
- flagValue (from --rpc-url flag)
- KH_RPC_URL env var
- Config file rpc.<chainID>
- Platform /api/chains primaryRpcUrl (from cached chain data)
- Platform /api/chains fallbackRpcUrl
- Error if nothing found
Types ¶
type ChainInfo ¶
type ChainInfo struct {
ChainID int `json:"chainId"`
Name string `json:"name"`
Type string `json:"chainType"`
IsEnabled bool `json:"isEnabled"`
PrimaryRpcURL string `json:"defaultPrimaryRpc"`
FallbackRpcURL string `json:"defaultFallbackRpc"`
}
ChainInfo holds the RPC endpoint data for a single chain as returned by /api/chains.
func LoadChains ¶
LoadChains reads chain data from cache, returning nil if no cached data is available. The caller is responsible for fetching and caching fresh data when this returns nil.