Skip to content

Commit

Permalink
chore: change id to use uint64 in AccountAddressByID (#13411)
Browse files Browse the repository at this point in the history
  • Loading branch information
atheeshp committed Sep 28, 2022
1 parent 9b48c68 commit 3d0e214
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 91 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (codec) [#12964](https://github.com/cosmos/cosmos-sdk/pull/12964) `ProtoCodec.MarshalInterface` now returns an error when serializing unregistered types and a subsequent `ProtoCodec.UnmarshalInterface` would fail.
* (x/staking) [#12973](https://github.com/cosmos/cosmos-sdk/pull/12973) Removed `stakingkeeper.RandomValidator`. Use `testutil.RandSliceElem(r, sk.GetAllValidators(ctx))` instead.
* (x/gov) [13160](https://github.com/cosmos/cosmos-sdk/pull/13160) Remove custom marshaling of proposl and voteoption.
* (x/auth) [13411](https://github.com/cosmos/cosmos-sdk/pull/13411) Change account id to use uint64 in `AccountAddressByID` grpc query.

### CLI Breaking Changes

Expand Down
22 changes: 11 additions & 11 deletions api/cosmos/auth/v1beta1/query.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion proto/cosmos/auth/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ message AddressStringToBytesResponse {

// QueryAccountAddressByIDRequest is the request type for AccountAddressByID rpc method
message QueryAccountAddressByIDRequest {
int64 id = 1;
uint64 id = 1;
}

// QueryAccountAddressByIDResponse is the response type for AccountAddressByID rpc method
Expand Down
4 changes: 2 additions & 2 deletions x/auth/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ func GetAccountAddressByIDCmd() *cobra.Command {
return err
}

id, err := strconv.ParseInt(args[0], 10, 64)
id, err := strconv.ParseUint(args[0], 10, 64)
if err != nil {
return err
return fmt.Errorf("id %s not a valid uint, please input a valid account-id", args[0])
}

queryClient := types.NewQueryClient(clientCtx)
Expand Down
6 changes: 1 addition & 5 deletions x/auth/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ func (ak AccountKeeper) AccountAddressByID(c context.Context, req *types.QueryAc
return nil, status.Errorf(codes.InvalidArgument, "empty request")
}

if req.Id < 0 {
return nil, status.Error(codes.InvalidArgument, "Invalid account id")
}

ctx := sdk.UnwrapSDKContext(c)
address := ak.GetAccountAddressByID(ctx, uint64(req.GetId()))
address := ak.GetAccountAddressByID(ctx, req.Id)
if len(address) == 0 {
return nil, status.Errorf(codes.NotFound, "account address not found with id %d", req.Id)
}
Expand Down
10 changes: 1 addition & 9 deletions x/auth/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,6 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccountAddressByID() {
expPass bool
posttests func(res *types.QueryAccountAddressByIDResponse)
}{
{
"invalid request",
func() {
req = &types.QueryAccountAddressByIDRequest{Id: -1}
},
false,
func(res *types.QueryAccountAddressByIDResponse) {},
},
{
"account address not found",
func() {
Expand All @@ -187,7 +179,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccountAddressByID() {
func() {
account := suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr)
suite.accountKeeper.SetAccount(suite.ctx, account)
req = &types.QueryAccountAddressByIDRequest{Id: int64(account.GetAccountNumber())}
req = &types.QueryAccountAddressByIDRequest{Id: account.GetAccountNumber()}
},
true,
func(res *types.QueryAccountAddressByIDResponse) {
Expand Down

0 comments on commit 3d0e214

Please sign in to comment.