forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x/authz: audit updates (cosmos#9042)
* x/authz: audit updates * audit with Aaron * authz: Update Authorization.Accept method * authz: add event proto definitions * update query service * authz: use typed events * refactore and rename query authorizations * remve Authorization infix from proto services * renames wip * refactoring * update tests * fix compilation * fixing gRPC query tests * fix simulation tests * few renames * more refactore * add missing file * moving export genesis to keeper * Update docs * update tests * rename event Msg attribute to MsgTypeURL * Upate Authorization interface * rollback Makefile changes * fix tests * Apply suggestions from code review Co-authored-by: Aaron Craelius <[email protected]> * renames * refactore authz/exported * lint fix * authz/types refactore * comment update * conflict updates * Apply suggestions from code review Co-authored-by: Amaury <[email protected]> * authz: move storage keys to keeper * review updates * docs update * Update x/authz/client/cli/query.go Co-authored-by: Aaron Craelius <[email protected]> * move codec to the root package * authz CMD info update * comment update * update imports and build flags * fix functional tests * update proto comment * fix tests * fix test Co-authored-by: Aaron Craelius <[email protected]> Co-authored-by: Amaury <[email protected]>
- Loading branch information
1 parent
4f306fc
commit 59810f3
Showing
72 changed files
with
3,087 additions
and
3,194 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
syntax = "proto3"; | ||
package cosmos.authz.v1beta1; | ||
|
||
option go_package = "github.com/cosmos/cosmos-sdk/x/authz"; | ||
|
||
// EventGrant is emitted on Msg/Grant | ||
message EventGrant { | ||
// Msg type URL for which an autorization is granted | ||
string msg_type_url = 2; | ||
// Granter account address | ||
string granter = 3; | ||
// Grantee account address | ||
string grantee = 4; | ||
} | ||
|
||
// EventRevoke is emitted on Msg/Revoke | ||
message EventRevoke { | ||
// Msg type URL for which an autorization is revoked | ||
string msg_type_url = 2; | ||
// Granter account address | ||
string granter = 3; | ||
// Grantee account address | ||
string grantee = 4; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package authz | ||
|
||
import ( | ||
"time" | ||
|
||
proto "github.com/gogo/protobuf/proto" | ||
|
||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
) | ||
|
||
// NewGrant returns new AuthrizationGrant | ||
func NewGrant(authorization Authorization, expiration time.Time) (Grant, error) { | ||
auth := Grant{ | ||
Expiration: expiration, | ||
} | ||
msg, ok := authorization.(proto.Message) | ||
if !ok { | ||
return Grant{}, sdkerrors.Wrapf(sdkerrors.ErrPackAny, "cannot proto marshal %T", authorization) | ||
} | ||
|
||
any, err := cdctypes.NewAnyWithValue(msg) | ||
if err != nil { | ||
return Grant{}, err | ||
} | ||
|
||
auth.Authorization = any | ||
|
||
return auth, nil | ||
} | ||
|
||
var ( | ||
_ cdctypes.UnpackInterfacesMessage = &Grant{} | ||
) | ||
|
||
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces | ||
func (auth Grant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { | ||
var authorization Authorization | ||
return unpacker.UnpackAny(auth.Authorization, &authorization) | ||
} | ||
|
||
// GetAuthorization returns the cached value from the Grant.Authorization if present. | ||
func (auth Grant) GetAuthorization() Authorization { | ||
authorization, ok := auth.Authorization.GetCachedValue().(Authorization) | ||
if !ok { | ||
return nil | ||
} | ||
return authorization | ||
} |
Oops, something went wrong.