Procházet zdrojové kódy

sdk: Auto-generate ChainID methods (#4402)

* sdk: Auto-generate ChainID methods

* document the process to add a new chainid

* rebase to ensure codex is included in auto-generated list

* ci: add chainid to spellcheck

* fix formatting

* mention proto and watcher changes

* add cspell

* autogenerate plume
John Saigle před 4 měsíci
rodič
revize
befd9a6b29
6 změnil soubory, kde provedl 618 přidání a 374 odebrání
  1. 3 0
      cspell-custom-words.txt
  2. 5 0
      sdk/Makefile
  3. 24 0
      sdk/README.md
  4. 202 0
      sdk/chainid_generator.go
  5. 384 0
      sdk/vaa/chainid_generated.go
  6. 0 374
      sdk/vaa/structs.go

+ 3 - 0
cspell-custom-words.txt

@@ -30,6 +30,8 @@ celestia
 Celestia
 celo
 certusone
+chainid
+ChainID
 Chainlink
 Coinspect
 collateralization
@@ -144,6 +146,7 @@ protobuf
 protos
 prototxt
 pubkey
+publicrpc
 pushbytes
 pushint
 pytest

+ 5 - 0
sdk/Makefile

@@ -0,0 +1,5 @@
+.PHONY: go-generate
+go-generate:
+	go run chainid_generator.go
+go-test:
+	go test ./vaa/...

+ 24 - 0
sdk/README.md

@@ -3,6 +3,30 @@
 This directory contains libraries in various languages for developing software that interacts with
 wormhole.
 
+## Adding a New ChainID
+
+To add a new ChainID to Wormhole:
+
+1. **Add the constant** in `vaa/structs.go`:
+   ```go
+   // ChainIDNewChain is the ChainID of NewChain
+   ChainIDNewChain ChainID = 99
+   ```
+   Keep constants in numerical order and follow the naming convention.
+
+2. **Regenerate methods** by running:
+   ```bash
+   make go-generate
+   ```
+   This runs `chainid_generator.go` which auto-generates `String()`, `ChainIDFromString()`, and `GetAllNetworkIDs()` methods.
+
+3. **Update other components** as needed:
+   - Add to governor chain lists (`node/pkg/governor/mainnet_chains.go`)
+   - Add manual tokens if required (`node/pkg/governor/manual_tokens.go`)
+   - Update any chain-specific configuration files
+   - Add the ChainID in `proto/publicrpc/v1/publicrpc.proto`.
+   - If watcher support is necessary, update the guardian code.
+
 # Directory Structure
 
  * [sdk/](./): Go SDK.  This package must live in this directory so that clients can use the

+ 202 - 0
sdk/chainid_generator.go

@@ -0,0 +1,202 @@
+//go:build ignore
+
+// ChainID Auto-Generation Tool
+//
+// This file generates the ChainID methods for the VAA struct in the SDK.
+// It automatically creates String(), ChainIDFromString(), and GetAllNetworkIDs()
+// methods by parsing ChainID constants from vaa/structs.go.
+//
+// ADDING A NEW CHAINID:
+//  1. Add the new ChainID constant to vaa/structs.go following the pattern:
+//     // ChainIDNewChain is the ChainID of NewChain
+//     ChainIDNewChain ChainID = 99
+//
+// 2. Run `make go-generate` to regenerate the methods in vaa/chainid_generated.go
+//
+// 3. The generator will automatically:
+//   - Extract the chain name from the constant (removes "ChainID" prefix)
+//   - Convert to lowercase for string representation
+//   - Handle special cases like testnet names (e.g., "PolygonSepolia" -> "polygon_sepolia")
+//   - Add the new chain to all generated methods
+//
+// The generated file should never be edited manually - always regenerate it.
+package main
+
+import (
+	"fmt"
+	"go/ast"
+	"go/parser"
+	"go/token"
+	"log"
+	"os"
+	"sort"
+	"strconv"
+	"strings"
+	"text/template"
+)
+
+type ChainInfo struct {
+	Name   string
+	Value  int
+	GoName string
+}
+
+func main() {
+	// Parse the source file to extract ChainID constants from vaa/structs.go
+	// This reads the Go source code and builds an Abstract Syntax Tree (AST)
+	// to programmatically find all ChainID constant declarations
+	fset := token.NewFileSet()
+	node, err := parser.ParseFile(fset, "vaa/structs.go", nil, parser.ParseComments)
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	// Stores each ChainID declared as a constant in vaa/structs.go
+	// Each ChainInfo contains the chain name, numeric value, and Go constant name
+	var chains []ChainInfo
+
+	// Walk the AST to find ChainID constants
+	// This traverses the parsed Go code looking for constant declarations
+	// that have the type "ChainID"
+	ast.Inspect(node, func(n ast.Node) bool {
+		switch x := n.(type) {
+		case *ast.GenDecl:
+			if x.Tok == token.CONST {
+				for _, spec := range x.Specs {
+					if vspec, ok := spec.(*ast.ValueSpec); ok {
+						// Check if this is a ChainID constant by examining the type
+						if vspec.Type != nil {
+							if ident, ok := vspec.Type.(*ast.Ident); ok && ident.Name == "ChainID" {
+								for i, name := range vspec.Names {
+									if name.Name == "ChainIDUnset" {
+										// Skip the unset value (ChainIDUnset = 0)
+										// This is a special case that shouldn't be included in generated methods
+										continue
+									}
+
+									// Extract the numeric value from the constant declaration
+									var value int
+									if len(vspec.Values) > i {
+										if basic, ok := vspec.Values[i].(*ast.BasicLit); ok {
+											if v, err := strconv.Atoi(basic.Value); err == nil {
+												value = v
+											}
+										}
+									}
+
+									// Extract the chain name from the constant name
+									// e.g., "ChainIDEthereum" -> "Ethereum"
+									chainName := strings.TrimPrefix(name.Name, "ChainID")
+
+									// Convert to lowercase for string representation
+									// e.g., "Ethereum" -> "ethereum"
+									chainNameLower := strings.ToLower(chainName)
+
+									// Handle special naming for testnet chains
+									// Separate alt-EVM testnet names with underscores.
+									// e.g. `PolygonSepolia` --> `polygon_sepolia`.
+									// (Don't match on "sepolia" itself though.)
+									if strings.HasSuffix(chainNameLower, "sepolia") && len(chainNameLower) > len("sepolia") {
+										chainNameLower = fmt.Sprintf("%s_sepolia", strings.TrimSuffix(chainNameLower, "sepolia"))
+									}
+
+									// Store the chain information for code generation
+									chains = append(chains, ChainInfo{
+										Name:   chainNameLower, // String representation (e.g., "ethereum")
+										Value:  value,          // Numeric ID (e.g., 2)
+										GoName: name.Name,      // Go constant name (e.g., "ChainIDEthereum")
+									})
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+		return true
+	})
+
+	// Sort by numeric value for consistent output
+	// This ensures the generated code has chains in the same order as the constants
+	sort.Slice(chains, func(i, j int) bool {
+		return chains[i].Value < chains[j].Value
+	})
+
+	// Generate the code template for the output file
+	// This template creates three methods:
+	// 1. String() - converts ChainID to string representation
+	// 2. ChainIDFromString() - converts string to ChainID
+	// 3. GetAllNetworkIDs() - returns slice of all known ChainIDs
+	// NOTE: This should follow gofumpt formatting in order to pass CI checks.
+	tmpl := `// Code generated by go generate; DO NOT EDIT.
+
+package vaa
+
+import (
+	"fmt"
+	"strings"
+)
+
+// String returns the string representation of the ChainID
+func (c ChainID) String() string {
+	switch c {
+	case ChainIDUnset:
+		return "unset"
+{{- range .Chains }}
+	case {{ .GoName }}:
+		return "{{ .Name }}"
+{{- end }}
+	default:
+		return fmt.Sprintf("unknown chain ID: %d", c)
+	}
+}
+
+// ChainIDFromString converts from a chain's full name to its corresponding ChainID.
+func ChainIDFromString(s string) (ChainID, error) {
+	s = strings.ToLower(s)
+
+	switch s {
+{{- range .Chains }}
+	case "{{ .Name }}":
+		return {{ .GoName }}, nil
+{{- end }}
+	default:
+		return ChainIDUnset, fmt.Errorf("unknown chain ID: %s", s)
+	}
+}
+
+// GetAllNetworkIDs returns all known ChainIDs
+func GetAllNetworkIDs() []ChainID {
+	return []ChainID{
+{{- range .Chains }}
+		{{ .GoName }},
+{{- end }}
+	}
+}
+`
+
+	// Write the generated code to the output file
+	outfile := "vaa/chainid_generated.go"
+	t, err := template.New("chainid").Parse(tmpl)
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	output, err := os.Create(outfile)
+	if err != nil {
+		log.Fatal(err)
+	}
+	defer output.Close()
+
+	// Execute the template with the extracted chain information
+	err = t.Execute(output, struct {
+		Chains []ChainInfo
+	}{
+		Chains: chains,
+	})
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	fmt.Printf("Generated %s with %d chains\n", outfile, len(chains))
+}

+ 384 - 0
sdk/vaa/chainid_generated.go

@@ -0,0 +1,384 @@
+// Code generated by go generate; DO NOT EDIT.
+
+package vaa
+
+import (
+	"fmt"
+	"strings"
+)
+
+// String returns the string representation of the ChainID
+func (c ChainID) String() string {
+	switch c {
+	case ChainIDUnset:
+		return "unset"
+	case ChainIDSolana:
+		return "solana"
+	case ChainIDEthereum:
+		return "ethereum"
+	case ChainIDTerra:
+		return "terra"
+	case ChainIDBSC:
+		return "bsc"
+	case ChainIDPolygon:
+		return "polygon"
+	case ChainIDAvalanche:
+		return "avalanche"
+	case ChainIDOasis:
+		return "oasis"
+	case ChainIDAlgorand:
+		return "algorand"
+	case ChainIDAurora:
+		return "aurora"
+	case ChainIDFantom:
+		return "fantom"
+	case ChainIDKarura:
+		return "karura"
+	case ChainIDAcala:
+		return "acala"
+	case ChainIDKlaytn:
+		return "klaytn"
+	case ChainIDCelo:
+		return "celo"
+	case ChainIDNear:
+		return "near"
+	case ChainIDMoonbeam:
+		return "moonbeam"
+	case ChainIDTerra2:
+		return "terra2"
+	case ChainIDInjective:
+		return "injective"
+	case ChainIDOsmosis:
+		return "osmosis"
+	case ChainIDSui:
+		return "sui"
+	case ChainIDAptos:
+		return "aptos"
+	case ChainIDArbitrum:
+		return "arbitrum"
+	case ChainIDOptimism:
+		return "optimism"
+	case ChainIDGnosis:
+		return "gnosis"
+	case ChainIDPythNet:
+		return "pythnet"
+	case ChainIDXpla:
+		return "xpla"
+	case ChainIDBtc:
+		return "btc"
+	case ChainIDBase:
+		return "base"
+	case ChainIDFileCoin:
+		return "filecoin"
+	case ChainIDSei:
+		return "sei"
+	case ChainIDRootstock:
+		return "rootstock"
+	case ChainIDScroll:
+		return "scroll"
+	case ChainIDMantle:
+		return "mantle"
+	case ChainIDBlast:
+		return "blast"
+	case ChainIDXLayer:
+		return "xlayer"
+	case ChainIDLinea:
+		return "linea"
+	case ChainIDBerachain:
+		return "berachain"
+	case ChainIDSeiEVM:
+		return "seievm"
+	case ChainIDEclipse:
+		return "eclipse"
+	case ChainIDBOB:
+		return "bob"
+	case ChainIDSnaxchain:
+		return "snaxchain"
+	case ChainIDUnichain:
+		return "unichain"
+	case ChainIDWorldchain:
+		return "worldchain"
+	case ChainIDInk:
+		return "ink"
+	case ChainIDHyperEVM:
+		return "hyperevm"
+	case ChainIDMonad:
+		return "monad"
+	case ChainIDMovement:
+		return "movement"
+	case ChainIDMezo:
+		return "mezo"
+	case ChainIDFogo:
+		return "fogo"
+	case ChainIDSonic:
+		return "sonic"
+	case ChainIDConverge:
+		return "converge"
+	case ChainIDCodex:
+		return "codex"
+	case ChainIDPlume:
+		return "plume"
+	case ChainIDWormchain:
+		return "wormchain"
+	case ChainIDCosmoshub:
+		return "cosmoshub"
+	case ChainIDEvmos:
+		return "evmos"
+	case ChainIDKujira:
+		return "kujira"
+	case ChainIDNeutron:
+		return "neutron"
+	case ChainIDCelestia:
+		return "celestia"
+	case ChainIDStargaze:
+		return "stargaze"
+	case ChainIDSeda:
+		return "seda"
+	case ChainIDDymension:
+		return "dymension"
+	case ChainIDProvenance:
+		return "provenance"
+	case ChainIDNoble:
+		return "noble"
+	case ChainIDSepolia:
+		return "sepolia"
+	case ChainIDArbitrumSepolia:
+		return "arbitrum_sepolia"
+	case ChainIDBaseSepolia:
+		return "base_sepolia"
+	case ChainIDOptimismSepolia:
+		return "optimism_sepolia"
+	case ChainIDHolesky:
+		return "holesky"
+	case ChainIDPolygonSepolia:
+		return "polygon_sepolia"
+	default:
+		return fmt.Sprintf("unknown chain ID: %d", c)
+	}
+}
+
+// ChainIDFromString converts from a chain's full name to its corresponding ChainID.
+func ChainIDFromString(s string) (ChainID, error) {
+	s = strings.ToLower(s)
+
+	switch s {
+	case "solana":
+		return ChainIDSolana, nil
+	case "ethereum":
+		return ChainIDEthereum, nil
+	case "terra":
+		return ChainIDTerra, nil
+	case "bsc":
+		return ChainIDBSC, nil
+	case "polygon":
+		return ChainIDPolygon, nil
+	case "avalanche":
+		return ChainIDAvalanche, nil
+	case "oasis":
+		return ChainIDOasis, nil
+	case "algorand":
+		return ChainIDAlgorand, nil
+	case "aurora":
+		return ChainIDAurora, nil
+	case "fantom":
+		return ChainIDFantom, nil
+	case "karura":
+		return ChainIDKarura, nil
+	case "acala":
+		return ChainIDAcala, nil
+	case "klaytn":
+		return ChainIDKlaytn, nil
+	case "celo":
+		return ChainIDCelo, nil
+	case "near":
+		return ChainIDNear, nil
+	case "moonbeam":
+		return ChainIDMoonbeam, nil
+	case "terra2":
+		return ChainIDTerra2, nil
+	case "injective":
+		return ChainIDInjective, nil
+	case "osmosis":
+		return ChainIDOsmosis, nil
+	case "sui":
+		return ChainIDSui, nil
+	case "aptos":
+		return ChainIDAptos, nil
+	case "arbitrum":
+		return ChainIDArbitrum, nil
+	case "optimism":
+		return ChainIDOptimism, nil
+	case "gnosis":
+		return ChainIDGnosis, nil
+	case "pythnet":
+		return ChainIDPythNet, nil
+	case "xpla":
+		return ChainIDXpla, nil
+	case "btc":
+		return ChainIDBtc, nil
+	case "base":
+		return ChainIDBase, nil
+	case "filecoin":
+		return ChainIDFileCoin, nil
+	case "sei":
+		return ChainIDSei, nil
+	case "rootstock":
+		return ChainIDRootstock, nil
+	case "scroll":
+		return ChainIDScroll, nil
+	case "mantle":
+		return ChainIDMantle, nil
+	case "blast":
+		return ChainIDBlast, nil
+	case "xlayer":
+		return ChainIDXLayer, nil
+	case "linea":
+		return ChainIDLinea, nil
+	case "berachain":
+		return ChainIDBerachain, nil
+	case "seievm":
+		return ChainIDSeiEVM, nil
+	case "eclipse":
+		return ChainIDEclipse, nil
+	case "bob":
+		return ChainIDBOB, nil
+	case "snaxchain":
+		return ChainIDSnaxchain, nil
+	case "unichain":
+		return ChainIDUnichain, nil
+	case "worldchain":
+		return ChainIDWorldchain, nil
+	case "ink":
+		return ChainIDInk, nil
+	case "hyperevm":
+		return ChainIDHyperEVM, nil
+	case "monad":
+		return ChainIDMonad, nil
+	case "movement":
+		return ChainIDMovement, nil
+	case "mezo":
+		return ChainIDMezo, nil
+	case "fogo":
+		return ChainIDFogo, nil
+	case "sonic":
+		return ChainIDSonic, nil
+	case "converge":
+		return ChainIDConverge, nil
+	case "codex":
+		return ChainIDCodex, nil
+	case "plume":
+		return ChainIDPlume, nil
+	case "wormchain":
+		return ChainIDWormchain, nil
+	case "cosmoshub":
+		return ChainIDCosmoshub, nil
+	case "evmos":
+		return ChainIDEvmos, nil
+	case "kujira":
+		return ChainIDKujira, nil
+	case "neutron":
+		return ChainIDNeutron, nil
+	case "celestia":
+		return ChainIDCelestia, nil
+	case "stargaze":
+		return ChainIDStargaze, nil
+	case "seda":
+		return ChainIDSeda, nil
+	case "dymension":
+		return ChainIDDymension, nil
+	case "provenance":
+		return ChainIDProvenance, nil
+	case "noble":
+		return ChainIDNoble, nil
+	case "sepolia":
+		return ChainIDSepolia, nil
+	case "arbitrum_sepolia":
+		return ChainIDArbitrumSepolia, nil
+	case "base_sepolia":
+		return ChainIDBaseSepolia, nil
+	case "optimism_sepolia":
+		return ChainIDOptimismSepolia, nil
+	case "holesky":
+		return ChainIDHolesky, nil
+	case "polygon_sepolia":
+		return ChainIDPolygonSepolia, nil
+	default:
+		return ChainIDUnset, fmt.Errorf("unknown chain ID: %s", s)
+	}
+}
+
+// GetAllNetworkIDs returns all known ChainIDs
+func GetAllNetworkIDs() []ChainID {
+	return []ChainID{
+		ChainIDSolana,
+		ChainIDEthereum,
+		ChainIDTerra,
+		ChainIDBSC,
+		ChainIDPolygon,
+		ChainIDAvalanche,
+		ChainIDOasis,
+		ChainIDAlgorand,
+		ChainIDAurora,
+		ChainIDFantom,
+		ChainIDKarura,
+		ChainIDAcala,
+		ChainIDKlaytn,
+		ChainIDCelo,
+		ChainIDNear,
+		ChainIDMoonbeam,
+		ChainIDTerra2,
+		ChainIDInjective,
+		ChainIDOsmosis,
+		ChainIDSui,
+		ChainIDAptos,
+		ChainIDArbitrum,
+		ChainIDOptimism,
+		ChainIDGnosis,
+		ChainIDPythNet,
+		ChainIDXpla,
+		ChainIDBtc,
+		ChainIDBase,
+		ChainIDFileCoin,
+		ChainIDSei,
+		ChainIDRootstock,
+		ChainIDScroll,
+		ChainIDMantle,
+		ChainIDBlast,
+		ChainIDXLayer,
+		ChainIDLinea,
+		ChainIDBerachain,
+		ChainIDSeiEVM,
+		ChainIDEclipse,
+		ChainIDBOB,
+		ChainIDSnaxchain,
+		ChainIDUnichain,
+		ChainIDWorldchain,
+		ChainIDInk,
+		ChainIDHyperEVM,
+		ChainIDMonad,
+		ChainIDMovement,
+		ChainIDMezo,
+		ChainIDFogo,
+		ChainIDSonic,
+		ChainIDConverge,
+		ChainIDCodex,
+		ChainIDPlume,
+		ChainIDWormchain,
+		ChainIDCosmoshub,
+		ChainIDEvmos,
+		ChainIDKujira,
+		ChainIDNeutron,
+		ChainIDCelestia,
+		ChainIDStargaze,
+		ChainIDSeda,
+		ChainIDDymension,
+		ChainIDProvenance,
+		ChainIDNoble,
+		ChainIDSepolia,
+		ChainIDArbitrumSepolia,
+		ChainIDBaseSepolia,
+		ChainIDOptimismSepolia,
+		ChainIDHolesky,
+		ChainIDPolygonSepolia,
+	}
+}

+ 0 - 374
sdk/vaa/structs.go

@@ -139,155 +139,6 @@ func (a SignatureData) String() string {
 	return hex.EncodeToString(a[:])
 }
 
-func (c ChainID) String() string {
-	switch c {
-	case ChainIDUnset:
-		return "unset"
-	case ChainIDSolana:
-		return "solana"
-	case ChainIDEthereum:
-		return "ethereum"
-	case ChainIDTerra:
-		return "terra"
-	case ChainIDBSC:
-		return "bsc"
-	case ChainIDPolygon:
-		return "polygon"
-	case ChainIDAvalanche:
-		return "avalanche"
-	case ChainIDOasis:
-		return "oasis"
-	case ChainIDAlgorand:
-		return "algorand"
-	case ChainIDAurora:
-		return "aurora"
-	case ChainIDFantom:
-		return "fantom"
-	case ChainIDKarura:
-		return "karura"
-	case ChainIDAcala:
-		return "acala"
-	case ChainIDKlaytn:
-		return "klaytn"
-	case ChainIDCelo:
-		return "celo"
-	case ChainIDNear:
-		return "near"
-	case ChainIDMoonbeam:
-		return "moonbeam"
-	case ChainIDTerra2:
-		return "terra2"
-	case ChainIDInjective:
-		return "injective"
-	case ChainIDOsmosis:
-		return "osmosis"
-	case ChainIDSui:
-		return "sui"
-	case ChainIDAptos:
-		return "aptos"
-	case ChainIDArbitrum:
-		return "arbitrum"
-	case ChainIDOptimism:
-		return "optimism"
-	case ChainIDGnosis:
-		return "gnosis"
-	case ChainIDPythNet:
-		return "pythnet"
-	case ChainIDXpla:
-		return "xpla"
-	case ChainIDBtc:
-		return "btc"
-	case ChainIDBase:
-		return "base"
-	case ChainIDFileCoin:
-		return "filecoin"
-	case ChainIDSei:
-		return "sei"
-	case ChainIDRootstock:
-		return "rootstock"
-	case ChainIDScroll:
-		return "scroll"
-	case ChainIDMantle:
-		return "mantle"
-	case ChainIDBlast:
-		return "blast"
-	case ChainIDXLayer:
-		return "xlayer"
-	case ChainIDLinea:
-		return "linea"
-	case ChainIDBerachain:
-		return "berachain"
-	case ChainIDSeiEVM:
-		return "seievm"
-	case ChainIDEclipse:
-		return "eclipse"
-	case ChainIDBOB:
-		return "bob"
-	case ChainIDSnaxchain:
-		return "snaxchain"
-	case ChainIDUnichain:
-		return "unichain"
-	case ChainIDWorldchain:
-		return "worldchain"
-	case ChainIDInk:
-		return "ink"
-	case ChainIDHyperEVM:
-		return "hyperevm"
-	case ChainIDMonad:
-		return "monad"
-	case ChainIDMovement:
-		return "movement"
-	case ChainIDMezo:
-		return "mezo"
-	case ChainIDFogo:
-		return "fogo"
-	case ChainIDSonic:
-		return "sonic"
-	case ChainIDConverge:
-		return "converge"
-	case ChainIDCodex:
-		return "codex"
-	case ChainIDPlume:
-		return "plume"
-	case ChainIDWormchain:
-		return "wormchain"
-	case ChainIDCosmoshub:
-		return "cosmoshub"
-	case ChainIDEvmos:
-		return "evmos"
-	case ChainIDKujira:
-		return "kujira"
-	case ChainIDNeutron:
-		return "neutron"
-	case ChainIDCelestia:
-		return "celestia"
-	case ChainIDStargaze:
-		return "stargaze"
-	case ChainIDSeda:
-		return "seda"
-	case ChainIDDymension:
-		return "dymension"
-	case ChainIDProvenance:
-		return "provenance"
-	case ChainIDNoble:
-		return "noble"
-	case ChainIDSepolia:
-		return "sepolia"
-	case ChainIDArbitrumSepolia:
-		return "arbitrum_sepolia"
-	case ChainIDBaseSepolia:
-		return "base_sepolia"
-	case ChainIDOptimismSepolia:
-		return "optimism_sepolia"
-	case ChainIDHolesky:
-		return "holesky"
-	case ChainIDPolygonSepolia:
-		return "polygon_sepolia"
-	default:
-		return fmt.Sprintf("unknown chain ID: %d", c)
-	}
-}
-
 // ChainIDFromNumber converts an unsigned integer into a ChainID. This function only determines whether the input is valid
 // with respect to its type; it does not check whether the ChainID is actually registered or used anywhere.
 // This function can be used to validate ChainID values that are deserialized from protobuf messages. (As protobuf
@@ -350,231 +201,6 @@ func StringToKnownChainID(s string) (ChainID, error) {
 	return KnownChainIDFromNumber(u16)
 }
 
-// ChainIDFromString converts from a chain's full name (e.g. "solana") to its corresponding ChainID.
-func ChainIDFromString(s string) (ChainID, error) {
-	s = strings.ToLower(s)
-
-	switch s {
-	case "solana":
-		return ChainIDSolana, nil
-	case "ethereum":
-		return ChainIDEthereum, nil
-	case "terra":
-		return ChainIDTerra, nil
-	case "bsc":
-		return ChainIDBSC, nil
-	case "polygon":
-		return ChainIDPolygon, nil
-	case "avalanche":
-		return ChainIDAvalanche, nil
-	case "oasis":
-		return ChainIDOasis, nil
-	case "algorand":
-		return ChainIDAlgorand, nil
-	case "aurora":
-		return ChainIDAurora, nil
-	case "fantom":
-		return ChainIDFantom, nil
-	case "karura":
-		return ChainIDKarura, nil
-	case "acala":
-		return ChainIDAcala, nil
-	case "klaytn":
-		return ChainIDKlaytn, nil
-	case "celo":
-		return ChainIDCelo, nil
-	case "near":
-		return ChainIDNear, nil
-	case "moonbeam":
-		return ChainIDMoonbeam, nil
-	case "terra2":
-		return ChainIDTerra2, nil
-	case "injective":
-		return ChainIDInjective, nil
-	case "osmosis":
-		return ChainIDOsmosis, nil
-	case "sui":
-		return ChainIDSui, nil
-	case "aptos":
-		return ChainIDAptos, nil
-	case "arbitrum":
-		return ChainIDArbitrum, nil
-	case "optimism":
-		return ChainIDOptimism, nil
-	case "gnosis":
-		return ChainIDGnosis, nil
-	case "pythnet":
-		return ChainIDPythNet, nil
-	case "xpla":
-		return ChainIDXpla, nil
-	case "btc":
-		return ChainIDBtc, nil
-	case "base":
-		return ChainIDBase, nil
-	case "filecoin":
-		return ChainIDFileCoin, nil
-	case "sei":
-		return ChainIDSei, nil
-	case "rootstock":
-		return ChainIDRootstock, nil
-	case "scroll":
-		return ChainIDScroll, nil
-	case "mantle":
-		return ChainIDMantle, nil
-	case "blast":
-		return ChainIDBlast, nil
-	case "xlayer":
-		return ChainIDXLayer, nil
-	case "linea":
-		return ChainIDLinea, nil
-	case "berachain":
-		return ChainIDBerachain, nil
-	case "seievm":
-		return ChainIDSeiEVM, nil
-	case "eclipse":
-		return ChainIDEclipse, nil
-	case "bob":
-		return ChainIDBOB, nil
-	case "snaxchain":
-		return ChainIDSnaxchain, nil
-	case "unichain":
-		return ChainIDUnichain, nil
-	case "worldchain":
-		return ChainIDWorldchain, nil
-	case "ink":
-		return ChainIDInk, nil
-	case "hyperevm":
-		return ChainIDHyperEVM, nil
-	case "monad":
-		return ChainIDMonad, nil
-	case "movement":
-		return ChainIDMovement, nil
-	case "mezo":
-		return ChainIDMezo, nil
-	case "fogo":
-		return ChainIDFogo, nil
-	case "sonic":
-		return ChainIDSonic, nil
-	case "converge":
-		return ChainIDConverge, nil
-	case "codex":
-		return ChainIDCodex, nil
-	case "plume":
-		return ChainIDPlume, nil
-	case "wormchain":
-		return ChainIDWormchain, nil
-	case "cosmoshub":
-		return ChainIDCosmoshub, nil
-	case "evmos":
-		return ChainIDEvmos, nil
-	case "kujira":
-		return ChainIDKujira, nil
-	case "neutron":
-		return ChainIDNeutron, nil
-	case "celestia":
-		return ChainIDCelestia, nil
-	case "stargaze":
-		return ChainIDStargaze, nil
-	case "seda":
-		return ChainIDSeda, nil
-	case "dymension":
-		return ChainIDDymension, nil
-	case "provenance":
-		return ChainIDProvenance, nil
-	case "noble":
-		return ChainIDNoble, nil
-	case "sepolia":
-		return ChainIDSepolia, nil
-	case "arbitrum_sepolia":
-		return ChainIDArbitrumSepolia, nil
-	case "base_sepolia":
-		return ChainIDBaseSepolia, nil
-	case "optimism_sepolia":
-		return ChainIDOptimismSepolia, nil
-	case "holesky":
-		return ChainIDHolesky, nil
-	case "polygon_sepolia":
-		return ChainIDPolygonSepolia, nil
-	default:
-		return ChainIDUnset, fmt.Errorf("unknown chain ID: %s", s)
-	}
-}
-
-func GetAllNetworkIDs() []ChainID {
-	return []ChainID{
-		ChainIDSolana,
-		ChainIDEthereum,
-		ChainIDTerra,
-		ChainIDBSC,
-		ChainIDPolygon,
-		ChainIDAvalanche,
-		ChainIDOasis,
-		ChainIDAlgorand,
-		ChainIDAurora,
-		ChainIDFantom,
-		ChainIDKarura,
-		ChainIDAcala,
-		ChainIDKlaytn,
-		ChainIDCelo,
-		ChainIDNear,
-		ChainIDMoonbeam,
-		ChainIDTerra2,
-		ChainIDInjective,
-		ChainIDOsmosis,
-		ChainIDSui,
-		ChainIDAptos,
-		ChainIDArbitrum,
-		ChainIDOptimism,
-		ChainIDGnosis,
-		ChainIDPythNet,
-		ChainIDXpla,
-		ChainIDBtc,
-		ChainIDBase,
-		ChainIDFileCoin,
-		ChainIDSei,
-		ChainIDRootstock,
-		ChainIDScroll,
-		ChainIDMantle,
-		ChainIDBlast,
-		ChainIDXLayer,
-		ChainIDLinea,
-		ChainIDBerachain,
-		ChainIDSeiEVM,
-		ChainIDEclipse,
-		ChainIDBOB,
-		ChainIDSnaxchain,
-		ChainIDUnichain,
-		ChainIDWorldchain,
-		ChainIDInk,
-		ChainIDHyperEVM,
-		ChainIDMonad,
-		ChainIDMovement,
-		ChainIDMezo,
-		ChainIDFogo,
-		ChainIDSonic,
-		ChainIDConverge,
-		ChainIDCodex,
-		ChainIDPlume,
-		ChainIDWormchain,
-		ChainIDCosmoshub,
-		ChainIDEvmos,
-		ChainIDKujira,
-		ChainIDNeutron,
-		ChainIDCelestia,
-		ChainIDStargaze,
-		ChainIDSeda,
-		ChainIDDymension,
-		ChainIDProvenance,
-		ChainIDNoble,
-		ChainIDSepolia,
-		ChainIDArbitrumSepolia,
-		ChainIDBaseSepolia,
-		ChainIDOptimismSepolia,
-		ChainIDHolesky,
-		ChainIDPolygonSepolia,
-	}
-}
-
 // NOTE: Please keep these in numerical order.
 const (
 	ChainIDUnset ChainID = 0