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 ADR 033 #157

Merged
merged 19 commits into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
24 changes: 19 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
servermodule "github.com/regen-network/regen-ledger/types/module/server"
"io"
"math/big"
"net/http"
Expand Down Expand Up @@ -87,6 +88,7 @@ import (

"github.com/CosmWasm/wasmd/x/wasm"
wasmclient "github.com/CosmWasm/wasmd/x/wasm/client"

data "github.com/regen-network/regen-ledger/x/data/module"
ecocredit "github.com/regen-network/regen-ledger/x/ecocredit/module"
)
Expand Down Expand Up @@ -123,9 +125,9 @@ var (
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
data.AppModuleBasic{},
wasm.AppModuleBasic{},
ecocredit.AppModuleBasic{},
ecocredit.Module{},
data.Module{},
)

// module account permissions
Expand Down Expand Up @@ -213,7 +215,7 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
data.StoreKey, ecocredit.StoreKey, wasm.StoreKey,
wasm.StoreKey,
)

tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -345,6 +347,20 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
&stakingKeeper, govRouter,
)

/* New Module Wiring START */
newModuleManager := servermodule.NewManager(app.BaseApp, codec.NewProtoCodec(interfaceRegistry))

err := newModuleManager.RegisterModules(ModuleBasics)
if err != nil {
panic(err)
}

err = newModuleManager.CompleteInitialization()
if err != nil {
panic(err)
}
/* New Module Wiring END */

app.mm = module.NewManager(
genutil.NewAppModule(
app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx,
Expand All @@ -365,9 +381,7 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.ParamsKeeper),
transferModule,
data.NewAppModule(keys[data.StoreKey]),
wasm.NewAppModule(app.wasmKeeper),
ecocredit.NewAppModule(keys[ecocredit.StoreKey]),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ go 1.15

require (
github.com/CosmWasm/wasmd v0.12.0-alpha1.0.20201105090402-41cf73dae976
github.com/armon/go-metrics v0.3.4
github.com/btcsuite/btcutil v1.0.2
github.com/cockroachdb/apd/v2 v2.0.2
github.com/cosmos/cosmos-sdk v0.40.0-rc2
github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.4.3
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.15.2
github.com/ipfs/go-cid v0.0.7
github.com/lib/pq v1.8.0 // indirect
github.com/multiformats/go-multihash v0.0.14
github.com/rakyll/statik v0.1.7
github.com/regen-network/cosmos-proto v0.3.0
github.com/spf13/afero v1.3.4 // indirect
github.com/spf13/cast v1.3.1
github.com/spf13/cobra v1.1.1
Expand All @@ -23,8 +26,9 @@ require (
github.com/tendermint/tendermint v0.34.0-rc5
github.com/tendermint/tm-db v0.6.2
golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9 // indirect
google.golang.org/genproto v0.0.0-20201112120144-2985b7af83de // indirect
google.golang.org/genproto v0.0.0-20201112120144-2985b7af83de
google.golang.org/grpc v1.33.0
gopkg.in/yaml.v2 v2.3.0
)

replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4
104 changes: 0 additions & 104 deletions testutil/server/configurator/configurator.go

This file was deleted.

15 changes: 0 additions & 15 deletions testutil/server/configurator/helper.go

This file was deleted.

78 changes: 0 additions & 78 deletions testutil/server/configurator/router.go

This file was deleted.

2 changes: 1 addition & 1 deletion testutil/server/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type FixtureFactory interface {
// independent of the backend.
type Fixture interface {

// Context is the context.Context to be used with gRPC generated cient code.
// Context is the context.Context to be used with gRPC generated client code.
Context() context.Context

// TxConn is the grpc.ClientConnInterface to be used when constructing Msg service clients.
Expand Down
13 changes: 13 additions & 0 deletions types/address.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package types

import "crypto/sha256"

func AddressHash(prefix string, contents []byte) []byte {
preImage := []byte(prefix)
if len(contents) != 0 {
preImage = append(preImage, 0)
preImage = append(preImage, contents...)
}
sum := sha256.Sum256(preImage)
return sum[:20]
}
10 changes: 10 additions & 0 deletions types/module/base.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package module

import (
"github.com/cosmos/cosmos-sdk/codec/types"
)

type ModuleBase interface {
Name() string
RegisterInterfaces(types.InterfaceRegistry)
}
18 changes: 18 additions & 0 deletions types/module/client/cli/module.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cli

import (
"encoding/json"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/regen-network/regen-ledger/types/module"
"github.com/spf13/cobra"
)

type Module interface {
module.ModuleBase

DefaultGenesis(codec.JSONMarshaler) json.RawMessage
ValidateGenesis(codec.JSONMarshaler, client.TxEncodingConfig, json.RawMessage) error
GetTxCmd() *cobra.Command
GetQueryCmd() *cobra.Command
}
13 changes: 13 additions & 0 deletions types/module/client/grpc_gateway/module.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package grpc_gateway

import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/regen-network/regen-ledger/types/module"
)

type Module interface {
module.ModuleBase

RegisterGRPCGatewayRoutes(client.Context, *runtime.ServeMux)
}
12 changes: 12 additions & 0 deletions types/module/id.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package module

import "github.com/regen-network/regen-ledger/types"

type ModuleID struct {
ModuleName string
Path []byte
}

func (m ModuleID) Address() []byte {
return types.AddressHash(m.ModuleName, m.Path)
}
Loading