Skip to content

Commit

Permalink
Fixes padWorkflowName()
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzaldysanchez committed Dec 18, 2024
1 parent bbe318c commit 5a0f919
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/capabilities/consensus/ocr3/types/aggregator.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types

import (
"encoding/hex"
"strings"

ocrcommon "github.com/smartcontractkit/libocr/commontypes"
Expand All @@ -27,7 +28,10 @@ type Metadata struct {
// the json schema allows for a variable length string <= len(10)
// pad with trailing spaces to meet the contract requirements
func (m *Metadata) padWorkflowName() {
if len(m.WorkflowName) < 10 {
b, err := hex.DecodeString(m.WorkflowName)
if err == nil && len(b) < 10 {
m.WorkflowName = hex.EncodeToString(append(b, make([]byte, 10-len(b))...))
} else if len(m.WorkflowName) < 10 {
suffix := strings.Repeat(" ", 10-len(m.WorkflowName))
m.WorkflowName += suffix
}
Expand Down

0 comments on commit 5a0f919

Please sign in to comment.