Skip to content

Commit

Permalink
Warn if the wallet address is over 20 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
elffjs committed Nov 25, 2024
1 parent b2397f3 commit 85300e7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/rpc/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import (
"github.com/DIMO-Network/accounts-api/models"
pb "github.com/DIMO-Network/accounts-api/pkg/grpc"
"github.com/DIMO-Network/shared/db"
"github.com/ethereum/go-ethereum/common"
"github.com/volatiletech/sqlboiler/v4/queries/qm"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
)

Expand Down Expand Up @@ -35,7 +38,10 @@ func (s *Server) ListAccounts(ctx context.Context, in *pb.ListAccountsRequest) (
if in.PartialEmailAddress != "" {
mods = append(mods, qm.Where(emailHas, in.PartialEmailAddress))
}
if len(in.PartialWalletAddress) != 0 {
if addrLen := len(in.PartialWalletAddress); addrLen != 0 {
if addrLen > common.AddressLength {
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("Partial wallet address, at %d bytes, is too long.", addrLen))
}
mods = append(mods, qm.Where(walletHas, in.PartialWalletAddress))
}

Expand Down

0 comments on commit 85300e7

Please sign in to comment.