@@ -9,9 +9,13 @@ import (
99
1010 "github.com/ethereum/go-ethereum/accounts/abi"
1111 v1 "github.com/smartcontractkit/data-streams-sdk/go/report/v1"
12+ v10 "github.com/smartcontractkit/data-streams-sdk/go/report/v10"
1213 v2 "github.com/smartcontractkit/data-streams-sdk/go/report/v2"
1314 v3 "github.com/smartcontractkit/data-streams-sdk/go/report/v3"
1415 v4 "github.com/smartcontractkit/data-streams-sdk/go/report/v4"
16+ v5 "github.com/smartcontractkit/data-streams-sdk/go/report/v5"
17+ v6 "github.com/smartcontractkit/data-streams-sdk/go/report/v6"
18+ v7 "github.com/smartcontractkit/data-streams-sdk/go/report/v7"
1519 v8 "github.com/smartcontractkit/data-streams-sdk/go/report/v8"
1620 v9 "github.com/smartcontractkit/data-streams-sdk/go/report/v9"
1721)
@@ -73,6 +77,48 @@ func TestReport(t *testing.T) {
7377 t .Errorf ("expected: %#v, got: %#v" , v4Report , rv4 )
7478 }
7579
80+ b , err = schema .Pack (v5Report .ReportContext , v5Report .ReportBlob , v5Report .RawRs , v5Report .RawSs , v5Report .RawVs )
81+ if err != nil {
82+ t .Errorf ("failed to encode report: %s" , err )
83+ }
84+
85+ rv5 , err := Decode [v5.Data ](b )
86+ if err != nil {
87+ t .Errorf ("failed to decode report: %s" , err )
88+ }
89+
90+ if ! reflect .DeepEqual (v5Report , rv5 ) {
91+ t .Errorf ("expected: %#v, got: %#v" , v5Report , rv5 )
92+ }
93+
94+ b , err = schema .Pack (v6Report .ReportContext , v6Report .ReportBlob , v6Report .RawRs , v6Report .RawSs , v6Report .RawVs )
95+ if err != nil {
96+ t .Errorf ("failed to encode report: %s" , err )
97+ }
98+
99+ rv6 , err := Decode [v6.Data ](b )
100+ if err != nil {
101+ t .Errorf ("failed to decode report: %s" , err )
102+ }
103+
104+ if ! reflect .DeepEqual (v6Report , rv6 ) {
105+ t .Errorf ("expected: %#v, got: %#v" , v6Report , rv6 )
106+ }
107+
108+ b , err = schema .Pack (v7Report .ReportContext , v7Report .ReportBlob , v7Report .RawRs , v7Report .RawSs , v7Report .RawVs )
109+ if err != nil {
110+ t .Errorf ("failed to encode report: %s" , err )
111+ }
112+
113+ rv7 , err := Decode [v7.Data ](b )
114+ if err != nil {
115+ t .Errorf ("failed to decode report: %s" , err )
116+ }
117+
118+ if ! reflect .DeepEqual (v7Report , rv7 ) {
119+ t .Errorf ("expected: %#v, got: %#v" , v7Report , rv7 )
120+ }
121+
76122 b , err = schema .Pack (v8Report .ReportContext , v8Report .ReportBlob , v8Report .RawRs , v8Report .RawSs , v8Report .RawVs )
77123 if err != nil {
78124 t .Errorf ("failed to encode report: %s" , err )
@@ -97,9 +143,23 @@ func TestReport(t *testing.T) {
97143 t .Errorf ("failed to decode report: %s" , err )
98144 }
99145
100- if ! reflect .DeepEqual (v8Report , rv8 ) {
146+ if ! reflect .DeepEqual (v9Report , rv9 ) {
101147 t .Errorf ("expected: %#v, got: %#v" , v9Report , rv9 )
102148 }
149+
150+ b , err = schema .Pack (v10Report .ReportContext , v10Report .ReportBlob , v10Report .RawRs , v10Report .RawSs , v10Report .RawVs )
151+ if err != nil {
152+ t .Errorf ("failed to encode report: %s" , err )
153+ }
154+
155+ rv10 , err := Decode [v10.Data ](b )
156+ if err != nil {
157+ t .Errorf ("failed to decode report: %s" , err )
158+ }
159+
160+ if ! reflect .DeepEqual (v10Report , rv10 ) {
161+ t .Errorf ("expected: %#v, got: %#v" , v10Report , rv10 )
162+ }
103163}
104164
105165var v1Report = & Report [v1.Data ]{
@@ -138,6 +198,33 @@ var v4Report = &Report[v4.Data]{
138198 RawVs : [32 ]uint8 {00 , 01 , 10 , 74 , 67 , 29 , 24 , 17 , 12 , 18 , 22 , 11 , 69 , 11 , 63 , 86 , 12 , 86 , 23 , 58 , 13 , 53 , 29 , 12 , 17 , 10 , 17 , 12 , 63 , 27 , 12 , 14 },
139199}
140200
201+ var v5Report = & Report [v5.Data ]{
202+ Data : v5Data ,
203+ ReportContext : [3 ][32 ]uint8 {},
204+ ReportBlob : mustPackData (v5Data ),
205+ RawRs : [][32 ]uint8 {{00 , 01 , 10 , 74 , 67 , 29 , 24 , 17 , 12 , 18 , 22 , 11 , 69 , 11 , 63 , 86 , 12 , 86 , 23 , 58 , 13 , 53 , 29 , 12 , 17 , 10 , 17 , 12 , 63 , 27 , 12 , 14 }},
206+ RawSs : [][32 ]uint8 {{01 , 02 , 10 , 73 , 65 , 19 , 14 , 27 , 42 , 48 , 52 , 18 , 39 , 116 , 67 , 85 , 13 , 82 , 33 , 48 , 23 , 33 , 49 , 32 , 67 , 50 , 37 , 32 , 63 , 77 , 14 , 64 }},
207+ RawVs : [32 ]uint8 {00 , 01 , 10 , 74 , 67 , 29 , 24 , 17 , 12 , 18 , 22 , 11 , 69 , 11 , 63 , 86 , 12 , 86 , 23 , 58 , 13 , 53 , 29 , 12 , 17 , 10 , 17 , 12 , 63 , 27 , 12 , 14 },
208+ }
209+
210+ var v6Report = & Report [v6.Data ]{
211+ Data : v6Data ,
212+ ReportContext : [3 ][32 ]uint8 {},
213+ ReportBlob : mustPackData (v6Data ),
214+ RawRs : [][32 ]uint8 {{00 , 01 , 10 , 74 , 67 , 29 , 24 , 17 , 12 , 18 , 22 , 11 , 69 , 11 , 63 , 86 , 12 , 86 , 23 , 58 , 13 , 53 , 29 , 12 , 17 , 10 , 17 , 12 , 63 , 27 , 12 , 14 }},
215+ RawSs : [][32 ]uint8 {{01 , 02 , 10 , 73 , 65 , 19 , 14 , 27 , 42 , 48 , 52 , 18 , 39 , 116 , 67 , 85 , 13 , 82 , 33 , 48 , 23 , 33 , 49 , 32 , 67 , 50 , 37 , 32 , 63 , 77 , 14 , 64 }},
216+ RawVs : [32 ]uint8 {00 , 01 , 10 , 74 , 67 , 29 , 24 , 17 , 12 , 18 , 22 , 11 , 69 , 11 , 63 , 86 , 12 , 86 , 23 , 58 , 13 , 53 , 29 , 12 , 17 , 10 , 17 , 12 , 63 , 27 , 12 , 14 },
217+ }
218+
219+ var v7Report = & Report [v7.Data ]{
220+ Data : v7Data ,
221+ ReportContext : [3 ][32 ]uint8 {},
222+ ReportBlob : mustPackData (v7Data ),
223+ RawRs : [][32 ]uint8 {{00 , 01 , 10 , 74 , 67 , 29 , 24 , 17 , 12 , 18 , 22 , 11 , 69 , 11 , 63 , 86 , 12 , 86 , 23 , 58 , 13 , 53 , 29 , 12 , 17 , 10 , 17 , 12 , 63 , 27 , 12 , 14 }},
224+ RawSs : [][32 ]uint8 {{01 , 02 , 10 , 73 , 65 , 19 , 14 , 27 , 42 , 48 , 52 , 18 , 39 , 116 , 67 , 85 , 13 , 82 , 33 , 48 , 23 , 33 , 49 , 32 , 67 , 50 , 37 , 32 , 63 , 77 , 14 , 64 }},
225+ RawVs : [32 ]uint8 {00 , 01 , 10 , 74 , 67 , 29 , 24 , 17 , 12 , 18 , 22 , 11 , 69 , 11 , 63 , 86 , 12 , 86 , 23 , 58 , 13 , 53 , 29 , 12 , 17 , 10 , 17 , 12 , 63 , 27 , 12 , 14 },
226+ }
227+
141228var v8Report = & Report [v8.Data ]{
142229 Data : v8Data ,
143230 ReportContext : [3 ][32 ]uint8 {},
@@ -156,6 +243,15 @@ var v9Report = &Report[v9.Data]{
156243 RawVs : [32 ]uint8 {00 , 01 , 10 , 74 , 67 , 29 , 24 , 17 , 12 , 18 , 22 , 11 , 69 , 11 , 63 , 86 , 12 , 86 , 23 , 58 , 13 , 53 , 29 , 12 , 17 , 10 , 17 , 12 , 63 , 27 , 12 , 14 },
157244}
158245
246+ var v10Report = & Report [v10.Data ]{
247+ Data : v10Data ,
248+ ReportContext : [3 ][32 ]uint8 {},
249+ ReportBlob : mustPackData (v10Data ),
250+ RawRs : [][32 ]uint8 {{00 , 01 , 10 , 74 , 67 , 29 , 24 , 17 , 12 , 18 , 22 , 11 , 69 , 11 , 63 , 86 , 12 , 86 , 23 , 58 , 13 , 53 , 29 , 12 , 17 , 10 , 17 , 12 , 63 , 27 , 12 , 14 }},
251+ RawSs : [][32 ]uint8 {{01 , 02 , 10 , 73 , 65 , 19 , 14 , 27 , 42 , 48 , 52 , 18 , 39 , 116 , 67 , 85 , 13 , 82 , 33 , 48 , 23 , 33 , 49 , 32 , 67 , 50 , 37 , 32 , 63 , 77 , 14 , 64 }},
252+ RawVs : [32 ]uint8 {00 , 01 , 10 , 74 , 67 , 29 , 24 , 17 , 12 , 18 , 22 , 11 , 69 , 11 , 63 , 86 , 12 , 86 , 23 , 58 , 13 , 53 , 29 , 12 , 17 , 10 , 17 , 12 , 63 , 27 , 12 , 14 },
253+ }
254+
159255var v1Data = v1.Data {
160256 FeedID : [32 ]uint8 {00 , 01 , 107 , 74 , 167 , 229 , 124 , 167 , 182 , 138 , 225 , 191 , 69 , 101 , 63 , 86 , 182 , 86 , 253 , 58 , 163 , 53 , 239 , 127 , 174 , 105 , 107 , 102 , 63 , 27 , 132 , 114 },
161257 ObservationsTimestamp : uint32 (time .Now ().Unix ()),
@@ -201,6 +297,42 @@ var v4Data = v4.Data{
201297 MarketStatus : v4 .MarketStatusOpen ,
202298}
203299
300+ var v5Data = v5.Data {
301+ FeedID : [32 ]uint8 {00 , 5 , 107 , 74 , 167 , 229 , 124 , 167 , 182 , 138 , 225 , 191 , 69 , 101 , 63 , 86 , 182 , 86 , 253 , 58 , 163 , 53 , 239 , 127 , 174 , 105 , 107 , 102 , 63 , 27 , 132 , 114 },
302+ ValidFromTimestamp : uint32 (time .Now ().Unix ()),
303+ ObservationsTimestamp : uint32 (time .Now ().Unix ()),
304+ NativeFee : big .NewInt (10 ),
305+ LinkFee : big .NewInt (10 ),
306+ ExpiresAt : uint32 (time .Now ().Unix ()) + 100 ,
307+ Rate : big .NewInt (550 ),
308+ Timestamp : uint32 (time .Now ().Unix ()),
309+ Duration : uint32 (86400 ),
310+ }
311+
312+ var v6Data = v6.Data {
313+ FeedID : [32 ]uint8 {00 , 6 , 107 , 74 , 167 , 229 , 124 , 167 , 182 , 138 , 225 , 191 , 69 , 101 , 63 , 86 , 182 , 86 , 253 , 58 , 163 , 53 , 239 , 127 , 174 , 105 , 107 , 102 , 63 , 27 , 132 , 114 },
314+ ValidFromTimestamp : uint32 (time .Now ().Unix ()),
315+ ObservationsTimestamp : uint32 (time .Now ().Unix ()),
316+ NativeFee : big .NewInt (10 ),
317+ LinkFee : big .NewInt (10 ),
318+ ExpiresAt : uint32 (time .Now ().Unix ()) + 100 ,
319+ Price : big .NewInt (600 ),
320+ Price2 : big .NewInt (601 ),
321+ Price3 : big .NewInt (602 ),
322+ Price4 : big .NewInt (603 ),
323+ Price5 : big .NewInt (604 ),
324+ }
325+
326+ var v7Data = v7.Data {
327+ FeedID : [32 ]uint8 {00 , 7 , 107 , 74 , 167 , 229 , 124 , 167 , 182 , 138 , 225 , 191 , 69 , 101 , 63 , 86 , 182 , 86 , 253 , 58 , 163 , 53 , 239 , 127 , 174 , 105 , 107 , 102 , 63 , 27 , 132 , 114 },
328+ ValidFromTimestamp : uint32 (time .Now ().Unix ()),
329+ ObservationsTimestamp : uint32 (time .Now ().Unix ()),
330+ NativeFee : big .NewInt (10 ),
331+ LinkFee : big .NewInt (10 ),
332+ ExpiresAt : uint32 (time .Now ().Unix ()) + 100 ,
333+ ExchangeRate : big .NewInt (700 ),
334+ }
335+
204336var v8Data = v8.Data {
205337 FeedID : [32 ]uint8 {00 , 8 , 107 , 74 , 167 , 229 , 124 , 167 , 182 , 138 , 225 , 191 , 69 , 101 , 63 , 86 , 182 , 86 , 253 , 58 , 163 , 53 , 239 , 127 , 174 , 105 , 107 , 102 , 63 , 27 , 132 , 114 },
206338 ValidFromTimestamp : uint32 (time .Now ().Unix ()),
@@ -226,6 +358,22 @@ var v9Data = v9.Data{
226358 Ripcord : 108 ,
227359}
228360
361+ var v10Data = v10.Data {
362+ FeedID : [32 ]uint8 {00 , 10 , 107 , 74 , 167 , 229 , 124 , 167 , 182 , 138 , 225 , 191 , 69 , 101 , 63 , 86 , 182 , 86 , 253 , 58 , 163 , 53 , 239 , 127 , 174 , 105 , 107 , 102 , 63 , 27 , 132 , 114 },
363+ ValidFromTimestamp : uint32 (time .Now ().Unix ()),
364+ ObservationsTimestamp : uint32 (time .Now ().Unix ()),
365+ NativeFee : big .NewInt (10 ),
366+ LinkFee : big .NewInt (10 ),
367+ ExpiresAt : uint32 (time .Now ().Unix ()) + 100 ,
368+ LastUpdateTimestamp : uint64 (time .Now ().UnixNano () - int64 (10 * time .Second )),
369+ Price : big .NewInt (1000 ),
370+ MarketStatus : 1 ,
371+ CurrentMultiplier : big .NewInt (100 ),
372+ NewMultiplier : big .NewInt (101 ),
373+ ActivationDateTime : uint32 (time .Now ().Unix ()) + 200 ,
374+ TokenizedPrice : big .NewInt (1001 ),
375+ }
376+
229377func mustPackData (d interface {}) []byte {
230378 var args []interface {}
231379 var dataSchema abi.Arguments
@@ -280,6 +428,45 @@ func mustPackData(d interface{}) []byte {
280428 v .BenchmarkPrice ,
281429 v .MarketStatus ,
282430 }
431+ case v5.Data :
432+ dataSchema = v5 .Schema ()
433+ args = []interface {}{
434+ v .FeedID ,
435+ v .ValidFromTimestamp ,
436+ v .ObservationsTimestamp ,
437+ v .NativeFee ,
438+ v .LinkFee ,
439+ v .ExpiresAt ,
440+ v .Rate ,
441+ v .Timestamp ,
442+ v .Duration ,
443+ }
444+ case v6.Data :
445+ dataSchema = v6 .Schema ()
446+ args = []interface {}{
447+ v .FeedID ,
448+ v .ValidFromTimestamp ,
449+ v .ObservationsTimestamp ,
450+ v .NativeFee ,
451+ v .LinkFee ,
452+ v .ExpiresAt ,
453+ v .Price ,
454+ v .Price2 ,
455+ v .Price3 ,
456+ v .Price4 ,
457+ v .Price5 ,
458+ }
459+ case v7.Data :
460+ dataSchema = v7 .Schema ()
461+ args = []interface {}{
462+ v .FeedID ,
463+ v .ValidFromTimestamp ,
464+ v .ObservationsTimestamp ,
465+ v .NativeFee ,
466+ v .LinkFee ,
467+ v .ExpiresAt ,
468+ v .ExchangeRate ,
469+ }
283470 case v8.Data :
284471 dataSchema = v8 .Schema ()
285472 args = []interface {}{
@@ -307,6 +494,23 @@ func mustPackData(d interface{}) []byte {
307494 v .Aum ,
308495 v .Ripcord ,
309496 }
497+ case v10.Data :
498+ dataSchema = v10 .Schema ()
499+ args = []interface {}{
500+ v .FeedID ,
501+ v .ValidFromTimestamp ,
502+ v .ObservationsTimestamp ,
503+ v .NativeFee ,
504+ v .LinkFee ,
505+ v .ExpiresAt ,
506+ v .LastUpdateTimestamp ,
507+ v .Price ,
508+ v .MarketStatus ,
509+ v .CurrentMultiplier ,
510+ v .NewMultiplier ,
511+ v .ActivationDateTime ,
512+ v .TokenizedPrice ,
513+ }
310514 default :
311515 panic (fmt .Sprintf ("invalid type to pack: %#v" , v ))
312516 }
0 commit comments