Skip to content

Commit f44c16a

Browse files
committed
Add context.Context to Signer methods
For more details, see hyperledger-labs/yui-relayer#153 Signed-off-by: abicky <takeshi.arabiki@datachain.jp>
1 parent 1add2df commit f44c16a

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,6 @@ require (
204204
pgregory.net/rapid v1.1.0 // indirect
205205
sigs.k8s.io/yaml v1.4.0 // indirect
206206
)
207+
208+
// TODO: Delete the following line before making the PR ready for review
209+
replace github.com/hyperledger-labs/yui-relayer => github.com/abicky/yui-relayer v0.0.0-20250210124308-708cf668078d

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX
236236
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
237237
github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE=
238238
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
239+
github.com/abicky/yui-relayer v0.0.0-20250210124308-708cf668078d h1:nKmF34bekatP5sizip1enpVAvY/KEitJTBKNcOQmJHs=
240+
github.com/abicky/yui-relayer v0.0.0-20250210124308-708cf668078d/go.mod h1:kJvSmuagdDsSlvbnHtEHbhmkUlAS43/ArLDwukOKSlo=
239241
github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I=
240242
github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg=
241243
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
@@ -731,8 +733,6 @@ github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0Jr
731733
github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw=
732734
github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w=
733735
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
734-
github.com/hyperledger-labs/yui-relayer v0.5.10 h1:j35SRowNfVDU3gvq4Th3Wy8ufRD5K4wbXDLQAGOgT8w=
735-
github.com/hyperledger-labs/yui-relayer v0.5.10/go.mod h1:kJvSmuagdDsSlvbnHtEHbhmkUlAS43/ArLDwukOKSlo=
736736
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
737737
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
738738
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=

pkg/hd/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package hd
22

33
import (
4-
fmt "fmt"
4+
"fmt"
55

66
"github.com/datachainlab/ibc-hd-signer/pkg/wallet"
77
"github.com/hyperledger-labs/yui-relayer/signer"

pkg/hd/signer.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package hd
22

33
import (
4+
"context"
45
"crypto/ecdsa"
56
"fmt"
67

@@ -23,11 +24,11 @@ func NewSigner(mnemonic, path string) (*Signer, error) {
2324
return &Signer{key}, nil
2425
}
2526

26-
func (s *Signer) GetPublicKey() ([]byte, error) {
27+
func (s *Signer) GetPublicKey(ctx context.Context) ([]byte, error) {
2728
return gethcrypto.CompressPubkey(&s.key.PublicKey), nil
2829
}
2930

30-
func (s *Signer) Sign(digest []byte) ([]byte, error) {
31+
func (s *Signer) Sign(ctx context.Context, digest []byte) ([]byte, error) {
3132
sig, err := gethcrypto.Sign(digest, s.key)
3233
if err != nil {
3334
return nil, fmt.Errorf("failed to sign tx: %v", err)

pkg/hd/signer_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package hd
22

33
import (
4+
"context"
45
"encoding/hex"
56
"slices"
67
"testing"
@@ -28,7 +29,7 @@ func TestGetPublicKey(t *testing.T) {
2829
continue
2930
}
3031

31-
pkBytes, err := signer.GetPublicKey()
32+
pkBytes, err := signer.GetPublicKey(context.TODO())
3233
if c.isErr {
3334
if err == nil {
3435
t.Errorf("GetPublicKey(%s, %s) unexpectedly returned %v", c.mnemonic, c.path, pkBytes)
@@ -72,7 +73,7 @@ func TestSign(t *testing.T) {
7273
continue
7374
}
7475

75-
sign, err := signer.Sign(digest)
76+
sign, err := signer.Sign(context.TODO(), digest)
7677
if c.isErr {
7778
if err == nil {
7879
t.Errorf("Sign(%s, %s) unexpectedly returned %v", c.mnemonic, c.path, sign)

0 commit comments

Comments
 (0)