Skip to content

Commit

Permalink
Replace type with string
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanTinianov committed Dec 11, 2023
1 parent c9c8230 commit dbfb822
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
16 changes: 8 additions & 8 deletions core/chains/evm/config/toml/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (cs EVMConfigs) totalChains() int {
}
return total
}
func (cs EVMConfigs) Chains(ids ...types.ChainID) (r []commontypes.ChainStatus, total int, err error) {
func (cs EVMConfigs) Chains(ids ...string) (r []commontypes.ChainStatus, total int, err error) {
total = cs.totalChains()
for _, ch := range cs {
if ch == nil {
Expand Down Expand Up @@ -153,7 +153,7 @@ func (cs EVMConfigs) NodeStatus(name string) (commontypes.NodeStatus, error) {
for i := range cs {
for _, n := range cs[i].Nodes {
if n.Name != nil && *n.Name == name {
return nodeStatus(n, types.ChainID(cs[i].ChainID.String()))
return nodeStatus(n, cs[i].ChainID.String())
}
}
}
Expand All @@ -178,7 +178,7 @@ func legacyNode(n *Node, chainID *utils.Big) (v2 types.Node) {
return
}

func nodeStatus(n *Node, chainID types.ChainID) (commontypes.NodeStatus, error) {
func nodeStatus(n *Node, chainID string) (commontypes.NodeStatus, error) {
var s commontypes.NodeStatus
s.ChainID = chainID
s.Name = *n.Name
Expand All @@ -190,7 +190,7 @@ func nodeStatus(n *Node, chainID types.ChainID) (commontypes.NodeStatus, error)
return s, nil
}

func (cs EVMConfigs) nodes(id types.ChainID) (ns EVMNodes) {
func (cs EVMConfigs) nodes(id string) (ns EVMNodes) {
for _, c := range cs {
if c.ChainID.String() == id {
return c.Nodes
Expand All @@ -199,7 +199,7 @@ func (cs EVMConfigs) nodes(id types.ChainID) (ns EVMNodes) {
return nil
}

func (cs EVMConfigs) Nodes(chainID types.ChainID) (ns []types.Node, err error) {
func (cs EVMConfigs) Nodes(chainID string) (ns []types.Node, err error) {
evmID, err := ChainIDInt64(chainID)
if err != nil {
return nil, fmt.Errorf("invalid evm chain id %q : %w", chainID, err)
Expand All @@ -219,14 +219,14 @@ func (cs EVMConfigs) Nodes(chainID types.ChainID) (ns []types.Node, err error) {
return
}

func (cs EVMConfigs) NodeStatuses(chainIDs ...types.ChainID) (ns []commontypes.NodeStatus, err error) {
func (cs EVMConfigs) NodeStatuses(chainIDs ...string) (ns []commontypes.NodeStatus, err error) {
if len(chainIDs) == 0 {
for i := range cs {
for _, n := range cs[i].Nodes {
if n == nil {
continue
}
n2, err := nodeStatus(n, types.ChainID(cs[i].ChainID.String()))
n2, err := nodeStatus(n, cs[i].ChainID.String())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -815,6 +815,6 @@ func (n *Node) SetFrom(f *Node) {
}
}

func ChainIDInt64(cid types.ChainID) (int64, error) {
func ChainIDInt64(cid string) (int64, error) {
return strconv.ParseInt(cid, 10, 64)
}
6 changes: 2 additions & 4 deletions core/chains/evm/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/utils"
)

type ChainID = string

type Configs interface {
Chains(ids ...ChainID) ([]types.ChainStatus, int, error)
Chains(ids ...string) ([]types.ChainStatus, int, error)
Node(name string) (Node, error)
Nodes(chainID ChainID) (nodes []Node, err error)
Nodes(chainID string) (nodes []Node, err error)
NodeStatus(name string) (types.NodeStatus, error)
}

Expand Down

0 comments on commit dbfb822

Please sign in to comment.