Skip to content

Commit 2ebe6eb

Browse files
authored
Aptos Cap Hasher Type (#22153)
1 parent f493a85 commit 2ebe6eb

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

core/capabilities/remote/executable/hasher.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"google.golang.org/protobuf/types/known/anypb"
1111

1212
"github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb"
13+
aptoscappb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/v2/chain-capabilities/aptos"
1314
evmcappb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/v2/chain-capabilities/evm"
1415
solcappb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/v2/chain-capabilities/solana"
1516
"github.com/smartcontractkit/chainlink/v2/core/capabilities/remote/types"
@@ -128,6 +129,20 @@ func (r *writeReportExcludeSignaturesHasher) Hash(msg *types.MessageBody) ([32]b
128129
return [32]byte{}, errors.New("WriteReportRequest.Report is nil")
129130
}
130131

132+
wrReq.Report.Sigs = nil // exclude signatures from hash
133+
payload, err = anypb.New(&wrReq)
134+
if err != nil {
135+
return [32]byte{}, fmt.Errorf("failed to marshal WriteReportRequest back to anypb: %w", err)
136+
}
137+
case writeReportFamilyAptos:
138+
var wrReq aptoscappb.WriteReportRequest
139+
if err = req.Payload.UnmarshalTo(&wrReq); err != nil {
140+
return [32]byte{}, fmt.Errorf("failed to unmarshal Payload to WriteReportRequest: %w", err)
141+
}
142+
if wrReq.Report == nil {
143+
return [32]byte{}, errors.New("WriteReportRequest.Report is nil")
144+
}
145+
131146
wrReq.Report.Sigs = nil // exclude signatures from hash
132147
payload, err = anypb.New(&wrReq)
133148
if err != nil {
@@ -151,6 +166,7 @@ type writeReportFamily string
151166
var (
152167
writeReportFamilyEVM writeReportFamily = "evm"
153168
writeReportFamilySolana writeReportFamily = "solana"
169+
writeReportFamilyAptos writeReportFamily = "aptos"
154170
)
155171

156172
func getWriteReportFamily(msg *types.MessageBody) (writeReportFamily, error) {
@@ -164,9 +180,11 @@ func getWriteReportFamily(msg *types.MessageBody) (writeReportFamily, error) {
164180
return writeReportFamilyEVM, nil
165181
case "solana":
166182
return writeReportFamilySolana, nil
183+
case "aptos":
184+
return writeReportFamilyAptos, nil
167185
}
168186

169-
return "", errors.New("report family is unknown, available families: evm, solana")
187+
return "", errors.New("report family is unknown, available families: evm, solana, aptos")
170188
}
171189

172190
func NewWriteReportExcludeSignaturesHasher() types.MessageHasher {

0 commit comments

Comments
 (0)