Skip to content

Commit

Permalink
chore: disable local source
Browse files Browse the repository at this point in the history
  • Loading branch information
MonikaCat committed Feb 5, 2024
1 parent 4d9992a commit 151ee31
Show file tree
Hide file tree
Showing 9 changed files with 704 additions and 704 deletions.
2 changes: 1 addition & 1 deletion database/feegrant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveFeeGrantAllowance() {
suite.Require().Equal(rows[0].Height, int64(121622))

var stored feegranttypes.FeeAllowanceI
err = suite.database.EncodingConfig.Marshaler.UnmarshalInterfaceJSON([]byte(rows[0].Allowance), &stored)
err = suite.database.Cdc.UnmarshalInterfaceJSON([]byte(rows[0].Allowance), &stored)
suite.Require().NoError(err)
suite.Require().Equal(allowance, stored)
}
Expand Down
2 changes: 1 addition & 1 deletion database/gov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (suite *DbTestSuite) encodeProposalContent(content govtypes.Content) string
anyContent, err := codectypes.NewAnyWithValue(protoContent)
suite.Require().NoError(err)

contentBz, err := suite.database.EncodingConfig.Marshaler.MarshalJSON(anyContent)
contentBz, err := suite.database.Cdc.MarshalJSON(anyContent)
suite.Require().NoError(err)

return string(contentBz)
Expand Down
192 changes: 96 additions & 96 deletions modules/bank/source/local/source.go
Original file line number Diff line number Diff line change
@@ -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
// }
Loading

0 comments on commit 151ee31

Please sign in to comment.