Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: added new field account-id with uint64 in AccountAddressByID #13780

Merged
merged 32 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
82ef03d
add changes
atheeshp Nov 7, 2022
bd53cb1
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/change-ac…
atheeshp Nov 7, 2022
335db34
Update CHANGELOG.md
atheeshp Nov 7, 2022
4b944b8
Update CHANGELOG.md
atheeshp Nov 7, 2022
ce167ea
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/change-ac…
atheeshp Nov 10, 2022
94d4cf2
Merge branch 'ap/change-acc-id-type' of github.com:cosmos/cosmos-sdk …
atheeshp Nov 10, 2022
2289441
review changes
atheeshp Nov 10, 2022
7f468bb
add test
atheeshp Nov 10, 2022
a272769
fix static check
atheeshp Nov 10, 2022
dd4d69f
fix lint
atheeshp Nov 10, 2022
98b9113
fix lint
atheeshp Nov 10, 2022
7e09506
fix lint
atheeshp Nov 10, 2022
3bc2c5e
Merge branch 'main' into ap/change-acc-id-type
atheeshp Nov 10, 2022
9592596
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/change-ac…
atheeshp Nov 14, 2022
21d8396
Merge branch 'ap/change-acc-id-type' of github.com:cosmos/cosmos-sdk …
atheeshp Nov 14, 2022
8a622ea
review changes
atheeshp Nov 14, 2022
6302d29
review changes
atheeshp Nov 16, 2022
2cf1d2c
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/change-ac…
atheeshp Nov 16, 2022
5875b96
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/change-ac…
atheeshp Nov 17, 2022
bdbaaa2
review changes
atheeshp Nov 17, 2022
c270cec
review changes
atheeshp Nov 17, 2022
03b5bd0
fix tests
atheeshp Nov 17, 2022
2b32933
Update CHANGELOG.md
atheeshp Nov 17, 2022
037b354
Update CHANGELOG.md
atheeshp Nov 17, 2022
78d46b9
Update proto/cosmos/auth/v1beta1/query.proto
atheeshp Nov 17, 2022
34130b5
review changes
atheeshp Nov 17, 2022
93b888e
Merge branch 'ap/change-acc-id-type' of github.com:cosmos/cosmos-sdk …
atheeshp Nov 17, 2022
c3b198c
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/change-ac…
atheeshp Nov 17, 2022
1d680e7
lint
atheeshp Nov 17, 2022
718c752
review changes
atheeshp Nov 17, 2022
faee1f8
Merge branch 'main' of github.com:cosmos/cosmos-sdk into ap/change-ac…
atheeshp Nov 18, 2022
3a39765
Merge branch 'main' into ap/change-acc-id-type
atheeshp Nov 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#13236](https://github.com/cosmos/cosmos-sdk/pull/13236) Integrate Filter Logging
* [#13528](https://github.com/cosmos/cosmos-sdk/pull/13528) Update `ValidateMemoDecorator` to only check memo against `MaxMemoCharacters` param when a memo is present.
* [#13651](https://github.com/cosmos/cosmos-sdk/pull/13651) Update `server/config/config.GetConfig` function.
* [#13780](https://github.com/cosmos/cosmos-sdk/pull/13780) `id` (type of int64) in `AccountAddressByID` grpc query is now deprecated, update to use account-id(type of uint64) to request `AccountAddressByID`.
atheeshp marked this conversation as resolved.
Show resolved Hide resolved

### State Machine Breaking

Expand Down
325 changes: 194 additions & 131 deletions api/cosmos/auth/v1beta1/query.pulsar.go

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions proto/cosmos/auth/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,17 @@ message AddressStringToBytesResponse {
//
// Since: cosmos-sdk 0.46.2
message QueryAccountAddressByIDRequest {
// Deprecated, use account_id instead
//
// 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add the proto deprecated annotation here


// account_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.
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
atheeshp marked this conversation as resolved.
Show resolved Hide resolved
uint64 account_id = 2;
}

// QueryAccountAddressByIDResponse is the response type for AccountAddressByID rpc method
Expand Down
11 changes: 10 additions & 1 deletion x/auth/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,17 @@ func GetAccountAddressByIDCmd() *cobra.Command {
return err
}

accNumUint, err := strconv.ParseUint(args[0], 10, 64)
atheeshp marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.AccountAddressByID(cmd.Context(), &types.QueryAccountAddressByIDRequest{Id: accNum})
res, err := queryClient.AccountAddressByID(cmd.Context(), &types.QueryAccountAddressByIDRequest{
Id: accNum,
AccountId: accNumUint,
})

if err != nil {
return err
}
Expand Down
11 changes: 10 additions & 1 deletion x/auth/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@ func (ak AccountKeeper) AccountAddressByID(c context.Context, req *types.QueryAc
return nil, status.Error(codes.InvalidArgument, "invalid account number")
}

var accId uint64
if req.AccountId > 0 && req.Id > 0 && req.AccountId != uint64(req.Id) {
Fixed Show fixed Hide fixed
return nil, status.Errorf(codes.InvalidArgument, "different values passed for id (%d) & account-id (%d)", req.Id, req.AccountId)
} else if req.AccountId > 0 {
accId = req.AccountId
} else if req.Id > 0 {
accId = uint64(req.Id)
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
}

ctx := sdk.UnwrapSDKContext(c)
address := ak.GetAccountAddressByID(ctx, uint64(req.GetId()))
address := ak.GetAccountAddressByID(ctx, accId)
if len(address) == 0 {
return nil, status.Errorf(codes.NotFound, "account address not found with account number %d", req.Id)
}
Expand Down
20 changes: 20 additions & 0 deletions x/auth/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccountAddressByID() {
false,
func(res *types.QueryAccountAddressByIDResponse) {},
},
{
"invalid: account-id, id are not same",
func() {
req = &types.QueryAccountAddressByIDRequest{AccountId: 0, Id: 1}
},
false,
func(res *types.QueryAccountAddressByIDResponse) {},
},
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
{
"account address not found",
func() {
Expand All @@ -182,6 +190,18 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccountAddressByID() {
false,
func(res *types.QueryAccountAddressByIDResponse) {},
},
{
"valid account-id",
func() {
account := suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr)
suite.accountKeeper.SetAccount(suite.ctx, account)
req = &types.QueryAccountAddressByIDRequest{AccountId: account.GetAccountNumber()}
},
true,
func(res *types.QueryAccountAddressByIDResponse) {
suite.Require().NotNil(res.AccountAddress)
},
},
{
"valid request",
func() {
Expand Down
175 changes: 108 additions & 67 deletions x/auth/types/query.pb.go

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

Loading