diff --git a/config.yml b/config.yml index 99b27eb2..4017eef6 100644 --- a/config.yml +++ b/config.yml @@ -31,17 +31,17 @@ accounts: - 1000000000000000tkyve mnemonic: open home share route party lake room solution quantum pact model avocado humor dilemma review desert turtle total humor produce rate keen eagle fee -# - name: team -# coins: -# - 165000000000000tkyve -# address: kyve1e29j95xmsw3zmvtrk4st8e89z5n72v7nf70ma4 + # - name: team + # coins: + # - 165000000000000tkyve + # address: kyve1e29j95xmsw3zmvtrk4st8e89z5n72v7nf70ma4 - name: foundation coins: # for fees - 1000000tkyve mnemonic: evidence taxi material cabin annual phrase practice unhappy safe jealous section drink illness panther bread aim mouse dolphin deliver ready doll finger search cheap -# address: kyve1fd4qu868n7arav8vteghcppxxa0p2vna5f5ep8 + # address: kyve1fd4qu868n7arav8vteghcppxxa0p2vna5f5ep8 - name: foundation_inflation coins: # for fees @@ -134,7 +134,7 @@ genesis: pool: params: protocol_inflation_share: "0.04" - pool_count: "1" + pool_count: "2" pool_list: - config: "{\"network\":\"kyve-1\",\"rpc\":\"https://rpc-eu-1.kyve.network\"}" current_compression_id: "1" @@ -162,6 +162,32 @@ genesis: binaries: "" scheduled_at: "0" duration: "0" + - config: "{\"network\":\"kyve-1\",\"rpc\":\"https://rpc-eu-1.kyve.network\"}" + current_compression_id: "1" + current_index: "0" + current_key: "" + current_storage_provider_id: "1" + current_summary: "" + id: "1" + logo: "" + max_bundle_size: "100" + min_delegation: "100000000000" + name: "KYVE // Blub" + inflation_share_weight: "2500000000" + disabled: false + runtime: '@kyvejs/tendermint-bsync' + start_key: "1" + total_bundles: "0" + upload_interval: "60" + protocol: + version: "1.0.0" + binaries: "{\"kyve-linux-arm64\":\"https://github.com/KYVENetwork/kyvejs/releases/download/%40kyvejs%2Ftendermint-bsync%401.0.0/kyve-linux-arm64.zip\",\"kyve-linux-x64\":\"https://github.com/KYVENetwork/kyvejs/releases/download/%40kyvejs%2Ftendermint-bsync%401.0.0/kyve-linux-x64.zip\",\"kyve-macos-x64\":\"https://github.com/KYVENetwork/kyvejs/releases/download/%40kyvejs%2Ftendermint-bsync%401.0.0/kyve-macos-x64.zip\"}" + last_upgrade: "0" + upgrade_plan: + version: "" + binaries: "" + scheduled_at: "0" + duration: "0" stakers: params: commission_change_time: 10 @@ -179,16 +205,35 @@ genesis: description: "Alice is the first funder of the KYVE network." website: "https://kyve.network" identity: "0657A086E5201562" + - address: "kyve1e29j95xmsw3zmvtrk4st8e89z5n72v7nf70ma4" + contact: "https://twitter.com/kyvenetwork" + moniker: "Otto" + description: "Another funder of the KYVE network." + website: "https://ot.to" + identity: "0657A086E5201562" funding_list: - pool_id: 0 funder_address: "kyve1jq304cthpx0lwhpqzrdjrcza559ukyy3zsl2vd" - amount: 1000000 - amount_per_bundle: 1000 - total_funded: 0 + amount: 5000000000000 + amount_per_bundle: 230000000 + total_funded: 2200400000000 + - pool_id: 0 + funder_address: "kyve1e29j95xmsw3zmvtrk4st8e89z5n72v7nf70ma4" + amount: 200000000000 + amount_per_bundle: 20000000 + total_funded: 64500000000 + - pool_id: 1 + funder_address: "kyve1jq304cthpx0lwhpqzrdjrcza559ukyy3zsl2vd" + amount: 100000000000 + amount_per_bundle: 10000000 + total_funded: 23000000000 funding_state_list: - pool_id: 0 active_funder_addresses: [] - total_amount: 1000000 + total_amount: 5200000000000 + - pool_id: 1 + active_funder_addresses: [ ] + total_amount: 100000000000 chain_id: kyve-local validators: - name: alice diff --git a/x/bundles/types/errors.go b/x/bundles/types/errors.go index bacc1e93..5b3d2ff7 100644 --- a/x/bundles/types/errors.go +++ b/x/bundles/types/errors.go @@ -18,7 +18,6 @@ var ( ErrPoolDisabled = errors.Register(ModuleName, 1121, "pool is disabled") ErrPoolCurrentlyUpgrading = errors.Register(ModuleName, 1122, "pool currently upgrading") ErrMinDelegationNotReached = errors.Register(ModuleName, 1200, "min delegation not reached") - ErrPoolOutOfFunds = errors.Register(ModuleName, 1201, "pool is out of funds") ErrBundleDropped = errors.Register(ModuleName, 1202, "bundle proposal is dropped") ErrAlreadyVotedValid = errors.Register(ModuleName, 1204, "already voted valid on bundle proposal") ErrAlreadyVotedInvalid = errors.Register(ModuleName, 1205, "already voted invalid on bundle proposal") diff --git a/x/query/client/cli/query.go b/x/query/client/cli/query.go index 55df931a..2598a301 100644 --- a/x/query/client/cli/query.go +++ b/x/query/client/cli/query.go @@ -55,6 +55,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { // Funders cmd.AddCommand(CmdShowFunder()) cmd.AddCommand(CmdListFunders()) + cmd.AddCommand(CmdListFundings()) return cmd } diff --git a/x/query/client/cli/query_fundings.go b/x/query/client/cli/query_fundings.go new file mode 100644 index 00000000..5903e5d0 --- /dev/null +++ b/x/query/client/cli/query_fundings.go @@ -0,0 +1,83 @@ +package cli + +import ( + "context" + "github.com/KYVENetwork/chain/x/query/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/spf13/cobra" + "strconv" +) + +func byFunder( + clientCtx client.Context, + queryClient types.QueryFundersClient, + pageReq *query.PageRequest, + address string, +) error { + params := &types.QueryFundingsByFunderRequest{ + Pagination: pageReq, + Address: address, + WithInactiveFundings: true, + } + + res, err := queryClient.FundingsByFunder(context.Background(), params) + if err != nil { + return err + } + return clientCtx.PrintProto(res) +} + +func byPool( + clientCtx client.Context, + queryClient types.QueryFundersClient, + pageReq *query.PageRequest, + poolId uint64, +) error { + params := &types.QueryFundingsByPoolRequest{ + Pagination: pageReq, + PoolId: poolId, + WithInactiveFundings: true, + } + + res, err := queryClient.FundingsByPool(context.Background(), params) + if err != nil { + return err + } + return clientCtx.PrintProto(res) +} + +func CmdListFundings() *cobra.Command { + cmd := &cobra.Command{ + Use: "fundings [address | pool-id]", + Short: "list all fundings of a user or a pool", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + reqAddressOrPool := args[0] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryFundersClient(clientCtx) + + poolId, err := strconv.ParseUint(reqAddressOrPool, 10, 64) + if err != nil { + return byFunder(clientCtx, queryClient, pageReq, reqAddressOrPool) + } + return byPool(clientCtx, queryClient, pageReq, poolId) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/query/keeper/grpc_account_funded.go b/x/query/keeper/grpc_account_funded.go index 5ffe02ee..f87e47e0 100644 --- a/x/query/keeper/grpc_account_funded.go +++ b/x/query/keeper/grpc_account_funded.go @@ -17,23 +17,22 @@ func (k Keeper) AccountFundedList(goCtx context.Context, req *types.QueryAccount ctx := sdk.UnwrapSDKContext(goCtx) var funded []types.Funded - pools := k.poolKeeper.GetAllPools(ctx) - - for _, pool := range pools { - funding, found := k.fundersKeeper.GetFunding(ctx, req.Address, pool.Id) - if !found { - return nil, status.Error(codes.Internal, "funding not found") - } - fundingState, found := k.fundersKeeper.GetFundingState(ctx, pool.Id) - if !found { - return nil, status.Error(codes.Internal, "funding state not found") - } + fundings := k.fundersKeeper.GetFundingsOfFunder(ctx, req.Address) + for _, funding := range fundings { if funding.Amount > 0 { + pool, found := k.poolKeeper.GetPool(ctx, funding.PoolId) + if !found { + return nil, status.Error(codes.Internal, "pool not found") + } + fundingState, found := k.fundersKeeper.GetFundingState(ctx, funding.PoolId) + if !found { + return nil, status.Error(codes.Internal, "funding state not found") + } funded = append(funded, types.Funded{ Amount: funding.Amount, Pool: &types.BasicPool{ - Id: pool.Id, + Id: funding.PoolId, Name: pool.Name, Runtime: pool.Runtime, Logo: pool.Logo,