-
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.
refactor: make tx router and query router per module
- Loading branch information
1 parent
baf6a8f
commit 15b554e
Showing
22 changed files
with
701 additions
and
206 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 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,45 @@ | ||
package authz | ||
|
||
import ( | ||
"github.com/xpladev/xpla.go/core" | ||
"github.com/xpladev/xpla.go/types/errors" | ||
"github.com/xpladev/xpla.go/util" | ||
|
||
cmclient "github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/x/authz" | ||
) | ||
|
||
type coreModule struct{} | ||
|
||
func NewCoreModule() core.CoreModule { | ||
return &coreModule{} | ||
} | ||
|
||
func (c *coreModule) Name() string { | ||
return AuthzModule | ||
} | ||
|
||
func (c *coreModule) NewTxRouter(builder cmclient.TxBuilder, msgType string, msg interface{}) (cmclient.TxBuilder, error) { | ||
switch { | ||
case msgType == AuthzGrantMsgType: | ||
convertMsg := msg.(authz.MsgGrant) | ||
builder.SetMsgs(&convertMsg) | ||
|
||
case msgType == AuthzRevokeMsgType: | ||
convertMsg := msg.(authz.MsgRevoke) | ||
builder.SetMsgs(&convertMsg) | ||
|
||
case msgType == AuthzExecMsgType: | ||
convertMsg := msg.(authz.MsgExec) | ||
builder.SetMsgs(&convertMsg) | ||
|
||
default: | ||
return nil, util.LogErr(errors.ErrInvalidMsgType, msgType) | ||
} | ||
|
||
return builder, nil | ||
} | ||
|
||
func (c *coreModule) NewQueryRouter(q core.QueryClient) (string, error) { | ||
return QueryAuthz(q) | ||
} |
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,37 @@ | ||
package bank | ||
|
||
import ( | ||
"github.com/xpladev/xpla.go/core" | ||
"github.com/xpladev/xpla.go/types/errors" | ||
"github.com/xpladev/xpla.go/util" | ||
|
||
cmclient "github.com/cosmos/cosmos-sdk/client" | ||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
) | ||
|
||
type coreModule struct{} | ||
|
||
func NewCoreModule() core.CoreModule { | ||
return &coreModule{} | ||
} | ||
|
||
func (c *coreModule) Name() string { | ||
return BankModule | ||
} | ||
|
||
func (c *coreModule) NewTxRouter(builder cmclient.TxBuilder, msgType string, msg interface{}) (cmclient.TxBuilder, error) { | ||
switch { | ||
case msgType == BankSendMsgType: | ||
convertMsg := msg.(banktypes.MsgSend) | ||
builder.SetMsgs(&convertMsg) | ||
|
||
default: | ||
return nil, util.LogErr(errors.ErrInvalidMsgType, msgType) | ||
} | ||
|
||
return builder, nil | ||
} | ||
|
||
func (c *coreModule) NewQueryRouter(q core.QueryClient) (string, error) { | ||
return QueryBank(q) | ||
} |
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,27 @@ | ||
package base | ||
|
||
import ( | ||
"github.com/xpladev/xpla.go/core" | ||
"github.com/xpladev/xpla.go/types/errors" | ||
"github.com/xpladev/xpla.go/util" | ||
|
||
cmclient "github.com/cosmos/cosmos-sdk/client" | ||
) | ||
|
||
type coreModule struct{} | ||
|
||
func NewCoreModule() core.CoreModule { | ||
return &coreModule{} | ||
} | ||
|
||
func (c *coreModule) Name() string { | ||
return Base | ||
} | ||
|
||
func (c *coreModule) NewTxRouter(_ cmclient.TxBuilder, _ string, _ interface{}) (cmclient.TxBuilder, error) { | ||
return nil, util.LogErr(errors.ErrInvalidRequest, c.Name(), "module has not tx") | ||
} | ||
|
||
func (c *coreModule) NewQueryRouter(q core.QueryClient) (string, error) { | ||
return QueryBase(q) | ||
} |
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
Oops, something went wrong.