From a4f2cb5731730981b3a803ee50c3f63230b824f9 Mon Sep 17 00:00:00 2001 From: 0xmuralik Date: Mon, 17 Oct 2022 12:17:56 +0530 Subject: [PATCH] gofumpt and ignore duplicates --- app/ante/ante_test.go | 2 +- ethereum/eip712/preprocess_test.go | 8 ++++--- gql/resolver.go | 2 -- gql/util.go | 21 +--------------- tests/rpc/ws_test.go | 5 ++-- x/auction/client/cli/tx.go | 2 +- x/auction/keeper/grpc_query_test.go | 4 +--- x/auction/keeper/msg_server.go | 2 ++ x/auction/types/msgs.go | 2 -- x/bond/client/testutil/grpc.go | 2 -- x/bond/client/testutil/query.go | 1 - x/bond/client/testutil/tx.go | 2 ++ x/bond/genesis.go | 4 ++-- x/bond/keeper/grpc_query_test.go | 4 +--- x/bond/keeper/msg_server.go | 2 ++ x/bond/types/params.go | 1 + x/evm/types/access_list_tx_test.go | 2 +- x/evm/types/tx_args_test.go | 32 ++++++++++++------------- x/nameservice/client/cli/query.go | 1 - x/nameservice/client/cli/tx.go | 2 +- x/nameservice/client/testutil/grpc.go | 16 +++++-------- x/nameservice/client/testutil/query.go | 14 ++++------- x/nameservice/client/testutil/tx.go | 15 ++++-------- x/nameservice/genesis.go | 3 +-- x/nameservice/helpers/helpers.go | 4 +--- x/nameservice/keeper/grpc_query_test.go | 2 +- x/nameservice/keeper/keeper.go | 7 ++---- x/nameservice/keeper/keeper_test.go | 4 +--- x/nameservice/keeper/msg_server.go | 3 +++ x/nameservice/keeper/naming_keeper.go | 1 - x/nameservice/keeper/record_keeper.go | 8 +++---- x/nameservice/module.go | 1 - x/nameservice/types/msg.go | 2 -- x/nameservice/types/params.go | 7 +++--- x/nameservice/types/types.go | 2 +- 35 files changed, 74 insertions(+), 116 deletions(-) diff --git a/app/ante/ante_test.go b/app/ante/ante_test.go index d712dbc2..b8415fac 100644 --- a/app/ante/ante_test.go +++ b/app/ante/ante_test.go @@ -344,7 +344,7 @@ func (suite AnteTestSuite) TestAnteHandler() { coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)) gasAmount := sdk.NewCoins(coinAmount) gas := uint64(200000) - //reusing the gasAmount for deposit + // reusing the gasAmount for deposit deposit := sdk.NewCoins(coinAmount) txBuilder := suite.CreateTestEIP712SubmitProposal(from, privKey, "ethermint_9000-1", gas, gasAmount, deposit) return txBuilder.GetTx() diff --git a/ethereum/eip712/preprocess_test.go b/ethereum/eip712/preprocess_test.go index e8b2c4a6..06aa690b 100644 --- a/ethereum/eip712/preprocess_test.go +++ b/ethereum/eip712/preprocess_test.go @@ -23,9 +23,11 @@ import ( ) // Testing Constants -var chainId = "ethermint_9000-1" -var ctx = client.Context{}.WithTxConfig( - encoding.MakeConfig(app.ModuleBasics).TxConfig, +var ( + chainId = "ethermint_9000-1" + ctx = client.Context{}.WithTxConfig( + encoding.MakeConfig(app.ModuleBasics).TxConfig, + ) ) var feePayerAddress = "ethm17xpfvakm2amg962yls6f84z3kell8c5lthdzgl" diff --git a/gql/resolver.go b/gql/resolver.go index 1ea452aa..cf1facd8 100644 --- a/gql/resolver.go +++ b/gql/resolver.go @@ -125,7 +125,6 @@ func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueI All: (all != nil && *all), }, ) - if err != nil { return nil, err } @@ -142,7 +141,6 @@ func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueI } return gqlResponse, nil - } func (q queryResolver) GetRecordsByIds(ctx context.Context, ids []string) ([]*Record, error) { diff --git a/gql/util.go b/gql/util.go index 034d1696..7c620bbe 100644 --- a/gql/util.go +++ b/gql/util.go @@ -38,6 +38,7 @@ func getGQLCoins(coins sdk.Coins) []*Coin { return gqlCoins } + func GetGQLNameAuthorityRecord(record *nstypes.NameAuthority) (*AuthorityRecord, error) { if record == nil { return nil, nil @@ -118,26 +119,6 @@ func getGQLBond(bondObj *bondtypes.Bond) (*Bond, error) { }, nil } -func matchBondOnAttributes(bondObj *bondtypes.Bond, attributes []*KeyValueInput) bool { - for _, attr := range attributes { - switch attr.Key { - case OwnerAttributeName: - { - if attr.Value.String == nil || bondObj.Owner != *attr.Value.String { - return false - } - } - default: - { - // Only attributes explicitly listed in the switch are queryable. - return false - } - } - } - - return true -} - func getAuctionBid(bid *auctiontypes.Bid) *AuctionBid { return &AuctionBid{ BidderAddress: bid.BidderAddress, diff --git a/tests/rpc/ws_test.go b/tests/rpc/ws_test.go index a13668e9..ea591808 100644 --- a/tests/rpc/ws_test.go +++ b/tests/rpc/ws_test.go @@ -3,13 +3,14 @@ package rpc import ( "encoding/json" "fmt" - "github.com/gorilla/websocket" - "github.com/stretchr/testify/require" "net/url" "os" "strings" "testing" "time" + + "github.com/gorilla/websocket" + "github.com/stretchr/testify/require" ) var ( diff --git a/x/auction/client/cli/tx.go b/x/auction/client/cli/tx.go index e87bac42..def12836 100644 --- a/x/auction/client/cli/tx.go +++ b/x/auction/client/cli/tx.go @@ -134,7 +134,7 @@ func GetCmdCommitBid() *cobra.Command { } // Save reveal file. - ioutil.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.GetFromName(), commitHash), content, 0600) + ioutil.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.GetFromName(), commitHash), content, 0o600) msg := types.NewMsgCommitBid(auctionID, commitHash, clientCtx.GetFromAddress()) err = msg.ValidateBasic() diff --git a/x/auction/keeper/grpc_query_test.go b/x/auction/keeper/grpc_query_test.go index 9a10e5d5..cf81e52d 100644 --- a/x/auction/keeper/grpc_query_test.go +++ b/x/auction/keeper/grpc_query_test.go @@ -13,9 +13,7 @@ import ( const testCommitHash = "71D8CF34026E32A3A34C2C2D4ADF25ABC8D7943A4619761BE27F196603D91B9D" -var ( - seed = int64(233) -) +var seed = int64(233) func (suite *KeeperTestSuite) TestGrpcGetAllAuctions() { client, ctx, k := suite.queryClient, suite.ctx, suite.app.AuctionKeeper diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index e336cb4e..75a97ab6 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -50,6 +50,7 @@ func (s msgServer) CreateAuction(c context.Context, msg *types.MsgCreateAuction) } // CommitBid is the command for committing a bid +//nolint: all func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types.MsgCommitBidResponse, error) { ctx := sdk.UnwrapSDKContext(c) @@ -80,6 +81,7 @@ func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types } //RevealBid is the command for revealing a bid +//nolint: all func (s msgServer) RevealBid(c context.Context, msg *types.MsgRevealBid) (*types.MsgRevealBidResponse, error) { ctx := sdk.UnwrapSDKContext(c) diff --git a/x/auction/types/msgs.go b/x/auction/types/msgs.go index 7b2069d8..fa5f916f 100644 --- a/x/auction/types/msgs.go +++ b/x/auction/types/msgs.go @@ -63,7 +63,6 @@ func (msg MsgCreateAuction) GetSigners() []sdk.AccAddress { // NewMsgCommitBid is the constructor function for MsgCommitBid. func NewMsgCommitBid(auctionID string, commitHash string, signer sdk.AccAddress) MsgCommitBid { - return MsgCommitBid{ AuctionId: auctionID, CommitHash: commitHash, @@ -107,7 +106,6 @@ func (msg MsgCommitBid) GetSigners() []sdk.AccAddress { // NewMsgRevealBid is the constructor function for MsgRevealBid. func NewMsgRevealBid(auctionID string, reveal string, signer sdk.AccAddress) MsgRevealBid { - return MsgRevealBid{ AuctionId: auctionID, Reveal: reveal, diff --git a/x/bond/client/testutil/grpc.go b/x/bond/client/testutil/grpc.go index d397e1be..658f3d28 100644 --- a/x/bond/client/testutil/grpc.go +++ b/x/bond/client/testutil/grpc.go @@ -28,7 +28,6 @@ func (s *IntegrationTestSuite) TestGRPCGetBonds() { true, "", func() { - }, }, { @@ -87,7 +86,6 @@ func (s *IntegrationTestSuite) TestGRPCGetBondsByOwner() { fmt.Sprintf(reqUrl, "asdasd"), true, func() { - }, }, { diff --git a/x/bond/client/testutil/query.go b/x/bond/client/testutil/query.go index cd83a4d6..85a77680 100644 --- a/x/bond/client/testutil/query.go +++ b/x/bond/client/testutil/query.go @@ -251,7 +251,6 @@ func (s *IntegrationTestSuite) TestGetQueryBondListsByOwner() { }, true, func() { - }, }, { diff --git a/x/bond/client/testutil/tx.go b/x/bond/client/testutil/tx.go index 37006594..5cff1071 100644 --- a/x/bond/client/testutil/tx.go +++ b/x/bond/client/testutil/tx.go @@ -63,6 +63,7 @@ func (s *IntegrationTestSuite) TestTxCreateBond() { } } +//nolint: all func (s *IntegrationTestSuite) TestTxRefillBond() { val := s.network.Validators[0] sr := s.Require() @@ -148,6 +149,7 @@ func (s *IntegrationTestSuite) TestTxRefillBond() { } } +//nolint: all func (s *IntegrationTestSuite) TestTxWithdrawAmountFromBond() { val := s.network.Validators[0] sr := s.Require() diff --git a/x/bond/genesis.go b/x/bond/genesis.go index cc6c884a..c144af86 100644 --- a/x/bond/genesis.go +++ b/x/bond/genesis.go @@ -10,8 +10,8 @@ import ( // InitGenesis initializes genesis state based on exported genesis func InitGenesis( ctx sdk.Context, - k keeper.Keeper, data types.GenesisState) []abci.ValidatorUpdate { - + k keeper.Keeper, data types.GenesisState, +) []abci.ValidatorUpdate { k.SetParams(ctx, data.Params) for _, bond := range data.Bonds { diff --git a/x/bond/keeper/grpc_query_test.go b/x/bond/keeper/grpc_query_test.go index c0a22dd3..519db248 100644 --- a/x/bond/keeper/grpc_query_test.go +++ b/x/bond/keeper/grpc_query_test.go @@ -11,9 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank/testutil" ) -var ( - seed = int64(233) -) +var seed = int64(233) func (suite *KeeperTestSuite) TestGrpcQueryBondsList() { grpcClient, ctx, k := suite.queryClient, suite.ctx, suite.app.BondKeeper diff --git a/x/bond/keeper/msg_server.go b/x/bond/keeper/msg_server.go index 818d3aab..ab7f9884 100644 --- a/x/bond/keeper/msg_server.go +++ b/x/bond/keeper/msg_server.go @@ -45,6 +45,7 @@ func (k msgServer) CreateBond(c context.Context, msg *types.MsgCreateBond) (*typ return &types.MsgCreateBondResponse{}, nil } +//nolint: all func (k msgServer) RefillBond(c context.Context, msg *types.MsgRefillBond) (*types.MsgRefillBondResponse, error) { ctx := sdk.UnwrapSDKContext(c) signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) @@ -74,6 +75,7 @@ func (k msgServer) RefillBond(c context.Context, msg *types.MsgRefillBond) (*typ return &types.MsgRefillBondResponse{}, nil } +//nolint: all func (k msgServer) WithdrawBond(c context.Context, msg *types.MsgWithdrawBond) (*types.MsgWithdrawBondResponse, error) { ctx := sdk.UnwrapSDKContext(c) signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) diff --git a/x/bond/types/params.go b/x/bond/types/params.go index 587f8c6f..c5933c3f 100644 --- a/x/bond/types/params.go +++ b/x/bond/types/params.go @@ -3,6 +3,7 @@ package types import ( "errors" "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) diff --git a/x/evm/types/access_list_tx_test.go b/x/evm/types/access_list_tx_test.go index 7ccef3ee..88a171da 100644 --- a/x/evm/types/access_list_tx_test.go +++ b/x/evm/types/access_list_tx_test.go @@ -60,7 +60,7 @@ func (suite *TxDataTestSuite) TestAccessListTxGetGasFeeCap() { func (suite *TxDataTestSuite) TestEmptyAccessList() { testCases := []struct { name string - tx AccessListTx + tx AccessListTx }{ { "empty access list tx", diff --git a/x/evm/types/tx_args_test.go b/x/evm/types/tx_args_test.go index 5ebc4d7c..9e8c20aa 100644 --- a/x/evm/types/tx_args_test.go +++ b/x/evm/types/tx_args_test.go @@ -11,9 +11,9 @@ import ( func (suite *TxDataTestSuite) TestTxArgsString() { testCases := []struct { - name string - txArgs TransactionArgs - expectedString string + name string + txArgs TransactionArgs + expectedString string }{ { "empty tx args", @@ -32,25 +32,25 @@ func (suite *TxDataTestSuite) TestTxArgsString() { AccessList: ðtypes.AccessList{}, }, fmt.Sprintf("TransactionArgs{From:%v, To:%v, Gas:%v, Nonce:%v, Data:%v, Input:%v, AccessList:%v}", - &suite.addr, - &suite.addr, - &suite.hexUint64, - &suite.hexUint64, - &suite.hexDataBytes, - &suite.hexInputBytes, - ðtypes.AccessList{}), + &suite.addr, + &suite.addr, + &suite.hexUint64, + &suite.hexUint64, + &suite.hexDataBytes, + &suite.hexInputBytes, + ðtypes.AccessList{}), }, } for _, tc := range testCases { outputString := tc.txArgs.String() - suite.Require().Equal(outputString, tc.expectedString) + suite.Require().Equal(outputString, tc.expectedString) } } func (suite *TxDataTestSuite) TestConvertTxArgsEthTx() { testCases := []struct { - name string - txArgs TransactionArgs + name string + txArgs TransactionArgs }{ { "empty tx args", @@ -227,9 +227,9 @@ func (suite *TxDataTestSuite) TestToMessageEVM() { func (suite *TxDataTestSuite) TestGetFrom() { testCases := []struct { - name string - txArgs TransactionArgs - expAddress common.Address + name string + txArgs TransactionArgs + expAddress common.Address }{ { "empty from field", diff --git a/x/nameservice/client/cli/query.go b/x/nameservice/client/cli/query.go index 627cd716..95427ba2 100644 --- a/x/nameservice/client/cli/query.go +++ b/x/nameservice/client/cli/query.go @@ -266,7 +266,6 @@ $ %s query %s query-by-bond [bond id] return err } return clientCtx.PrintProto(res) - }, } flags.AddQueryFlagsToCmd(cmd) diff --git a/x/nameservice/client/cli/tx.go b/x/nameservice/client/cli/tx.go index f181ae3c..1c9a6f5b 100644 --- a/x/nameservice/client/cli/tx.go +++ b/x/nameservice/client/cli/tx.go @@ -371,7 +371,7 @@ $ %s tx %s delete-name [crn] return cmd } -//GetPayloadFromFile Load payload object from YAML file. +// GetPayloadFromFile Load payload object from YAML file. func GetPayloadFromFile(filePath string) (*types.PayloadType, error) { var payload types.PayloadType diff --git a/x/nameservice/client/testutil/grpc.go b/x/nameservice/client/testutil/grpc.go index 138a0c56..cbe35d48 100644 --- a/x/nameservice/client/testutil/grpc.go +++ b/x/nameservice/client/testutil/grpc.go @@ -60,11 +60,12 @@ func (s *IntegrationTestSuite) TestGRPCQueryParams() { } } +//nolint: all func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() { val := s.network.Validators[0] sr := s.Require() reqUrl := val.APIAddress + "/vulcanize/nameservice/v1beta1/whois/%s" - var authorityName = "QueryWhoIS" + authorityName := "QueryWhoIS" testCases := []struct { name string url string @@ -78,7 +79,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() { true, "", func(authorityName string) { - }, }, { @@ -132,7 +132,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() { val := s.network.Validators[0] sr := s.Require() reqUrl := val.APIAddress + "/vulcanize/nameservice/v1beta1/lookup?crn=%s" - var authorityName = "QueryLookUp" + authorityName := "QueryLookUp" testCases := []struct { name string @@ -147,7 +147,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() { true, "", func(authorityName string) { - }, }, { @@ -181,6 +180,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() { } } +//nolint: all func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() { val := s.network.Validators[0] sr := s.Require() @@ -199,7 +199,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() { true, "", func(bondId string) { - }, }, { @@ -253,6 +252,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() { } } +//nolint: all func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() { val := s.network.Validators[0] sr := s.Require() @@ -271,7 +271,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() { true, "", func(authorityName string) { - }, }, { @@ -325,6 +324,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() { } } +//nolint: all func (s *IntegrationTestSuite) TestGRPCQueryListRecords() { val := s.network.Validators[0] sr := s.Require() @@ -343,7 +343,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryListRecords() { true, "", func(bondId string) { - }, }, { @@ -483,7 +482,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetRecordByBondID() { true, "", func(bondId string) { - }, }, { @@ -538,7 +536,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetNameServiceModuleBalance() { true, "", func(bondId string) { - }, }, { @@ -590,7 +587,6 @@ func (s *IntegrationTestSuite) TestGRPCQueryNamesList() { true, "", func(authorityName string) { - }, }, { diff --git a/x/nameservice/client/testutil/query.go b/x/nameservice/client/testutil/query.go index 6fdd3733..ee7026bd 100644 --- a/x/nameservice/client/testutil/query.go +++ b/x/nameservice/client/testutil/query.go @@ -66,7 +66,6 @@ func (s *IntegrationTestSuite) TestGetCmdQueryForRecords() { true, 0, func() { - }, }, { @@ -235,7 +234,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryForRecords() { func (s *IntegrationTestSuite) TestGetCmdWhoIs() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "test2" + authorityName := "test2" testCases := []struct { name string args []string @@ -249,7 +248,6 @@ func (s *IntegrationTestSuite) TestGetCmdWhoIs() { true, 1, func(authorityName string) { - }, }, { @@ -306,7 +304,7 @@ func (s *IntegrationTestSuite) TestGetCmdWhoIs() { func (s *IntegrationTestSuite) TestGetCmdLookupCRN() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "test1" + authorityName := "test1" testCases := []struct { name string args []string @@ -320,7 +318,6 @@ func (s *IntegrationTestSuite) TestGetCmdLookupCRN() { true, 0, func(authorityName string) { - }, }, { @@ -400,7 +397,7 @@ func (s *IntegrationTestSuite) TestGetCmdLookupCRN() { func (s *IntegrationTestSuite) GetRecordExpiryQueue() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "GetRecordExpiryQueue" + authorityName := "GetRecordExpiryQueue" testCasesForRecordsExpiry := []struct { name string @@ -415,7 +412,6 @@ func (s *IntegrationTestSuite) GetRecordExpiryQueue() { true, 0, func(authorityName string, s *IntegrationTestSuite) { - }, }, { @@ -451,10 +447,11 @@ func (s *IntegrationTestSuite) GetRecordExpiryQueue() { }) } } + func (s *IntegrationTestSuite) TestGetAuthorityExpiryQueue() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "TestGetAuthorityExpiryQueue" + authorityName := "TestGetAuthorityExpiryQueue" testCases := []struct { name string @@ -467,7 +464,6 @@ func (s *IntegrationTestSuite) TestGetAuthorityExpiryQueue() { []string{"invalid", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, true, func(authorityName string) { - }, }, { diff --git a/x/nameservice/client/testutil/tx.go b/x/nameservice/client/testutil/tx.go index eff742d7..02a45b03 100644 --- a/x/nameservice/client/testutil/tx.go +++ b/x/nameservice/client/testutil/tx.go @@ -42,7 +42,7 @@ func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite { func (s *IntegrationTestSuite) SetupSuite() { s.T().Log("setting up integration test suite") - var genesisState = s.cfg.GenesisState + genesisState := s.cfg.GenesisState var nsData nstypes.GenesisState s.Require().NoError(s.cfg.Codec.UnmarshalJSON(genesisState[nstypes.ModuleName], &nsData)) @@ -222,7 +222,7 @@ func (s *IntegrationTestSuite) TestGetCmdSetRecord() { func (s *IntegrationTestSuite) TestGetCmdReserveName() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "testtest" + authorityName := "testtest" testCases := []struct { name string args []string @@ -289,7 +289,7 @@ func (s *IntegrationTestSuite) TestGetCmdReserveName() { func (s *IntegrationTestSuite) TestGetCmdSetName() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "TestGetCmdSetName" + authorityName := "TestGetCmdSetName" testCases := []struct { name string args []string @@ -307,7 +307,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetName() { }, true, func(authorityName string) { - }, }, { @@ -394,7 +393,7 @@ func (s *IntegrationTestSuite) TestGetCmdSetName() { func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "TestGetCmdSetAuthorityBond" + authorityName := "TestGetCmdSetAuthorityBond" testCases := []struct { name string @@ -413,7 +412,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() { }, true, func(authorityName string) { - }, }, { @@ -480,7 +478,7 @@ func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() { func (s *IntegrationTestSuite) TestGetCmdDeleteName() { val := s.network.Validators[0] sr := s.Require() - var authorityName = "TestGetCmdDeleteName" + authorityName := "TestGetCmdDeleteName" testCasesForDeletingName := []struct { name string args []string @@ -498,7 +496,6 @@ func (s *IntegrationTestSuite) TestGetCmdDeleteName() { }, true, func(authorityName string, s *IntegrationTestSuite) { - }, }, { @@ -564,7 +561,6 @@ func (s *IntegrationTestSuite) TestGetCmdDissociateBond() { return "" }, func(recordId string, s *IntegrationTestSuite) { - }, }, { @@ -807,7 +803,6 @@ func (s *IntegrationTestSuite) TestGetCmdAssociateBond() { return "", "" }, func(recordId, bondId string, s *IntegrationTestSuite) { - }, }, { diff --git a/x/nameservice/genesis.go b/x/nameservice/genesis.go index fc082834..3abc6f49 100644 --- a/x/nameservice/genesis.go +++ b/x/nameservice/genesis.go @@ -17,7 +17,6 @@ func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data types.GenesisState) // Add to record expiry queue if expiry time is in the future. expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime) - if err != nil { panic(err) } @@ -33,7 +32,7 @@ func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, data types.GenesisState) } for _, authority := range data.Authorities { - //Only import authorities that are marked active. + // Only import authorities that are marked active. if authority.Entry.Status == types.AuthorityActive { keeper.SetNameAuthority(ctx, authority.Name, authority.Entry) diff --git a/x/nameservice/helpers/helpers.go b/x/nameservice/helpers/helpers.go index 3f28c9af..59776690 100644 --- a/x/nameservice/helpers/helpers.go +++ b/x/nameservice/helpers/helpers.go @@ -7,11 +7,10 @@ import ( "encoding/gob" "encoding/hex" "encoding/json" + "sort" wnsUtils "github.com/cerc-io/laconicd/utils" set "github.com/deckarep/golang-set" - - "sort" ) func StringToBytes(val string) []byte { @@ -62,7 +61,6 @@ func MarshalMapToJSONBytes(val map[string]interface{}) (bytes []byte) { func UnMarshalMapFromJSONBytes(bytes []byte) map[string]interface{} { var val map[string]interface{} err := json.Unmarshal(bytes, &val) - if err != nil { panic("Marshal error.") } diff --git a/x/nameservice/keeper/grpc_query_test.go b/x/nameservice/keeper/grpc_query_test.go index 06e94827..a166a033 100644 --- a/x/nameservice/keeper/grpc_query_test.go +++ b/x/nameservice/keeper/grpc_query_test.go @@ -220,7 +220,7 @@ func (suite *KeeperTestSuite) TestGrpcQueryNameserviceModuleBalance() { func (suite *KeeperTestSuite) TestGrpcQueryWhoIS() { grpcClient, ctx := suite.queryClient, suite.ctx sr := suite.Require() - var authorityName = "TestGrpcQueryWhoIS" + authorityName := "TestGrpcQueryWhoIS" testCases := []struct { msg string diff --git a/x/nameservice/keeper/keeper.go b/x/nameservice/keeper/keeper.go index fa81433d..48df9d2f 100644 --- a/x/nameservice/keeper/keeper.go +++ b/x/nameservice/keeper/keeper.go @@ -73,7 +73,8 @@ type Keeper struct { // NewKeeper creates new instances of the nameservice Keeper func NewKeeper(cdc codec.BinaryCodec, accountKeeper auth.AccountKeeper, bankKeeper bank.Keeper, recordKeeper RecordKeeper, - bondKeeper bondkeeper.Keeper, auctionKeeper auctionkeeper.Keeper, storeKey storetypes.StoreKey, ps paramtypes.Subspace) Keeper { + bondKeeper bondkeeper.Keeper, auctionKeeper auctionkeeper.Keeper, storeKey storetypes.StoreKey, ps paramtypes.Subspace, +) Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { ps = ps.WithKeyTable(types.ParamKeyTable()) @@ -295,7 +296,6 @@ func (k Keeper) GetRecordExpiryQueueTimeSlice(ctx sdk.Context, timestamp time.Ti // InsertRecordExpiryQueue inserts a record CID to the appropriate timeslice in the record expiry queue. func (k Keeper) InsertRecordExpiryQueue(ctx sdk.Context, val types.Record) { expiryTime, err := time.Parse(time.RFC3339, val.ExpiryTime) - if err != nil { panic(err) } @@ -308,7 +308,6 @@ func (k Keeper) InsertRecordExpiryQueue(ctx sdk.Context, val types.Record) { // DeleteRecordExpiryQueue deletes a record CID from the record expiry queue. func (k Keeper) DeleteRecordExpiryQueue(ctx sdk.Context, record types.Record) { expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime) - if err != nil { panic(err) } @@ -344,7 +343,6 @@ func (k Keeper) GetAllExpiredRecords(ctx sdk.Context, currTime time.Time) (expir for ; itr.Valid(); itr.Next() { timeslice, err := helpers.BytesArrToStringArr(itr.Value()) - if err != nil { panic(err) } @@ -426,7 +424,6 @@ func recordObjToRecord(store sdk.KVStore, codec codec.BinaryCodec, record types. if store.Has(reverseNameIndexKey) { names, err := helpers.BytesArrToStringArr(store.Get(reverseNameIndexKey)) - if err != nil { panic(err) } diff --git a/x/nameservice/keeper/keeper_test.go b/x/nameservice/keeper/keeper_test.go index 66fda3af..307a72a3 100644 --- a/x/nameservice/keeper/keeper_test.go +++ b/x/nameservice/keeper/keeper_test.go @@ -17,9 +17,7 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) -var ( - seed = int64(233) -) +var seed = int64(233) type KeeperTestSuite struct { suite.Suite diff --git a/x/nameservice/keeper/msg_server.go b/x/nameservice/keeper/msg_server.go index 3bef7bbe..c9a36708 100644 --- a/x/nameservice/keeper/msg_server.go +++ b/x/nameservice/keeper/msg_server.go @@ -51,6 +51,7 @@ func (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types return &types.MsgSetRecordResponse{Id: record.Id}, nil } +//nolint: all func (m msgServer) SetName(c context.Context, msg *types.MsgSetName) (*types.MsgSetNameResponse, error) { ctx := sdk.UnwrapSDKContext(c) _, err := sdk.AccAddressFromBech32(msg.Signer) @@ -107,6 +108,7 @@ func (m msgServer) ReserveName(c context.Context, msg *types.MsgReserveAuthority return &types.MsgReserveAuthorityResponse{}, nil } +//nolint: all func (m msgServer) SetAuthorityBond(c context.Context, msg *types.MsgSetAuthorityBond) (*types.MsgSetAuthorityBondResponse, error) { ctx := sdk.UnwrapSDKContext(c) _, err := sdk.AccAddressFromBech32(msg.Signer) @@ -180,6 +182,7 @@ func (m msgServer) RenewRecord(c context.Context, msg *types.MsgRenewRecord) (*t return &types.MsgRenewRecordResponse{}, nil } +//nolint: all func (m msgServer) AssociateBond(c context.Context, msg *types.MsgAssociateBond) (*types.MsgAssociateBondResponse, error) { ctx := sdk.UnwrapSDKContext(c) _, err := sdk.AccAddressFromBech32(msg.Signer) diff --git a/x/nameservice/keeper/naming_keeper.go b/x/nameservice/keeper/naming_keeper.go index 4ab6e16e..bac988b8 100644 --- a/x/nameservice/keeper/naming_keeper.go +++ b/x/nameservice/keeper/naming_keeper.go @@ -653,7 +653,6 @@ func (k Keeper) GetAllExpiredAuthorities(ctx sdk.Context, currTime time.Time) (e for ; itr.Valid(); itr.Next() { timeslice := []string{} timeslice, err := helpers.BytesArrToStringArr(itr.Value()) - if err != nil { panic(err) } diff --git a/x/nameservice/keeper/record_keeper.go b/x/nameservice/keeper/record_keeper.go index f3e65f7e..4d88ef80 100644 --- a/x/nameservice/keeper/record_keeper.go +++ b/x/nameservice/keeper/record_keeper.go @@ -89,8 +89,10 @@ func (k RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionID string) } // Record keeper implements the bond usage keeper interface. -var _ bondtypes.BondUsageKeeper = (*RecordKeeper)(nil) -var _ auctiontypes.AuctionUsageKeeper = (*RecordKeeper)(nil) +var ( + _ bondtypes.BondUsageKeeper = (*RecordKeeper)(nil) + _ auctiontypes.AuctionUsageKeeper = (*RecordKeeper)(nil) +) // ModuleName returns the module name. func (k RecordKeeper) ModuleName() string { @@ -162,7 +164,6 @@ func (k Keeper) ProcessRenewRecord(ctx sdk.Context, msg types.MsgRenewRecord) er // Check if renewal is required (i.e. expired record marked as deleted). record := k.GetRecord(ctx, msg.RecordId) expiryTime, err := time.Parse(time.RFC3339, record.ExpiryTime) - if err != nil { panic(err) } @@ -182,7 +183,6 @@ func (k Keeper) ProcessRenewRecord(ctx sdk.Context, msg types.MsgRenewRecord) er // ProcessAssociateBond associates a record with a bond. func (k Keeper) ProcessAssociateBond(ctx sdk.Context, msg types.MsgAssociateBond) error { - if !k.HasRecord(ctx, msg.RecordId) { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Record not found.") } diff --git a/x/nameservice/module.go b/x/nameservice/module.go index 246ce1ce..a835a97b 100644 --- a/x/nameservice/module.go +++ b/x/nameservice/module.go @@ -106,7 +106,6 @@ func (am AppModule) LegacyQuerierHandler(amino *codec.LegacyAmino) sdk.Querier { } func (am AppModule) RegisterServices(cfg module.Configurator) { - querier := keeper.Querier{Keeper: am.keeper} types.RegisterQueryServer(cfg.QueryServer(), querier) diff --git a/x/nameservice/types/msg.go b/x/nameservice/types/msg.go index 309ab017..72e58653 100644 --- a/x/nameservice/types/msg.go +++ b/x/nameservice/types/msg.go @@ -31,7 +31,6 @@ func (msg MsgSetName) Type() string { return "set-name" } // ValidateBasic Implements Msg. func (msg MsgSetName) ValidateBasic() error { - if msg.Crn == "" { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "CRN is required.") } @@ -76,7 +75,6 @@ func (msg MsgReserveAuthority) Type() string { return "reserve-authority" } // ValidateBasic Implements Msg. func (msg MsgReserveAuthority) ValidateBasic() error { - if len(msg.Name) == 0 { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "name is required.") } diff --git a/x/nameservice/types/params.go b/x/nameservice/types/params.go index a6aa6b80..b32fbdd0 100644 --- a/x/nameservice/types/params.go +++ b/x/nameservice/types/params.go @@ -3,9 +3,10 @@ package types import ( "bytes" "fmt" + "time" + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "time" ) // Default parameter values. @@ -75,8 +76,8 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { func NewParams(recordRent sdk.Coin, recordRentDuration time.Duration, authorityRent sdk.Coin, authorityRentDuration time.Duration, authorityGracePeriod time.Duration, authorityAuctionEnabled bool, commitsDuration time.Duration, revealsDuration time.Duration, - commitFee sdk.Coin, revealFee sdk.Coin, minimumBid sdk.Coin) Params { - + commitFee sdk.Coin, revealFee sdk.Coin, minimumBid sdk.Coin, +) Params { return Params{ RecordRent: recordRent, RecordRentDuration: recordRentDuration, diff --git a/x/nameservice/types/types.go b/x/nameservice/types/types.go index 86a2109c..f97c033f 100644 --- a/x/nameservice/types/types.go +++ b/x/nameservice/types/types.go @@ -22,7 +22,7 @@ type PayloadType struct { // ToPayload converts PayloadType to Payload object. // Why? Because go-amino can't handle maps: https://github.com/tendermint/go-amino/issues/4. func (payloadObj *PayloadType) ToPayload() Payload { - var payload = Payload{ + payload := Payload{ Record: &Record{ Deleted: false, Owners: nil,