Skip to content

Commit

Permalink
use goware/logger interface
Browse files Browse the repository at this point in the history
  • Loading branch information
pkieltyka committed Jul 6, 2023
1 parent 116e182 commit 339a843
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
v1 "github.com/0xsequence/go-sequence/core/v1"
v2 "github.com/0xsequence/go-sequence/core/v2"
"github.com/0xsequence/go-sequence/eip6492"
"github.com/goware/logger"
)

// Utility functions to use with ethauth, in order to validate Sequence Wallet signatures, encoded
Expand All @@ -32,7 +33,7 @@ func V2ValidateSequenceAccountProof() ethauth.ValidatorFunc {
return GenericValidateSequenceAccountProofWith[*v2.WalletConfig](V2SequenceContext())
}

func ValidateSequenceAccountProof() ethauth.ValidatorFunc {
func ValidateSequenceAccountProof(log logger.Logger) ethauth.ValidatorFunc {
eip6492Validator := EIP6492ValidateSignature()
legacyValidator := V2ValidateSequenceAccountProof()

Expand All @@ -51,7 +52,7 @@ func ValidateSequenceAccountProof() ethauth.ValidatorFunc {
}

if legacyIsValid {
fmt.Printf("WARNING: Legacy signature validation used, please upgrade to EIP-6492: %s, %s\n", proof.Address, proof.Signature)
log.Errorf("WARNING: Legacy signature validation used, please upgrade to EIP-6492: %s, %s", proof.Address, proof.Signature)
}

return legacyIsValid, addr, nil
Expand Down
5 changes: 3 additions & 2 deletions signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
v1 "github.com/0xsequence/go-sequence/core/v1"
v2 "github.com/0xsequence/go-sequence/core/v2"
"github.com/0xsequence/go-sequence/eip6492"
"github.com/goware/logger"
)

func Sign[C core.WalletConfig](wallet *Wallet[C], input common.Hash) ([]byte, core.Signature[C], error) {
Expand Down Expand Up @@ -154,7 +155,7 @@ func GeneralIsValidSignature(walletAddress common.Address, digest common.Hash, s
return isValid, nil
}

func IsValidSignature(walletAddress common.Address, digest common.Hash, seqSig []byte, walletContexts WalletContexts, chainID *big.Int, provider *ethrpc.Provider) (bool, error) {
func IsValidSignature(log logger.Logger, walletAddress common.Address, digest common.Hash, seqSig []byte, walletContexts WalletContexts, chainID *big.Int, provider *ethrpc.Provider) (bool, error) {
eip6492isValid, _ := eip6492.ValidateEIP6492Offchain(provider, walletAddress, digest, seqSig)
if eip6492isValid {
return true, nil
Expand All @@ -169,7 +170,7 @@ func IsValidSignature(walletAddress common.Address, digest common.Hash, seqSig [
}

if generalIsValid {
fmt.Printf("WARNING: Legacy signature validation used, please upgrade to EIP-6492: %s, %s, %s\n", walletAddress, digest, common.Bytes2Hex(seqSig))
log.Errorf("WARNING: Legacy signature validation used, please upgrade to EIP-6492: %s, %s, %s", walletAddress, digest, common.Bytes2Hex(seqSig))
}

return generalIsValid, nil
Expand Down

0 comments on commit 339a843

Please sign in to comment.