-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsigner.go
More file actions
48 lines (37 loc) · 965 Bytes
/
signer.go
File metadata and controls
48 lines (37 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package sequence
import (
"context"
"math/big"
"github.com/0xsequence/ethkit/ethwallet"
"github.com/0xsequence/ethkit/go-ethereum/common"
)
type MessageSigner interface {
SignMessage(msg []byte) ([]byte, error)
}
type DigestSigner interface {
SignDigest(ctx context.Context, digest common.Hash, optChainID ...*big.Int) ([]byte, error)
}
type Signer interface {
Address() common.Address
}
type SignerMessageSigner interface {
Signer
MessageSigner
}
type SignerDigestSigner interface {
Signer
DigestSigner
}
// NewSigner adapts an ethwallet.Wallet to the Signer and MessageSigner interfaces.
type walletSignerAdapter struct {
wallet *ethwallet.Wallet
}
func (w *walletSignerAdapter) Address() common.Address {
return w.wallet.Address()
}
func (w *walletSignerAdapter) SignMessage(msg []byte) ([]byte, error) {
return w.wallet.SignMessage(msg)
}
func NewSigner(wallet *ethwallet.Wallet) Signer {
return &walletSignerAdapter{wallet: wallet}
}