-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
spec.go
962 lines (758 loc) · 26.1 KB
/
spec.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
package resolver
import (
"github.com/graph-gophers/graphql-go"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/utils/stringutils"
"github.com/smartcontractkit/chainlink/v2/core/web/gqlscalar"
)
type SpecResolver struct {
j job.Job
}
func NewSpec(j job.Job) *SpecResolver {
return &SpecResolver{j: j}
}
func (r *SpecResolver) ToCronSpec() (*CronSpecResolver, bool) {
if r.j.Type != job.Cron {
return nil, false
}
return &CronSpecResolver{spec: *r.j.CronSpec}, true
}
func (r *SpecResolver) ToDirectRequestSpec() (*DirectRequestSpecResolver, bool) {
if r.j.Type != job.DirectRequest {
return nil, false
}
return &DirectRequestSpecResolver{spec: *r.j.DirectRequestSpec}, true
}
func (r *SpecResolver) ToFluxMonitorSpec() (*FluxMonitorSpecResolver, bool) {
if r.j.Type != job.FluxMonitor {
return nil, false
}
return &FluxMonitorSpecResolver{spec: *r.j.FluxMonitorSpec}, true
}
func (r *SpecResolver) ToKeeperSpec() (*KeeperSpecResolver, bool) {
if r.j.Type != job.Keeper {
return nil, false
}
return &KeeperSpecResolver{spec: *r.j.KeeperSpec}, true
}
func (r *SpecResolver) ToOCRSpec() (*OCRSpecResolver, bool) {
if r.j.Type != job.OffchainReporting {
return nil, false
}
return &OCRSpecResolver{spec: *r.j.OCROracleSpec}, true
}
func (r *SpecResolver) ToOCR2Spec() (*OCR2SpecResolver, bool) {
if r.j.Type != job.OffchainReporting2 {
return nil, false
}
return &OCR2SpecResolver{spec: *r.j.OCR2OracleSpec}, true
}
func (r *SpecResolver) ToVRFSpec() (*VRFSpecResolver, bool) {
if r.j.Type != job.VRF {
return nil, false
}
return &VRFSpecResolver{spec: *r.j.VRFSpec}, true
}
func (r *SpecResolver) ToWebhookSpec() (*WebhookSpecResolver, bool) {
if r.j.Type != job.Webhook {
return nil, false
}
return &WebhookSpecResolver{spec: *r.j.WebhookSpec}, true
}
// ToBlockhashStoreSpec returns the BlockhashStoreSpec from the SpecResolver if the job is a
// BlockhashStore job.
func (r *SpecResolver) ToBlockhashStoreSpec() (*BlockhashStoreSpecResolver, bool) {
if r.j.Type != job.BlockhashStore {
return nil, false
}
return &BlockhashStoreSpecResolver{spec: *r.j.BlockhashStoreSpec}, true
}
// ToBlockHeaderFeederSpec returns the BlockHeaderFeederSpec from the SpecResolver if the job is a
// BlockHeaderFeeder job.
func (r *SpecResolver) ToBlockHeaderFeederSpec() (*BlockHeaderFeederSpecResolver, bool) {
if r.j.Type != job.BlockHeaderFeeder {
return nil, false
}
return &BlockHeaderFeederSpecResolver{spec: *r.j.BlockHeaderFeederSpec}, true
}
// ToBootstrapSpec resolves to the Booststrap Spec Resolver
func (r *SpecResolver) ToBootstrapSpec() (*BootstrapSpecResolver, bool) {
if r.j.Type != job.Bootstrap {
return nil, false
}
return &BootstrapSpecResolver{spec: *r.j.BootstrapSpec}, true
}
type CronSpecResolver struct {
spec job.CronSpec
}
func (r *CronSpecResolver) Schedule() string {
return r.spec.CronSchedule
}
// CreatedAt resolves the spec's created at timestamp.
func (r *CronSpecResolver) CreatedAt() graphql.Time {
return graphql.Time{Time: r.spec.CreatedAt}
}
type DirectRequestSpecResolver struct {
spec job.DirectRequestSpec
}
// ContractAddress resolves the spec's contract address.
func (r *DirectRequestSpecResolver) ContractAddress() string {
return r.spec.ContractAddress.String()
}
// CreatedAt resolves the spec's created at timestamp.
func (r *DirectRequestSpecResolver) CreatedAt() graphql.Time {
return graphql.Time{Time: r.spec.CreatedAt}
}
// EVMChainID resolves the spec's evm chain id.
func (r *DirectRequestSpecResolver) EVMChainID() *string {
if r.spec.EVMChainID == nil {
return nil
}
chainID := r.spec.EVMChainID.String()
return &chainID
}
// MinIncomingConfirmations resolves the spec's min incoming confirmations.
func (r *DirectRequestSpecResolver) MinIncomingConfirmations() int32 {
if r.spec.MinIncomingConfirmations.Valid {
return int32(r.spec.MinIncomingConfirmations.Uint32)
}
return 0
}
// EVMChainID resolves the spec's evm chain id.
func (r *DirectRequestSpecResolver) MinIncomingConfirmationsEnv() bool {
return r.spec.MinIncomingConfirmationsEnv
}
// MinContractPaymentLinkJuels resolves the spec's min contract payment link.
func (r *DirectRequestSpecResolver) MinContractPaymentLinkJuels() string {
return r.spec.MinContractPayment.String()
}
// Requesters resolves the spec's evm chain id.
func (r *DirectRequestSpecResolver) Requesters() *[]string {
if r.spec.Requesters == nil {
return nil
}
requesters := r.spec.Requesters.ToStrings()
return &requesters
}
type FluxMonitorSpecResolver struct {
spec job.FluxMonitorSpec
}
// AbsoluteThreshold resolves the spec's absolute deviation threshold.
func (r *FluxMonitorSpecResolver) AbsoluteThreshold() float64 {
return float64(r.spec.AbsoluteThreshold)
}
// ContractAddress resolves the spec's contract address.
func (r *FluxMonitorSpecResolver) ContractAddress() string {
return r.spec.ContractAddress.String()
}
// CreatedAt resolves the spec's created at timestamp.
func (r *FluxMonitorSpecResolver) CreatedAt() graphql.Time {
return graphql.Time{Time: r.spec.CreatedAt}
}
// AbsoluteThreshold resolves the spec's absolute threshold.
func (r *FluxMonitorSpecResolver) DrumbeatEnabled() bool {
return r.spec.DrumbeatEnabled
}
// DrumbeatRandomDelay resolves the spec's drumbeat random delay.
func (r *FluxMonitorSpecResolver) DrumbeatRandomDelay() *string {
var delay *string
if r.spec.DrumbeatRandomDelay > 0 {
drumbeatRandomDelay := r.spec.DrumbeatRandomDelay.String()
delay = &drumbeatRandomDelay
}
return delay
}
// DrumbeatSchedule resolves the spec's drumbeat schedule.
func (r *FluxMonitorSpecResolver) DrumbeatSchedule() *string {
if r.spec.DrumbeatEnabled {
return &r.spec.DrumbeatSchedule
}
return nil
}
// EVMChainID resolves the spec's evm chain id.
func (r *FluxMonitorSpecResolver) EVMChainID() *string {
if r.spec.EVMChainID == nil {
return nil
}
chainID := r.spec.EVMChainID.String()
return &chainID
}
// IdleTimerDisabled resolves the spec's idle timer disabled flag.
func (r *FluxMonitorSpecResolver) IdleTimerDisabled() bool {
return r.spec.IdleTimerDisabled
}
// IdleTimerPeriod resolves the spec's idle timer period.
func (r *FluxMonitorSpecResolver) IdleTimerPeriod() string {
return r.spec.IdleTimerPeriod.String()
}
// MinPayment resolves the spec's min payment.
func (r *FluxMonitorSpecResolver) MinPayment() *string {
if r.spec.MinPayment != nil {
min := r.spec.MinPayment.String()
return &min
}
return nil
}
// PollTimerDisabled resolves the spec's poll timer disabled flag.
func (r *FluxMonitorSpecResolver) PollTimerDisabled() bool {
return r.spec.PollTimerDisabled
}
// PollTimerPeriod resolves the spec's poll timer period.
func (r *FluxMonitorSpecResolver) PollTimerPeriod() string {
return r.spec.PollTimerPeriod.String()
}
// Threshold resolves the spec's deviation threshold.
func (r *FluxMonitorSpecResolver) Threshold() float64 {
return float64(r.spec.Threshold)
}
type KeeperSpecResolver struct {
spec job.KeeperSpec
}
// ContractAddress resolves the spec's contract address.
func (r *KeeperSpecResolver) ContractAddress() string {
return r.spec.ContractAddress.String()
}
// CreatedAt resolves the spec's created at timestamp.
func (r *KeeperSpecResolver) CreatedAt() graphql.Time {
return graphql.Time{Time: r.spec.CreatedAt}
}
// EVMChainID resolves the spec's evm chain id.
func (r *KeeperSpecResolver) EVMChainID() *string {
if r.spec.EVMChainID == nil {
return nil
}
chainID := r.spec.EVMChainID.String()
return &chainID
}
// FromAddress resolves the spec's from contract address.
//
// Because VRF has an non required field of the same name, we have to be
// consistent in our return value of using a *string instead of a string even
// though this is a required field for the KeeperSpec.
//
// http://spec.graphql.org/draft/#sec-Field-Selection-Merging
func (r *KeeperSpecResolver) FromAddress() *string {
addr := r.spec.FromAddress.String()
return &addr
}
type OCRSpecResolver struct {
spec job.OCROracleSpec
}
// BlockchainTimeout resolves the spec's blockchain timeout.
func (r *OCRSpecResolver) BlockchainTimeout() *string {
if r.spec.BlockchainTimeout.Duration() == 0 {
return nil
}
timeout := r.spec.BlockchainTimeout.Duration().String()
return &timeout
}
// BlockchainTimeoutEnv resolves whether the spec's blockchain timeout comes
// from an env var.
func (r *OCRSpecResolver) BlockchainTimeoutEnv() bool {
return r.spec.BlockchainTimeoutEnv
}
// ContractAddress resolves the spec's contract address.
func (r *OCRSpecResolver) ContractAddress() string {
return r.spec.ContractAddress.String()
}
// ContractConfigConfirmations resolves the spec's confirmations config.
func (r *OCRSpecResolver) ContractConfigConfirmations() *int32 {
if r.spec.ContractConfigConfirmations == 0 {
return nil
}
confirmations := int32(r.spec.ContractConfigConfirmations)
return &confirmations
}
// ContractConfigConfirmationsEnv resolves whether spec's confirmations
// config comes from an env var.
func (r *OCRSpecResolver) ContractConfigConfirmationsEnv() bool {
return r.spec.ContractConfigConfirmationsEnv
}
// ContractConfigTrackerPollInterval resolves the spec's contract tracker poll
// interval config.
func (r *OCRSpecResolver) ContractConfigTrackerPollInterval() *string {
if r.spec.ContractConfigTrackerPollInterval.Duration() == 0 {
return nil
}
interval := r.spec.ContractConfigTrackerPollInterval.Duration().String()
return &interval
}
// ContractConfigTrackerPollIntervalEnv resolves the whether spec's tracker poll
// config comes from an env var.
func (r *OCRSpecResolver) ContractConfigTrackerPollIntervalEnv() bool {
return r.spec.ContractConfigTrackerPollIntervalEnv
}
// ContractConfigTrackerSubscribeInterval resolves the spec's tracker subscribe
// interval config.
func (r *OCRSpecResolver) ContractConfigTrackerSubscribeInterval() *string {
if r.spec.ContractConfigTrackerSubscribeInterval.Duration() == 0 {
return nil
}
interval := r.spec.ContractConfigTrackerSubscribeInterval.Duration().String()
return &interval
}
// ContractConfigTrackerSubscribeIntervalEnv resolves whether spec's tracker
// subscribe interval config comes from an env var.
func (r *OCRSpecResolver) ContractConfigTrackerSubscribeIntervalEnv() bool {
return r.spec.ContractConfigTrackerSubscribeIntervalEnv
}
// CreatedAt resolves the spec's created at timestamp.
func (r *OCRSpecResolver) CreatedAt() graphql.Time {
return graphql.Time{Time: r.spec.CreatedAt}
}
// EVMChainID resolves the spec's evm chain id.
func (r *OCRSpecResolver) EVMChainID() *string {
if r.spec.EVMChainID == nil {
return nil
}
chainID := r.spec.EVMChainID.String()
return &chainID
}
// DatabaseTimeout resolves the spec's database timeout.
func (r *OCRSpecResolver) DatabaseTimeout() string {
return r.spec.DatabaseTimeout.Duration().String()
}
// DatabaseTimeoutEnv resolves the whether spec's database timeout
// config comes from an env var.
func (r *OCRSpecResolver) DatabaseTimeoutEnv() bool {
return r.spec.DatabaseTimeoutEnv
}
// ObservationGracePeriod resolves the spec's observation grace period.
func (r *OCRSpecResolver) ObservationGracePeriod() string {
return r.spec.ObservationGracePeriod.Duration().String()
}
// ObservationGracePeriodEnv resolves the whether spec's observation grace period
// config comes from an env var.
func (r *OCRSpecResolver) ObservationGracePeriodEnv() bool {
return r.spec.ObservationGracePeriodEnv
}
// ContractTransmitterTransmitTimeout resolves the spec's contract transmitter transmit timeout.
func (r *OCRSpecResolver) ContractTransmitterTransmitTimeout() string {
return r.spec.ContractTransmitterTransmitTimeout.Duration().String()
}
// ContractTransmitterTransmitTimeoutEnv resolves the whether spec's
// contract transmitter transmit timeout config comes from an env var.
func (r *OCRSpecResolver) ContractTransmitterTransmitTimeoutEnv() bool {
return r.spec.ContractTransmitterTransmitTimeoutEnv
}
// IsBootstrapPeer resolves whether spec is a bootstrap peer.
func (r *OCRSpecResolver) IsBootstrapPeer() bool {
return r.spec.IsBootstrapPeer
}
// KeyBundleID resolves the spec's key bundle id.
func (r *OCRSpecResolver) KeyBundleID() *string {
if r.spec.EncryptedOCRKeyBundleID == nil {
return nil
}
bundleID := r.spec.EncryptedOCRKeyBundleID.String()
return &bundleID
}
// ObservationTimeout resolves the spec's observation timeout
func (r *OCRSpecResolver) ObservationTimeout() *string {
if r.spec.ObservationTimeout.Duration() == 0 {
return nil
}
timeout := r.spec.ObservationTimeout.Duration().String()
return &timeout
}
// ObservationTimeoutEnv resolves whether spec's observation timeout comes
// from an env var.
func (r *OCRSpecResolver) ObservationTimeoutEnv() bool {
return r.spec.ObservationTimeoutEnv
}
// P2PBootstrapPeers resolves the spec's p2p bootstrap peers
func (r *OCRSpecResolver) P2PBootstrapPeers() *[]string {
if len(r.spec.P2PBootstrapPeers) == 0 {
return nil
}
peers := []string(r.spec.P2PBootstrapPeers)
return &peers
}
// P2PV2Bootstrappers resolves the OCR1 spec's p2pv2 bootstrappers
func (r *OCRSpecResolver) P2PV2Bootstrappers() *[]string {
if len(r.spec.P2PV2Bootstrappers) == 0 {
return nil
}
peers := []string(r.spec.P2PV2Bootstrappers)
return &peers
}
// TransmitterAddress resolves the spec's transmitter address
func (r *OCRSpecResolver) TransmitterAddress() *string {
if r.spec.TransmitterAddress == nil {
return nil
}
addr := r.spec.TransmitterAddress.String()
return &addr
}
type OCR2SpecResolver struct {
spec job.OCR2OracleSpec
}
// BlockchainTimeout resolves the spec's blockchain timeout.
func (r *OCR2SpecResolver) BlockchainTimeout() *string {
if r.spec.BlockchainTimeout.Duration() == 0 {
return nil
}
timeout := r.spec.BlockchainTimeout.Duration().String()
return &timeout
}
// ContractID resolves the spec's contract address.
func (r *OCR2SpecResolver) ContractID() string {
return r.spec.ContractID
}
// ContractConfigConfirmations resolves the spec's confirmations config.
func (r *OCR2SpecResolver) ContractConfigConfirmations() *int32 {
if r.spec.ContractConfigConfirmations == 0 {
return nil
}
confirmations := int32(r.spec.ContractConfigConfirmations)
return &confirmations
}
// ContractConfigTrackerPollInterval resolves the spec's contract tracker poll
// interval config.
func (r *OCR2SpecResolver) ContractConfigTrackerPollInterval() *string {
if r.spec.ContractConfigTrackerPollInterval.Duration() == 0 {
return nil
}
interval := r.spec.ContractConfigTrackerPollInterval.Duration().String()
return &interval
}
// CreatedAt resolves the spec's created at timestamp.
func (r *OCR2SpecResolver) CreatedAt() graphql.Time {
return graphql.Time{Time: r.spec.CreatedAt}
}
// OcrKeyBundleID resolves the spec's key bundle id.
func (r *OCR2SpecResolver) OcrKeyBundleID() *string {
if !r.spec.OCRKeyBundleID.Valid {
return nil
}
return &r.spec.OCRKeyBundleID.String
}
// MonitoringEndpoint resolves the spec's monitoring endpoint
func (r *OCR2SpecResolver) MonitoringEndpoint() *string {
if !r.spec.MonitoringEndpoint.Valid {
return nil
}
return &r.spec.MonitoringEndpoint.String
}
// P2PV2Bootstrappers resolves the OCR2 spec's p2pv2 bootstrappers
func (r *OCR2SpecResolver) P2PV2Bootstrappers() *[]string {
if len(r.spec.P2PV2Bootstrappers) == 0 {
return nil
}
peers := []string(r.spec.P2PV2Bootstrappers)
return &peers
}
// Relay resolves the spec's relay
func (r *OCR2SpecResolver) Relay() string {
return string(r.spec.Relay)
}
// RelayConfig resolves the spec's relay config
func (r *OCR2SpecResolver) RelayConfig() gqlscalar.Map {
return gqlscalar.Map(r.spec.RelayConfig)
}
// PluginType resolves the spec's plugin type
func (r *OCR2SpecResolver) PluginType() string {
return string(r.spec.PluginType)
}
// PluginConfig resolves the spec's plugin config
func (r *OCR2SpecResolver) PluginConfig() gqlscalar.Map {
return gqlscalar.Map(r.spec.PluginConfig)
}
// TransmitterID resolves the spec's transmitter id
func (r *OCR2SpecResolver) TransmitterID() *string {
if !r.spec.TransmitterID.Valid {
return nil
}
addr := r.spec.TransmitterID.String
return &addr
}
// FeedID resolves the spec's feed ID
func (r *OCR2SpecResolver) FeedID() string {
return r.spec.FeedID.String()
}
type VRFSpecResolver struct {
spec job.VRFSpec
}
// MinIncomingConfirmations resolves the spec's min incoming confirmations.
func (r *VRFSpecResolver) MinIncomingConfirmations() int32 {
return int32(r.spec.MinIncomingConfirmations)
}
// MinIncomingConfirmations resolves the spec's min incoming confirmations.
func (r *VRFSpecResolver) MinIncomingConfirmationsEnv() bool {
return r.spec.ConfirmationsEnv
}
// CoordinatorAddress resolves the spec's coordinator address.
func (r *VRFSpecResolver) CoordinatorAddress() string {
return r.spec.CoordinatorAddress.String()
}
// CreatedAt resolves the spec's created at timestamp.
func (r *VRFSpecResolver) CreatedAt() graphql.Time {
return graphql.Time{Time: r.spec.CreatedAt}
}
// EVMChainID resolves the spec's evm chain id.
func (r *VRFSpecResolver) EVMChainID() *string {
if r.spec.EVMChainID == nil {
return nil
}
chainID := r.spec.EVMChainID.String()
return &chainID
}
// FromAddresses resolves the spec's from addresses.
func (r *VRFSpecResolver) FromAddresses() *[]string {
if len(r.spec.FromAddresses) == 0 {
return nil
}
var addresses []string
for _, a := range r.spec.FromAddresses {
addresses = append(addresses, a.Address().String())
}
return &addresses
}
// PollPeriod resolves the spec's poll period.
func (r *VRFSpecResolver) PollPeriod() string {
return r.spec.PollPeriod.String()
}
// PublicKey resolves the spec's public key.
func (r *VRFSpecResolver) PublicKey() string {
return r.spec.PublicKey.String()
}
// RequestedConfsDelay resolves the spec's requested conf delay.
func (r *VRFSpecResolver) RequestedConfsDelay() int32 {
// GraphQL doesn't support 64 bit integers, so we have to cast.
return int32(r.spec.RequestedConfsDelay)
}
// RequestTimeout resolves the spec's request timeout.
func (r *VRFSpecResolver) RequestTimeout() string {
return r.spec.RequestTimeout.String()
}
// BatchCoordinatorAddress resolves the spec's batch coordinator address.
func (r *VRFSpecResolver) BatchCoordinatorAddress() *string {
if r.spec.BatchCoordinatorAddress == nil {
return nil
}
addr := r.spec.BatchCoordinatorAddress.String()
return &addr
}
// BatchFulfillmentEnabled resolves the spec's batch fulfillment enabled flag.
func (r *VRFSpecResolver) BatchFulfillmentEnabled() bool {
return r.spec.BatchFulfillmentEnabled
}
// BatchFulfillmentGasMultiplier resolves the spec's batch fulfillment gas multiplier.
func (r *VRFSpecResolver) BatchFulfillmentGasMultiplier() float64 {
return float64(r.spec.BatchFulfillmentGasMultiplier)
}
// ChunkSize resolves the spec's chunk size.
func (r *VRFSpecResolver) ChunkSize() int32 {
return int32(r.spec.ChunkSize)
}
// BackoffInitialDelay resolves the spec's backoff initial delay.
func (r *VRFSpecResolver) BackoffInitialDelay() string {
return r.spec.BackoffInitialDelay.String()
}
// BackoffMaxDelay resolves the spec's backoff max delay.
func (r *VRFSpecResolver) BackoffMaxDelay() string {
return r.spec.BackoffMaxDelay.String()
}
// GasLanePrice resolves the spec's gas lane price.
func (r *VRFSpecResolver) GasLanePrice() *string {
if r.spec.GasLanePrice == nil {
return nil
}
gasLanePriceGWei := r.spec.GasLanePrice.String()
return &gasLanePriceGWei
}
type WebhookSpecResolver struct {
spec job.WebhookSpec
}
// CreatedAt resolves the spec's created at timestamp.
func (r *WebhookSpecResolver) CreatedAt() graphql.Time {
return graphql.Time{Time: r.spec.CreatedAt}
}
// BlockhashStoreSpecResolver exposes the job parameters for a BlockhashStoreSpec.
type BlockhashStoreSpecResolver struct {
spec job.BlockhashStoreSpec
}
// CoordinatorV1Address returns the address of the V1 Coordinator, if any.
func (b *BlockhashStoreSpecResolver) CoordinatorV1Address() *string {
if b.spec.CoordinatorV1Address == nil {
return nil
}
addr := b.spec.CoordinatorV1Address.String()
return &addr
}
// CoordinatorV2Address returns the address of the V2 Coordinator, if any.
func (b *BlockhashStoreSpecResolver) CoordinatorV2Address() *string {
if b.spec.CoordinatorV2Address == nil {
return nil
}
addr := b.spec.CoordinatorV2Address.String()
return &addr
}
// WaitBlocks returns the job's WaitBlocks param.
func (b *BlockhashStoreSpecResolver) WaitBlocks() int32 {
return b.spec.WaitBlocks
}
// LookbackBlocks returns the job's LookbackBlocks param.
func (b *BlockhashStoreSpecResolver) LookbackBlocks() int32 {
return b.spec.LookbackBlocks
}
// BlockhashStoreAddress returns the job's BlockhashStoreAddress param.
func (b *BlockhashStoreSpecResolver) BlockhashStoreAddress() string {
return b.spec.BlockhashStoreAddress.String()
}
// PollPeriod return's the job's PollPeriod param.
func (b *BlockhashStoreSpecResolver) PollPeriod() string {
return b.spec.PollPeriod.String()
}
// RunTimeout return's the job's RunTimeout param.
func (b *BlockhashStoreSpecResolver) RunTimeout() string {
return b.spec.RunTimeout.String()
}
// EVMChainID returns the job's EVMChainID param.
func (b *BlockhashStoreSpecResolver) EVMChainID() *string {
chainID := b.spec.EVMChainID.String()
return &chainID
}
// FromAddress returns the job's FromAddress param, if any.
func (b *BlockhashStoreSpecResolver) FromAddresses() *[]string {
if b.spec.FromAddresses == nil {
return nil
}
var addresses []string
for _, a := range b.spec.FromAddresses {
addresses = append(addresses, a.Address().String())
}
return &addresses
}
// CreatedAt resolves the spec's created at timestamp.
func (b *BlockhashStoreSpecResolver) CreatedAt() graphql.Time {
return graphql.Time{Time: b.spec.CreatedAt}
}
// BlockHeaderFeederSpecResolver exposes the job parameters for a BlockHeaderFeederSpec.
type BlockHeaderFeederSpecResolver struct {
spec job.BlockHeaderFeederSpec
}
// CoordinatorV1Address returns the address of the V1 Coordinator, if any.
func (b *BlockHeaderFeederSpecResolver) CoordinatorV1Address() *string {
if b.spec.CoordinatorV1Address == nil {
return nil
}
addr := b.spec.CoordinatorV1Address.String()
return &addr
}
// CoordinatorV2Address returns the address of the V2 Coordinator, if any.
func (b *BlockHeaderFeederSpecResolver) CoordinatorV2Address() *string {
if b.spec.CoordinatorV2Address == nil {
return nil
}
addr := b.spec.CoordinatorV2Address.String()
return &addr
}
// WaitBlocks returns the job's WaitBlocks param.
func (b *BlockHeaderFeederSpecResolver) WaitBlocks() int32 {
return b.spec.WaitBlocks
}
// LookbackBlocks returns the job's LookbackBlocks param.
func (b *BlockHeaderFeederSpecResolver) LookbackBlocks() int32 {
return b.spec.LookbackBlocks
}
// BlockhashStoreAddress returns the job's BlockhashStoreAddress param.
func (b *BlockHeaderFeederSpecResolver) BlockhashStoreAddress() string {
return b.spec.BlockhashStoreAddress.String()
}
// BatchBlockhashStoreAddress returns the job's BatchBlockhashStoreAddress param.
func (b *BlockHeaderFeederSpecResolver) BatchBlockhashStoreAddress() string {
return b.spec.BatchBlockhashStoreAddress.String()
}
// PollPeriod return's the job's PollPeriod param.
func (b *BlockHeaderFeederSpecResolver) PollPeriod() string {
return b.spec.PollPeriod.String()
}
// RunTimeout return's the job's RunTimeout param.
func (b *BlockHeaderFeederSpecResolver) RunTimeout() string {
return b.spec.RunTimeout.String()
}
// EVMChainID returns the job's EVMChainID param.
func (b *BlockHeaderFeederSpecResolver) EVMChainID() *string {
chainID := b.spec.EVMChainID.String()
return &chainID
}
// FromAddress returns the job's FromAddress param, if any.
func (b *BlockHeaderFeederSpecResolver) FromAddresses() *[]string {
if b.spec.FromAddresses == nil {
return nil
}
var addresses []string
for _, a := range b.spec.FromAddresses {
addresses = append(addresses, a.Address().String())
}
return &addresses
}
// GetBlockhashesBatchSize returns the job's GetBlockhashesBatchSize param.
func (b *BlockHeaderFeederSpecResolver) GetBlockhashesBatchSize() int32 {
return int32(b.spec.GetBlockhashesBatchSize)
}
// StoreBlockhashesBatchSize returns the job's StoreBlockhashesBatchSize param.
func (b *BlockHeaderFeederSpecResolver) StoreBlockhashesBatchSize() int32 {
return int32(b.spec.StoreBlockhashesBatchSize)
}
// CreatedAt resolves the spec's created at timestamp.
func (b *BlockHeaderFeederSpecResolver) CreatedAt() graphql.Time {
return graphql.Time{Time: b.spec.CreatedAt}
}
// BootstrapSpecResolver defines the Bootstrap Spec Resolver
type BootstrapSpecResolver struct {
spec job.BootstrapSpec
}
// ID resolves the Bootstrap spec ID
func (r *BootstrapSpecResolver) ID() graphql.ID {
return graphql.ID(stringutils.FromInt32(r.spec.ID))
}
// ContractID resolves the spec's contract address
func (r *BootstrapSpecResolver) ContractID() string {
return r.spec.ContractID
}
// Relay resolves the spec's relay
func (r *BootstrapSpecResolver) Relay() string {
return string(r.spec.Relay)
}
// RelayConfig resolves the spec's relay config
func (r *BootstrapSpecResolver) RelayConfig() gqlscalar.Map {
return gqlscalar.Map(r.spec.RelayConfig)
}
// MonitoringEndpoint resolves the spec's monitoring endpoint
func (r *BootstrapSpecResolver) MonitoringEndpoint() *string {
if !r.spec.MonitoringEndpoint.Valid {
return nil
}
return &r.spec.MonitoringEndpoint.String
}
// BlockchainTimeout resolves the spec's blockchain timeout
func (r *BootstrapSpecResolver) BlockchainTimeout() *string {
if r.spec.BlockchainTimeout.Duration() == 0 {
return nil
}
interval := r.spec.BlockchainTimeout.Duration().String()
return &interval
}
// ContractConfigTrackerPollInterval resolves the spec's contract tracker poll
// interval config.
func (r *BootstrapSpecResolver) ContractConfigTrackerPollInterval() *string {
if r.spec.ContractConfigTrackerPollInterval.Duration() == 0 {
return nil
}
interval := r.spec.ContractConfigTrackerPollInterval.Duration().String()
return &interval
}
// ContractConfigConfirmations resolves the spec's confirmations config.
func (r *BootstrapSpecResolver) ContractConfigConfirmations() *int32 {
if r.spec.ContractConfigConfirmations == 0 {
return nil
}
confirmations := int32(r.spec.ContractConfigConfirmations)
return &confirmations
}
// CreatedAt resolves the spec's created at timestamp.
func (r *BootstrapSpecResolver) CreatedAt() graphql.Time {
return graphql.Time{Time: r.spec.CreatedAt}
}