From e4b8010077aac5987727758610e7909448767e07 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Wed, 21 Mar 2018 02:22:15 +0100 Subject: [PATCH] ParseAccount -> AccountDecoder --- examples/basecoin/cmd/basecli/main.go | 2 +- examples/basecoin/types/account.go | 4 ++-- types/account.go | 4 ++-- types/tx_msg.go | 2 +- x/auth/commands/account.go | 8 ++++---- x/auth/rest/query.go | 4 ++-- x/auth/rest/root.go | 2 +- x/ibc/commands/relay.go | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/basecoin/cmd/basecli/main.go b/examples/basecoin/cmd/basecli/main.go index a8ee8c1cf4..6fabc612c7 100644 --- a/examples/basecoin/cmd/basecli/main.go +++ b/examples/basecoin/cmd/basecli/main.go @@ -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( diff --git a/examples/basecoin/types/account.go b/examples/basecoin/types/account.go index 2e0b8397fb..552ce657bf 100644 --- a/examples/basecoin/types/account.go +++ b/examples/basecoin/types/account.go @@ -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) diff --git a/types/account.go b/types/account.go index 266b62d40f..c0fadcd3cf 100644 --- a/types/account.go +++ b/types/account.go @@ -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) diff --git a/types/tx_msg.go b/types/tx_msg.go index b81d2ddf98..79272f3862 100644 --- a/types/tx_msg.go +++ b/types/tx_msg.go @@ -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) //__________________________________________________________ diff --git a/x/auth/commands/account.go b/x/auth/commands/account.go index b6eb51896d..382e4f6fb3 100644 --- a/x/auth/commands/account.go +++ b/x/auth/commands/account.go @@ -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) @@ -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, @@ -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 { diff --git a/x/auth/rest/query.go b/x/auth/rest/query.go index 5629f15476..75220ed59c 100644 --- a/x/auth/rest/query.go +++ b/x/auth/rest/query.go @@ -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) diff --git a/x/auth/rest/root.go b/x/auth/rest/root.go index c6d6fd9ed7..5417cf8683 100644 --- a/x/auth/rest/root.go +++ b/x/auth/rest/root.go @@ -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") } diff --git a/x/ibc/commands/relay.go b/x/ibc/commands/relay.go index 37e4a4935e..8af5b83ab3 100644 --- a/x/ibc/commands/relay.go +++ b/x/ibc/commands/relay.go @@ -27,7 +27,7 @@ const ( type relayCommander struct { cdc *wire.Codec address sdk.Address - parser sdk.ParseAccount + parser sdk.AccountDecoder mainStore string ibcStore string } @@ -35,7 +35,7 @@ type relayCommander struct { func IBCRelayCmd(cdc *wire.Codec) *cobra.Command { cmdr := relayCommander{ cdc: cdc, - parser: authcmd.GetParseAccount(cdc), + parser: authcmd.GetAccountDecoder(cdc), ibcStore: "ibc", mainStore: "main", }