Skip to content

Commit

Permalink
chore: linter complains. Avoid unneded data copy in a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
x1m3 committed Dec 3, 2024
1 parent 14457f3 commit 09de990
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions protocol/payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,16 @@ type PaymentProofItem interface {

// UnmarshalJSON unmarshal the PaymentRequestInfoData from JSON.
func (p *PaymentProof) UnmarshalJSON(data []byte) error {
var col []EthereumEip712Signature2021
var col []*EthereumEip712Signature2021
if err := json.Unmarshal(data, &col); err != nil {
var single EthereumEip712Signature2021
if err := json.Unmarshal(data, &single); err != nil {
return fmt.Errorf("failed to unmarshal EthereumEip712Signature2021Col: %w", err)

Check failure on line 223 in protocol/payment.go

View workflow job for this annotation

GitHub Actions / lint

undefined: dataType

Check failure on line 223 in protocol/payment.go

View workflow job for this annotation

GitHub Actions / lint

undefined: Eip712SignatureProofType

Check failure on line 223 in protocol/payment.go

View workflow job for this annotation

GitHub Actions / lint

undefined: dataType

Check failure on line 223 in protocol/payment.go

View workflow job for this annotation

GitHub Actions / lint

undefined: Eip712SignatureProofType
}

Check failure on line 224 in protocol/payment.go

View workflow job for this annotation

GitHub Actions / lint

undefined: eip712Signature

Check failure on line 224 in protocol/payment.go

View workflow job for this annotation

GitHub Actions / lint

cannot use data (variable of type []EthereumEip712Signature2021) as PaymentProofItem value in array or slice literal: []EthereumEip712Signature2021 does not implement PaymentProofItem (missing method PaymentProofItem)) (typecheck)

Check failure on line 224 in protocol/payment.go

View workflow job for this annotation

GitHub Actions / lint

undefined: eip712Signature

Check failure on line 224 in protocol/payment.go

View workflow job for this annotation

GitHub Actions / lint

cannot use data (variable of type []EthereumEip712Signature2021) as PaymentProofItem value in array or slice literal: []EthereumEip712Signature2021 does not implement PaymentProofItem (missing method PaymentProofItem)) (typecheck)
col = append(col, single)
col = append(col, &single)
}
for _, item := range col {
*p = append(*p, item)
*p = append(*p, *item)
}
return nil
}
Expand All @@ -245,6 +245,7 @@ type EthereumEip712Signature2021 struct {
Eip712 Eip712Data `json:"eip712"`
}

// PaymentProofItem implements the PaymentProofItem interface.
func (e EthereumEip712Signature2021) PaymentProofItem() verifiable.ProofType {
return document.EthereumEip712SignatureProof2021Type
}
Expand Down

0 comments on commit 09de990

Please sign in to comment.