diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index add638f07f..d6e5aee1d6 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -73,6 +73,8 @@ - [QueryContractInfoResponse](#cosmwasm.wasm.v1.QueryContractInfoResponse) - [QueryContractsByCodeRequest](#cosmwasm.wasm.v1.QueryContractsByCodeRequest) - [QueryContractsByCodeResponse](#cosmwasm.wasm.v1.QueryContractsByCodeResponse) + - [QueryContractsByCreatorRequest](#cosmwasm.wasm.v1.QueryContractsByCreatorRequest) + - [QueryContractsByCreatorResponse](#cosmwasm.wasm.v1.QueryContractsByCreatorResponse) - [QueryParamsRequest](#cosmwasm.wasm.v1.QueryParamsRequest) - [QueryParamsResponse](#cosmwasm.wasm.v1.QueryParamsResponse) - [QueryPinnedCodesRequest](#cosmwasm.wasm.v1.QueryPinnedCodesRequest) @@ -1131,6 +1133,40 @@ Query/ContractsByCode RPC method + + +### QueryContractsByCreatorRequest +QueryContractsByCreatorRequest is the request type for the +Query/ContractsByCreator RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `creator_address` | [string](#string) | | CreatorAddress is the address of contract creator | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | Pagination defines an optional pagination for the request. | + + + + + + + + +### QueryContractsByCreatorResponse +QueryContractsByCreatorResponse is the response type for the +Query/ContractsByCreator RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `contract_addresses` | [string](#string) | repeated | ContractAddresses result set | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | Pagination defines the pagination in the response. | + + + + + + ### QueryParamsRequest @@ -1278,6 +1314,7 @@ Query provides defines the gRPC querier service | `Codes` | [QueryCodesRequest](#cosmwasm.wasm.v1.QueryCodesRequest) | [QueryCodesResponse](#cosmwasm.wasm.v1.QueryCodesResponse) | Codes gets the metadata for all stored wasm codes | GET|/cosmwasm/wasm/v1/code| | `PinnedCodes` | [QueryPinnedCodesRequest](#cosmwasm.wasm.v1.QueryPinnedCodesRequest) | [QueryPinnedCodesResponse](#cosmwasm.wasm.v1.QueryPinnedCodesResponse) | PinnedCodes gets the pinned code ids | GET|/cosmwasm/wasm/v1/codes/pinned| | `Params` | [QueryParamsRequest](#cosmwasm.wasm.v1.QueryParamsRequest) | [QueryParamsResponse](#cosmwasm.wasm.v1.QueryParamsResponse) | Params gets the module params | GET|/cosmwasm/wasm/v1/codes/params| +| `ContractsByCreator` | [QueryContractsByCreatorRequest](#cosmwasm.wasm.v1.QueryContractsByCreatorRequest) | [QueryContractsByCreatorResponse](#cosmwasm.wasm.v1.QueryContractsByCreatorResponse) | ContractsByCreator gets the contracts by creator | GET|/cosmwasm/wasm/v1/contracts/creator/{creator_address}| diff --git a/proto/cosmwasm/wasm/v1/query.proto b/proto/cosmwasm/wasm/v1/query.proto index 41d959d800..ffe48d2429 100644 --- a/proto/cosmwasm/wasm/v1/query.proto +++ b/proto/cosmwasm/wasm/v1/query.proto @@ -63,6 +63,13 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/cosmwasm/wasm/v1/codes/params"; } + + // ContractsByCreator gets the contracts by creator + rpc ContractsByCreator(QueryContractsByCreatorRequest) + returns (QueryContractsByCreatorResponse) { + option (google.api.http).get = + "/cosmwasm/wasm/v1/contracts/creator/{creator_address}"; + } } // QueryContractInfoRequest is the request type for the Query/ContractInfo RPC @@ -236,3 +243,21 @@ message QueryParamsResponse { // params defines the parameters of the module. Params params = 1 [ (gogoproto.nullable) = false ]; } + +// QueryContractsByCreatorRequest is the request type for the +// Query/ContractsByCreator RPC method. +message QueryContractsByCreatorRequest { + // CreatorAddress is the address of contract creator + string creator_address = 1; + // Pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryContractsByCreatorResponse is the response type for the +// Query/ContractsByCreator RPC method. +message QueryContractsByCreatorResponse { + // ContractAddresses result set + repeated string contract_addresses = 1; + // Pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} \ No newline at end of file diff --git a/x/wasm/client/cli/query.go b/x/wasm/client/cli/query.go index b847b3d843..8d13a1192a 100644 --- a/x/wasm/client/cli/query.go +++ b/x/wasm/client/cli/query.go @@ -41,6 +41,7 @@ func GetQueryCmd() *cobra.Command { GetCmdLibVersion(), GetCmdQueryParams(), GetCmdBuildAddress(), + GetCmdListContractsByCreator(), ) return queryCmd } @@ -528,6 +529,45 @@ func GetCmdListPinnedCode() *cobra.Command { return cmd } +// GetCmdListContractsByCreator lists all contracts by creator +func GetCmdListContractsByCreator() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-contracts-by-creator [creator]", + Short: "List all contracts by creator", + Long: "\t\tLong: List all contracts by creator,\n", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + _, err = sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err + } + pageReq, err := client.ReadPageRequest(withPageKeyDecoded(cmd.Flags())) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.ContractsByCreator( + context.Background(), + &types.QueryContractsByCreatorRequest{ + CreatorAddress: args[0], + Pagination: pageReq, + }, + ) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + type argumentDecoder struct { // dec is the default decoder dec func(string) ([]byte, error) diff --git a/x/wasm/keeper/genesis_test.go b/x/wasm/keeper/genesis_test.go index aee7ad009e..1d8f29a40f 100644 --- a/x/wasm/keeper/genesis_test.go +++ b/x/wasm/keeper/genesis_test.go @@ -110,7 +110,9 @@ func TestGenesisExportImport(t *testing.T) { // reset contract code index in source DB for comparison with dest DB wasmKeeper.IterateContractInfo(srcCtx, func(address sdk.AccAddress, info wasmTypes.ContractInfo) bool { + creatorAddress := sdk.MustAccAddressFromBech32(info.Creator) wasmKeeper.removeFromContractCodeSecondaryIndex(srcCtx, address, wasmKeeper.getLastContractHistoryEntry(srcCtx, address)) + prefixStore := prefix.NewStore(srcCtx.KVStore(wasmKeeper.storeKey), types.GetContractCodeHistoryElementPrefix(address)) iter := prefixStore.Iterator(nil, nil) @@ -121,6 +123,7 @@ func TestGenesisExportImport(t *testing.T) { newHistory := x.ResetFromGenesis(dstCtx) wasmKeeper.storeContractInfo(srcCtx, address, x) wasmKeeper.addToContractCodeSecondaryIndex(srcCtx, address, newHistory) + wasmKeeper.addToContractCreatorSecondaryIndex(srcCtx, creatorAddress, newHistory.Updated, address) wasmKeeper.appendToContractHistory(srcCtx, address, newHistory) iter.Close() return false diff --git a/x/wasm/keeper/keeper.go b/x/wasm/keeper/keeper.go index f29f6e18ed..6a32d2bcb0 100644 --- a/x/wasm/keeper/keeper.go +++ b/x/wasm/keeper/keeper.go @@ -378,6 +378,7 @@ func (k Keeper) instantiate( // store contract before dispatch so that contract could be called back historyEntry := contractInfo.InitialHistory(initMsg) k.addToContractCodeSecondaryIndex(ctx, contractAddress, historyEntry) + k.addToContractCreatorSecondaryIndex(ctx, creator, historyEntry.Updated, contractAddress) k.appendToContractHistory(ctx, contractAddress, historyEntry) k.storeContractInfo(ctx, contractAddress, &contractInfo) @@ -489,7 +490,6 @@ func (k Keeper) migrate(ctx sdk.Context, contractAddress sdk.AccAddress, caller if err != nil { return nil, sdkerrors.Wrap(types.ErrMigrationFailed, err.Error()) } - // delete old secondary index entry k.removeFromContractCodeSecondaryIndex(ctx, contractAddress, k.getLastContractHistoryEntry(ctx, contractAddress)) // persist migration updates @@ -596,6 +596,23 @@ func (k Keeper) removeFromContractCodeSecondaryIndex(ctx sdk.Context, contractAd ctx.KVStore(k.storeKey).Delete(types.GetContractByCreatedSecondaryIndexKey(contractAddress, entry)) } +// addToContractCreatorSecondaryIndex adds element to the index for contracts-by-creator queries +func (k Keeper) addToContractCreatorSecondaryIndex(ctx sdk.Context, creatorAddress sdk.AccAddress, position *types.AbsoluteTxPosition, contractAddress sdk.AccAddress) { + store := ctx.KVStore(k.storeKey) + store.Set(types.GetContractByCreatorSecondaryIndexKey(creatorAddress, position.Bytes(), contractAddress), []byte{}) +} + +// IterateContractsByCreator iterates over all contracts with given creator address in order of creation time asc. +func (k Keeper) IterateContractsByCreator(ctx sdk.Context, creator sdk.AccAddress, cb func(address sdk.AccAddress) bool) { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.GetContractsByCreatorPrefix(creator)) + for iter := prefixStore.Iterator(nil, nil); iter.Valid(); iter.Next() { + key := iter.Key() + if cb(key[types.AbsoluteTxPositionLen:]) { + return + } + } +} + // IterateContractsByCode iterates over all contracts with given codeID ASC on code update time. func (k Keeper) IterateContractsByCode(ctx sdk.Context, codeID uint64, cb func(address sdk.AccAddress) bool) { prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.GetContractByCodeIDSecondaryIndexPrefix(codeID)) @@ -1051,10 +1068,15 @@ func (k Keeper) importContract(ctx sdk.Context, contractAddr sdk.AccAddress, c * return sdkerrors.Wrapf(types.ErrDuplicate, "contract: %s", contractAddr) } + creatorAddress, err := sdk.AccAddressFromBech32(c.Creator) + if err != nil { + return err + } historyEntry := c.ResetFromGenesis(ctx) k.appendToContractHistory(ctx, contractAddr, historyEntry) k.storeContractInfo(ctx, contractAddr, c) k.addToContractCodeSecondaryIndex(ctx, contractAddr, historyEntry) + k.addToContractCreatorSecondaryIndex(ctx, creatorAddress, historyEntry.Updated, contractAddr) return k.importContractState(ctx, contractAddr, state) } diff --git a/x/wasm/keeper/keeper_test.go b/x/wasm/keeper/keeper_test.go index 947edd27c3..e385c8268f 100644 --- a/x/wasm/keeper/keeper_test.go +++ b/x/wasm/keeper/keeper_test.go @@ -400,7 +400,7 @@ func TestInstantiate(t *testing.T) { gasAfter := ctx.GasMeter().GasConsumed() if types.EnableGasVerification { - require.Equal(t, uint64(0x1964f), gasAfter-gasBefore) + require.Equal(t, uint64(0x1a7bb), gasAfter-gasBefore) } // ensure it is stored properly @@ -2188,3 +2188,93 @@ func TestCoinBurnerPruneBalances(t *testing.T) { }) } } + +func TestIteratorAllContract(t *testing.T) { + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities) + example1 := InstantiateHackatomExampleContract(t, ctx, keepers) + example2 := InstantiateHackatomExampleContract(t, ctx, keepers) + example3 := InstantiateHackatomExampleContract(t, ctx, keepers) + example4 := InstantiateHackatomExampleContract(t, ctx, keepers) + + var allContract []string + keepers.WasmKeeper.IterateContractInfo(ctx, func(addr sdk.AccAddress, _ types.ContractInfo) bool { + allContract = append(allContract, addr.String()) + return false + }) + + // IterateContractInfo not ordering + expContracts := []string{example4.Contract.String(), example2.Contract.String(), example1.Contract.String(), example3.Contract.String()} + require.Equal(t, allContract, expContracts) +} + +func TestIteratorContractByCreator(t *testing.T) { + // setup test + parentCtx, keepers := CreateTestInput(t, false, AvailableCapabilities) + keeper := keepers.ContractKeeper + + depositFund := sdk.NewCoins(sdk.NewInt64Coin("denom", 1000000)) + topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 5000)) + creator := DeterministicAccountAddress(t, 1) + keepers.Faucet.Fund(parentCtx, creator, depositFund.Add(depositFund...)...) + mockAddress1 := keepers.Faucet.NewFundedRandomAccount(parentCtx, topUp...) + mockAddress2 := keepers.Faucet.NewFundedRandomAccount(parentCtx, topUp...) + mockAddress3 := keepers.Faucet.NewFundedRandomAccount(parentCtx, topUp...) + + contract1ID, _, err := keeper.Create(parentCtx, creator, hackatomWasm, nil) + contract2ID, _, err := keeper.Create(parentCtx, creator, hackatomWasm, nil) + + require.NoError(t, err) + + initMsgBz := HackatomExampleInitMsg{ + Verifier: mockAddress1, + Beneficiary: mockAddress1, + }.GetBytes(t) + + depositContract := sdk.NewCoins(sdk.NewCoin("denom", sdk.NewInt(1_000))) + + gotAddr1, _, _ := keepers.ContractKeeper.Instantiate(parentCtx, contract1ID, mockAddress1, nil, initMsgBz, "label", depositContract) + ctx := parentCtx.WithBlockHeight(parentCtx.BlockHeight() + 1) + gotAddr2, _, _ := keepers.ContractKeeper.Instantiate(ctx, contract1ID, mockAddress2, nil, initMsgBz, "label", depositContract) + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) + gotAddr3, _, _ := keepers.ContractKeeper.Instantiate(ctx, contract1ID, gotAddr1, nil, initMsgBz, "label", depositContract) + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) + gotAddr4, _, _ := keepers.ContractKeeper.Instantiate(ctx, contract2ID, mockAddress2, nil, initMsgBz, "label", depositContract) + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) + gotAddr5, _, _ := keepers.ContractKeeper.Instantiate(ctx, contract2ID, mockAddress2, nil, initMsgBz, "label", depositContract) + + specs := map[string]struct { + creatorAddr sdk.AccAddress + contractsAddr []string + }{ + "single contract": { + creatorAddr: mockAddress1, + contractsAddr: []string{gotAddr1.String()}, + }, + "multiple contracts": { + creatorAddr: mockAddress2, + contractsAddr: []string{gotAddr2.String(), gotAddr4.String(), gotAddr5.String()}, + }, + "contractAdress": { + creatorAddr: gotAddr1, + contractsAddr: []string{gotAddr3.String()}, + }, + "no contracts- unknown": { + creatorAddr: mockAddress3, + contractsAddr: nil, + }, + } + + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + var allContract []string + keepers.WasmKeeper.IterateContractsByCreator(parentCtx, spec.creatorAddr, func(addr sdk.AccAddress) bool { + allContract = append(allContract, addr.String()) + return false + }) + require.Equal(t, + allContract, + spec.contractsAddr, + ) + }) + } +} diff --git a/x/wasm/keeper/migrate_test.go b/x/wasm/keeper/migrate_test.go new file mode 100644 index 0000000000..3b762c49d0 --- /dev/null +++ b/x/wasm/keeper/migrate_test.go @@ -0,0 +1,61 @@ +package keeper + +import ( + "bytes" + "encoding/json" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" + "github.com/stretchr/testify/require" + + "github.com/CosmWasm/wasmd/x/wasm/types" +) + +func TestMigrate1To2(t *testing.T) { + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities) + wasmKeeper := keepers.WasmKeeper + + deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 100000)) + creator := sdk.AccAddress(bytes.Repeat([]byte{1}, address.Len)) + keepers.Faucet.Fund(ctx, creator, deposit...) + example := StoreHackatomExampleContract(t, ctx, keepers) + + initMsg := HackatomExampleInitMsg{ + Verifier: RandomAccountAddress(t), + Beneficiary: RandomAccountAddress(t), + } + initMsgBz, err := json.Marshal(initMsg) + require.NoError(t, err) + + em := sdk.NewEventManager() + + // create with no balance is also legal + gotContractAddr1, _, err := keepers.ContractKeeper.Instantiate(ctx.WithEventManager(em), example.CodeID, creator, nil, initMsgBz, "demo contract 1", nil) + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) + gotContractAddr2, _, err := keepers.ContractKeeper.Instantiate(ctx.WithEventManager(em), example.CodeID, creator, nil, initMsgBz, "demo contract 1", nil) + ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) + gotContractAddr3, _, err := keepers.ContractKeeper.Instantiate(ctx.WithEventManager(em), example.CodeID, creator, nil, initMsgBz, "demo contract 1", nil) + + info1 := wasmKeeper.GetContractInfo(ctx, gotContractAddr1) + info2 := wasmKeeper.GetContractInfo(ctx, gotContractAddr2) + info3 := wasmKeeper.GetContractInfo(ctx, gotContractAddr3) + + // remove key + ctx.KVStore(wasmKeeper.storeKey).Delete(types.GetContractByCreatorSecondaryIndexKey(creator, info1.Created.Bytes(), gotContractAddr1)) + ctx.KVStore(wasmKeeper.storeKey).Delete(types.GetContractByCreatorSecondaryIndexKey(creator, info2.Created.Bytes(), gotContractAddr2)) + ctx.KVStore(wasmKeeper.storeKey).Delete(types.GetContractByCreatorSecondaryIndexKey(creator, info3.Created.Bytes(), gotContractAddr3)) + + // migrator + migrator := NewMigrator(*wasmKeeper) + migrator.Migrate1to2(ctx) + + // check new store + var allContract []string + wasmKeeper.IterateContractsByCreator(ctx, creator, func(addr sdk.AccAddress) bool { + allContract = append(allContract, addr.String()) + return false + }) + + require.Equal(t, []string{gotContractAddr1.String(), gotContractAddr2.String(), gotContractAddr3.String()}, allContract) +} diff --git a/x/wasm/keeper/migrations.go b/x/wasm/keeper/migrations.go new file mode 100644 index 0000000000..ffb80cc2ed --- /dev/null +++ b/x/wasm/keeper/migrations.go @@ -0,0 +1,27 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/CosmWasm/wasmd/x/wasm/types" +) + +// Migrator is a struct for handling in-place store migrations. +type Migrator struct { + keeper Keeper +} + +// NewMigrator returns a new Migrator. +func NewMigrator(keeper Keeper) Migrator { + return Migrator{keeper: keeper} +} + +// Migrate1to2 migrates from version 1 to 2. +func (m Migrator) Migrate1to2(ctx sdk.Context) error { + m.keeper.IterateContractInfo(ctx, func(contractAddr sdk.AccAddress, contractInfo types.ContractInfo) bool { + creator := sdk.MustAccAddressFromBech32(contractInfo.Creator) + m.keeper.addToContractCreatorSecondaryIndex(ctx, creator, contractInfo.Created, contractAddr) + return false + }) + return nil +} diff --git a/x/wasm/keeper/querier.go b/x/wasm/keeper/querier.go index 8cd882c7a8..9b23c68d96 100644 --- a/x/wasm/keeper/querier.go +++ b/x/wasm/keeper/querier.go @@ -318,3 +318,32 @@ func (q grpcQuerier) Params(c context.Context, req *types.QueryParamsRequest) (* params := q.keeper.GetParams(ctx) return &types.QueryParamsResponse{Params: params}, nil } + +func (q grpcQuerier) ContractsByCreator(c context.Context, req *types.QueryContractsByCreatorRequest) (*types.QueryContractsByCreatorResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(c) + contracts := make([]string, 0) + + creatorAddress, err := sdk.AccAddressFromBech32(req.CreatorAddress) + if err != nil { + return nil, err + } + prefixStore := prefix.NewStore(ctx.KVStore(q.storeKey), types.GetContractsByCreatorPrefix(creatorAddress)) + pageRes, err := query.FilteredPaginate(prefixStore, req.Pagination, func(key []byte, _ []byte, accumulate bool) (bool, error) { + if accumulate { + accAddres := sdk.AccAddress(key[types.AbsoluteTxPositionLen:]) + contracts = append(contracts, accAddres.String()) + } + return true, nil + }) + if err != nil { + return nil, err + } + + return &types.QueryContractsByCreatorResponse{ + ContractAddresses: contracts, + Pagination: pageRes, + }, nil +} diff --git a/x/wasm/keeper/querier_test.go b/x/wasm/keeper/querier_test.go index f4341d169d..52a17d0e11 100644 --- a/x/wasm/keeper/querier_test.go +++ b/x/wasm/keeper/querier_test.go @@ -802,6 +802,110 @@ func TestQueryCodeInfoList(t *testing.T) { require.EqualValues(t, allCodesResponse, got.CodeInfos) } +func TestQueryContractsByCreatorList(t *testing.T) { + ctx, keepers := CreateTestInput(t, false, AvailableCapabilities) + + deposit := sdk.NewCoins(sdk.NewInt64Coin("denom", 1000000)) + topUp := sdk.NewCoins(sdk.NewInt64Coin("denom", 500)) + creator := keepers.Faucet.NewFundedRandomAccount(ctx, deposit...) + anyAddr := keepers.Faucet.NewFundedRandomAccount(ctx, topUp...) + + wasmCode, err := os.ReadFile("./testdata/hackatom.wasm") + require.NoError(t, err) + + codeID, _, err := keepers.ContractKeeper.Create(ctx, creator, wasmCode, nil) + require.NoError(t, err) + + _, _, bob := keyPubAddr() + initMsg := HackatomExampleInitMsg{ + Verifier: anyAddr, + Beneficiary: bob, + } + initMsgBz, err := json.Marshal(initMsg) + require.NoError(t, err) + + // manage some realistic block settings + var h int64 = 10 + setBlock := func(ctx sdk.Context, height int64) sdk.Context { + ctx = ctx.WithBlockHeight(height) + meter := sdk.NewGasMeter(1000000) + ctx = ctx.WithGasMeter(meter) + ctx = ctx.WithBlockGasMeter(meter) + return ctx + } + + var allExpecedContracts []string + // create 10 contracts with real block/gas setup + for i := 0; i < 10; i++ { + ctx = setBlock(ctx, h) + h++ + contract, _, err := keepers.ContractKeeper.Instantiate(ctx, codeID, creator, nil, initMsgBz, fmt.Sprintf("contract %d", i), topUp) + allExpecedContracts = append(allExpecedContracts, contract.String()) + require.NoError(t, err) + } + + specs := map[string]struct { + srcQuery *types.QueryContractsByCreatorRequest + expContractAddr []string + expErr error + }{ + "query all": { + srcQuery: &types.QueryContractsByCreatorRequest{ + CreatorAddress: creator.String(), + }, + expContractAddr: allExpecedContracts, + expErr: nil, + }, + "with pagination offset": { + srcQuery: &types.QueryContractsByCreatorRequest{ + CreatorAddress: creator.String(), + Pagination: &query.PageRequest{ + Offset: 1, + }, + }, + expContractAddr: allExpecedContracts[1:], + expErr: nil, + }, + "with pagination limit": { + srcQuery: &types.QueryContractsByCreatorRequest{ + CreatorAddress: creator.String(), + Pagination: &query.PageRequest{ + Limit: 1, + }, + }, + expContractAddr: allExpecedContracts[0:1], + expErr: nil, + }, + "nil creator": { + srcQuery: &types.QueryContractsByCreatorRequest{ + Pagination: &query.PageRequest{}, + }, + expContractAddr: allExpecedContracts, + expErr: errors.New("empty address string is not allowed"), + }, + "nil req": { + srcQuery: nil, + expContractAddr: allExpecedContracts, + expErr: status.Error(codes.InvalidArgument, "empty request"), + }, + } + + q := Querier(keepers.WasmKeeper) + for msg, spec := range specs { + t.Run(msg, func(t *testing.T) { + got, err := q.ContractsByCreator(sdk.WrapSDKContext(ctx), spec.srcQuery) + + if spec.expErr != nil { + require.Equal(t, spec.expErr, err) + return + } + require.NoError(t, err) + require.NotNil(t, got) + assert.Equal(t, spec.expContractAddr, got.ContractAddresses) + }) + } +} + func fromBase64(s string) []byte { r, err := base64.StdEncoding.DecodeString(s) if err != nil { diff --git a/x/wasm/module.go b/x/wasm/module.go index 956887dabe..a52dc1bf0b 100644 --- a/x/wasm/module.go +++ b/x/wasm/module.go @@ -115,7 +115,7 @@ type AppModule struct { // module. It should be incremented on each consensus-breaking change // introduced by the module. To avoid wrong/empty versions, the initial version // should be set to 1. -func (AppModule) ConsensusVersion() uint64 { return 1 } +func (AppModule) ConsensusVersion() uint64 { return 2 } // NewAppModule creates a new AppModule object func NewAppModule( @@ -138,6 +138,12 @@ func NewAppModule( func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(keeper.NewDefaultPermissionKeeper(am.keeper))) types.RegisterQueryServer(cfg.QueryServer(), NewQuerier(am.keeper)) + + m := keeper.NewMigrator(*am.keeper) + err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2) + if err != nil { + panic(err) + } } func (am AppModule) LegacyQuerierHandler(amino *codec.LegacyAmino) sdk.Querier { //nolint:staticcheck diff --git a/x/wasm/module_integration_test.go b/x/wasm/module_integration_test.go index 0cbec6641f..bdce6cf34f 100644 --- a/x/wasm/module_integration_test.go +++ b/x/wasm/module_integration_test.go @@ -27,5 +27,5 @@ func TestModuleMigrations(t *testing.T) { gotVM, err := wasmApp.ModuleManager().RunMigrations(ctx, wasmApp.ModuleConfigurator(), fromVM) // then require.NoError(t, err) - assert.Equal(t, uint64(1), gotVM[wasm.ModuleName]) + assert.Equal(t, uint64(2), gotVM[wasm.ModuleName]) } diff --git a/x/wasm/types/exported_keepers.go b/x/wasm/types/exported_keepers.go index e68df8ee7b..dcf97cb2cc 100644 --- a/x/wasm/types/exported_keepers.go +++ b/x/wasm/types/exported_keepers.go @@ -14,6 +14,7 @@ type ViewKeeper interface { HasContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) bool GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) *ContractInfo IterateContractInfo(ctx sdk.Context, cb func(sdk.AccAddress, ContractInfo) bool) + IterateContractsByCreator(ctx sdk.Context, creator sdk.AccAddress, cb func(address sdk.AccAddress) bool) IterateContractsByCode(ctx sdk.Context, codeID uint64, cb func(address sdk.AccAddress) bool) IterateContractState(ctx sdk.Context, contractAddress sdk.AccAddress, cb func(key, value []byte) bool) GetCodeInfo(ctx sdk.Context, codeID uint64) *CodeInfo diff --git a/x/wasm/types/keys.go b/x/wasm/types/keys.go index fb636ef4f3..95078e1445 100644 --- a/x/wasm/types/keys.go +++ b/x/wasm/types/keys.go @@ -2,6 +2,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" ) const ( @@ -31,6 +32,7 @@ var ( ContractByCodeIDAndCreatedSecondaryIndexPrefix = []byte{0x06} PinnedCodeIndexPrefix = []byte{0x07} TXCounterPrefix = []byte{0x08} + ContractsByCreatorPrefix = []byte{0x09} KeyLastCodeID = append(SequenceKeyPrefix, []byte("lastCodeId")...) KeyLastInstanceID = append(SequenceKeyPrefix, []byte("lastContractId")...) @@ -47,6 +49,12 @@ func GetContractAddressKey(addr sdk.AccAddress) []byte { return append(ContractKeyPrefix, addr...) } +// GetContractsByCreatorPrefix returns the contracts by creator prefix for the WASM contract instance +func GetContractsByCreatorPrefix(addr sdk.AccAddress) []byte { + bz := address.MustLengthPrefix(addr) + return append(ContractsByCreatorPrefix, bz...) +} + // GetContractStorePrefix returns the store prefix for the WASM contract instance func GetContractStorePrefix(addr sdk.AccAddress) []byte { return append(ContractStorePrefix, addr...) @@ -75,6 +83,19 @@ func GetContractByCodeIDSecondaryIndexPrefix(codeID uint64) []byte { return r } +// GetContractByCreatorSecondaryIndexKey returns the key for the second index: `` +func GetContractByCreatorSecondaryIndexKey(bz []byte, position []byte, contractAddr sdk.AccAddress) []byte { + prefixBytes := GetContractsByCreatorPrefix(bz) + lenPrefixBytes := len(prefixBytes) + r := make([]byte, lenPrefixBytes+AbsoluteTxPositionLen+len(contractAddr)) + + copy(r[:lenPrefixBytes], prefixBytes) + copy(r[lenPrefixBytes:lenPrefixBytes+AbsoluteTxPositionLen], position) + copy(r[lenPrefixBytes+AbsoluteTxPositionLen:], contractAddr) + + return r +} + // GetContractCodeHistoryElementKey returns the key a contract code history entry: `` func GetContractCodeHistoryElementKey(contractAddr sdk.AccAddress, pos uint64) []byte { prefix := GetContractCodeHistoryElementPrefix(contractAddr) diff --git a/x/wasm/types/keys_test.go b/x/wasm/types/keys_test.go index 552703fea0..3db6bbadfe 100644 --- a/x/wasm/types/keys_test.go +++ b/x/wasm/types/keys_test.go @@ -85,3 +85,63 @@ func TestGetContractByCreatedSecondaryIndexKey(t *testing.T) { } assert.Equal(t, exp, got) } + +func TestGetContractByCreatorSecondaryIndexKey(t *testing.T) { + creatorAddr := bytes.Repeat([]byte{4}, 20) + e := ContractCodeHistoryEntry{ + CodeID: 1, + Updated: &AbsoluteTxPosition{2 + 1<<(8*7), 3 + 1<<(8*7)}, + } + + // test that contract addresses of 20 length are still supported + contractAddr := bytes.Repeat([]byte{4}, 20) + got := GetContractByCreatorSecondaryIndexKey(creatorAddr, e.Updated.Bytes(), contractAddr) + exp := []byte{ + 9, // prefix + 20, // creator address length + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // creator address with fixed length prefix + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 1, 0, 0, 0, 0, 0, 0, 2, // height + 1, 0, 0, 0, 0, 0, 0, 3, // index + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // address 20 bytes + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + } + assert.Equal(t, exp, got) + + // test that contract addresses of 32 length are still supported + contractAddr = bytes.Repeat([]byte{4}, 32) + got = GetContractByCreatorSecondaryIndexKey(creatorAddr, e.Updated.Bytes(), contractAddr) + exp = []byte{ + 9, // prefix + 20, // creator address length + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // creator address with fixed length prefix + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 1, 0, 0, 0, 0, 0, 0, 2, // height + 1, 0, 0, 0, 0, 0, 0, 3, // index + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // address 32 bytes + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, + } + + // test that creator is contract addresses of 32 length + contractAddr = bytes.Repeat([]byte{4}, 32) + creatorAddr = bytes.Repeat([]byte{8}, 32) + got = GetContractByCreatorSecondaryIndexKey(creatorAddr, e.Updated.Bytes(), contractAddr) + exp = []byte{ + 9, // prefix + 32, // creator address length + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // creator address is a contract address + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, + 1, 0, 0, 0, 0, 0, 0, 2, // height + 1, 0, 0, 0, 0, 0, 0, 3, // index + + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // address 32 bytes + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, + } + assert.Equal(t, exp, got) +} diff --git a/x/wasm/types/query.pb.go b/x/wasm/types/query.pb.go index dea3e53b01..bb08b7571c 100644 --- a/x/wasm/types/query.pb.go +++ b/x/wasm/types/query.pb.go @@ -987,6 +987,100 @@ func (m *QueryParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo +// QueryContractsByCreatorRequest is the request type for the +// Query/ContractsByCreator RPC method. +type QueryContractsByCreatorRequest struct { + // CreatorAddress is the address of contract creator + CreatorAddress string `protobuf:"bytes,1,opt,name=creator_address,json=creatorAddress,proto3" json:"creator_address,omitempty"` + // Pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryContractsByCreatorRequest) Reset() { *m = QueryContractsByCreatorRequest{} } +func (m *QueryContractsByCreatorRequest) String() string { return proto.CompactTextString(m) } +func (*QueryContractsByCreatorRequest) ProtoMessage() {} +func (*QueryContractsByCreatorRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9677c207036b9f2b, []int{21} +} + +func (m *QueryContractsByCreatorRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *QueryContractsByCreatorRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryContractsByCreatorRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} + +func (m *QueryContractsByCreatorRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryContractsByCreatorRequest.Merge(m, src) +} + +func (m *QueryContractsByCreatorRequest) XXX_Size() int { + return m.Size() +} + +func (m *QueryContractsByCreatorRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryContractsByCreatorRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryContractsByCreatorRequest proto.InternalMessageInfo + +// QueryContractsByCreatorResponse is the response type for the +// Query/ContractsByCreator RPC method. +type QueryContractsByCreatorResponse struct { + // ContractAddresses result set + ContractAddresses []string `protobuf:"bytes,1,rep,name=contract_addresses,json=contractAddresses,proto3" json:"contract_addresses,omitempty"` + // Pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryContractsByCreatorResponse) Reset() { *m = QueryContractsByCreatorResponse{} } +func (m *QueryContractsByCreatorResponse) String() string { return proto.CompactTextString(m) } +func (*QueryContractsByCreatorResponse) ProtoMessage() {} +func (*QueryContractsByCreatorResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9677c207036b9f2b, []int{22} +} + +func (m *QueryContractsByCreatorResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} + +func (m *QueryContractsByCreatorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryContractsByCreatorResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} + +func (m *QueryContractsByCreatorResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryContractsByCreatorResponse.Merge(m, src) +} + +func (m *QueryContractsByCreatorResponse) XXX_Size() int { + return m.Size() +} + +func (m *QueryContractsByCreatorResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryContractsByCreatorResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryContractsByCreatorResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*QueryContractInfoRequest)(nil), "cosmwasm.wasm.v1.QueryContractInfoRequest") proto.RegisterType((*QueryContractInfoResponse)(nil), "cosmwasm.wasm.v1.QueryContractInfoResponse") @@ -1009,90 +1103,98 @@ func init() { proto.RegisterType((*QueryPinnedCodesResponse)(nil), "cosmwasm.wasm.v1.QueryPinnedCodesResponse") proto.RegisterType((*QueryParamsRequest)(nil), "cosmwasm.wasm.v1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "cosmwasm.wasm.v1.QueryParamsResponse") + proto.RegisterType((*QueryContractsByCreatorRequest)(nil), "cosmwasm.wasm.v1.QueryContractsByCreatorRequest") + proto.RegisterType((*QueryContractsByCreatorResponse)(nil), "cosmwasm.wasm.v1.QueryContractsByCreatorResponse") } func init() { proto.RegisterFile("cosmwasm/wasm/v1/query.proto", fileDescriptor_9677c207036b9f2b) } var fileDescriptor_9677c207036b9f2b = []byte{ - // 1245 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x98, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xc7, 0x3d, 0xa9, 0xe3, 0x1f, 0x93, 0xa0, 0x9a, 0xa1, 0x24, 0xc6, 0xa4, 0xbb, 0xd1, 0x52, - 0x42, 0x9a, 0x86, 0x5d, 0x92, 0x26, 0x14, 0x90, 0x10, 0xaa, 0x53, 0x68, 0x12, 0x29, 0x52, 0xba, - 0x15, 0xaa, 0x44, 0x0f, 0xd1, 0xd8, 0x3b, 0x71, 0x56, 0x8a, 0x77, 0x9c, 0x9d,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 0xd4, 0x13, 0xb4, 0x6d, 0x96, 0xd1, - 0xe6, 0x05, 0xe8, 0x2c, 0x9a, 0xe9, 0x06, 0x6a, 0x11, 0xe3, 0x40, 0x56, 0xed, 0xa1, 0x71, 0x36, - 0xe1, 0xfc, 0x02, 0x60, 0xae, 0x7d, 0x20, 0x40, 0x71, 0x0b, 0xc7, 0x0c, 0x2f, 0x05, 0xa3, 0x6f, - 0xfb, 0x7e, 0x48, 0x3b, 0x24, 0x65, 0x02, 0xea, 0x37, 0x00, 0x73, 0xed, 0x07, 0x78, 0x2c, 0x69, - 0xcc, 0x08, 0x11, 0x4b, 0x1a, 0x37, 0x19, 0x68, 0xef, 0x0b, 0xd2, 0x5b, 0x68, 0xb1, 0x2f, 0x52, - 0x17, 0xef, 0x1b, 0x07, 0x67, 0x27, 0xff, 0x21, 0xfa, 0x03, 0x40, 0xd4, 0x79, 0x9a, 0xa3, 0xb7, - 0x62, 0x30, 0x62, 0x67, 0x8d, 0xc2, 0xdc, 0x05, 0x3c, 0x24, 0xfa, 0x07, 0x02, 0xfd, 0x5d, 0x74, - 0xab, 0x3f, 0x91, 0xbd, 0x40, 0x51, 0xf8, 0x3a, 0x4c, 0x8a, 0xb2, 0xd5, 0x62, 0xeb, 0xf0, 0xac, - 0x56, 0x5f, 0x3b, 0xd7, 0x46, 0x12, 0x4d, 0x0b, 0x22, 0x0d, 0x4d, 0xf6, 0x2a, 0x50, 0xe4, 0xc2, - 0x61, 0xd1, 0x73, 0xd1, 0x79, 0x71, 0x83, 0x2e, 0x58, 0xb8, 0x76, 0xbe, 0x91, 0x5c, 0x5d, 0x11, - 0xab, 0xe7, 0xd1, 0x58, 0xf7, 0xd5, 0xd1, 0x57, 0x00, 0x8e, 0x84, 0xda, 0x3d, 0xba, 0x1e, 0x13, - 0xb5, 0xf3, 0xd8, 0x29, 0xcc, 0xf4, 0x63, 0x2a, 0x31, 0xa6, 0x04, 0xc6, 0x24, 0x52, 0xba, 0x63, - 0x30, 0xa3, 0x26, 0x9c, 0xd0, 0x21, 0x4c, 0xf9, 0x3d, 0x1a, 0xc5, 0xa5, 0x17, 0x39, 0x0a, 0x0a, - 0xaf, 0xf7, 0xb0, 0xea, 0x7b, 0x79, 0xff, 0x60, 0x58, 0x3e, 0xfa, 0x47, 0x49, 0xfc, 0xda, 0x54, - 0x12, 0x47, 0x4d, 0x05, 0x1c, 0x37, 0x15, 0xf0, 0x77, 0x53, 0x01, 0xdf, 0x9e, 0x28, 0x89, 0xe3, - 0x13, 0x25, 0xf1, 0xd7, 0x89, 0x92, 0xf8, 0x64, 0x2a, 0x34, 0xc0, 0x2d, 0x51, 0x56, 0x7d, 0x10, - 0xc4, 0xb2, 0x8c, 0x47, 0x7e, 0x4c, 0xf1, 0x8f, 0x42, 0x29, 0x25, 0xfe, 0x08, 0xb8, 0xf9, 0x7f, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xa4, 0x0e, 0x41, 0xb8, 0x10, 0x00, 0x00, + // 1331 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x98, 0xcd, 0x6f, 0x1b, 0xc5, + 0x1b, 0xc7, 0x3d, 0xa9, 0xe3, 0x97, 0x69, 0xfa, 0xab, 0x3b, 0xbf, 0xd2, 0x18, 0x93, 0xae, 0xa3, + 0xa5, 0xa4, 0x69, 0x9a, 0xee, 0x92, 0x34, 0xa1, 0x80, 0x84, 0x50, 0x9c, 0x42, 0x93, 0x48, 0x91, + 0xd2, 0xad, 0x50, 0x25, 0x7a, 0xb0, 0xc6, 0xde, 0x89, 0xb3, 0x52, 0xbc, 0xeb, 0xec, 0x4c, 0x92, + 0x5a, 0x51, 0x00, 0x55, 0xe2, 0x86, 0x78, 0x11, 0xe2, 0xc0, 0x01, 0xc1, 0x01, 0x15, 0xce, 0x70, + 0x41, 0x5c, 0xb9, 0xe4, 0x18, 0x89, 0x0b, 0x27, 0x0b, 0x1c,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 0xff, 0x2e, 0x81, 0xbe, 0x05, 0xf0, 0x6a, 0x04, 0x82, 0xd0, + 0x62, 0x1e, 0x26, 0xaa, 0x8e, 0x49, 0x36, 0x65, 0x02, 0x8d, 0x76, 0x26, 0xd0, 0xaa, 0x37, 0x2e, + 0xb2, 0x45, 0x18, 0x0f, 0x4e, 0xa4, 0x87, 0x42, 0x23, 0x03, 0xef, 0x9e, 0x51, 0xa3, 0xab, 0x10, + 0x72, 0x1f, 0x45, 0x13, 0x33, 0xcc, 0x11, 0x46, 0x8c, 0x34, 0xff, 0x72, 0x17, 0x33, 0xac, 0xde, + 0x16, 0x91, 0x77, 0x2e, 0x2c, 0x22, 0x47, 0x30, 0xce, 0x67, 0x02, 0x3e, 0x93, 0x3f, 0xab, 0x5b, + 0x50, 0xe1, 0x93, 0x1e, 0x54, 0xb1, 0xcb, 0xce, 0xc8, 0x33, 0xdf, 0xc9, 0x53, 0xb8, 0xf2, 0xac, + 0x91, 0x47, 0x01, 0x82, 0x55, 0x42, 0xa9, 0xa7, 0x44, 0x80, 0x73, 0x15, 0xe6, 0x23, 0x5d, 0x0a, + 0xd2, 0xa9, 0x20, 0x69, 0xe4, 0x9a, 0x7e, 0x04, 0x37, 0x61, 0x46, 0xe4, 0x7e, 0xef, 0x13, 0xa7, + 0x7e, 0x33, 0x04, 0x33, 0x9e, 0x61, 0xe8, 0xa2, 0xbd, 0xd1, 0x66, 0x5d, 0xc8, 0x34, 0x1b, 0xf9, + 0x04, 0x37, 0xbb, 0x7b, 0xdc, 0xc8, 0x0f, 0x59, 0x66, 0xeb, 0xc4, 0x66, 0x61, 0xb2, 0xec, 0x12, + 0xcc, 0x1c, 0x97, 0xc7, 0x9b, 0x36, 0xe4, 0x2b, 0x7a, 0x0f, 0xa6, 0x3d, 0x9c, 0xe2, 0x06, 0xa6, + 0x1b, 0xd9, 0x73, 0x9c, 0xfb, 0xf5, 0x67, 0x8d, 0xfc, 0x5c, 0xc5, 0x62, 0x1b, 0xdb, 0x25, 0xad, + 0xec, 0x54, 0x75, 0x46, 0x6c, 0x93, 0xb8, 0x55, 0xcb, 0x66, 0xc1, 0xc7, 0x4d, 0xab, 0x44, 0xf5, + 0x52, 0x9d, 0x11, 0xaa, 0x2d, 0x91, 0xc7, 0x05, 0xef, 0xc1, 0x48, 0x79, 0x4b, 0x2d, 0x61, 0xba, + 0x81, 0x1e, 0xc1, 0x2b, 0x96, 0x4d, 0x19, 0xb6, 0x99, 0x85, 0x19, 0x29, 0xd6, 0xbc, 0x49, 0x94, + 0x7a, 0x29, 0x98, 0x88, 0xba, 0xf3, 0x17, 0xca, 0x65, 0x42, 0xe9, 0xa2, 0x63, 0xaf, 0x5b, 0x15, + 0x91, 0xc4, 0x2f, 0x04, 0xd6, 0x58, 0x6b, 0x2d, 0xe1, 0x5f, 0xfa, 0x2b, 0xf1, 0x54, 0x3c, 0x33, + 0xbc, 0x12, 0x4f, 0x0d, 0x67, 0x12, 0xea, 0x13, 0x00, 0x2f, 0x05, 0xd4, 0x14, 0x02, 0x2d, 0x7b, + 0xd7, 0x87, 0x27, 0x90, 0x57, 0x6b, 0x00, 0xf7, 0xab, 0x76, 0xbb, 0x76, 0xc3, 0xba, 0x16, 0x52, + 0xad, 0x5a, 0x93, 0x2a, 0x8b, 0x31, 0x34, 0x26, 0x76, 0xd6, 0xcf, 0x96, 0xd4, 0x71, 0x23, 0xcf, + 0xdf, 0xfd, 0xbd, 0x14, 0x55, 0xe8, 0x51, 0x80, 0x81, 0xca, 0x2d, 0x0d, 0x5f, 0x10, 0xe0, 0xb9, + 0x2f, 0x88, 0xa7, 0x00, 0xa2, 0xe0, 0xea, 0x22, 0xc4, 0x7b, 0x10, 0xb6, 0x42, 0x94, 0x37, 0x43, + 0x3f, 0x31, 0xfa, 0xfa, 0xa6, 0x65, 0x7c, 0x03, 0xbc, 0x27, 0x30, 0x1c, 0xe5, 0x9c, 0x6b, 0x96, + 0x6d, 0x13, 0xf3, 0x14, 0x2d, 0x9e, 0xff, 0x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 0x02, 0xe0, 0xf9, 0x40, 0x79, 0x44, 0x37, 0x22, 0x56, 0xed, 0x2c, 0xd3, 0xb9, 0xa9, + 0x7e, 0x4c, 0x05, 0xc6, 0x04, 0xc7, 0x18, 0x47, 0x4a, 0x77, 0x0c, 0xaa, 0xd7, 0xf8, 0x24, 0xb4, + 0x0f, 0x13, 0x7e, 0x4d, 0x43, 0x51, 0xe1, 0x85, 0x4a, 0x67, 0xee, 0x95, 0x1e, 0x56, 0x7d, 0xbb, + 0xf7, 0x9d, 0xfe, 0x02, 0x20, 0xea, 0xac, 0x50, 0x91, 0x99, 0x1b, 0x59, 0x60, 0x23, 0x33, 0x37, + 0xba, 0xfc, 0xf5, 0x73, 0xe8, 0xa8, 0x2e, 0xca, 0xb3, 0xbe, 0xd7, 0x56, 0xbe, 0xf7, 0x0b, 0x4b, + 0x07, 0x7f, 0x29, 0xb1, 0x1f, 0x9b, 0x4a, 0xec, 0xa0, 0xa9, 0x80, 0xc3, 0xa6, 0x02, 0xfe, 0x6c, + 0x2a, 0xe0, 0xf3, 0x23, 0x25, 0x76, 0x78, 0xa4, 0xc4, 0xfe, 0x38, 0x52, 0x62, 0xef, 0x4f, 0x04, + 0x7a, 0xf5, 0x45, 0x87, 0x56, 0x1f, 0x4a, 0x17, 0xa6, 0xfe, 0xd8, 0x77, 0xc5, 0xff, 0x3c, 0x2a, + 0x25, 0xf8, 0x7f, 0x3e, 0xb7, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x78, 0x46, 0xe1, 0xa8, 0xa3, + 0x12, 0x00, 0x00, } func (this *QueryContractInfoResponse) Equal(that interface{}) bool { @@ -1217,6 +1319,8 @@ type QueryClient interface { PinnedCodes(ctx context.Context, in *QueryPinnedCodesRequest, opts ...grpc.CallOption) (*QueryPinnedCodesResponse, error) // Params gets the module params Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // ContractsByCreator gets the contracts by creator + ContractsByCreator(ctx context.Context, in *QueryContractsByCreatorRequest, opts ...grpc.CallOption) (*QueryContractsByCreatorResponse, error) } type queryClient struct { @@ -1317,6 +1421,15 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } +func (c *queryClient) ContractsByCreator(ctx context.Context, in *QueryContractsByCreatorRequest, opts ...grpc.CallOption) (*QueryContractsByCreatorResponse, error) { + out := new(QueryContractsByCreatorResponse) + err := c.cc.Invoke(ctx, "/cosmwasm.wasm.v1.Query/ContractsByCreator", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // ContractInfo gets the contract meta data @@ -1339,6 +1452,8 @@ type QueryServer interface { PinnedCodes(context.Context, *QueryPinnedCodesRequest) (*QueryPinnedCodesResponse, error) // Params gets the module params Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // ContractsByCreator gets the contracts by creator + ContractsByCreator(context.Context, *QueryContractsByCreatorRequest) (*QueryContractsByCreatorResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1384,6 +1499,10 @@ func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsReq return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } +func (*UnimplementedQueryServer) ContractsByCreator(ctx context.Context, req *QueryContractsByCreatorRequest) (*QueryContractsByCreatorResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ContractsByCreator not implemented") +} + func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } @@ -1568,6 +1687,24 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_ContractsByCreator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryContractsByCreatorRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ContractsByCreator(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmwasm.wasm.v1.Query/ContractsByCreator", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ContractsByCreator(ctx, req.(*QueryContractsByCreatorRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmwasm.wasm.v1.Query", HandlerType: (*QueryServer)(nil), @@ -1612,6 +1749,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "ContractsByCreator", + Handler: _Query_ContractsByCreator_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmwasm/wasm/v1/query.proto", @@ -2437,6 +2578,92 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryContractsByCreatorRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryContractsByCreatorRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryContractsByCreatorRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.CreatorAddress) > 0 { + i -= len(m.CreatorAddress) + copy(dAtA[i:], m.CreatorAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.CreatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryContractsByCreatorResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryContractsByCreatorResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryContractsByCreatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ContractAddresses) > 0 { + for iNdEx := len(m.ContractAddresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ContractAddresses[iNdEx]) + copy(dAtA[i:], m.ContractAddresses[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ContractAddresses[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -2780,6 +3007,42 @@ func (m *QueryParamsResponse) Size() (n int) { return n } +func (m *QueryContractsByCreatorRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CreatorAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryContractsByCreatorResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ContractAddresses) > 0 { + for _, s := range m.ContractAddresses { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -5049,6 +5312,244 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { return nil } +func (m *QueryContractsByCreatorRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryContractsByCreatorRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryContractsByCreatorRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CreatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CreatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + +func (m *QueryContractsByCreatorResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryContractsByCreatorResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryContractsByCreatorResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddresses", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContractAddresses = append(m.ContractAddresses, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} + func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/wasm/types/query.pb.gw.go b/x/wasm/types/query.pb.gw.go index 1fa96f457a..527cac4e74 100644 --- a/x/wasm/types/query.pb.gw.go +++ b/x/wasm/types/query.pb.gw.go @@ -572,6 +572,74 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal return msg, metadata, err } +var filter_Query_ContractsByCreator_0 = &utilities.DoubleArray{Encoding: map[string]int{"creator_address": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + +func request_Query_ContractsByCreator_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryContractsByCreatorRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["creator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "creator_address") + } + + protoReq.CreatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "creator_address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ContractsByCreator_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ContractsByCreator(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Query_ContractsByCreator_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryContractsByCreatorRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["creator_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "creator_address") + } + + protoReq.CreatorAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "creator_address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ContractsByCreator_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ContractsByCreator(ctx, &protoReq) + return msg, metadata, err +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -797,6 +865,25 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) + mux.Handle("GET", pattern_Query_ContractsByCreator_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ContractsByCreator_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ContractsByCreator_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil } @@ -1027,6 +1114,25 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) + mux.Handle("GET", pattern_Query_ContractsByCreator_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ContractsByCreator_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ContractsByCreator_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil } @@ -1049,7 +1155,9 @@ var ( pattern_Query_PinnedCodes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"cosmwasm", "wasm", "v1", "codes", "pinned"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"cosmwasm", "wasm", "v1", "codes", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"cosmwasm", "wasm", "v1", "codes", "params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_ContractsByCreator_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"cosmwasm", "wasm", "v1", "contracts", "creator", "creator_address"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -1072,4 +1180,6 @@ var ( forward_Query_PinnedCodes_0 = runtime.ForwardResponseMessage forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_ContractsByCreator_0 = runtime.ForwardResponseMessage )