Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spikeekips/11506bb6eeb07a9b645e5e146f4176c7 to your computer and use it in GitHub Desktop.
Save spikeekips/11506bb6eeb07a9b645e5e146f4176c7 to your computer and use it in GitHub Desktop.
diff --git a/base/address_decoder.go b/base/address_decoder.go
index b7a4b5fb..2443ca70 100644
--- a/base/address_decoder.go
+++ b/base/address_decoder.go
@@ -11,6 +11,10 @@ type AddressDecoder struct {
}
func (ad *AddressDecoder) Encode(enc encoder.Encoder) (Address, error) {
+ if ad == nil {
+ return nil, nil
+ }
+
var i Address
err := encoder.DecodeWithHint(ad.b, enc, hint.NewHint(ad.ty, ""), &i)
return i, err
diff --git a/base/key/decoder.go b/base/key/decoder.go
index bf5ffcfc..c3ed7a09 100644
--- a/base/key/decoder.go
+++ b/base/key/decoder.go
@@ -53,6 +53,10 @@ type PrivatekeyDecoder struct {
}
func (kd *PrivatekeyDecoder) Encode(enc encoder.Encoder) (Privatekey, error) {
+ if kd == nil {
+ return nil, nil
+ }
+
k, err := kd.KeyDecoder.Encode(enc)
switch {
case err != nil:
@@ -75,6 +79,10 @@ type PublickeyDecoder struct {
}
func (kd *PublickeyDecoder) Encode(enc encoder.Encoder) (Publickey, error) {
+ if kd == nil {
+ return nil, nil
+ }
+
k, err := kd.KeyDecoder.Encode(enc)
switch {
case err != nil:
diff --git a/base/key/priv_test.go b/base/key/priv_test.go
index f5f05d83..514d0af6 100644
--- a/base/key/priv_test.go
+++ b/base/key/priv_test.go
@@ -332,7 +332,7 @@ func TestBasePrivatekeyDecoderBSON(t *testing.T) {
}
s.decode = func(b []byte) Key {
var d struct {
- K PrivatekeyDecoder
+ K *PrivatekeyDecoder
}
s.NoError(s.enc.Unmarshal(b, &d))
uk, err := d.K.Encode(s.enc)
@@ -382,7 +382,7 @@ func TestNilBasePrivatekeyDecoderBSON(t *testing.T) {
}
s.decode = func(b []byte) Key {
var d struct {
- K PrivatekeyDecoder
+ K *PrivatekeyDecoder
}
s.NoError(s.enc.Unmarshal(b, &d))
uk, err := d.K.Encode(s.enc)
diff --git a/base/key/pub_test.go b/base/key/pub_test.go
index c6a7765e..d98993a5 100644
--- a/base/key/pub_test.go
+++ b/base/key/pub_test.go
@@ -213,7 +213,7 @@ func TestBasePublickeyDecoderBSON(t *testing.T) {
}
s.decode = func(b []byte) Key {
var d struct {
- K PublickeyDecoder
+ K *PublickeyDecoder
}
s.NoError(s.enc.Unmarshal(b, &d))
uk, err := d.K.Encode(s.enc)
@@ -263,7 +263,7 @@ func TestNilBasePublickeyDecoderBSON(t *testing.T) {
}
s.decode = func(b []byte) Key {
var d struct {
- K PublickeyDecoder
+ K *PublickeyDecoder
}
s.NoError(s.enc.Unmarshal(b, &d))
uk, err := d.K.Encode(s.enc)
diff --git a/base/string_address_test.go b/base/string_address_test.go
index e6f8f64d..55288132 100644
--- a/base/string_address_test.go
+++ b/base/string_address_test.go
@@ -462,8 +462,9 @@ func TestNilStringAddressDecoderBSON(t *testing.T) {
}
s.decode = func(b []byte) (Address, error) {
var u struct {
- A AddressDecoder
+ A *AddressDecoder
}
+
s.NoError(s.enc.Unmarshal(b, &u))
uad, err := u.A.Encode(s.enc)
diff --git a/go.mod b/go.mod
index d613999b..3743ce05 100644
--- a/go.mod
+++ b/go.mod
@@ -37,7 +37,7 @@ require (
github.com/ulule/limiter/v3 v3.9.0
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
github.com/zeebo/blake3 v0.2.1
- go.mongodb.org/mongo-driver v1.8.0
+ go.mongodb.org/mongo-driver v1.9.0
go.uber.org/automaxprocs v1.4.0
go.uber.org/goleak v1.1.10
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e
diff --git a/go.sum b/go.sum
index 9e4ef7cb..bb52a096 100644
--- a/go.sum
+++ b/go.sum
@@ -355,6 +355,8 @@ github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo=
github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
go.mongodb.org/mongo-driver v1.8.0 h1:R/P/JJzu8LJvJ1lDfph9GLNIKQxEtIHFfnUUUve35zY=
go.mongodb.org/mongo-driver v1.8.0/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY=
+go.mongodb.org/mongo-driver v1.9.0 h1:f3aLGJvQmBl8d9S40IL+jEyBC6hfLPbJjv9t5hEM9ck=
+go.mongodb.org/mongo-driver v1.9.0/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY=
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
go.uber.org/automaxprocs v1.4.0 h1:CpDZl6aOlLhReez+8S3eEotD7Jx0Os++lemPlMULQP0=
go.uber.org/automaxprocs v1.4.0/go.mod h1:/mTEdr7LvHhs0v7mjdxDreTz1OG5zdZGqgOnhWiR/+Q=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment