Skip to content

Commit

Permalink
Sign by address
Browse files Browse the repository at this point in the history
  • Loading branch information
Vizualni committed May 12, 2022
1 parent 3ea334c commit a8008dd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions signing/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"

"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// Signer is an interface that can sign byte slice and return a signature and
Expand Down Expand Up @@ -35,6 +36,15 @@ func KeyringSigner(k keyring.Signer, uid string) SignerFnc {
})
}

// KeyringSigner returns a function that implements the Signer interface, which
// will sign a byte slice given a keyring and a key's address..
func KeyringSignerByAddress(k keyring.Signer, address sdk.Address) SignerFnc {
return SignerFnc(func(b []byte) ([]byte, error) {
signedBytes, _, err := k.SignByAddress(address, b)
return signedBytes, err
})
}

type SerializeFnc func(any) ([]byte, error)

func (fnc SerializeFnc) DeterministicSerialize(msg any) ([]byte, error) {
Expand Down

0 comments on commit a8008dd

Please sign in to comment.