Skip to content

Commit 3d0e214

Browse files
authored
chore: change id to use uint64 in AccountAddressByID (cosmos#13411)
1 parent 9b48c68 commit 3d0e214

File tree

8 files changed

+80
-91
lines changed

8 files changed

+80
-91
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
148148
* (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.
149149
* (x/staking) [#12973](https://github.com/cosmos/cosmos-sdk/pull/12973) Removed `stakingkeeper.RandomValidator`. Use `testutil.RandSliceElem(r, sk.GetAllValidators(ctx))` instead.
150150
* (x/gov) [13160](https://github.com/cosmos/cosmos-sdk/pull/13160) Remove custom marshaling of proposl and voteoption.
151+
* (x/auth) [13411](https://github.com/cosmos/cosmos-sdk/pull/13411) Change account id to use uint64 in `AccountAddressByID` grpc query.
151152

152153
### CLI Breaking Changes
153154

api/cosmos/auth/v1beta1/query.pulsar.go

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/cosmos/auth/v1beta1/query.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ message AddressStringToBytesResponse {
181181

182182
// QueryAccountAddressByIDRequest is the request type for AccountAddressByID rpc method
183183
message QueryAccountAddressByIDRequest {
184-
int64 id = 1;
184+
uint64 id = 1;
185185
}
186186

187187
// QueryAccountAddressByIDResponse is the response type for AccountAddressByID rpc method

x/auth/client/cli/query.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ func GetAccountAddressByIDCmd() *cobra.Command {
139139
return err
140140
}
141141

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

147147
queryClient := types.NewQueryClient(clientCtx)

x/auth/keeper/grpc_query.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,8 @@ func (ak AccountKeeper) AccountAddressByID(c context.Context, req *types.QueryAc
2424
return nil, status.Errorf(codes.InvalidArgument, "empty request")
2525
}
2626

27-
if req.Id < 0 {
28-
return nil, status.Error(codes.InvalidArgument, "Invalid account id")
29-
}
30-
3127
ctx := sdk.UnwrapSDKContext(c)
32-
address := ak.GetAccountAddressByID(ctx, uint64(req.GetId()))
28+
address := ak.GetAccountAddressByID(ctx, req.Id)
3329
if len(address) == 0 {
3430
return nil, status.Errorf(codes.NotFound, "account address not found with id %d", req.Id)
3531
}

x/auth/keeper/grpc_query_test.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,6 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccountAddressByID() {
166166
expPass bool
167167
posttests func(res *types.QueryAccountAddressByIDResponse)
168168
}{
169-
{
170-
"invalid request",
171-
func() {
172-
req = &types.QueryAccountAddressByIDRequest{Id: -1}
173-
},
174-
false,
175-
func(res *types.QueryAccountAddressByIDResponse) {},
176-
},
177169
{
178170
"account address not found",
179171
func() {
@@ -187,7 +179,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccountAddressByID() {
187179
func() {
188180
account := suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr)
189181
suite.accountKeeper.SetAccount(suite.ctx, account)
190-
req = &types.QueryAccountAddressByIDRequest{Id: int64(account.GetAccountNumber())}
182+
req = &types.QueryAccountAddressByIDRequest{Id: account.GetAccountNumber()}
191183
},
192184
true,
193185
func(res *types.QueryAccountAddressByIDResponse) {

0 commit comments

Comments
 (0)