@@ -3,8 +3,10 @@ package pb
33import (
44 "errors"
55 "fmt"
6+ "time"
67
78 "google.golang.org/protobuf/proto"
9+ "google.golang.org/protobuf/types/known/timestamppb"
810
911 "github.com/smartcontractkit/chainlink-common/pkg/capabilities"
1012 meter "github.com/smartcontractkit/chainlink-common/pkg/metering/pb"
@@ -71,6 +73,7 @@ func CapabilityRequestToProto(req capabilities.CapabilityRequest) *CapabilityReq
7173 DecodedWorkflowName : req .Metadata .DecodedWorkflowName ,
7274 SpendLimits : spendLimitsToProto (req .Metadata .SpendLimits ),
7375 WorkflowTag : req .Metadata .WorkflowTag ,
76+ ExecutionTimestamp : timeToProto (req .Metadata .ExecutionTimestamp ),
7477 },
7578 Inputs : values .ProtoMap (inputs ),
7679 Config : values .ProtoMap (config ),
@@ -133,6 +136,7 @@ func CapabilityRequestFromProto(pr *CapabilityRequest) (capabilities.CapabilityR
133136 DecodedWorkflowName : md .DecodedWorkflowName ,
134137 SpendLimits : spendLimitsFromProto (md .SpendLimits ),
135138 WorkflowTag : md .WorkflowTag ,
139+ ExecutionTimestamp : timeFromProto (md .ExecutionTimestamp ),
136140 },
137141 Config : config ,
138142 Inputs : inputs ,
@@ -332,13 +336,28 @@ func TriggerRegistrationRequestToProto(req capabilities.TriggerRegistrationReque
332336 WorkflowRegistryChainSelector : md .WorkflowRegistryChainSelector ,
333337 WorkflowRegistryAddress : md .WorkflowRegistryAddress ,
334338 EngineVersion : md .EngineVersion ,
339+ ExecutionTimestamp : timeToProto (md .ExecutionTimestamp ),
335340 },
336341 Config : values .ProtoMap (config ),
337342 Payload : req .Payload ,
338343 Method : req .Method ,
339344 }
340345}
341346
347+ func timeToProto (t time.Time ) * timestamppb.Timestamp {
348+ if t .IsZero () {
349+ return nil
350+ }
351+ return timestamppb .New (t )
352+ }
353+
354+ func timeFromProto (ts * timestamppb.Timestamp ) time.Time {
355+ if ts == nil {
356+ return time.Time {}
357+ }
358+ return ts .AsTime ()
359+ }
360+
342361func spendLimitsToProto (limits []capabilities.SpendLimit ) []* SpendLimit {
343362 result := make ([]* SpendLimit , len (limits ))
344363 for i , limit := range limits {
@@ -382,6 +401,7 @@ func TriggerRegistrationRequestFromProto(req *TriggerRegistrationRequest) (capab
382401 WorkflowRegistryChainSelector : md .WorkflowRegistryChainSelector ,
383402 WorkflowRegistryAddress : md .WorkflowRegistryAddress ,
384403 EngineVersion : md .EngineVersion ,
404+ ExecutionTimestamp : timeFromProto (md .ExecutionTimestamp ),
385405 },
386406 Config : config ,
387407 Payload : req .Payload ,
0 commit comments