rpc

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
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:

  1. flagValue (from --rpc-url flag)
  2. KH_RPC_URL env var
  3. Config file rpc.<chainID>
  4. Platform /api/chains primaryRpcUrl (from cached chain data)
  5. Platform /api/chains fallbackRpcUrl
  6. 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

func LoadChains() ([]ChainInfo, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL