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

implement x/authz module #7629

Merged
merged 215 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
215 commits
Select commit Hold shift + click to select a range
5a34c06
WIP: Msg authorization module added
atheeshp Sep 23, 2020
d30572c
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_author…
atheeshp Sep 24, 2020
5087ad3
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_auth_p…
atheeshp Sep 25, 2020
3eac303
fixing errors
atheeshp Sep 25, 2020
beb7cc2
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_auth_p…
atheeshp Sep 25, 2020
39f1715
fixed errors
atheeshp Sep 25, 2020
0f71c06
fixed module.go
atheeshp Sep 29, 2020
ffd988e
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_auth_p…
atheeshp Sep 29, 2020
14870e4
Add msg_tests
aleem1314 Sep 30, 2020
c2d6db2
fixes compile issues
atheeshp Sep 30, 2020
307cc99
Merge branch 'msg_auth_proto' of https://github.com/cosmos/cosmos-sdk…
aleem1314 Sep 30, 2020
5362872
fix test
atheeshp Sep 30, 2020
61834b6
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_auth_p…
atheeshp Sep 30, 2020
7b80c0f
fix test
atheeshp Sep 30, 2020
ca9062e
Merge branch 'master' into msg_authorization
atheeshp Sep 30, 2020
f27b8f1
Merge branch 'msg_authorization' of github.com:cosmos/cosmos-sdk into…
atheeshp Sep 30, 2020
64224ea
Merge branch 'msg_auth_proto' of https://github.com/cosmos/cosmos-sdk…
aleem1314 Sep 30, 2020
5d9da55
Add msg types tests
aleem1314 Oct 1, 2020
e4b8dd5
Fix Getmsgs
aleem1314 Oct 3, 2020
4f2e40e
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into al…
aleem1314 Oct 3, 2020
3b487ad
fixed codec issue
atheeshp Oct 3, 2020
c0ec30e
Fix syntax issues
aleem1314 Oct 3, 2020
df76719
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_auth_p…
atheeshp Oct 3, 2020
8d480cd
Merge branch 'msg_auth_proto' of https://github.com/cosmos/cosmos-sdk…
aleem1314 Oct 3, 2020
3e985e7
Fix keeper
aleem1314 Oct 3, 2020
f6024d3
fixed proto issues
atheeshp Oct 3, 2020
6243445
Fix keeper tests
aleem1314 Oct 3, 2020
2490825
Merge branch 'msg_auth_proto' of https://github.com/cosmos/cosmos-sdk…
aleem1314 Oct 3, 2020
2f75c50
fixed router in keeper
atheeshp Oct 3, 2020
4cb8b77
Merge branch 'master' into msg_authorization
atheeshp Oct 5, 2020
9745393
Merge branch 'msg_authorization' of github.com:cosmos/cosmos-sdk into…
atheeshp Oct 5, 2020
24da343
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_author…
atheeshp Oct 5, 2020
fbbcbac
Merge branch 'msg_authorization' of github.com:cosmos/cosmos-sdk into…
atheeshp Oct 5, 2020
d280dad
Merge branch 'msg_auth_proto' of github.com:cosmos/cosmos-sdk into ms…
atheeshp Oct 5, 2020
63acf05
Fix query proto
aleem1314 Oct 5, 2020
f22d8be
Merge branch 'aleem/msg_authorization' into msg_authorization
aleem1314 Oct 5, 2020
6d4f640
Merge branch 'master' of github.com:cosmos/cosmos-sdk into msg_author…
atheeshp Oct 5, 2020
cd4dba1
Merge branch 'msg_authorization' of github.com:cosmos/cosmos-sdk into…
atheeshp Oct 5, 2020
0f6266b
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 6, 2020
38566b6
Fix cli txs
aleem1314 Oct 6, 2020
b118e4c
Add grpc query client implementation
aleem1314 Oct 6, 2020
01ad577
Add grpc-keeper test
aleem1314 Oct 6, 2020
246f3f4
Add grpc query tests
aleem1314 Oct 7, 2020
f4a5734
Fix linting issues
aleem1314 Oct 7, 2020
d442400
Fix cli query
aleem1314 Oct 7, 2020
2bae46c
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 7, 2020
2b759a7
fix lint errors
aleem1314 Oct 7, 2020
6f6cf7e
Add Genesis state
aleem1314 Oct 8, 2020
35e107d
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 8, 2020
edf46c8
Fix query authorization
aleem1314 Oct 9, 2020
4bd54a6
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 9, 2020
9d1040d
Review changes
aleem1314 Oct 9, 2020
d8a2a18
Fix grant authorization handler
aleem1314 Oct 12, 2020
d100e49
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 12, 2020
9ec3f39
Add cli tests
aleem1314 Oct 12, 2020
ab3f14a
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 12, 2020
f1e434b
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 13, 2020
5c37e32
Add cli tests
aleem1314 Oct 14, 2020
8be9599
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 14, 2020
8b16c06
Fix genesis test
aleem1314 Oct 14, 2020
291ec19
Fix issues
aleem1314 Oct 14, 2020
d81ec6b
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 14, 2020
1d6aa18
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 15, 2020
cd72441
update module to use proto msg services
aleem1314 Oct 15, 2020
53462e6
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 15, 2020
39f876b
Add simultion tests
aleem1314 Oct 15, 2020
8656392
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 15, 2020
04f3c8a
Fix lint
aleem1314 Oct 16, 2020
cf097d4
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 16, 2020
5f95ca8
fix lint
aleem1314 Oct 16, 2020
721aab3
Merge branch 'msg_authorization' of github.com:cosmos/cosmos-sdk into…
atheeshp Oct 16, 2020
fc60444
Merge branch 'master' into msg_authorization
atheeshp Oct 16, 2020
f417681
WIP simulations
aleem1314 Oct 16, 2020
eb782c5
Merge branch 'msg_authorization' of https://github.com/cosmos/cosmos-…
aleem1314 Oct 16, 2020
d78a517
Merge branch 'msg_authorization' of github.com:cosmos/cosmos-sdk into…
atheeshp Oct 16, 2020
8d28432
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 19, 2020
1c166e0
WIP simulations
aleem1314 Oct 19, 2020
3d43482
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 19, 2020
1ea7693
add msg tests
aleem1314 Oct 19, 2020
fc9438a
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into ms…
aleem1314 Oct 20, 2020
39bb25d
Fix simulation
aleem1314 Oct 20, 2020
f728be7
Fix errors
aleem1314 Oct 20, 2020
be3c14d
Merge branch 'msg_authorization' of github.com:cosmos/cosmos-sdk into…
atheeshp Oct 20, 2020
5c5d126
fix genesis import export
atheeshp Oct 20, 2020
bbd3930
fix sim tests
atheeshp Oct 20, 2020
85dfb75
fix sim
atheeshp Oct 20, 2020
a4a81c7
fix test
atheeshp Oct 20, 2020
f5bfa38
Merge branch 'master' into msg_authorization
atheeshp Oct 20, 2020
b2b2106
Merge branch 'master' into msg_authorization
atheeshp Oct 21, 2020
2ea639a
Register RegisterMsgServer
aleem1314 Oct 21, 2020
47f4ac9
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aleem/msg_…
atheeshp Oct 21, 2020
db113e2
WIP
aleem1314 Oct 22, 2020
6a04be8
WIP
aleem1314 Oct 22, 2020
09a5719
Update keeper test
aleem1314 Oct 22, 2020
c137e61
change msg_authorization module name to authz
aleem1314 Oct 22, 2020
e503d68
Merge branch 'aleem/msg_auth' of github.com:cosmos/cosmos-sdk into al…
atheeshp Oct 27, 2020
c438834
changed type conversion for serviceMsg
atheeshp Oct 27, 2020
4f1520e
serviceMsg change to any
atheeshp Oct 27, 2020
8dc4846
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into al…
aleem1314 Oct 29, 2020
cfed278
Fix issues
aleem1314 Oct 29, 2020
d31990d
fix msg tests
aleem1314 Nov 1, 2020
dcf026e
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into al…
aleem1314 Nov 1, 2020
7223783
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into al…
aleem1314 Nov 6, 2020
fb0b351
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into al…
aleem1314 Nov 23, 2020
22fa802
fix errors
aleem1314 Nov 23, 2020
dd9972d
proto format
aleem1314 Nov 23, 2020
b45bd34
remove LegacyQuerierHandler
aleem1314 Nov 23, 2020
437439e
Use MsgServiceRouter
amaury1093 Nov 24, 2020
e1dfcee
fix keeper-test
aleem1314 Nov 24, 2020
78142a5
fix query authorizations
aleem1314 Nov 24, 2020
e8cddb1
fix NewCmdSendAs
aleem1314 Nov 26, 2020
30cbbe2
fix simtests
aleem1314 Nov 26, 2020
741adb0
fix error
aleem1314 Nov 26, 2020
decc159
fix lint
aleem1314 Nov 26, 2020
2cb7d01
fix lint
aleem1314 Nov 26, 2020
4e05888
add tests for generic authorization
aleem1314 Nov 27, 2020
cec3b9c
fix imports
aleem1314 Nov 27, 2020
f6b7ce5
format
aleem1314 Nov 27, 2020
2ba4c34
Update error message
aleem1314 Nov 27, 2020
4020981
remove println
aleem1314 Nov 27, 2020
171bb72
add query all grants
aleem1314 Nov 27, 2020
4d972ca
Add pagination for queries
aleem1314 Nov 30, 2020
0a85ba1
format
aleem1314 Nov 30, 2020
757fb1e
fix lint
aleem1314 Nov 30, 2020
2795f38
Merge branch 'master' into aleem/msg_auth
aleem1314 Dec 1, 2020
194b6ae
review changes
aleem1314 Dec 2, 2020
3ad6c20
fix grpc tests
aleem1314 Dec 2, 2020
b52df75
Merge branch 'aleem/msg_auth' of https://github.com/cosmos/cosmos-sdk…
aleem1314 Dec 2, 2020
139120f
add pagination to cli query
aleem1314 Dec 3, 2020
224d5c1
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into al…
aleem1314 Dec 3, 2020
2c668ec
Merge branch 'master' into aleem/msg_auth
aleem1314 Dec 4, 2020
cf6a6de
Merge branch 'master' into aleem/msg_auth
aleem1314 Dec 7, 2020
3be560a
review changes
aleem1314 Dec 8, 2020
c58fec7
replace panic with error
aleem1314 Dec 8, 2020
75a4e7d
Merge branch 'master' into aleem/msg_auth
aleem1314 Dec 8, 2020
431a7ce
lint
aleem1314 Dec 8, 2020
a428821
Merge branch 'master' into aleem/msg_auth
aleem1314 Dec 10, 2020
dce25ea
fix errors
aleem1314 Dec 10, 2020
4f88487
fix tests
aleem1314 Dec 10, 2020
ba048bd
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into al…
aleem1314 Dec 10, 2020
aced2c7
Merge branch 'master' into aleem/msg_auth
aleem1314 Dec 10, 2020
8c74b8b
remove gogoproto extensions
aleem1314 Dec 14, 2020
a7f0a13
update function doc
aleem1314 Dec 14, 2020
3f7ad76
review changes
aleem1314 Dec 14, 2020
a0c52b7
Merge branch 'master' into aleem/msg_auth
aleem1314 Dec 14, 2020
cf4bdd0
Merge branch 'master' into aleem/msg_auth
aleem1314 Dec 15, 2020
5c9e96f
fix errors
aleem1314 Dec 15, 2020
5b2d626
fix query flags
aleem1314 Dec 15, 2020
f6f12e3
Merge branch 'master' into aleem/msg_auth
aleem1314 Dec 16, 2020
9b58041
fix grpc query test
aleem1314 Dec 16, 2020
148cd39
init service-msg
aleem1314 Dec 17, 2020
00ac779
remove unsed field
aleem1314 Dec 17, 2020
3985344
add proto-codec for simulations
aleem1314 Dec 17, 2020
31b1ecb
fix codec issue
aleem1314 Dec 17, 2020
98ceb21
update authz simulations
aleem1314 Dec 18, 2020
00a64d4
Merge pull request #8188 from cosmos/aleem/x-service-msg-sims
aleem1314 Dec 18, 2020
68ad8c3
change msgauth to authz
aleem1314 Dec 18, 2020
73a9aad
add check for invalid msg-type
aleem1314 Dec 18, 2020
c4a1228
change expiration flag to Unix
aleem1314 Dec 18, 2020
8566fbb
doc
aleem1314 Dec 18, 2020
31a4701
Merge branch 'master' into aleem/msg_auth
aleem1314 Dec 18, 2020
60356a0
update module.go
aleem1314 Dec 19, 2020
bda70a4
fix sims
aleem1314 Dec 19, 2020
f94054d
Merge branch 'master' into aleem/msg_auth
aleem1314 Dec 19, 2020
ea90c2d
fix grant-authorization sims
aleem1314 Dec 19, 2020
dda1dcd
Merge branch 'aleem/msg_auth' of https://github.com/cosmos/cosmos-sdk…
aleem1314 Dec 19, 2020
ae13f09
Merge branch 'master' into aleem/msg_auth
aleem1314 Jan 2, 2021
50e5a54
fix error
aleem1314 Jan 7, 2021
b3e4cab
fix error
aleem1314 Jan 7, 2021
fd7fc1b
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into al…
aleem1314 Jan 7, 2021
2c0508d
add build flag
aleem1314 Jan 7, 2021
c243099
Merge branch 'master' into aleem/msg_auth
aleem1314 Jan 11, 2021
9832e9d
fix codec issue
aleem1314 Jan 11, 2021
19afaf1
rename
aleem1314 Jan 11, 2021
864e00b
Merge branch 'master' into aleem/msg_auth
aleem1314 Jan 11, 2021
62f2334
review changes
aleem1314 Jan 12, 2021
3a1130e
format
aleem1314 Jan 12, 2021
ee4ff5a
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into al…
aleem1314 Jan 12, 2021
655054d
review changes
aleem1314 Jan 15, 2021
470b1af
Merge branch 'master' into aleem/msg_auth
aleem1314 Jan 15, 2021
6b0b6e3
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into al…
aleem1314 Jan 16, 2021
c5a81f3
go.mod
aleem1314 Jan 16, 2021
57ce066
Merge branch 'master' into aleem/msg_auth
aleem1314 Jan 18, 2021
87fdfce
refactor
aleem1314 Jan 18, 2021
70e08c6
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into al…
aleem1314 Jan 18, 2021
4c13898
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into al…
aleem1314 Jan 19, 2021
1b91709
proto-gen
aleem1314 Jan 19, 2021
d83b242
Update x/authz/keeper/grpc_query_test.go
anilcse Jan 21, 2021
97b0bf2
Merge branch 'master' into aleem/msg_auth
anilcse Jan 21, 2021
2496853
Update x/authz/keeper/grpc_query_test.go
anilcse Jan 21, 2021
61c21e5
Update x/authz/keeper/grpc_query_test.go
anilcse Jan 21, 2021
ec2e364
Fix review comments
anilcse Jan 22, 2021
f6e3dff
fix protogen
anilcse Jan 22, 2021
0b9457f
Follow Msg...Request style for msg requests
anilcse Jan 22, 2021
9824d61
update comment
anilcse Jan 22, 2021
f4107c1
Fix error codes
anilcse Jan 22, 2021
989811b
fix review comment
anilcse Jan 22, 2021
a8e5c4b
improve msg validations
anilcse Jan 22, 2021
51ab5b1
Handle error in casting msgs
anilcse Jan 22, 2021
7c74368
rename actor => grantStoreKey
anilcse Jan 22, 2021
7166a84
add godoc
anilcse Jan 22, 2021
ba8f70f
add godoc
anilcse Jan 22, 2021
c701f9e
Fix simulations
anilcse Jan 22, 2021
0dcb2c7
Merge branch 'master' into aleem/msg_auth
anilcse Jan 22, 2021
9d536e3
Fix cli, cli_tests
anilcse Jan 22, 2021
d863c41
Merge branch 'aleem/msg_auth' of github.com:cosmos/cosmos-sdk into al…
anilcse Jan 22, 2021
ca43006
Fix simulations
anilcse Jan 22, 2021
35d00b8
rename to GetOrRevokeAuthorization
anilcse Jan 22, 2021
f0af7ab
Move events to keeper
anilcse Jan 22, 2021
6a55031
Fix fmt
anilcse Jan 22, 2021
735ce47
Update x/authz/client/cli/tx.go
anilcse Jan 22, 2021
c6f5f65
Merge branch 'master' into aleem/msg_auth
anilcse Jan 22, 2021
4805466
rename actor
anilcse Jan 22, 2021
b282396
fix lint
aleem1314 Jan 25, 2021
6fd4efd
Merge branch 'master' into aleem/msg_auth
aleem1314 Jan 25, 2021
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
977 changes: 664 additions & 313 deletions docs/core/proto-docs.md

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions proto/cosmos/authz/v1beta1/authz.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
syntax = "proto3";
package cosmos.authz.v1beta1;

import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "google/protobuf/timestamp.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/authz/types";

// SendAuthorization allows the grantee to spend up to spend_limit coins from
// the granter's account.
message SendAuthorization {
option (cosmos_proto.implements_interface) = "Authorization";

repeated cosmos.base.v1beta1.Coin spend_limit = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
}

// GenericAuthorization gives the grantee unrestricted permissions to execute
// the provided method on behalf of the granter's account.
message GenericAuthorization {
option (cosmos_proto.implements_interface) = "Authorization";

// method name to grant unrestricted permissions to execute
// Note: MethodName() is already a method on `GenericAuthorization` type,
// we need some custom naming here so using `MessageName`
string method_name = 1 [(gogoproto.customname) = "MessageName"];
anilcse marked this conversation as resolved.
Show resolved Hide resolved
}

// AuthorizationGrant gives permissions to execute
// the provide method with expiration time.
message AuthorizationGrant {
google.protobuf.Any authorization = 1 [(cosmos_proto.accepts_interface) = "Authorization"];
google.protobuf.Timestamp expiration = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
anilcse marked this conversation as resolved.
Show resolved Hide resolved
}
24 changes: 24 additions & 0 deletions proto/cosmos/authz/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
syntax = "proto3";
package cosmos.authz.v1beta1;

import "google/protobuf/timestamp.proto";
import "google/protobuf/any.proto";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/authz/v1beta1/tx.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/authz/types";

// GenesisState defines the authz module's genesis state.
message GenesisState {
repeated GrantAuthorization authorization = 1 [(gogoproto.nullable) = false];
}

// GrantAuthorization defines the GenesisState/GrantAuthorization type.
message GrantAuthorization {
string granter = 1;
string grantee = 2;

google.protobuf.Any authorization = 3 [(cosmos_proto.accepts_interface) = "Authorization"];
google.protobuf.Timestamp expiration = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
54 changes: 54 additions & 0 deletions proto/cosmos/authz/v1beta1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
syntax = "proto3";
package cosmos.authz.v1beta1;

import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "google/api/annotations.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmos/authz/v1beta1/authz.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/authz/types";

// Query defines the gRPC querier service.
service Query {
// Returns any `Authorization` (or `nil`), with the expiration time, granted to the grantee by the granter for the
// provided msg type.
rpc Authorization(QueryAuthorizationRequest) returns (QueryAuthorizationResponse) {
option (google.api.http).get = "/cosmos/authz/v1beta1/granters/{granter}/grantees/{grantee}/grant";
}

// Returns list of `Authorization`, granted to the grantee by the granter.
rpc Authorizations(QueryAuthorizationsRequest) returns (QueryAuthorizationsResponse) {
option (google.api.http).get = "/cosmos/authz/v1beta1/granters/{granter}/grantees/{grantee}/grants";
}
}

// QueryAuthorizationRequest is the request type for the Query/Authorization RPC method.
message QueryAuthorizationRequest {
string granter = 1;
string grantee = 2;
string method_name = 3;
}

// QueryAuthorizationResponse is the response type for the Query/Authorization RPC method.
message QueryAuthorizationResponse {
// authorization is a authorization granted for grantee by granter.
cosmos.authz.v1beta1.AuthorizationGrant authorization = 1;
}

// QueryAuthorizationsRequest is the request type for the Query/Authorizations RPC method.
message QueryAuthorizationsRequest {
string granter = 1;
string grantee = 2;
// pagination defines an pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 3;
}

// QueryAuthorizationsResponse is the response type for the Query/Authorizations RPC method.
message QueryAuthorizationsResponse {
// authorizations is a list of grants granted for grantee by granter.
repeated cosmos.authz.v1beta1.AuthorizationGrant authorizations = 1;
// pagination defines an pagination for the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
62 changes: 62 additions & 0 deletions proto/cosmos/authz/v1beta1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
syntax = "proto3";
package cosmos.authz.v1beta1;

import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/any.proto";
import "cosmos/base/abci/v1beta1/abci.proto";
option go_package = "github.com/cosmos/cosmos-sdk/x/authz/types";

// Msg defines the authz Msg service.
service Msg {
// GrantAuthorization grants the provided authorization to the grantee on the granter's
// account with the provided expiration time.
rpc GrantAuthorization(MsgGrantAuthorizationRequest) returns (MsgGrantAuthorizationResponse);

// ExecAuthorized attempts to execute the provided messages using
// authorizations granted to the grantee. Each message should have only
// one signer corresponding to the granter of the authorization.
rpc ExecAuthorized(MsgExecAuthorizedRequest) returns (MsgExecAuthorizedResponse);

// RevokeAuthorization revokes any authorization corresponding to the provided method name on the
// granter's account that has been granted to the grantee.
rpc RevokeAuthorization(MsgRevokeAuthorizationRequest) returns (MsgRevokeAuthorizationResponse);
}

// MsgGrantAuthorizationRequest grants the provided authorization to the grantee on the granter's
// account with the provided expiration time.
message MsgGrantAuthorizationRequest {
string granter = 1;
string grantee = 2;

google.protobuf.Any authorization = 3 [(cosmos_proto.accepts_interface) = "Authorization"];
google.protobuf.Timestamp expiration = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}

// MsgExecAuthorizedResponse defines the Msg/MsgExecAuthorizedResponse response type.
message MsgExecAuthorizedResponse {
cosmos.base.abci.v1beta1.Result result = 1;
}

// MsgExecAuthorizedRequest attempts to execute the provided messages using
// authorizations granted to the grantee. Each message should have only
// one signer corresponding to the granter of the authorization.
message MsgExecAuthorizedRequest {
string grantee = 1;
repeated google.protobuf.Any msgs = 2;
}

// MsgGrantAuthorizationResponse defines the Msg/MsgGrantAuthorization response type.
message MsgGrantAuthorizationResponse {}

// MsgRevokeAuthorizationRequest revokes any authorization with the provided sdk.Msg type on the
// granter's account with that has been granted to the grantee.
message MsgRevokeAuthorizationRequest {
string granter = 1;
string grantee = 2;
string method_name = 3;
}

// MsgRevokeAuthorizationResponse defines the Msg/MsgRevokeAuthorizationResponse response type.
message MsgRevokeAuthorizationResponse {}
14 changes: 13 additions & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/capability"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"

"github.com/cosmos/cosmos-sdk/x/crisis"
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
Expand Down Expand Up @@ -87,6 +88,10 @@ import (
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

authz "github.com/cosmos/cosmos-sdk/x/authz"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
authztypes "github.com/cosmos/cosmos-sdk/x/authz/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
)
Expand Down Expand Up @@ -118,6 +123,7 @@ var (
upgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
authz.AppModuleBasic{},
vesting.AppModuleBasic{},
)

Expand Down Expand Up @@ -171,6 +177,7 @@ type SimApp struct {
CrisisKeeper crisiskeeper.Keeper
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
AuthzKeeper authzkeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
Expand Down Expand Up @@ -217,6 +224,7 @@ func NewSimApp(
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
authztypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -282,6 +290,8 @@ func NewSimApp(
appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, scopedIBCKeeper,
)

app.AuthzKeeper = authzkeeper.NewKeeper(keys[authztypes.StoreKey], appCodec, app.BaseApp.MsgServiceRouter())

// register the proposal types
govRouter := govtypes.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
Expand Down Expand Up @@ -346,6 +356,7 @@ func NewSimApp(
evidence.NewAppModule(app.EvidenceKeeper),
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.ParamsKeeper),
authz.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
transferModule,
)

Expand All @@ -367,7 +378,7 @@ func NewSimApp(
app.mm.SetOrderInitGenesis(
capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName,
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName,
ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName,
ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authztypes.ModuleName, ibctransfertypes.ModuleName,
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
Expand All @@ -392,6 +403,7 @@ func NewSimApp(
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
params.NewAppModule(app.ParamsKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
authz.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
ibc.NewAppModule(app.IBCKeeper),
transferModule,
)
Expand Down
2 changes: 2 additions & 0 deletions simapp/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
authztypes "github.com/cosmos/cosmos-sdk/x/authz/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
Expand Down Expand Up @@ -177,6 +178,7 @@ func TestAppImportExport(t *testing.T) {
{app.keys[capabilitytypes.StoreKey], newApp.keys[capabilitytypes.StoreKey], [][]byte{}},
{app.keys[ibchost.StoreKey], newApp.keys[ibchost.StoreKey], [][]byte{}},
{app.keys[ibctransfertypes.StoreKey], newApp.keys[ibctransfertypes.StoreKey], [][]byte{}},
{app.keys[authztypes.StoreKey], newApp.keys[authztypes.StoreKey], [][]byte{}},
}

for _, skp := range storeKeysPrefixes {
Expand Down
3 changes: 3 additions & 0 deletions types/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ var (
// supported.
ErrNotSupported = Register(RootCodespace, 37, "feature not supported")

// ErrNotFound defines an error when requested entity doesn't exist in the state.
ErrNotFound = Register(RootCodespace, 38, "not found")

// ErrPanic is only set when we recover from a panic, so we know to
// redact potentially sensitive system info
ErrPanic = Register(UndefinedCodespace, 111222, "panic")
Expand Down
50 changes: 50 additions & 0 deletions types/msgservice/service_msg_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package msgservice

import (
"context"
"fmt"

gogogrpc "github.com/gogo/protobuf/grpc"
grpc "google.golang.org/grpc"

sdk "github.com/cosmos/cosmos-sdk/types"
)

var _ gogogrpc.ClientConn = &ServiceMsgClientConn{}

// ServiceMsgClientConn is an instance of grpc.ClientConn that is used to test building
// transactions with MsgClient's. It is intended to be replaced by the work in
// https://github.com/cosmos/cosmos-sdk/issues/7541 when that is ready.
type ServiceMsgClientConn struct {
msgs []sdk.Msg
}

// Invoke implements the grpc ClientConn.Invoke method
func (t *ServiceMsgClientConn) Invoke(_ context.Context, method string, args, _ interface{}, _ ...grpc.CallOption) error {
req, ok := args.(sdk.MsgRequest)
if !ok {
return fmt.Errorf("%T should implement %T", args, (*sdk.MsgRequest)(nil))
}

err := req.ValidateBasic()
if err != nil {
return err
}

t.msgs = append(t.msgs, sdk.ServiceMsg{
MethodName: method,
Request: req,
})

return nil
}

// NewStream implements the grpc ClientConn.NewStream method
func (t *ServiceMsgClientConn) NewStream(context.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) {
return nil, fmt.Errorf("not supported")
}

// GetMsgs returns ServiceMsgClientConn.msgs
func (t *ServiceMsgClientConn) GetMsgs() []sdk.Msg {
return t.msgs
}
13 changes: 12 additions & 1 deletion types/simulation/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package simulation

import (
"encoding/json"
"fmt"
"math/rand"
"reflect"
"time"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -75,7 +77,16 @@ func NewOperationMsgBasic(route, name, comment string, ok bool, msg []byte) Oper
}

// NewOperationMsg - create a new operation message from sdk.Msg
func NewOperationMsg(msg sdk.Msg, ok bool, comment string) OperationMsg {
func NewOperationMsg(msg sdk.Msg, ok bool, comment string, cdc *codec.ProtoCodec) OperationMsg {
if reflect.TypeOf(msg) == reflect.TypeOf(sdk.ServiceMsg{}) {
srvMsg, ok := msg.(sdk.ServiceMsg)
if !ok {
panic(fmt.Sprintf("Expecting %T to implement sdk.ServiceMsg", msg))
}
bz := cdc.MustMarshalJSON(srvMsg.Request)

return NewOperationMsgBasic(srvMsg.MethodName, srvMsg.MethodName, comment, ok, bz)
}
return NewOperationMsgBasic(msg.Route(), msg.Type(), comment, ok, msg.GetSignBytes())
}

Expand Down
Loading