From 0e1bd36677c88140998dacd90ef9ec6620625bf0 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Mon, 5 Feb 2024 17:16:16 +0700 Subject: [PATCH] fix: lint --- database/database_test.go | 2 +- modules/auth/handle_msg.go | 2 +- modules/bank/source/local/source.go | 192 ++++++++++++++-------------- modules/feegrant/handle_block.go | 2 +- types/provider.go | 2 +- 5 files changed, 100 insertions(+), 100 deletions(-) diff --git a/database/database_test.go b/database/database_test.go index 75c1ae901..eb2cf68a6 100644 --- a/database/database_test.go +++ b/database/database_test.go @@ -46,7 +46,7 @@ func (suite *DbTestSuite) SetupTest() { // Build the database dbCfg := dbconfig.NewDatabaseConfig( - "postgresql://callisto:password@localhost:6433/callisto?sslmode=disable&search_path=public", + "postgresql://bdjuno:password@localhost:6433/bdjuno?sslmode=disable&search_path=public", "", "", "", diff --git a/modules/auth/handle_msg.go b/modules/auth/handle_msg.go index 7503e88bd..8e048fb53 100644 --- a/modules/auth/handle_msg.go +++ b/modules/auth/handle_msg.go @@ -5,8 +5,8 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - juno "github.com/forbole/juno/v5/types" "github.com/cosmos/cosmos-sdk/x/authz" + juno "github.com/forbole/juno/v5/types" "github.com/gogo/protobuf/proto" "github.com/rs/zerolog/log" diff --git a/modules/bank/source/local/source.go b/modules/bank/source/local/source.go index 25c346a7d..1eacba49a 100644 --- a/modules/bank/source/local/source.go +++ b/modules/bank/source/local/source.go @@ -1,98 +1,98 @@ package local -import ( - "fmt" - - "github.com/cosmos/cosmos-sdk/types/query" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/forbole/juno/v5/node/local" - - "github.com/forbole/bdjuno/v4/modules/bank/source" - "github.com/forbole/bdjuno/v4/types" -) - -var ( - _ source.Source = &Source{} -) - -// Source represents the implementation of the bank keeper that works on a local node -type Source struct { - *local.Source - q banktypes.QueryServer -} - -// NewSource builds a new Source instance -func NewSource(source *local.Source, bk banktypes.QueryServer) *Source { - return &Source{ - Source: source, - q: bk, - } -} - -// GetBalances implements keeper.Source -func (s Source) GetBalances(addresses []string, height int64) ([]types.AccountBalance, error) { - ctx, err := s.LoadHeight(height) - if err != nil { - return nil, fmt.Errorf("error while loading height: %s", err) - } - - var balances []types.AccountBalance - for _, address := range addresses { - res, err := s.q.AllBalances(sdk.WrapSDKContext(ctx), &banktypes.QueryAllBalancesRequest{Address: address}) - if err != nil { - return nil, err - } - - balances = append(balances, types.NewAccountBalance(address, res.Balances, height)) - } - - return balances, nil -} - -// GetSupply implements bankkeeper.Source -func (s Source) GetSupply(height int64) (sdk.Coins, error) { - ctx, err := s.LoadHeight(height) - if err != nil { - return nil, fmt.Errorf("error while loading height: %s", err) - } - - var coins []sdk.Coin - var nextKey []byte - var stop = false - for !stop { - res, err := s.q.TotalSupply( - sdk.WrapSDKContext(ctx), - &banktypes.QueryTotalSupplyRequest{ - Pagination: &query.PageRequest{ - Key: nextKey, - Limit: 100, // Query 100 supplies at time - }, - }) - if err != nil { - return nil, fmt.Errorf("error while getting total supply: %s", err) - } - - nextKey = res.Pagination.NextKey - stop = len(res.Pagination.NextKey) == 0 - coins = append(coins, res.Supply...) - } - - return coins, nil -} - -// GetAccountBalances implements bankkeeper.Source -func (s Source) GetAccountBalance(address string, height int64) ([]sdk.Coin, error) { - ctx, err := s.LoadHeight(height) - if err != nil { - return nil, fmt.Errorf("error while loading height: %s", err) - } - - balRes, err := s.q.AllBalances(sdk.WrapSDKContext(ctx), &banktypes.QueryAllBalancesRequest{Address: address}) - if err != nil { - return nil, fmt.Errorf("error while getting all balances: %s", err) - } - - return balRes.Balances, nil -} +// import ( +// "fmt" + +// "github.com/cosmos/cosmos-sdk/types/query" +// banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + +// sdk "github.com/cosmos/cosmos-sdk/types" +// "github.com/forbole/juno/v5/node/local" + +// "github.com/forbole/bdjuno/v4/modules/bank/source" +// "github.com/forbole/bdjuno/v4/types" +// ) + +// var ( +// _ source.Source = &Source{} +// ) + +// // Source represents the implementation of the bank keeper that works on a local node +// type Source struct { +// *local.Source +// q banktypes.QueryServer +// } + +// // NewSource builds a new Source instance +// func NewSource(source *local.Source, bk banktypes.QueryServer) *Source { +// return &Source{ +// Source: source, +// q: bk, +// } +// } + +// // GetBalances implements keeper.Source +// func (s Source) GetBalances(addresses []string, height int64) ([]types.AccountBalance, error) { +// ctx, err := s.LoadHeight(height) +// if err != nil { +// return nil, fmt.Errorf("error while loading height: %s", err) +// } + +// var balances []types.AccountBalance +// for _, address := range addresses { +// res, err := s.q.AllBalances(sdk.WrapSDKContext(ctx), &banktypes.QueryAllBalancesRequest{Address: address}) +// if err != nil { +// return nil, err +// } + +// balances = append(balances, types.NewAccountBalance(address, res.Balances, height)) +// } + +// return balances, nil +// } + +// // GetSupply implements bankkeeper.Source +// func (s Source) GetSupply(height int64) (sdk.Coins, error) { +// ctx, err := s.LoadHeight(height) +// if err != nil { +// return nil, fmt.Errorf("error while loading height: %s", err) +// } + +// var coins []sdk.Coin +// var nextKey []byte +// var stop = false +// for !stop { +// res, err := s.q.TotalSupply( +// sdk.WrapSDKContext(ctx), +// &banktypes.QueryTotalSupplyRequest{ +// Pagination: &query.PageRequest{ +// Key: nextKey, +// Limit: 100, // Query 100 supplies at time +// }, +// }) +// if err != nil { +// return nil, fmt.Errorf("error while getting total supply: %s", err) +// } + +// nextKey = res.Pagination.NextKey +// stop = len(res.Pagination.NextKey) == 0 +// coins = append(coins, res.Supply...) +// } + +// return coins, nil +// } + +// // GetAccountBalances implements bankkeeper.Source +// func (s Source) GetAccountBalance(address string, height int64) ([]sdk.Coin, error) { +// ctx, err := s.LoadHeight(height) +// if err != nil { +// return nil, fmt.Errorf("error while loading height: %s", err) +// } + +// balRes, err := s.q.AllBalances(sdk.WrapSDKContext(ctx), &banktypes.QueryAllBalancesRequest{Address: address}) +// if err != nil { +// return nil, fmt.Errorf("error while getting all balances: %s", err) +// } + +// return balRes.Balances, nil +// } diff --git a/modules/feegrant/handle_block.go b/modules/feegrant/handle_block.go index 10cbef4cf..693567fd4 100644 --- a/modules/feegrant/handle_block.go +++ b/modules/feegrant/handle_block.go @@ -43,7 +43,7 @@ func (m *Module) removeExpiredFeeGrantAllowances(height int64, events []abci.Eve if err != nil { return fmt.Errorf("error while getting fee grant grantee address: %s", err) } - err = m.db.DeleteFeeGrantAllowance(types.NewGrantRemoval(string(granteeAddress.Value), string(granterAddress.Value), height)) + err = m.db.DeleteFeeGrantAllowance(types.NewGrantRemoval(granteeAddress.Value, granterAddress.Value, height)) if err != nil { return fmt.Errorf("error while deleting fee grant allowance: %s", err) diff --git a/types/provider.go b/types/provider.go index 9bdc0d2e4..fd30e610f 100644 --- a/types/provider.go +++ b/types/provider.go @@ -1,8 +1,8 @@ package types import ( - akashtypes "github.com/akash-network/akash-api/go/node/types/v1beta3" providertypes "github.com/akash-network/akash-api/go/node/provider/v1beta3" + akashtypes "github.com/akash-network/akash-api/go/node/types/v1beta3" provider "github.com/akash-network/provider" clustertypes "github.com/akash-network/provider/cluster/types/v1beta3" )