Skip to content

Commit 2b441fb

Browse files
committed
address feedback
1 parent 486b248 commit 2b441fb

File tree

8 files changed

+306
-108
lines changed

8 files changed

+306
-108
lines changed

pkg/report/datafeeds/id.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package datafeeds
22

33
import (
4-
"bytes"
5-
"encoding/binary"
64
"encoding/hex"
75
"fmt"
86
)
@@ -92,33 +90,3 @@ func GetDecimals(dataType uint8) (uint8, bool) {
9290
// Else if the data type is not a number
9391
return 0, false
9492
}
95-
96-
func (rm Metadata) Encode() ([]byte, error) {
97-
buf := new(bytes.Buffer)
98-
err := binary.Write(buf, binary.BigEndian, rm)
99-
if err != nil {
100-
return nil, err
101-
}
102-
return buf.Bytes(), nil
103-
}
104-
105-
func (rm Metadata) Length() int {
106-
bytes, err := rm.Encode()
107-
if err != nil {
108-
return 0
109-
}
110-
return len(bytes)
111-
}
112-
113-
// Note: This should be a shared type that the OCR3 package validates as well
114-
type Metadata struct {
115-
Version uint8
116-
WorkflowExecutionID [32]byte
117-
Timestamp uint32
118-
DonID uint32
119-
DonConfigVersion uint32
120-
WorkflowCID [32]byte
121-
WorkflowName [10]byte
122-
WorkflowOwner [20]byte
123-
ReportID [2]byte
124-
}

pkg/report/datafeeds/metadata.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package datafeeds
2+
3+
import (
4+
"bytes"
5+
"encoding/binary"
6+
)
7+
8+
func (rm Metadata) Encode() ([]byte, error) {
9+
buf := new(bytes.Buffer)
10+
err := binary.Write(buf, binary.BigEndian, rm)
11+
if err != nil {
12+
return nil, err
13+
}
14+
return buf.Bytes(), nil
15+
}
16+
17+
func (rm Metadata) Length() int {
18+
bytes, err := rm.Encode()
19+
if err != nil {
20+
return 0
21+
}
22+
return len(bytes)
23+
}
24+
25+
// TODO: Unify with chainlink-common type: https://smartcontract-it.atlassian.net/browse/BCFR-1223
26+
type Metadata struct {
27+
Version uint8
28+
WorkflowExecutionID [32]byte
29+
Timestamp uint32
30+
DonID uint32
31+
DonConfigVersion uint32
32+
WorkflowCID [32]byte
33+
WorkflowName [10]byte
34+
WorkflowOwner [20]byte
35+
ReportID [2]byte
36+
}

pkg/report/datafeeds/types.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ import (
77
"github.com/ethereum/go-ethereum/accounts/abi"
88
)
99

10-
// FeedPrice represents a decoded data record with the new types.
10+
// This is ABI encoding - abi: "(bytes32 FeedID, bytes RawReport)[] Reports" (set in workflow)
11+
// Encoded with: https://github.com/smartcontractkit/chainlink/blob/develop/core/services/relay/evm/cap_encoder.go
1112
type FeedReport struct {
1213
FeedID [32]byte
13-
Price *big.Int // *big.Int is used because go-ethereum converts large uints to *big.Int.
1414
Timestamp uint32
15+
Price *big.Int // *big.Int is used because go-ethereum converts large uints to *big.Int.
1516
}
1617

1718
type Reports = []FeedReport
1819

19-
// Define the ABI schema for our tuple: (bytes32, uint224, uint32)[].
20+
// Define the ABI schema
2021
var schema = GetSchema()
2122

2223
func GetSchema() abi.Arguments {
@@ -34,8 +35,8 @@ func GetSchema() abi.Arguments {
3435
// This defines the array of tuple records.
3536
Type: mustNewType("tuple(bytes32,uint224,uint32)[]", "", []abi.ArgumentMarshaling{
3637
{Name: "feedID", Type: "bytes32"},
37-
{Name: "price", Type: "uint224"},
3838
{Name: "timestamp", Type: "uint32"},
39+
{Name: "price", Type: "uint224"},
3940
}),
4041
},
4142
})

pkg/report/pb/data-feeds/on-chain/registry/decode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func DecodeAsFeedUpdated(m *wt_msg.WriteConfirmed) ([]*FeedUpdated, error) {
3232
feedID := datafeeds.FeedID(rf.FeedID)
3333

3434
// TODO: unsure if r.Data is correct for Report
35-
msgs = append(msgs, NewFeedUpdated(m, feedID, rf.Timestamp, rf.Price, r.Data, false))
35+
msgs = append(msgs, NewFeedUpdated(m, feedID, rf.Timestamp, rf.Price, []byte{}, false))
3636
}
3737

3838
return msgs, nil

0 commit comments

Comments
 (0)