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 29 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/gov) [#12771](https://github.com/cosmos/cosmos-sdk/pull/12771) Initial deposit requirement for proposals at submission time.
* (x/staking) [#12967](https://github.com/cosmos/cosmos-sdk/pull/12967) `unbond` now creates only one unbonding delegation entry when multiple unbondings exist at a single height (e.g. through multiple messages in a transaction).
* (x/auth/vesting) [#13502](https://github.com/cosmos/cosmos-sdk/pull/13502) Add Amino Msg registration for `MsgCreatePeriodicVestingAccount`.
* (x/auth)[#13780](https://github.com/cosmos/cosmos-sdk/pull/13780) `id` (type of int64) in `AccountAddressByID` grpc query is now deprecated, update to account-id(type of uint64) to use `AccountAddressByID`.
* (x/group) [#13876](https://github.com/cosmos/cosmos-sdk/pull/13876) Fix group MinExecutionPeriod that is checked on execution now, instead of voting period end.

### API Breaking Changes

Expand Down Expand Up @@ -167,6 +169,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#13794](https://github.com/cosmos/cosmos-sdk/pull/13794) Most methods on `types/module.AppModule` have been moved to
extension interfaces. `module.Manager.Modules` is now of type `map[string]interface{}` to support in parallel the new
`cosmossdk.io/core/appmodule.AppModule` API.
* (x/group) [#13876](https://github.com/cosmos/cosmos-sdk/pull/13876) Add `GetMinExecutionPeriod` method on DecisionPolicy interface.
* (x/auth)[#13780](https://github.com/cosmos/cosmos-sdk/pull/13780) Querying with `id` (type of int64) in `AccountAddressByID` grpc query now throws error, use account-id(type of uint64) instead.

### CLI Breaking Changes

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

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion 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;
int64 id = 1 [deprecated = true];

// account_id is the account number of the address to be queried.
//
// Since: cosmos-sdk 0.47
uint64 account_id = 2;
}

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

accNum, err := strconv.ParseInt(args[0], 10, 64)
accNum, err := strconv.ParseUint(args[0], 10, 64)
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{
AccountId: accNum,
})
if err != nil {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions x/auth/keeper/deterministic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,24 @@ func (suite *DeterministicTestSuite) TestGRPCQueryAccountAddressByID() {
pub := pubkeyGenerator(t).Draw(t, "pubkey")
addr := sdk.AccAddress(pub.Address())

accNum := rapid.Int64Min(0).Draw(t, "account-number")
accNum := rapid.Uint64().Draw(t, "account-number")
seq := rapid.Uint64().Draw(t, "sequence")

acc1 := types.NewBaseAccount(addr, &pub, uint64(accNum), seq)
acc1 := types.NewBaseAccount(addr, &pub, accNum, seq)
suite.accountKeeper.SetAccount(suite.ctx, acc1)

req := &types.QueryAccountAddressByIDRequest{Id: accNum}
req := &types.QueryAccountAddressByIDRequest{AccountId: accNum}
testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.AccountAddressByID, 0, true)
})

// Regression test
accNum := int64(10087)
accNum := uint64(10087)
seq := uint64(0)

acc1 := types.NewBaseAccount(addr, &secp256k1.PubKey{Key: pub}, uint64(accNum), seq)
acc1 := types.NewBaseAccount(addr, &secp256k1.PubKey{Key: pub}, accNum, seq)

suite.accountKeeper.SetAccount(suite.ctx, acc1)
req := &types.QueryAccountAddressByIDRequest{Id: accNum}
req := &types.QueryAccountAddressByIDRequest{AccountId: accNum}
testdata.DeterministicIterations(suite.ctx, suite.Require(), req, suite.queryClient.AccountAddressByID, 1123, false)
}

Expand Down
8 changes: 5 additions & 3 deletions x/auth/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ 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 number")
if req.Id > 0 || req.Id < 0 { // ignoring `0` case since it is default value.
atheeshp marked this conversation as resolved.
Show resolved Hide resolved
return nil, status.Error(codes.InvalidArgument, "requesting with id isn't supported, try to request using account-id")
}

accId := req.AccountId

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
14 changes: 12 additions & 2 deletions x/auth/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,27 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccountAddressByID() {
func(res *types.QueryAccountAddressByIDResponse) {},
},
{
"valid request",
"valid account-id",
func() {
account := suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr)
suite.accountKeeper.SetAccount(suite.ctx, account)
req = &types.QueryAccountAddressByIDRequest{Id: int64(account.GetAccountNumber())}
req = &types.QueryAccountAddressByIDRequest{AccountId: account.GetAccountNumber()}
},
true,
func(res *types.QueryAccountAddressByIDResponse) {
suite.Require().NotNil(res.AccountAddress)
},
},
{
"invalid request",
func() {
account := suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr)
suite.accountKeeper.SetAccount(suite.ctx, account)
req = &types.QueryAccountAddressByIDRequest{Id: 1}
},
false,
func(res *types.QueryAccountAddressByIDResponse) {},
},
}

for _, tc := range testCases {
Expand Down
Loading