-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
R4R [Staging PR 1/3]: module generalization #4033
Changes from 29 commits
fc3343b
2ed7ec3
fa8d51b
78beb8b
f3c84d2
31e268a
f04fd65
b9fea80
53096ec
f89b67b
fc2c20a
f026bec
45d82f9
3f4d0cf
050317d
69a543e
95236c4
03328ee
9031e9d
480c10e
ef5ec28
3c681a6
4ad51d2
3620b2e
62342b2
6ce6260
c8c3a08
cd4d68f
2d95c57
631298e
a2cd3dc
022498e
092aab3
7977e7e
87ed491
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,16 +6,12 @@ import ( | |
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// Router provides handlers for each transaction type. | ||
type Router interface { | ||
AddRoute(r string, h sdk.Handler) (rtr Router) | ||
Route(path string) (h sdk.Handler) | ||
} | ||
|
||
type router struct { | ||
routes map[string]sdk.Handler | ||
} | ||
|
||
var _ sdk.Router = NewRouter() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct it's required to live there in order to not cause circular dependancies because the ModuleManager wants to use the the router interface |
||
|
||
// NewRouter returns a reference to a new router. | ||
// | ||
// TODO: Either make the function private or make return type (router) public. | ||
|
@@ -27,7 +23,7 @@ func NewRouter() *router { // nolint: golint | |
|
||
// AddRoute adds a route path to the router with a given handler. The route must | ||
// be alphanumeric. | ||
func (rtr *router) AddRoute(path string, h sdk.Handler) Router { | ||
func (rtr *router) AddRoute(path string, h sdk.Handler) sdk.Router { | ||
if !isAlphaNumeric(path) { | ||
panic("route expressions can only contain alphanumeric characters") | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,7 +231,7 @@ func TestCoinMultiSendGenerateOnly(t *testing.T) { | |
var stdTx auth.StdTx | ||
require.Nil(t, cdc.UnmarshalJSON([]byte(body), &stdTx)) | ||
require.Equal(t, len(stdTx.Msgs), 1) | ||
require.Equal(t, stdTx.GetMsgs()[0].Route(), "bank") | ||
require.Equal(t, stdTx.GetMsgs()[0].Route(), bank.RouterKey) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I can just kinda change everything to be using the module name, I've currently left things moreless how their structured which is define other constants to the name and then pass those these ways... I'm not sure that really makes sense - probably everything should just be switched to the module name aye? |
||
require.Equal(t, stdTx.GetMsgs()[0].GetSigners(), []sdk.AccAddress{addr}) | ||
require.Equal(t, 0, len(stdTx.Signatures)) | ||
require.Equal(t, memo, stdTx.Memo) | ||
|
@@ -267,7 +267,7 @@ func TestCoinSendGenerateSignAndBroadcast(t *testing.T) { | |
var tx auth.StdTx | ||
require.Nil(t, cdc.UnmarshalJSON([]byte(body), &tx)) | ||
require.Equal(t, len(tx.Msgs), 1) | ||
require.Equal(t, tx.Msgs[0].Route(), "bank") | ||
require.Equal(t, tx.Msgs[0].Route(), bank.RouterKey) | ||
require.Equal(t, tx.Msgs[0].GetSigners(), []sdk.AccAddress{addr}) | ||
require.Equal(t, 0, len(tx.Signatures)) | ||
require.Equal(t, memo, tx.Memo) | ||
|
@@ -387,8 +387,8 @@ func TestPoolParamsQuery(t *testing.T) { | |
tokens := sdk.TokensFromTendermintPower(100) | ||
freeTokens := sdk.TokensFromTendermintPower(50) | ||
initialPool.NotBondedTokens = initialPool.NotBondedTokens.Add(tokens) | ||
initialPool.BondedTokens = initialPool.BondedTokens.Add(tokens) // Delegate tx on GaiaAppGenState | ||
initialPool.NotBondedTokens = initialPool.NotBondedTokens.Add(freeTokens) // freeTokensPerAcc = 50 on GaiaAppGenState | ||
initialPool.BondedTokens = initialPool.BondedTokens.Add(tokens) // Delegate tx on GaiaAppGenState | ||
initialPool.NotBondedTokens = initialPool.NotBondedTokens.Add(freeTokens) | ||
|
||
require.Equal(t, initialPool.BondedTokens, pool.BondedTokens) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the
QueryRouter
implementation also want to live intypes
too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, for the reason mentioned in my previous comment