Skip to content

Commit dccaeb6

Browse files
Remove CCIP delegates hardcoding of EVM (#17088)
* CCIP delegates to support Tron * fix error
1 parent cfa9c31 commit dccaeb6

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

core/services/ocr2/delegate.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,8 +1619,8 @@ func (d *Delegate) newServicesOCR2Functions(
16191619

16201620
func (d *Delegate) newServicesCCIPCommit(ctx context.Context, lggr logger.SugaredLogger, jb job.Job, bootstrapPeers []commontypes.BootstrapperLocator, kb ocr2key.KeyBundle, ocrDB *db, lc ocrtypes.LocalConfig, transmitterID string) ([]job.ServiceCtx, error) {
16211621
spec := jb.OCR2OracleSpec
1622-
if spec.Relay != relay.NetworkEVM {
1623-
return nil, errors.New("non evm chains are not supported for CCIP commit")
1622+
if !isCCIPSupportedNetwork(spec.Relay) {
1623+
return nil, fmt.Errorf("chain not supported for CCIP commit: %s", spec.Relay)
16241624
}
16251625
dstRid, err := spec.RelayID()
16261626
if err != nil {
@@ -1763,8 +1763,8 @@ func newCCIPCommitPluginBytes(isSourceProvider bool, sourceStartBlock uint64, de
17631763

17641764
func (d *Delegate) ccipCommitGetDstProvider(ctx context.Context, jb job.Job, pluginJobSpecConfig ccipconfig.CommitPluginJobSpecConfig, transmitterID string) (types.CCIPCommitProvider, error) {
17651765
spec := jb.OCR2OracleSpec
1766-
if spec.Relay != relay.NetworkEVM {
1767-
return nil, errors.New("non evm chains are not supported for CCIP commit")
1766+
if !isCCIPSupportedNetwork(spec.Relay) {
1767+
return nil, fmt.Errorf("chain not supported for CCIP commit: %s", spec.Relay)
17681768
}
17691769

17701770
dstRid, err := spec.RelayID()
@@ -1863,8 +1863,8 @@ func (d *Delegate) ccipCommitGetSrcProvider(ctx context.Context, jb job.Job, plu
18631863

18641864
func (d *Delegate) newServicesCCIPExecution(ctx context.Context, lggr logger.SugaredLogger, jb job.Job, bootstrapPeers []commontypes.BootstrapperLocator, kb ocr2key.KeyBundle, ocrDB *db, lc ocrtypes.LocalConfig, transmitterID string) ([]job.ServiceCtx, error) {
18651865
spec := jb.OCR2OracleSpec
1866-
if spec.Relay != relay.NetworkEVM {
1867-
return nil, errors.New("non evm chains are not supported for CCIP execution")
1866+
if !isCCIPSupportedNetwork(spec.Relay) {
1867+
return nil, fmt.Errorf("chain not supported for CCIP execution: %s", spec.Relay)
18681868
}
18691869
dstRid, err := spec.RelayID()
18701870

@@ -1923,8 +1923,8 @@ func (d *Delegate) newServicesCCIPExecution(ctx context.Context, lggr logger.Sug
19231923

19241924
func (d *Delegate) ccipExecGetDstProvider(ctx context.Context, jb job.Job, pluginJobSpecConfig ccipconfig.ExecPluginJobSpecConfig, transmitterID string) (types.CCIPExecProvider, error) {
19251925
spec := jb.OCR2OracleSpec
1926-
if spec.Relay != relay.NetworkEVM {
1927-
return nil, errors.New("non evm chains are not supported for CCIP execution")
1926+
if !isCCIPSupportedNetwork(spec.Relay) {
1927+
return nil, fmt.Errorf("chain not supported for CCIP execution: %s", spec.Relay)
19281928
}
19291929
dstRid, err := spec.RelayID()
19301930

@@ -2046,3 +2046,12 @@ func (l *logWriter) Write(p []byte) (n int, err error) {
20462046
n = len(p)
20472047
return
20482048
}
2049+
2050+
func isCCIPSupportedNetwork(network string) bool {
2051+
switch network {
2052+
case relay.NetworkEVM, relay.NetworkTron:
2053+
return true
2054+
default:
2055+
return false
2056+
}
2057+
}

0 commit comments

Comments
 (0)