From a57231f5317e46b5a27683b98f79fdd5babd16f4 Mon Sep 17 00:00:00 2001 From: Joey Date: Mon, 12 Jul 2021 10:59:21 +0100 Subject: [PATCH 1/9] Test: add IsAllowedSender test --- x/airdrop/keeper/params_test.go | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 x/airdrop/keeper/params_test.go diff --git a/x/airdrop/keeper/params_test.go b/x/airdrop/keeper/params_test.go new file mode 100644 index 0000000000..b87ca5ca91 --- /dev/null +++ b/x/airdrop/keeper/params_test.go @@ -0,0 +1,46 @@ +package keeper_test + +import ( + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/airdrop/types" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "testing" + "time" +) + +var ( + AllowedAddress = sdk.AccAddress([]byte("allowed_____________")) + BlockedAddress1 = sdk.AccAddress([]byte("blocked_____________")) + BlockedAddress2 = sdk.AccAddress([]byte("")) + ) + +type ParamsTestSuite struct { + suite.Suite + + app *simapp.SimApp + ctx sdk.Context +} + +func (s *ParamsTestSuite) SetupTest() { + app := simapp.Setup(false) + s.app = app + s.ctx = app.BaseApp.NewContext(false, tmproto.Header{ + Time: time.Now(), + Height: 10, + }) + + s.app.AirdropKeeper.SetParams(s.ctx, types.NewParams(AllowedAddress.String())) +} + +func (s *ParamsTestSuite) TestIsAllowedSender () { + s.Require().True(s.app.AirdropKeeper.GetParams(s.ctx).IsAllowedSender(AllowedAddress)) // Address is in AllowList and has correct format + s.Require().False(s.app.AirdropKeeper.GetParams(s.ctx).IsAllowedSender(BlockedAddress1)) // Address is not in AllowList and has correct format + s.Require().False(s.app.AirdropKeeper.GetParams(s.ctx).IsAllowedSender(BlockedAddress2)) // Address is not in AllowList and has incorrect format +} + + +func TestParamsTestSuite(t *testing.T) { + suite.Run(t, new(ParamsTestSuite)) +} From 09cc6a7c66ed779d1413909156beef416fe42777 Mon Sep 17 00:00:00 2001 From: Joey Date: Mon, 12 Jul 2021 17:33:06 +0100 Subject: [PATCH 2/9] Test: test for validateAllowList --- x/airdrop/keeper/params_test.go | 10 ++++++++++ x/airdrop/types/params.go | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/x/airdrop/keeper/params_test.go b/x/airdrop/keeper/params_test.go index b87ca5ca91..13c6eea623 100644 --- a/x/airdrop/keeper/params_test.go +++ b/x/airdrop/keeper/params_test.go @@ -40,6 +40,16 @@ func (s *ParamsTestSuite) TestIsAllowedSender () { s.Require().False(s.app.AirdropKeeper.GetParams(s.ctx).IsAllowedSender(BlockedAddress2)) // Address is not in AllowList and has incorrect format } +func (s *ParamsTestSuite) TestValidateAllowList () { + Correct := types.NewParams(AllowedAddress.String()) // Allow list contains address with correct format + Incorrect := types.NewParams(AllowedAddress.String(), BlockedAddress2.String()) // Allow list contains address with incorrect format + for _, paramPairs := range Correct.ParamSetPairs() { + s.Require().NoError(paramPairs.ValidatorFn(Correct.AllowList)) + } + for _, paramPairs := range Incorrect.ParamSetPairs() { + s.Require().Error(paramPairs.ValidatorFn(Incorrect.AllowList)) + } +} func TestParamsTestSuite(t *testing.T) { suite.Run(t, new(ParamsTestSuite)) diff --git a/x/airdrop/types/params.go b/x/airdrop/types/params.go index 51eb62de3a..5a69f23599 100644 --- a/x/airdrop/types/params.go +++ b/x/airdrop/types/params.go @@ -24,11 +24,11 @@ func ParamKeyTable() paramtypes.KeyTable { func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyWhiteList, &p.AllowList, validateWhiteList), + paramtypes.NewParamSetPair(KeyWhiteList, &p.AllowList, validateAllowList), } } -func validateWhiteList(i interface{}) error { +func validateAllowList(i interface{}) error { clients, ok := i.([]string) if !ok { return fmt.Errorf("invalid parameter type: %T", i) From 940648ea56af8f7554806052a554023f24e916d3 Mon Sep 17 00:00:00 2001 From: Joey Date: Mon, 12 Jul 2021 17:41:39 +0100 Subject: [PATCH 3/9] Tidy: readability of params_test.go --- x/airdrop/keeper/params_test.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/x/airdrop/keeper/params_test.go b/x/airdrop/keeper/params_test.go index 13c6eea623..b50beb9835 100644 --- a/x/airdrop/keeper/params_test.go +++ b/x/airdrop/keeper/params_test.go @@ -18,7 +18,6 @@ var ( type ParamsTestSuite struct { suite.Suite - app *simapp.SimApp ctx sdk.Context } @@ -30,7 +29,6 @@ func (s *ParamsTestSuite) SetupTest() { Time: time.Now(), Height: 10, }) - s.app.AirdropKeeper.SetParams(s.ctx, types.NewParams(AllowedAddress.String())) } @@ -41,8 +39,8 @@ func (s *ParamsTestSuite) TestIsAllowedSender () { } func (s *ParamsTestSuite) TestValidateAllowList () { - Correct := types.NewParams(AllowedAddress.String()) // Allow list contains address with correct format - Incorrect := types.NewParams(AllowedAddress.String(), BlockedAddress2.String()) // Allow list contains address with incorrect format + Correct := types.NewParams(AllowedAddress.String()) // Allow list contains address with correct format + Incorrect := types.NewParams(AllowedAddress.String(), BlockedAddress2.String()) // Allow list contains address with incorrect format for _, paramPairs := range Correct.ParamSetPairs() { s.Require().NoError(paramPairs.ValidatorFn(Correct.AllowList)) } From d4b6eba33c88ca23d19cb584a2562f17f3f3366a Mon Sep 17 00:00:00 2001 From: Joey Date: Mon, 12 Jul 2021 18:08:23 +0100 Subject: [PATCH 4/9] Refactor: change WhiteList to AllowList --- x/airdrop/keeper/keeper.go | 2 +- x/airdrop/keeper/params.go | 6 +++--- x/airdrop/types/genesis.go | 4 ++-- x/airdrop/types/params.go | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/x/airdrop/keeper/keeper.go b/x/airdrop/keeper/keeper.go index 557df45ff8..2393ef461a 100644 --- a/x/airdrop/keeper/keeper.go +++ b/x/airdrop/keeper/keeper.go @@ -48,7 +48,7 @@ func (k Keeper) AddFund(ctx sdk.Context, sender sdk.AccAddress, fund types.Fund) if !params.IsAllowedSender(sender) { return sdkerrors.Wrapf( sdkerrors.ErrConflict, - "Non-whitelist sender %s", sender.String(), + "Non-allowlist sender %s", sender.String(), ) } diff --git a/x/airdrop/keeper/params.go b/x/airdrop/keeper/params.go index c748d41074..2d32c69d5d 100644 --- a/x/airdrop/keeper/params.go +++ b/x/airdrop/keeper/params.go @@ -5,15 +5,15 @@ import ( "github.com/cosmos/cosmos-sdk/x/airdrop/types" ) -func (k Keeper) GetWhiteListClients(ctx sdk.Context) []string { +func (k Keeper) GetAllowListClients(ctx sdk.Context) []string { var res []string - k.paramSpace.Get(ctx, types.KeyWhiteList, &res) + k.paramSpace.Get(ctx, types.KeyAllowList, &res) return res } // GetParams returns the total set of ibc-transfer parameters. func (k Keeper) GetParams(ctx sdk.Context) types.Params { - return types.NewParams(k.GetWhiteListClients(ctx)...) + return types.NewParams(k.GetAllowListClients(ctx)...) } // SetParams sets the total set of ibc-transfer parameters. diff --git a/x/airdrop/types/genesis.go b/x/airdrop/types/genesis.go index 8ffe5c4596..5a1182fc49 100644 --- a/x/airdrop/types/genesis.go +++ b/x/airdrop/types/genesis.go @@ -14,14 +14,14 @@ func NewGenesisState(params Params, funds []ActiveFund) *GenesisState { } func (gs *GenesisState) Validate() error { - whiteListAddresses := []sdk.AccAddress{} + allowListAddresses := []sdk.AccAddress{} for _, address := range gs.Params.AllowList { accAddress, err := sdk.AccAddressFromBech32(strings.TrimSpace(address)) if err != nil { return err } - whiteListAddresses = append(whiteListAddresses, accAddress) + allowListAddresses = append(allowListAddresses, accAddress) } return nil diff --git a/x/airdrop/types/params.go b/x/airdrop/types/params.go index 5a69f23599..3e663dcc99 100644 --- a/x/airdrop/types/params.go +++ b/x/airdrop/types/params.go @@ -8,13 +8,13 @@ import ( ) var ( - // KeyWhiteList is store's key for WhiteList Params - KeyWhiteList = []byte("AllowList") + // KeyAllowList is store's key for AllowList Params + KeyAllowList = []byte("AllowList") ) -func NewParams(whiteListClients ...string) Params { +func NewParams(allowListClients ...string) Params { return Params{ - AllowList: whiteListClients, + AllowList: allowListClients, } } @@ -24,7 +24,7 @@ func ParamKeyTable() paramtypes.KeyTable { func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyWhiteList, &p.AllowList, validateAllowList), + paramtypes.NewParamSetPair(KeyAllowList, &p.AllowList, validateAllowList), } } From 98b30efb709efb3a26424cc0d5fe9daee36da772 Mon Sep 17 00:00:00 2001 From: Joey Date: Tue, 13 Jul 2021 10:33:23 +0100 Subject: [PATCH 5/9] Refactor: correct and tidy code --- codec/types/interface_registry.go | 6 ++-- x/airdrop/types/params_test.go | 54 +++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 x/airdrop/types/params_test.go diff --git a/codec/types/interface_registry.go b/codec/types/interface_registry.go index 0f9eb760be..fe3fbd0ff6 100644 --- a/codec/types/interface_registry.go +++ b/codec/types/interface_registry.go @@ -10,11 +10,11 @@ import ( ) // AnyUnpacker is an interface which allows safely unpacking types packed -// in Any's against a whitelist of registered types +// in Any's against a allowlist of registered types type AnyUnpacker interface { // UnpackAny unpacks the value in any to the interface pointer passed in as // iface. Note that the type in any must have been registered in the - // underlying whitelist registry as a concrete type for that interface + // underlying allowlist registry as a concrete type for that interface // Ex: // var msg sdk.Msg // err := cdc.UnpackAny(any, &msg) @@ -67,7 +67,7 @@ type InterfaceRegistry interface { // UnpackInterfacesMessage is meant to extend protobuf types (which implement // proto.Message) to support a post-deserialization phase which unpacks -// types packed within Any's using the whitelist provided by AnyUnpacker +// types packed within Any's using the allowlist provided by AnyUnpacker type UnpackInterfacesMessage interface { // UnpackInterfaces is implemented in order to unpack values packed within // Any's using the AnyUnpacker. It should generally be implemented as diff --git a/x/airdrop/types/params_test.go b/x/airdrop/types/params_test.go new file mode 100644 index 0000000000..0ab413fb8e --- /dev/null +++ b/x/airdrop/types/params_test.go @@ -0,0 +1,54 @@ +package types_test + +import ( + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/airdrop/types" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/tendermint/tendermint/types/time" + "testing" +) + +var ( + allowedAddress = sdk.AccAddress([]byte("allowed_____________")) + blockedAddress1 = sdk.AccAddress([]byte("blocked_____________")) + blockedAddress2 = sdk.AccAddress([]byte("")) +) + +type ParamsTestSuite struct { + suite.Suite + app *simapp.SimApp + ctx sdk.Context +} + +func (s *ParamsTestSuite) SetupTest() { + app := simapp.Setup(false) + s.app = app + s.ctx = app.BaseApp.NewContext(false, tmproto.Header{ + Time: time.Now(), + Height: 10, + }) +} + +func (s *ParamsTestSuite) TestIsAllowedSender () { + correct := types.NewParams(allowedAddress.String()) // New set of parameters with a new AllowList + s.Require().True(correct.IsAllowedSender(allowedAddress)) // Address is in AllowList and has correct format + s.Require().False(correct.IsAllowedSender(blockedAddress1)) // Address is not in AllowList and has correct format + s.Require().False(correct.IsAllowedSender(blockedAddress2)) // Address is not in AllowList and has incorrect format +} + +func (s *ParamsTestSuite) TestValidateAllowList () { + correct := types.NewParams(allowedAddress.String()) // Allow list contains address with correct format + incorrect := types.NewParams(allowedAddress.String(), blockedAddress2.String()) // Allow list contains address with incorrect format + for _, paramPairs := range correct.ParamSetPairs() { + s.Require().NoError(paramPairs.ValidatorFn(correct.AllowList)) + } + for _, paramPairs := range incorrect.ParamSetPairs() { + s.Require().Error(paramPairs.ValidatorFn(incorrect.AllowList)) + } +} + +func TestParamsTestSuite(t *testing.T) { + suite.Run(t, new(ParamsTestSuite)) +} From b5983c13381d598792541b7a5d59523d72d33274 Mon Sep 17 00:00:00 2001 From: Joey Date: Tue, 13 Jul 2021 10:49:04 +0100 Subject: [PATCH 6/9] tidy: remove unnecessary file --- x/airdrop/keeper/params_test.go | 54 --------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 x/airdrop/keeper/params_test.go diff --git a/x/airdrop/keeper/params_test.go b/x/airdrop/keeper/params_test.go deleted file mode 100644 index b50beb9835..0000000000 --- a/x/airdrop/keeper/params_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package keeper_test - -import ( - "github.com/cosmos/cosmos-sdk/simapp" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/airdrop/types" - "github.com/stretchr/testify/suite" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "testing" - "time" -) - -var ( - AllowedAddress = sdk.AccAddress([]byte("allowed_____________")) - BlockedAddress1 = sdk.AccAddress([]byte("blocked_____________")) - BlockedAddress2 = sdk.AccAddress([]byte("")) - ) - -type ParamsTestSuite struct { - suite.Suite - app *simapp.SimApp - ctx sdk.Context -} - -func (s *ParamsTestSuite) SetupTest() { - app := simapp.Setup(false) - s.app = app - s.ctx = app.BaseApp.NewContext(false, tmproto.Header{ - Time: time.Now(), - Height: 10, - }) - s.app.AirdropKeeper.SetParams(s.ctx, types.NewParams(AllowedAddress.String())) -} - -func (s *ParamsTestSuite) TestIsAllowedSender () { - s.Require().True(s.app.AirdropKeeper.GetParams(s.ctx).IsAllowedSender(AllowedAddress)) // Address is in AllowList and has correct format - s.Require().False(s.app.AirdropKeeper.GetParams(s.ctx).IsAllowedSender(BlockedAddress1)) // Address is not in AllowList and has correct format - s.Require().False(s.app.AirdropKeeper.GetParams(s.ctx).IsAllowedSender(BlockedAddress2)) // Address is not in AllowList and has incorrect format -} - -func (s *ParamsTestSuite) TestValidateAllowList () { - Correct := types.NewParams(AllowedAddress.String()) // Allow list contains address with correct format - Incorrect := types.NewParams(AllowedAddress.String(), BlockedAddress2.String()) // Allow list contains address with incorrect format - for _, paramPairs := range Correct.ParamSetPairs() { - s.Require().NoError(paramPairs.ValidatorFn(Correct.AllowList)) - } - for _, paramPairs := range Incorrect.ParamSetPairs() { - s.Require().Error(paramPairs.ValidatorFn(Incorrect.AllowList)) - } -} - -func TestParamsTestSuite(t *testing.T) { - suite.Run(t, new(ParamsTestSuite)) -} From f7be8300e149a98676522878d4548685577ba34d Mon Sep 17 00:00:00 2001 From: Joey Date: Tue, 13 Jul 2021 13:26:22 +0100 Subject: [PATCH 7/9] tidy: run goimports --- x/airdrop/types/params_test.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/x/airdrop/types/params_test.go b/x/airdrop/types/params_test.go index 0ab413fb8e..e990b9636e 100644 --- a/x/airdrop/types/params_test.go +++ b/x/airdrop/types/params_test.go @@ -1,19 +1,20 @@ package types_test import ( + "testing" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/airdrop/types" "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/tendermint/tendermint/types/time" - "testing" ) var ( allowedAddress = sdk.AccAddress([]byte("allowed_____________")) blockedAddress1 = sdk.AccAddress([]byte("blocked_____________")) - blockedAddress2 = sdk.AccAddress([]byte("")) + blockedAddress2 = sdk.AccAddress([]byte("")) ) type ParamsTestSuite struct { @@ -31,16 +32,16 @@ func (s *ParamsTestSuite) SetupTest() { }) } -func (s *ParamsTestSuite) TestIsAllowedSender () { - correct := types.NewParams(allowedAddress.String()) // New set of parameters with a new AllowList - s.Require().True(correct.IsAllowedSender(allowedAddress)) // Address is in AllowList and has correct format - s.Require().False(correct.IsAllowedSender(blockedAddress1)) // Address is not in AllowList and has correct format - s.Require().False(correct.IsAllowedSender(blockedAddress2)) // Address is not in AllowList and has incorrect format +func (s *ParamsTestSuite) TestIsAllowedSender() { + correct := types.NewParams(allowedAddress.String()) // New set of parameters with a new AllowList + s.Require().True(correct.IsAllowedSender(allowedAddress)) // Address is in AllowList and has correct format + s.Require().False(correct.IsAllowedSender(blockedAddress1)) // Address is not in AllowList and has correct format + s.Require().False(correct.IsAllowedSender(blockedAddress2)) // Address is not in AllowList and has incorrect format } -func (s *ParamsTestSuite) TestValidateAllowList () { - correct := types.NewParams(allowedAddress.String()) // Allow list contains address with correct format - incorrect := types.NewParams(allowedAddress.String(), blockedAddress2.String()) // Allow list contains address with incorrect format +func (s *ParamsTestSuite) TestValidateAllowList() { + correct := types.NewParams(allowedAddress.String()) // Allow list contains address with correct format + incorrect := types.NewParams(allowedAddress.String(), blockedAddress2.String()) // Allow list contains address with incorrect format for _, paramPairs := range correct.ParamSetPairs() { s.Require().NoError(paramPairs.ValidatorFn(correct.AllowList)) } From f033cc52d5c9f24a16c4595f696663e3dab9b799 Mon Sep 17 00:00:00 2001 From: Joey Date: Tue, 13 Jul 2021 17:51:34 +0100 Subject: [PATCH 8/9] Tidy: call goimports on all x/airdrop --- x/airdrop/abci.go | 3 ++- x/airdrop/client/cli/query.go | 3 ++- x/airdrop/client/cli/tx.go | 3 ++- x/airdrop/keeper/grpc_query.go | 1 + x/airdrop/keeper/grpc_query_test.go | 3 ++- x/airdrop/keeper/keeper_test.go | 5 +++-- x/airdrop/keeper/msg_server.go | 1 + x/airdrop/module.go | 1 + x/airdrop/types/airdrop.pb.go | 7 ++++--- x/airdrop/types/genesis.go | 3 ++- x/airdrop/types/genesis.pb.go | 5 +++-- x/airdrop/types/params.go | 3 ++- x/airdrop/types/query.pb.go | 7 ++++--- x/airdrop/types/tx.pb.go | 7 ++++--- 14 files changed, 33 insertions(+), 19 deletions(-) diff --git a/x/airdrop/abci.go b/x/airdrop/abci.go index b9d44560f0..1be75851f3 100644 --- a/x/airdrop/abci.go +++ b/x/airdrop/abci.go @@ -1,11 +1,12 @@ package airdrop import ( + "time" + "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/airdrop/keeper" "github.com/cosmos/cosmos-sdk/x/airdrop/types" - "time" ) func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { diff --git a/x/airdrop/client/cli/query.go b/x/airdrop/client/cli/query.go index ea0eec4fb0..c41dd14577 100644 --- a/x/airdrop/client/cli/query.go +++ b/x/airdrop/client/cli/query.go @@ -2,12 +2,13 @@ package cli import ( "fmt" + "strings" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/airdrop/types" "github.com/spf13/cobra" - "strings" ) func GetQueryCmd() *cobra.Command { diff --git a/x/airdrop/client/cli/tx.go b/x/airdrop/client/cli/tx.go index 1dec797153..82d5fc41ab 100644 --- a/x/airdrop/client/cli/tx.go +++ b/x/airdrop/client/cli/tx.go @@ -2,6 +2,8 @@ package cli import ( "fmt" + "strings" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -10,7 +12,6 @@ import ( "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/airdrop/types" "github.com/spf13/cobra" - "strings" ) func GetTxCmd() *cobra.Command { diff --git a/x/airdrop/keeper/grpc_query.go b/x/airdrop/keeper/grpc_query.go index aea5437db8..63f1855935 100644 --- a/x/airdrop/keeper/grpc_query.go +++ b/x/airdrop/keeper/grpc_query.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" diff --git a/x/airdrop/keeper/grpc_query_test.go b/x/airdrop/keeper/grpc_query_test.go index 9aa3e6dbce..8c7014d59b 100644 --- a/x/airdrop/keeper/grpc_query_test.go +++ b/x/airdrop/keeper/grpc_query_test.go @@ -3,6 +3,8 @@ package keeper_test import ( gocontext "context" "fmt" + "testing" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" @@ -10,7 +12,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/airdrop/types" "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "testing" ) var ( diff --git a/x/airdrop/keeper/keeper_test.go b/x/airdrop/keeper/keeper_test.go index 94aa2b7d79..2a06749817 100644 --- a/x/airdrop/keeper/keeper_test.go +++ b/x/airdrop/keeper/keeper_test.go @@ -1,11 +1,12 @@ package keeper_test import ( - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/x/airdrop/types" "testing" "time" + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/x/airdrop/types" + sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/stretchr/testify/suite" diff --git a/x/airdrop/keeper/msg_server.go b/x/airdrop/keeper/msg_server.go index 3660e1a453..a30cba8966 100644 --- a/x/airdrop/keeper/msg_server.go +++ b/x/airdrop/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/airdrop/types" ) diff --git a/x/airdrop/module.go b/x/airdrop/module.go index 5b5ec2e87b..2fc0314c9d 100644 --- a/x/airdrop/module.go +++ b/x/airdrop/module.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/airdrop/types/airdrop.pb.go b/x/airdrop/types/airdrop.pb.go index d92faf136e..fcc8c4c5c8 100644 --- a/x/airdrop/types/airdrop.pb.go +++ b/x/airdrop/types/airdrop.pb.go @@ -5,14 +5,15 @@ package types import ( fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" _ "github.com/regen-network/cosmos-proto" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/airdrop/types/genesis.go b/x/airdrop/types/genesis.go index 5a1182fc49..804febcf4f 100644 --- a/x/airdrop/types/genesis.go +++ b/x/airdrop/types/genesis.go @@ -1,8 +1,9 @@ package types import ( - sdk "github.com/cosmos/cosmos-sdk/types" "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" ) func DefaultGenesisState() *GenesisState { diff --git a/x/airdrop/types/genesis.pb.go b/x/airdrop/types/genesis.pb.go index c390336d28..14f9227735 100644 --- a/x/airdrop/types/genesis.pb.go +++ b/x/airdrop/types/genesis.pb.go @@ -5,11 +5,12 @@ package types import ( fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/airdrop/types/params.go b/x/airdrop/types/params.go index 3e663dcc99..4946a5eeb0 100644 --- a/x/airdrop/types/params.go +++ b/x/airdrop/types/params.go @@ -2,9 +2,10 @@ package types import ( "fmt" + "strings" + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "strings" ) var ( diff --git a/x/airdrop/types/query.pb.go b/x/airdrop/types/query.pb.go index 782aabf26c..9df8650bd1 100644 --- a/x/airdrop/types/query.pb.go +++ b/x/airdrop/types/query.pb.go @@ -6,6 +6,10 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" @@ -14,9 +18,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/airdrop/types/tx.pb.go b/x/airdrop/types/tx.pb.go index 748f1dbc5a..b4c18b2a0b 100644 --- a/x/airdrop/types/tx.pb.go +++ b/x/airdrop/types/tx.pb.go @@ -6,15 +6,16 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. From 4c93980125a3b971ac1774fc23e9b9a61d329093 Mon Sep 17 00:00:00 2001 From: Joey Date: Wed, 14 Jul 2021 16:45:27 +0100 Subject: [PATCH 9/9] Tidy: remove junk code from genesis.go --- x/airdrop/types/genesis.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x/airdrop/types/genesis.go b/x/airdrop/types/genesis.go index 804febcf4f..7cdcd83a0e 100644 --- a/x/airdrop/types/genesis.go +++ b/x/airdrop/types/genesis.go @@ -15,14 +15,11 @@ func NewGenesisState(params Params, funds []ActiveFund) *GenesisState { } func (gs *GenesisState) Validate() error { - allowListAddresses := []sdk.AccAddress{} - for _, address := range gs.Params.AllowList { - accAddress, err := sdk.AccAddressFromBech32(strings.TrimSpace(address)) + _, err := sdk.AccAddressFromBech32(strings.TrimSpace(address)) if err != nil { return err } - allowListAddresses = append(allowListAddresses, accAddress) } return nil