Skip to content

Commit

Permalink
Slightly simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Nov 22, 2024
1 parent 39c17b8 commit 772a589
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 31 deletions.
30 changes: 18 additions & 12 deletions deployment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,24 +363,30 @@ func NodeInfo(nodeIDs []string, oc NodeChainConfigsLister) (Nodes, error) {
KeyBundleID: chainConfig.Ocr2Config.OcrKeyBundle.BundleId,
}

var details chain_selectors.ChainDetails
switch chainConfig.Chain.Type {
case nodev1.ChainType_CHAIN_TYPE_APTOS:
details, err = chain_selectors.GetChainDetailsByChainIDAndFamily(chainConfig.Chain.Id, chain_selectors.FamilyAptos)
if err != nil {
return nil, err
}
case nodev1.ChainType_CHAIN_TYPE_EVM:
if chainConfig.Chain.Type == nodev1.ChainType_CHAIN_TYPE_EVM {
// NOTE: Assume same adminAddr for all chains. We always use EVM addr
adminAddr = chainConfig.AdminAddress
details, err = chain_selectors.GetChainDetailsByChainIDAndFamily(chainConfig.Chain.Id, chain_selectors.FamilyEVM)
if err != nil {
return nil, err
}
}

var family string
switch chainConfig.Chain.Type {
case nodev1.ChainType_CHAIN_TYPE_EVM:
family = chain_selectors.FamilyEVM
case nodev1.ChainType_CHAIN_TYPE_APTOS:
family = chain_selectors.FamilyAptos
case nodev1.ChainType_CHAIN_TYPE_SOLANA:
family = chain_selectors.FamilySolana
case nodev1.ChainType_CHAIN_TYPE_STARKNET:
family = chain_selectors.FamilyStarknet
default:
return nil, fmt.Errorf("unsupported chain type %s", chainConfig.Chain.Type)
}

details, err := chain_selectors.GetChainDetailsByChainIDAndFamily(chainConfig.Chain.Id, family)
if err != nil {
return nil, err
}

selToOCRConfig[details] = ocrConfig
}
nodes = append(nodes, Node{
Expand Down
25 changes: 6 additions & 19 deletions deployment/environment/memory/job_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,39 +195,26 @@ func (j JobClient) ListNodeChainConfigs(ctx context.Context, in *nodev1.ListNode
continue
}

var chainID string
// NOTE: this supports non-EVM too
chainID, err := chainsel.GetChainIDFromSelector(selector)
if err != nil {
return nil, err
}

var ocrtype chaintype.ChainType
switch family {
case chainsel.FamilyEVM:
ocrtype = chaintype.EVM
cid, err := chainsel.ChainIdFromSelector(selector)
if err != nil {
return nil, err
}
chainID = strconv.Itoa(int(cid))
case chainsel.FamilySolana:
ocrtype = chaintype.Solana
cid, err := chainsel.SolanaChainIdFromSelector(selector)
if err != nil {
return nil, err
}
chainID = cid
case chainsel.FamilyStarknet:
ocrtype = chaintype.StarkNet
// TODO: support cid
case chainsel.FamilyCosmos:
ocrtype = chaintype.Cosmos
// TODO: support cid
case chainsel.FamilyAptos:
ocrtype = chaintype.Aptos
cid, err := chainsel.AptosChainIdFromSelector(selector)
if err != nil {
return nil, err
}
chainID = strconv.Itoa(int(cid))
default:
panic(fmt.Sprintf("Unsupported chain family %v", family))
return nil, fmt.Errorf("Unsupported chain family %v", family)
}

bundle := n.Keys.OCRKeyBundles[ocrtype]
Expand Down

0 comments on commit 772a589

Please sign in to comment.