Skip to content

Commit

Permalink
chore: fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiyong Ha committed Apr 19, 2021
1 parent 7354f3e commit 0237df4
Show file tree
Hide file tree
Showing 36 changed files with 170 additions and 141 deletions.
9 changes: 3 additions & 6 deletions store/prefix/legacy_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import (
tmdb "github.com/tendermint/tm-db"
)


// LegacyStore is an implementation to pass the store
// to the wasmvm for tendermint/tm-db dependency.
// line/tm-db/v2 has a modification to the Iterator interface, occured a type mismatch.
// line/tm-db/v2 has a modification to the Iterator interface, occurred a type mismatch.
// Do not use it for any purpose other than passing it to wasmvm in x/wasm.
type LegacyStore struct {
Store
Expand All @@ -20,7 +19,7 @@ func NewLegacyStore(parent types.KVStore, prefix []byte) LegacyStore {
return LegacyStore{
Store{
parent: parent,
prefix: prefix,
prefix: prefix,
},
}
}
Expand Down Expand Up @@ -74,20 +73,18 @@ type legacyPrefixIterator struct {
prefixIterator
}


func newLegacyPrefixIterator(prefix, start, end []byte, parent types.Iterator) *legacyPrefixIterator {
return &legacyPrefixIterator{
prefixIterator{
prefix: prefix,
start: start,
end: end,
iter: parent,
valid: parent.Valid() && bytes.HasPrefix(parent.Key(), prefix),
valid: parent.Valid() && bytes.HasPrefix(parent.Key(), prefix),
},
}
}


// Implements Iterator
func (pi *legacyPrefixIterator) Close() {
pi.iter.Close()
Expand Down
14 changes: 7 additions & 7 deletions x/wasm/client/cli/genesis_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"errors"
"fmt"

"github.com/line/lbm-sdk/v2/x/wasm/internal/types"
"github.com/line/lbm-sdk/v2/client"
"github.com/line/lbm-sdk/v2/client/flags"
"github.com/line/lbm-sdk/v2/crypto/keyring"
Expand All @@ -19,9 +18,10 @@ import (
banktypes "github.com/line/lbm-sdk/v2/x/bank/types"
"github.com/line/lbm-sdk/v2/x/genutil"
genutiltypes "github.com/line/lbm-sdk/v2/x/genutil/types"
"github.com/spf13/cobra"
"github.com/line/lbm-sdk/v2/x/wasm/internal/types"
"github.com/line/ostracon/crypto"
osttypes "github.com/line/ostracon/types"
"github.com/spf13/cobra"
)

// GenesisStoreCodeCmd cli command to add a `MsgStoreCode` to the wasm section of the genesis
Expand Down Expand Up @@ -198,7 +198,7 @@ func GenesisListCodesCmd(defaultNodeHome string) *cobra.Command {
if err != nil {
return err
}
return printJsonOutput(cmd, all)
return printJSONOutput(cmd, all)

},
}
Expand All @@ -221,7 +221,7 @@ func GenesisListContractsCmd(defaultNodeHome string) *cobra.Command {
}
state := g.wasmModuleState
all := getAllContracts(state)
return printJsonOutput(cmd, all)
return printJSONOutput(cmd, all)
},
}
cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory")
Expand All @@ -230,7 +230,7 @@ func GenesisListContractsCmd(defaultNodeHome string) *cobra.Command {
}

// clientCtx marshaller works only with proto or bytes so we marshal the output ourself
func printJsonOutput(cmd *cobra.Command, obj interface{}) error {
func printJSONOutput(cmd *cobra.Command, obj interface{}) error {
clientCtx := client.GetClientContextFromCmd(cmd)
bz, err := json.MarshalIndent(obj, "", " ")
if err != nil {
Expand All @@ -245,7 +245,7 @@ type codeMeta struct {
}

func getAllCodes(state *types.GenesisState) ([]codeMeta, error) {
var all []codeMeta
all := make([]codeMeta, 0, len(state.Codes))
for _, c := range state.Codes {
all = append(all, codeMeta{
CodeID: c.CodeID,
Expand Down Expand Up @@ -290,7 +290,7 @@ type contractMeta struct {
}

func getAllContracts(state *types.GenesisState) []contractMeta {
var all []contractMeta
all := make([]contractMeta, 0, len(state.Contracts))
for _, c := range state.Contracts {
all = append(all, contractMeta{
ContractAddress: c.ContractAddress,
Expand Down
2 changes: 1 addition & 1 deletion x/wasm/client/cli/gov_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package cli
import (
"fmt"

"github.com/line/lbm-sdk/v2/x/wasm/internal/types"
"github.com/line/lbm-sdk/v2/client"
"github.com/line/lbm-sdk/v2/client/tx"
sdk "github.com/line/lbm-sdk/v2/types"
"github.com/line/lbm-sdk/v2/x/gov/client/cli"
govtypes "github.com/line/lbm-sdk/v2/x/gov/types"
"github.com/line/lbm-sdk/v2/x/wasm/internal/types"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
Expand Down
8 changes: 6 additions & 2 deletions x/wasm/client/cli/new_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package cli
import (
"strconv"

"github.com/line/lbm-sdk/v2/x/wasm/internal/types"
"github.com/line/lbm-sdk/v2/client"
"github.com/line/lbm-sdk/v2/client/flags"
"github.com/line/lbm-sdk/v2/client/tx"
sdkerrors "github.com/line/lbm-sdk/v2/types/errors"
"github.com/line/lbm-sdk/v2/x/wasm/internal/types"
"github.com/spf13/cobra"
)

Expand All @@ -18,7 +18,7 @@ func MigrateContractCmd() *cobra.Command {
Short: "Migrate a wasm contract to a new code version",
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
clientCtx, _ := client.GetClientTxContext(cmd)

msg, err := parseMigrateContractArgs(args, clientCtx)
if err != nil {
Expand Down Expand Up @@ -60,6 +60,9 @@ func UpdateContractAdminCmd() *cobra.Command {
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

msg, err := parseUpdateContractAdminArgs(args, clientCtx)
if err != nil {
Expand All @@ -75,6 +78,7 @@ func UpdateContractAdminCmd() *cobra.Command {
return cmd
}

//nolint:unparam
func parseUpdateContractAdminArgs(args []string, cliCtx client.Context) (types.MsgUpdateAdmin, error) {
msg := types.MsgUpdateAdmin{
Sender: cliCtx.GetFromAddress().String(),
Expand Down
34 changes: 17 additions & 17 deletions x/wasm/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
"io/ioutil"
"strconv"

"github.com/line/lbm-sdk/v2/x/wasm/internal/types"
"github.com/gogo/protobuf/proto"
"github.com/line/lbm-sdk/v2/client"
"github.com/line/lbm-sdk/v2/client/flags"
codectypes "github.com/line/lbm-sdk/v2/codec/types"
sdk "github.com/line/lbm-sdk/v2/types"
"github.com/gogo/protobuf/proto"
"github.com/line/lbm-sdk/v2/x/wasm/internal/types"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
)
Expand Down Expand Up @@ -66,7 +66,7 @@ func GetCmdListCode() *cobra.Command {
if err != nil {
return err
}
return clientCtx.WithJSONMarshaler(&VanillaStdJsonMarshaller{}).PrintProto(res)
return clientCtx.WithJSONMarshaler(&VanillaStdJSONMarshaller{}).PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
Expand Down Expand Up @@ -107,7 +107,7 @@ func GetCmdListContractByCode() *cobra.Command {
if err != nil {
return err
}
return clientCtx.WithJSONMarshaler(&VanillaStdJsonMarshaller{}).PrintProto(res)
return clientCtx.WithJSONMarshaler(&VanillaStdJSONMarshaller{}).PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
Expand Down Expand Up @@ -148,7 +148,7 @@ func GetCmdQueryCode() *cobra.Command {
}

fmt.Printf("Downloading wasm code to %s\n", args[1])
return ioutil.WriteFile(args[1], res.Data, 0644)
return ioutil.WriteFile(args[1], res.Data, 0600)
},
}
flags.AddQueryFlagsToCmd(cmd)
Expand Down Expand Up @@ -183,7 +183,7 @@ func GetCmdGetContractInfo() *cobra.Command {
if err != nil {
return err
}
return clientCtx.WithJSONMarshaler(&VanillaStdJsonMarshaller{}).PrintProto(res)
return clientCtx.WithJSONMarshaler(&VanillaStdJSONMarshaller{}).PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
Expand Down Expand Up @@ -240,7 +240,7 @@ func GetCmdGetContractStateAll() *cobra.Command {
if err != nil {
return err
}
return clientCtx.WithJSONMarshaler(&VanillaStdJsonMarshaller{}).PrintProto(res)
return clientCtx.WithJSONMarshaler(&VanillaStdJSONMarshaller{}).PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
Expand Down Expand Up @@ -281,7 +281,7 @@ func GetCmdGetContractStateRaw() *cobra.Command {
if err != nil {
return err
}
return clientCtx.WithJSONMarshaler(&VanillaStdJsonMarshaller{}).PrintProto(res)
return clientCtx.WithJSONMarshaler(&VanillaStdJSONMarshaller{}).PrintProto(res)
},
}
decoder.RegisterFlags(cmd.PersistentFlags(), "key argument")
Expand Down Expand Up @@ -329,7 +329,7 @@ func GetCmdGetContractStateSmart() *cobra.Command {
if err != nil {
return err
}
return clientCtx.WithJSONMarshaler(&VanillaStdJsonMarshaller{}).PrintProto(res)
return clientCtx.WithJSONMarshaler(&VanillaStdJSONMarshaller{}).PrintProto(res)
},
}
decoder.RegisterFlags(cmd.PersistentFlags(), "query argument")
Expand Down Expand Up @@ -371,7 +371,7 @@ func GetCmdGetContractHistory() *cobra.Command {
return err
}

return clientCtx.WithJSONMarshaler(&VanillaStdJsonMarshaller{}).PrintProto(res)
return clientCtx.WithJSONMarshaler(&VanillaStdJSONMarshaller{}).PrintProto(res)
},
}

Expand Down Expand Up @@ -423,38 +423,38 @@ func asciiDecodeString(s string) ([]byte, error) {
return []byte(s), nil
}

type VanillaStdJsonMarshaller struct {
type VanillaStdJSONMarshaller struct {
}

func (x VanillaStdJsonMarshaller) MarshalInterfaceJSON(i proto.Message) ([]byte, error) {
func (x VanillaStdJSONMarshaller) MarshalInterfaceJSON(i proto.Message) ([]byte, error) {
any, err := codectypes.NewAnyWithValue(i)
if err != nil {
return nil, err
}
return x.MarshalJSON(any)
}

func (x VanillaStdJsonMarshaller) MarshalJSON(o proto.Message) ([]byte, error) {
func (x VanillaStdJSONMarshaller) MarshalJSON(o proto.Message) ([]byte, error) {
return json.MarshalIndent(o, "", " ")
}

func (x VanillaStdJsonMarshaller) MustMarshalJSON(o proto.Message) []byte {
func (x VanillaStdJSONMarshaller) MustMarshalJSON(o proto.Message) []byte {
b, err := x.MarshalJSON(o)
if err != nil {
panic(err)
}
return b
}

func (x VanillaStdJsonMarshaller) UnmarshalInterfaceJSON(bz []byte, ptr interface{}) error {
func (x VanillaStdJSONMarshaller) UnmarshalInterfaceJSON(bz []byte, ptr interface{}) error {
panic("not supported")
}

func (x VanillaStdJsonMarshaller) UnmarshalJSON(bz []byte, ptr proto.Message) error {
func (x VanillaStdJSONMarshaller) UnmarshalJSON(bz []byte, ptr proto.Message) error {
panic("not supported")
}

func (x VanillaStdJsonMarshaller) MustUnmarshalJSON(bz []byte, ptr proto.Message) {
func (x VanillaStdJSONMarshaller) MustUnmarshalJSON(bz []byte, ptr proto.Message) {
panic("not supported")
}

Expand Down
14 changes: 11 additions & 3 deletions x/wasm/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"io/ioutil"
"strconv"

wasmUtils "github.com/line/lbm-sdk/v2/x/wasm/client/utils"
"github.com/line/lbm-sdk/v2/x/wasm/internal/types"
"github.com/line/lbm-sdk/v2/client"
"github.com/line/lbm-sdk/v2/client/flags"
"github.com/line/lbm-sdk/v2/client/tx"
sdk "github.com/line/lbm-sdk/v2/types"
sdkerrors "github.com/line/lbm-sdk/v2/types/errors"
wasmUtils "github.com/line/lbm-sdk/v2/x/wasm/client/utils"
"github.com/line/lbm-sdk/v2/x/wasm/internal/types"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
)
Expand Down Expand Up @@ -57,6 +57,9 @@ func StoreCodeCmd() *cobra.Command {
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
msg, err := parseStoreCodeArgs(args[0], clientCtx.GetFromAddress(), cmd.Flags())
if err != nil {
return err
Expand Down Expand Up @@ -150,7 +153,9 @@ func InstantiateContractCmd() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {

clientCtx, err := client.GetClientTxContext(cmd)

if err != nil {
return err
}
msg, err := parseInstantiateArgs(args[0], args[1], clientCtx.GetFromAddress(), cmd.Flags())
if err != nil {
return err
Expand Down Expand Up @@ -216,6 +221,9 @@ func ExecuteContractCmd() *cobra.Command {
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

msg, err := parseExecuteArgs(args[0], args[1], clientCtx.GetFromAddress(), cmd.Flags())
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion x/wasm/client/proposal_handler.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package client

import (
govclient "github.com/line/lbm-sdk/v2/x/gov/client"
"github.com/line/lbm-sdk/v2/x/wasm/client/cli"
"github.com/line/lbm-sdk/v2/x/wasm/client/rest"
govclient "github.com/line/lbm-sdk/v2/x/gov/client"
)

// ProposalHandlers define the wasm cli proposal types and rest handler.
Expand Down
Loading

0 comments on commit 0237df4

Please sign in to comment.