Skip to content

Commit

Permalink
ParseAccount -> AccountDecoder
Browse files Browse the repository at this point in the history
  • Loading branch information
ebuchman committed Mar 21, 2018
1 parent 328dd2f commit e4b8010
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/basecoin/cmd/basecli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func main() {
// add query/post commands (custom to binary)
basecliCmd.AddCommand(
client.GetCommands(
authcmd.GetAccountCmd("main", cdc, types.GetParseAccount(cdc)),
authcmd.GetAccountCmd("main", cdc, types.GetAccountDecoder(cdc)),
)...)
basecliCmd.AddCommand(
client.PostCommands(
Expand Down
4 changes: 2 additions & 2 deletions examples/basecoin/types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ type AppAccount struct {
func (acc AppAccount) GetName() string { return acc.Name }
func (acc *AppAccount) SetName(name string) { acc.Name = name }

// Get the ParseAccount function for the custom AppAccount
func GetParseAccount(cdc *wire.Codec) sdk.ParseAccount {
// Get the AccountDecoder function for the custom AppAccount
func GetAccountDecoder(cdc *wire.Codec) sdk.AccountDecoder {
return func(accBytes []byte) (res sdk.Account, err error) {
acct := new(AppAccount)
err = cdc.UnmarshalBinary(accBytes, &acct)
Expand Down
4 changes: 2 additions & 2 deletions types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ type AccountMapper interface {
SetAccount(ctx Context, acc Account)
}

// Application function variable used to unmarshal account
type ParseAccount func([]byte) (Account, error)
// AccountDecoder unmarshals account bytes
type AccountDecoder func(accountBytes []byte) (Account, error)
2 changes: 1 addition & 1 deletion types/tx_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (msg StdSignMsg) Bytes() []byte {

//__________________________________________________________

// Application function variable used to unmarshal transaction bytes
// TxDeocder unmarshals transaction bytes
type TxDecoder func(txBytes []byte) (Tx, Error)

//__________________________________________________________
Expand Down
8 changes: 4 additions & 4 deletions x/auth/commands/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (

// GetAccountCmd for the auth.BaseAccount type
func GetAccountCmdDefault(storeName string, cdc *wire.Codec) *cobra.Command {
return GetAccountCmd(storeName, cdc, GetParseAccount(cdc))
return GetAccountCmd(storeName, cdc, GetAccountDecoder(cdc))
}

func GetParseAccount(cdc *wire.Codec) sdk.ParseAccount {
func GetAccountDecoder(cdc *wire.Codec) sdk.AccountDecoder {
return func(accBytes []byte) (sdk.Account, error) {
acct := new(auth.BaseAccount)
err := cdc.UnmarshalBinary(accBytes, &acct)
Expand All @@ -32,7 +32,7 @@ func GetParseAccount(cdc *wire.Codec) sdk.ParseAccount {

// GetAccountCmd returns a query account that will display the
// state of the account at a given address
func GetAccountCmd(storeName string, cdc *wire.Codec, parser sdk.ParseAccount) *cobra.Command {
func GetAccountCmd(storeName string, cdc *wire.Codec, parser sdk.AccountDecoder) *cobra.Command {
cmdr := commander{
storeName,
cdc,
Expand All @@ -48,7 +48,7 @@ func GetAccountCmd(storeName string, cdc *wire.Codec, parser sdk.ParseAccount) *
type commander struct {
storeName string
cdc *wire.Codec
parser sdk.ParseAccount
parser sdk.AccountDecoder
}

func (c commander) getAccountCmd(cmd *cobra.Command, args []string) error {
Expand Down
4 changes: 2 additions & 2 deletions x/auth/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
type commander struct {
storeName string
cdc *wire.Codec
parser sdk.ParseAccount
parser sdk.AccountDecoder
}

func QueryAccountRequestHandler(storeName string, cdc *wire.Codec, parser sdk.ParseAccount) func(http.ResponseWriter, *http.Request) {
func QueryAccountRequestHandler(storeName string, cdc *wire.Codec, parser sdk.AccountDecoder) func(http.ResponseWriter, *http.Request) {
c := commander{storeName, cdc, parser}
return func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
Expand Down
2 changes: 1 addition & 1 deletion x/auth/rest/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import (
)

func RegisterRoutes(r *mux.Router, cdc *wire.Codec, storeName string) {
r.HandleFunc("/accounts/{address}", QueryAccountRequestHandler(storeName, cdc, auth.GetParseAccount(cdc))).Methods("GET")
r.HandleFunc("/accounts/{address}", QueryAccountRequestHandler(storeName, cdc, auth.GetAccountDecoder(cdc))).Methods("GET")
}
4 changes: 2 additions & 2 deletions x/ibc/commands/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ const (
type relayCommander struct {
cdc *wire.Codec
address sdk.Address
parser sdk.ParseAccount
parser sdk.AccountDecoder
mainStore string
ibcStore string
}

func IBCRelayCmd(cdc *wire.Codec) *cobra.Command {
cmdr := relayCommander{
cdc: cdc,
parser: authcmd.GetParseAccount(cdc),
parser: authcmd.GetAccountDecoder(cdc),
ibcStore: "ibc",
mainStore: "main",
}
Expand Down

0 comments on commit e4b8010

Please sign in to comment.