Skip to content

Commit

Permalink
[x/group] Add amino JSON signing support and CLI (#220)
Browse files Browse the repository at this point in the history
* Add group module and updated proto

* Delete unrelevant files

* WIP on upgrade to stargate

* Add TODO

* Fix proto-gen

* Fix group AppModule and AppModuleBasic

* More migration in x/group

* Fix lint

* More lint fix

* Rename GroupID

* Fix TestGroupMetadataValidation and add UnpackInterfaces

* Refacto to use Msg services

* Move module impl to x/group/module and remove amino

* Fix build

* Fix lint

* Clean up testutil

* Add Proposal and CreateProposal rpc, use Any for msgs in it

* Fix lint

* Fix initParamsKeeper

* Comment group ref in app

* Add comments in proto

* gen proto

* wip on tests

* Setup test suite

* Rm keeper_test

* Rm testsupport.go

* Move old hander tests to testsuite and use msgClient in tests

* Use BinaryMarshaler in ORM to unpack Any's

* Fix exec proposal tests

* Fix group tests

* Add proposal executor tests

* Update ORM tests

* Wire up group module to regen app

* Fix lint

* Fix proto lint

* Renaming

* Update ORM

* Remove errors pkg

* Improve proposal doc

* Fix events types

* Update comment

* Clean up

* Use GroupId

* Use ProposalId

* Update conditions.go

* Rename to GetGroupMembers

* Add assertCommentSize

* Update x/group/server/keeper.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Update x/group/server/keeper.go

Co-authored-by: Robert Zaremba <robert@zaremba.ch>

* Rename result enum value

* Add doc

* Add doc

* Use apd.Decimal instead of sdk.Dec

* Rename to GroupInfo and GroupAcountInfo

* Move group/types to group

* Remove tmp query.proto

* Move Keeper methods to serverImpl

* Add Query service proto def

* Add first impl of query service

* Finish up query service and rm keeper

* Lint

* Rename GroupID to ID

* Support Key page request with index.Get

* Lint

* Format

* Use bech32 addresses

* Lint

* Update group events

* Refactor group module to work with new proto codegen

* Lint

* Update protocgen script

* Add amino registration and handler

* Add CLI wip

* Add tx cli

* WIP on query cli

* Add some query cmd

* Fix build

* Update protobuf.md

* group client and module cleanup

* Add remaining CLI queries

* rm dead code

* Register Msgs

* Add LegacyRouteModule

* CLI test wip

* Add more CLI tests

* Add more query CLI tests

* Add tx group update CLI tests wip

* Use app.AccountKeeper

* Add remaining CLI tests

* Revert orm index

* Add cli tests for group account actions (#258)

* add remaining tests

* removed logs

* fixed tests

* Update types/module/server/manager.go

Co-authored-by: Amaury <amaury.martiny@protonmail.com>

* Clean up

* Remove s.maxMetadataLength

* Lint

Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com>
Co-authored-by: Amaury <amaury.martiny@protonmail.com>
  • Loading branch information
4 people committed Feb 17, 2021
1 parent ded982b commit d19b384
Show file tree
Hide file tree
Showing 17 changed files with 3,589 additions and 60 deletions.
3 changes: 1 addition & 2 deletions app/experimental_appconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/types/module"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"

moduletypes "github.com/regen-network/regen-ledger/types/module"
servermodule "github.com/regen-network/regen-ledger/types/module/server"
Expand All @@ -29,7 +28,7 @@ func setCustomModules(app *RegenApp, interfaceRegistry types.InterfaceRegistry)
newModuleManager := servermodule.NewManager(app.BaseApp, codec.NewProtoCodec(interfaceRegistry))

// BEGIN HACK: this is a total, ugly hack until x/auth supports ADR 033 or we have a suitable alternative
groupModule := group.Module{AccountKeeper: authkeeper.AccountKeeper{}}
groupModule := group.Module{AccountKeeper: app.AccountKeeper}
// use a separate newModules from the global NewModules here because we need to pass state into the group module
newModules := []moduletypes.Module{
ecocredit.Module{},
Expand Down
1 change: 0 additions & 1 deletion docs/modules/data/protobuf.md
Original file line number Diff line number Diff line change
Expand Up @@ -571,4 +571,3 @@ The sender in StoreRawData is not attesting to the veracity of the underlying da
| <a name="bool" /> bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass |
| <a name="string" /> string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) |
| <a name="bytes" /> bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) |

43 changes: 43 additions & 0 deletions types/module/configurator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package module

import (
"github.com/cosmos/cosmos-sdk/codec"
sdkmodule "github.com/cosmos/cosmos-sdk/types/module"
"github.com/gogo/protobuf/grpc"
)

// Configurator extends the cosmos sdk Configurator interface
// with Marshaler()
type Configurator interface {
sdkmodule.Configurator

Marshaler() codec.Marshaler
}

type configurator struct {
msgServer grpc.Server
queryServer grpc.Server
cdc codec.Marshaler
}

// NewConfigurator returns a new Configurator instance
func NewConfigurator(msgServer grpc.Server, queryServer grpc.Server, cdc codec.Marshaler) Configurator {
return configurator{msgServer: msgServer, queryServer: queryServer, cdc: cdc}
}

var _ Configurator = configurator{}

// MsgServer implements the Configurator.MsgServer method
func (c configurator) MsgServer() grpc.Server {
return c.msgServer
}

// QueryServer implements the Configurator.QueryServer method
func (c configurator) QueryServer() grpc.Server {
return c.queryServer
}

// Marshaler implements the Configurator.Marshaler method
func (c configurator) Marshaler() codec.Marshaler {
return c.cdc
}
9 changes: 9 additions & 0 deletions types/module/server/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ func (mm *Manager) RegisterModules(modules []module.Module) error {

serverMod.RegisterServices(cfg)

// If mod implements LegacyRouteModule, register module route.
// This is currently used for the group module as part of #218.
routeMod, ok := mod.(LegacyRouteModule)
if ok {
if r := routeMod.Route(cfg); !r.Empty() {
mm.baseApp.Router().AddRoute(r)
}
}

for typ := range cfg.requiredServices {
mm.requiredServices[typ] = true
}
Expand Down
7 changes: 7 additions & 0 deletions types/module/server/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ type Configurator interface {
// TODO: remove once #225 addressed
Router() sdk.Router
}

// LegacyRouteModule is the module type that a module must implement
// to support legacy sdk.Msg routing.
// This is currently used for the group module as part of #218.
type LegacyRouteModule interface {
Route(Configurator) sdk.Route
}
Loading

0 comments on commit d19b384

Please sign in to comment.