Skip to content

Commit

Permalink
fix: PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
joanestebanr committed Dec 20, 2024
1 parent 78724d2 commit 8113e91
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
22 changes: 8 additions & 14 deletions agglayer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,7 @@ func (b *BridgeExit) UnmarshalJSON(data []byte) error {
Metadata interface{} `json:"metadata"`
}{}

err := json.Unmarshal(data, &aux)
if err != nil {
if err := json.Unmarshal(data, &aux); err != nil {
return err
}
b.LeafType = aux.LeafType
Expand Down Expand Up @@ -436,8 +435,7 @@ func (m *MerkleProof) UnmarshalJSON(data []byte) error {
Proof map[string][types.DefaultHeight]common.Hash `json:"proof"`
}{}

err := json.Unmarshal(data, &aux)
if err != nil {
if err := json.Unmarshal(data, &aux); err != nil {
return err
}
m.Root = aux.Root
Expand Down Expand Up @@ -551,8 +549,7 @@ func (c *ClaimFromMainnnet) UnmarshalJSON(data []byte) error {
L1Leaf *L1InfoTreeLeaf `json:"l1_leaf"`
} `json:"Mainnet"`
}{}
err := json.Unmarshal(data, &claimData)
if err != nil {
if err := json.Unmarshal(data, &claimData); err != nil {
return fmt.Errorf("failed to unmarshal the subobject: %w", err)
}
c.ProofLeafMER = claimData.Child.ProofLeafMER
Expand Down Expand Up @@ -616,8 +613,8 @@ func (c *ClaimFromRollup) UnmarshalJSON(data []byte) error {
L1Leaf *L1InfoTreeLeaf `json:"l1_leaf"`
} `json:"Rollup"`
}{}
err := json.Unmarshal(data, &claimData)
if err != nil {

if err := json.Unmarshal(data, &claimData); err != nil {
return fmt.Errorf("failed to unmarshal the subobject: %w", err)
}
c.ProofLeafLER = claimData.Child.ProofLeafLER
Expand Down Expand Up @@ -657,8 +654,7 @@ func (c *ClaimSelector) UnmarshalJSON(data []byte) error {
if string(data) == nullStr {
return nil
}
err := json.Unmarshal(data, &obj)
if err != nil {
if err := json.Unmarshal(data, &obj); err != nil {
return err
}
var ok bool
Expand Down Expand Up @@ -706,8 +702,7 @@ func (c *ImportedBridgeExit) UnmarshalJSON(data []byte) error {
ClaimData ClaimSelector `json:"claim_data"`
GlobalIndex *GlobalIndex `json:"global_index"`
}{}
err := json.Unmarshal(data, &aux)
if err != nil {
if err := json.Unmarshal(data, &aux); err != nil {
return err
}
c.BridgeExit = aux.BridgeExit
Expand Down Expand Up @@ -809,8 +804,7 @@ func (c *CertificateHeader) UnmarshalJSON(data []byte) error {
var agglayerErr error

for errKey, errValueRaw := range inErrDataMap {
errValueJSON, err := json.Marshal(errValueRaw)
if err != nil {
if errValueJSON, err := json.Marshal(errValueRaw); err != nil {
agglayerErr = &GenericError{
Key: errKey,
Value: fmt.Sprintf("failed to marshal the agglayer error to the JSON. Raw value: %+v\nReason: %+v",
Expand Down
3 changes: 3 additions & 0 deletions agglayer/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,9 @@ func Test_UnmarshalCertificate(t *testing.T) {
var cert SignedCertificate
err := json.Unmarshal([]byte(fullCertificateJSON), &cert)
require.NoError(t, err)
marshalData, err := json.Marshal(cert)
require.NoError(t, err)
require.JSONEq(t, fullCertificateJSON, string(marshalData))
}

func Test_UnmarshalImportedBridgeExit(t *testing.T) {
Expand Down

0 comments on commit 8113e91

Please sign in to comment.