-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP on module refactor, ADR 028, 033 * WIP * WIP * got it working * refactor * cleanup * cleanup * prevent re-entrancy * add authz middleware hook * use Modules instead of ModuleBasics * Update types/module/server/router.go Co-authored-by: Robert Zaremba <[email protected]> * lint * docs and cleanup * Update types/module/server/router.go Co-authored-by: Cory <[email protected]> * docs and cleanup Co-authored-by: Robert Zaremba <[email protected]> Co-authored-by: Cory <[email protected]>
- Loading branch information
1 parent
7f9fd48
commit e81ef35
Showing
32 changed files
with
803 additions
and
368 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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,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] | ||
} |
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,10 @@ | ||
package types | ||
|
||
type ModuleID struct { | ||
ModuleName string | ||
Path []byte | ||
} | ||
|
||
func (m ModuleID) Address() []byte { | ||
return AddressHash(m.ModuleName, m.Path) | ||
} |
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,15 @@ | ||
package module | ||
|
||
import "github.com/cosmos/cosmos-sdk/codec/types" | ||
|
||
// Module is the base module type that all modules (client and server) must satisfy. | ||
type Module interface { | ||
Name() string | ||
} | ||
|
||
// TypeModule is an interface that modules should implement to register types. | ||
type TypeModule interface { | ||
Module | ||
|
||
RegisterInterfaces(types.InterfaceRegistry) | ||
} |
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,20 @@ | ||
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" | ||
) | ||
|
||
// Module is an interface that modules should implement to integrate with the CLI framework. | ||
type Module interface { | ||
module.TypeModule | ||
|
||
DefaultGenesis(codec.JSONMarshaler) json.RawMessage | ||
ValidateGenesis(codec.JSONMarshaler, client.TxEncodingConfig, json.RawMessage) error | ||
GetTxCmd() *cobra.Command | ||
GetQueryCmd() *cobra.Command | ||
} |
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,14 @@ | ||
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" | ||
) | ||
|
||
// Module is an interface that modules should implement to register grpc-gateway routes. | ||
type Module interface { | ||
module.Module | ||
|
||
RegisterGRPCGatewayRoutes(client.Context, *runtime.ServeMux) | ||
} |
Oops, something went wrong.