Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove x/bank import from SDK #18381

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,277 changes: 1,229 additions & 48 deletions api/cosmos/accounts/testing/counter/v1/counter.pulsar.go

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions client/rpc/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package rpc_test

import (
"context"
"fmt"
"strconv"
"testing"

Expand All @@ -11,8 +10,6 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"

banktypes "cosmossdk.io/x/bank/types"

"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
"github.com/cosmos/cosmos-sdk/types/address"
Expand Down Expand Up @@ -97,7 +94,7 @@ func (s *IntegrationTestSuite) TestQueryABCIHeight() {
clientCtx = clientCtx.WithHeight(tc.ctxHeight)

req := abci.RequestQuery{
Path: fmt.Sprintf("store/%s/key", banktypes.StoreKey),
Path: "store/bank/key",
Height: tc.reqHeight,
Data: address.MustLengthPrefix(val.GetAddress()),
Prove: true,
Expand Down
16 changes: 16 additions & 0 deletions proto/cosmos/accounts/testing/counter/v1/counter.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package cosmos.accounts.testing.counter.v1;

import "cosmos/base/query/v1beta1/pagination.proto";

// MsgInit defines a message which initializes the counter with a given amount.
message MsgInit {
// initial_value is the initial amount to set the counter to.
Expand Down Expand Up @@ -32,3 +34,17 @@ message QueryCounterResponse {
// value defines the value of the counter.
uint64 value = 1;
}

// QueryEnumerateCounterRequest is used to query the counter enumeration.
message QueryEnumerateCounterRequest {
// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// QueryEnumerateCounterResponse returns the counter enumeration.
message QueryEnumerateCounterResponse {
// counter defines the counter enumerated.
repeated uint64 step = 1;
// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
1 change: 1 addition & 0 deletions testutil/configurator/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1"
"cosmossdk.io/core/appconfig"
"cosmossdk.io/depinject"

"github.com/cosmos/cosmos-sdk/testutil"
)

Expand Down
26 changes: 8 additions & 18 deletions testutil/sims/address_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,24 @@ package sims

import (
"bytes"
"context"
"encoding/hex"
"fmt"
"strconv"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"
bankkeeper "cosmossdk.io/x/bank/keeper"

"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

const mintModuleName = "mint"

type GenerateAccountStrategy func(int) []sdk.AccAddress

// BondDenomProvider is a subset of the staking keeper's public interface that
// provides the staking bond denom. It is used in arguments in this package's
// functions so that a mock staking keeper can be passed instead of the real one.
type BondDenomProvider interface {
BondDenom(ctx context.Context) (string, error)
}

// AddTestAddrsFromPubKeys adds the addresses into the SimApp providing only the public keys.
func AddTestAddrsFromPubKeys(bankKeeper bankkeeper.Keeper, stakingKeeper BondDenomProvider, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt math.Int) {
func AddTestAddrsFromPubKeys(bankKeeper BankKeeper, stakingKeeper StakingKeeper, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt math.Int) {
bondDenom, err := stakingKeeper.BondDenom(ctx)
if err != nil {
panic(err)
Expand All @@ -43,16 +33,16 @@ func AddTestAddrsFromPubKeys(bankKeeper bankkeeper.Keeper, stakingKeeper BondDen

// AddTestAddrs constructs and returns accNum amount of accounts with an
// initial balance of accAmt in random order
func AddTestAddrs(bankKeeper bankkeeper.Keeper, stakingKeeper BondDenomProvider, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress {
func AddTestAddrs(bankKeeper BankKeeper, stakingKeeper StakingKeeper, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress {
return addTestAddrs(bankKeeper, stakingKeeper, ctx, accNum, accAmt, CreateRandomAccounts)
}

// AddTestAddrsIncremental constructs and returns accNum amount of accounts with an initial balance of accAmt in random order
func AddTestAddrsIncremental(bankKeeper bankkeeper.Keeper, stakingKeeper BondDenomProvider, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress {
func AddTestAddrsIncremental(bankKeeper BankKeeper, stakingKeeper StakingKeeper, ctx sdk.Context, accNum int, accAmt math.Int) []sdk.AccAddress {
return addTestAddrs(bankKeeper, stakingKeeper, ctx, accNum, accAmt, CreateIncrementalAccounts)
}

func addTestAddrs(bankKeeper bankkeeper.Keeper, stakingKeeper BondDenomProvider, ctx sdk.Context, accNum int, accAmt math.Int, strategy GenerateAccountStrategy) []sdk.AccAddress {
func addTestAddrs(bankKeeper BankKeeper, stakingKeeper StakingKeeper, ctx sdk.Context, accNum int, accAmt math.Int, strategy GenerateAccountStrategy) []sdk.AccAddress {
testAddrs := strategy(accNum)
bondDenom, err := stakingKeeper.BondDenom(ctx)
if err != nil {
Expand All @@ -67,12 +57,12 @@ func addTestAddrs(bankKeeper bankkeeper.Keeper, stakingKeeper BondDenomProvider,
return testAddrs
}

func initAccountWithCoins(bankKeeper bankkeeper.Keeper, ctx sdk.Context, addr sdk.AccAddress, coins sdk.Coins) {
if err := bankKeeper.MintCoins(ctx, mintModuleName, coins); err != nil {
func initAccountWithCoins(bankKeeper BankKeeper, ctx sdk.Context, addr sdk.AccAddress, coins sdk.Coins) {
if err := bankKeeper.MintCoins(ctx, testutil.MintModuleName, coins); err != nil {
panic(err)
}

if err := bankKeeper.SendCoinsFromModuleToAccount(ctx, mintModuleName, addr, coins); err != nil {
if err := bankKeeper.SendCoinsFromModuleToAccount(ctx, testutil.MintModuleName, addr, coins); err != nil {
panic(err)
}
}
Expand Down
20 changes: 20 additions & 0 deletions testutil/sims/expected_keepers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package sims

import (
"context"

sdk "github.com/cosmos/cosmos-sdk/types"
)

type BankKeeper interface {
SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error

MintCoins(ctx context.Context, moduleName string, amt sdk.Coins) error
}

// StakingKeeper is a subset of the staking keeper's public interface that
// provides the staking bond denom. It is used in arguments in this package's
// functions so that a mock staking keeper can be passed instead of the real one.
type StakingKeeper interface {
BondDenom(ctx context.Context) (string, error)
}
7 changes: 3 additions & 4 deletions testutil/testdata/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions testutil/testdata/testdata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions testutil/testdata/testpb/query.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion testutil/testdata/testpb/query_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions testutil/testdata/testpb/testdata.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions testutil/testdata/testpb/tx.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion testutil/testdata/testpb/tx_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions testutil/testdata/testpb/unknonwnproto.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions testutil/testdata/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions testutil/testdata/unknonwnproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.