diff --git a/CHANGELOG.md b/CHANGELOG.md index 6393080c3d8f..77579ff6a7a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Improvements + +* (auth) [#13460](https://github.com/cosmos/cosmos-sdk/pull/13460) The `q auth address-by-id` CLI command has been renamed to `q auth address-by-acc-num` to be more explicit. However, the old `address-by-id` version is still kept as an alias, for backwards compatibility. + ## [v0.46.2](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.2) - 2022-10-03 ### API Breaking Changes diff --git a/go.mod b/go.mod index d3dca53a5d13..ee603a4e6592 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/bgentry/speakeasy v0.1.0 github.com/btcsuite/btcd v0.22.1 github.com/celestiaorg/smt v0.3.0 + github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e github.com/cockroachdb/apd/v2 v2.0.2 github.com/coinbase/rosetta-sdk-go v0.7.9 github.com/confio/ics23/go v0.7.0 @@ -75,7 +76,6 @@ require ( github.com/cenkalti/backoff/v4 v4.1.1 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect - github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/cosmos/ledger-go v0.9.2 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect diff --git a/proto/cosmos/auth/v1beta1/query.proto b/proto/cosmos/auth/v1beta1/query.proto index d09c63c113cc..b79f33e7a772 100644 --- a/proto/cosmos/auth/v1beta1/query.proto +++ b/proto/cosmos/auth/v1beta1/query.proto @@ -24,7 +24,9 @@ service Query { option (google.api.http).get = "/cosmos/auth/v1beta1/accounts/{address}"; } - // AccountAddressByID returns account address based on account id + // AccountAddressByID returns account address based on account number. + // + // Since: cosmos-sdk 0.46.2 rpc AccountAddressByID(QueryAccountAddressByIDRequest) returns (QueryAccountAddressByIDResponse) { option (google.api.http).get = "/cosmos/auth/v1beta1/address_by_id/{id}"; } @@ -159,11 +161,18 @@ message AddressStringToBytesResponse { } // QueryAccountAddressByIDRequest is the request type for AccountAddressByID rpc method -message QueryAccountAddressByIDRequest{ +// +// Since: cosmos-sdk 0.46.2 +message QueryAccountAddressByIDRequest { + // id is the account number of the address to be queried. This field + // should have been an uint64 (like all account numbers), and will be + // updated to uint64 in a future version of the auth query. int64 id = 1; } // QueryAccountAddressByIDResponse is the response type for AccountAddressByID rpc method +// +// Since: cosmos-sdk 0.46.2 message QueryAccountAddressByIDResponse { string account_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } diff --git a/x/auth/client/cli/query.go b/x/auth/client/cli/query.go index c3eda5b2d03e..552694c68e7d 100644 --- a/x/auth/client/cli/query.go +++ b/x/auth/client/cli/query.go @@ -129,23 +129,24 @@ func GetAccountCmd() *cobra.Command { // GetAccountAddressByIDCmd returns a query account that will display the account address of a given account id. func GetAccountAddressByIDCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "address-by-id [id]", - Short: "Query for account address by account id", + Use: "address-by-acc-num [acc-num]", + Aliases: []string{"address-by-id"}, + Short: "Query for an address by account number", Args: cobra.ExactArgs(1), - Example: fmt.Sprintf("%s q auth address-by-id 1", version.AppName), + Example: fmt.Sprintf("%s q auth address-by-acc-num 1", version.AppName), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err } - id, err := strconv.ParseInt(args[0], 10, 64) + accNum, err := strconv.ParseInt(args[0], 10, 64) if err != nil { return err } queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.AccountAddressByID(cmd.Context(), &types.QueryAccountAddressByIDRequest{Id: id}) + res, err := queryClient.AccountAddressByID(cmd.Context(), &types.QueryAccountAddressByIDRequest{Id: accNum}) if err != nil { return err } diff --git a/x/auth/keeper/grpc_query.go b/x/auth/keeper/grpc_query.go index 9d37a4ecc9f6..10d3682b377a 100644 --- a/x/auth/keeper/grpc_query.go +++ b/x/auth/keeper/grpc_query.go @@ -25,13 +25,13 @@ func (ak AccountKeeper) AccountAddressByID(c context.Context, req *types.QueryAc } if req.Id < 0 { - return nil, status.Error(codes.InvalidArgument, "Invalid account id") + return nil, status.Error(codes.InvalidArgument, "invalid account number") } ctx := sdk.UnwrapSDKContext(c) address := ak.GetAccountAddressByID(ctx, uint64(req.GetId())) if len(address) == 0 { - return nil, status.Errorf(codes.NotFound, "account address not found with id %d", req.Id) + return nil, status.Errorf(codes.NotFound, "account address not found with account number %d", req.Id) } return &types.QueryAccountAddressByIDResponse{AccountAddress: address}, nil diff --git a/x/auth/types/query.pb.go b/x/auth/types/query.pb.go index bbfd57379cd8..b4479d7bbc06 100644 --- a/x/auth/types/query.pb.go +++ b/x/auth/types/query.pb.go @@ -666,7 +666,12 @@ func (m *AddressStringToBytesResponse) GetAddressBytes() []byte { } // QueryAccountAddressByIDRequest is the request type for AccountAddressByID rpc method +// +// Since: cosmos-sdk 0.46.2 type QueryAccountAddressByIDRequest struct { + // id is the account number of the address to be queried. This field + // should have been an uint64 (like all account numbers), and will be + // updated to uint64 in a future version of the auth query. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` } @@ -711,6 +716,8 @@ func (m *QueryAccountAddressByIDRequest) GetId() int64 { } // QueryAccountAddressByIDResponse is the response type for AccountAddressByID rpc method +// +// Since: cosmos-sdk 0.46.2 type QueryAccountAddressByIDResponse struct { AccountAddress string `protobuf:"bytes,1,opt,name=account_address,json=accountAddress,proto3" json:"account_address,omitempty"` } @@ -854,7 +861,9 @@ type QueryClient interface { Accounts(ctx context.Context, in *QueryAccountsRequest, opts ...grpc.CallOption) (*QueryAccountsResponse, error) // Account returns account details based on address. Account(ctx context.Context, in *QueryAccountRequest, opts ...grpc.CallOption) (*QueryAccountResponse, error) - // AccountAddressByID returns account address based on account id + // AccountAddressByID returns account address based on account number. + // + // Since: cosmos-sdk 0.46.2 AccountAddressByID(ctx context.Context, in *QueryAccountAddressByIDRequest, opts ...grpc.CallOption) (*QueryAccountAddressByIDResponse, error) // Params queries all parameters. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) @@ -964,7 +973,9 @@ type QueryServer interface { Accounts(context.Context, *QueryAccountsRequest) (*QueryAccountsResponse, error) // Account returns account details based on address. Account(context.Context, *QueryAccountRequest) (*QueryAccountResponse, error) - // AccountAddressByID returns account address based on account id + // AccountAddressByID returns account address based on account number. + // + // Since: cosmos-sdk 0.46.2 AccountAddressByID(context.Context, *QueryAccountAddressByIDRequest) (*QueryAccountAddressByIDResponse, error) // Params queries all parameters. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)