Skip to content

Commit

Permalink
fix: check capability type (#15185)
Browse files Browse the repository at this point in the history
  • Loading branch information
agparadiso authored Nov 12, 2024
1 parent 66e3488 commit 710970c
Show file tree
Hide file tree
Showing 2 changed files with 343 additions and 114 deletions.
14 changes: 12 additions & 2 deletions core/capabilities/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,14 @@ func (w *launcher) exposeCapabilities(ctx context.Context, myPeerID p2ptypes.Pee
switch capability.CapabilityType {
case capabilities.CapabilityTypeTrigger:
newTriggerPublisher := func(cap capabilities.BaseCapability, info capabilities.CapabilityInfo) (remotetypes.ReceiverService, error) {
triggerCapability, ok := (cap).(capabilities.TriggerCapability)
if !ok {
return nil, errors.New("capability does not implement TriggerCapability")
}

publisher := remote.NewTriggerPublisher(
capabilityConfig.RemoteTriggerConfig,
cap.(capabilities.TriggerCapability),
triggerCapability,
info,
don.DON,
idsToDONs,
Expand All @@ -419,10 +424,15 @@ func (w *launcher) exposeCapabilities(ctx context.Context, myPeerID p2ptypes.Pee
w.lggr.Warn("no remote client configured for capability type consensus, skipping configuration")
case capabilities.CapabilityTypeTarget:
newTargetServer := func(cap capabilities.BaseCapability, info capabilities.CapabilityInfo) (remotetypes.ReceiverService, error) {
targetCapability, ok := (cap).(capabilities.TargetCapability)
if !ok {
return nil, errors.New("capability does not implement TargetCapability")
}

return target.NewServer(
capabilityConfig.RemoteTargetConfig,
myPeerID,
cap.(capabilities.TargetCapability),
targetCapability,
info,
don.DON,
idsToDONs,
Expand Down
Loading

0 comments on commit 710970c

Please sign in to comment.