Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(feeds) adds support for non EVM chain configs #14731

16 changes: 16 additions & 0 deletions core/services/feeds/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/pkg/errors"
"gopkg.in/guregu/null.v4"

proto "github.com/smartcontractkit/chainlink/v2/core/services/feeds/proto"
"github.com/smartcontractkit/chainlink/v2/core/utils/crypto"
)

Expand Down Expand Up @@ -77,7 +78,9 @@ type ChainType string

const (
ChainTypeUnknown ChainType = "UNKNOWN"
ChainTypeAptos ChainType = "APTOS"
ChainTypeEVM ChainType = "EVM"
ChainTypeSolana ChainType = "SOLANA"
ChainTypeStarknet ChainType = "STARKNET"
)

Expand All @@ -87,11 +90,24 @@ func NewChainType(s string) (ChainType, error) {
return ChainTypeEVM, nil
case "STARKNET":
return ChainTypeStarknet, nil
case "SOLANA":
return ChainTypeSolana, nil
case "APTOS":
return ChainTypeAptos, nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are missing cosmos as well, but we can get this PR in first (not that we need it for aptos)

default:
return ChainTypeUnknown, errors.New("invalid chain type")
}
}

// ChainTypeToProtoChainType converts a ChainType to a proto.ChainType.
func ChainTypeToProtoChainType(chainType ChainType) proto.ChainType {
prefixed := "CHAIN_TYPE_" + string(chainType)
if chainType, exists := proto.ChainType_value[prefixed]; exists {
return proto.ChainType(chainType)
}
return proto.ChainType_CHAIN_TYPE_UNSPECIFIED
}

// FeedsManager defines a registered Feeds Manager Service and the connection
// information.
type FeedsManager struct {
Expand Down
8 changes: 4 additions & 4 deletions core/services/feeds/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1225,9 +1225,9 @@ func (s *service) generateJob(ctx context.Context, spec string) (*job.Job, error

// newChainConfigMsg generates a chain config protobuf message.
func (s *service) newChainConfigMsg(cfg ChainConfig) (*pb.ChainConfig, error) {
// Only supports EVM Chains
if cfg.ChainType != "EVM" {
return nil, errors.New("unsupported chain type")
protoChainType := ChainTypeToProtoChainType(cfg.ChainType)
if protoChainType == pb.ChainType_CHAIN_TYPE_UNSPECIFIED {
return nil, errors.Errorf("unsupported chain type: %s", cfg.ChainType)
}

ocr1Cfg, err := s.newOCR1ConfigMsg(cfg.OCR1Config)
Expand All @@ -1243,7 +1243,7 @@ func (s *service) newChainConfigMsg(cfg ChainConfig) (*pb.ChainConfig, error) {
pbChainConfig := pb.ChainConfig{
Chain: &pb.Chain{
Id: cfg.ChainID,
Type: pb.ChainType_CHAIN_TYPE_EVM,
Type: protoChainType,
},
AccountAddress: cfg.AccountAddress,
AdminAddress: cfg.AdminAddress,
Expand Down
Loading
Loading