Files
zeekay f70bac500d refactor: migrate to vm/rpc/chain, remove node dependency from production code
- Update import from vm/rpcchainvm to vm/rpc/chain
- Update vm dependency to v1.0.18
- node dependency now test-only (platformvm.NewClient for warp tests)
2026-01-11 21:38:33 -08:00

48 lines
1.2 KiB
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package utils
import (
"fmt"
"path/filepath"
"strings"
"sync"
)
type ChainSuite struct {
blockchainIDs map[string]string
lock sync.RWMutex
}
func (s *ChainSuite) GetBlockchainID(alias string) string {
s.lock.RLock()
defer s.lock.RUnlock()
return s.blockchainIDs[alias]
}
func (s *ChainSuite) SetBlockchainIDs(blockchainIDs map[string]string) {
s.lock.Lock()
defer s.lock.Unlock()
s.blockchainIDs = blockchainIDs
}
// GetDefaultChainURI returns the default chain URI for a given blockchainID
func GetDefaultChainURI(blockchainID string) string {
return fmt.Sprintf("%s/ext/bc/%s/rpc", DefaultLocalNodeURI, blockchainID)
}
// GetFilesAndAliases returns a map of aliases to file paths in given [dir].
func GetFilesAndAliases(dir string) (map[string]string, error) {
files, err := filepath.Glob(dir)
if err != nil {
return nil, err
}
aliasesToFiles := make(map[string]string)
for _, file := range files {
alias := strings.TrimSuffix(filepath.Base(file), filepath.Ext(file))
aliasesToFiles[alias] = file
}
return aliasesToFiles, nil
}