From 8bde6c869f0d68528fe52458383308f503a01ae5 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+shaspitz@users.noreply.github.com> Date: Mon, 8 Jul 2024 15:36:29 -0700 Subject: [PATCH] fix: handle 0x prefix --- p2p/pkg/rpc/provider/service.go | 1 + p2p/pkg/rpc/provider/service_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/p2p/pkg/rpc/provider/service.go b/p2p/pkg/rpc/provider/service.go index 6034b1714..333d0a23d 100644 --- a/p2p/pkg/rpc/provider/service.go +++ b/p2p/pkg/rpc/provider/service.go @@ -205,6 +205,7 @@ func (s *Service) RegisterStake( } opts.Value = amount + stake.BlsPublicKey = strings.TrimPrefix(stake.BlsPublicKey, "0x") blsPubkeyBytes, err := hex.DecodeString(stake.BlsPublicKey) if err != nil { return nil, status.Errorf(codes.InvalidArgument, "decoding bls public key: %v", err) diff --git a/p2p/pkg/rpc/provider/service_test.go b/p2p/pkg/rpc/provider/service_test.go index 1e1e1dbe5..9e8e7aae4 100644 --- a/p2p/pkg/rpc/provider/service_test.go +++ b/p2p/pkg/rpc/provider/service_test.go @@ -184,6 +184,7 @@ func TestStakeHandling(t *testing.T) { if stake.Amount != tc.amount { t.Fatalf("expected amount to be %v, got %v", tc.amount, stake.Amount) } + tc.blsPublicKey = strings.TrimPrefix(tc.blsPublicKey, "0x") if stake.BlsPublicKey != tc.blsPublicKey { t.Fatalf("expected bls_public_key to be %v, got %v", tc.blsPublicKey, stake.BlsPublicKey) }