Skip to content

Commit

Permalink
Merge branch 'main' into CNS-fix-modify-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
omerlavanet authored Aug 25, 2024
2 parents 7c61586 + ea235a1 commit 0d98df3
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 27 deletions.
4 changes: 0 additions & 4 deletions x/epochstorage/keeper/stake_entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,6 @@ func (k Keeper) GetAllStakeEntriesCurrentForChainId(ctx sdk.Context, chainID str
func (k Keeper) GetStakeEntryCurrentForChainIdByVault(ctx sdk.Context, chainID string, vault string) (val types.StakeEntry, found bool) {
pk, err := k.stakeEntriesCurrent.Indexes.Index.MatchExact(ctx, collections.Join(chainID, vault))
if err != nil {
utils.LavaFormatWarning("GetStakeEntryCurrentForChainIdByVault: MatchExact with primary key failed", err,
utils.LogAttr("chain_id", chainID),
utils.LogAttr("vault", vault),
)
return types.StakeEntry{}, false
}

Expand Down
16 changes: 8 additions & 8 deletions x/rewards/client/cli/query_spec_tracked_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ func CmdSpecTrackedInfo() *cobra.Command {

Args: cobra.RangeArgs(1, 2),
RunE: func(cmd *cobra.Command, args []string) (err error) {
reqChainID := ""
if len(args) == 2 {
reqChainID = args[0]
}

clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
reqProvider, err := utils.ParseCLIAddress(clientCtx, args[1])
if err != nil {
return err

reqChainID := args[0]
reqProvider := ""
if len(args) == 2 {
reqProvider, err = utils.ParseCLIAddress(clientCtx, args[1])
if err != nil {
return err
}
}

queryClient := types.NewQueryClient(clientCtx)
Expand Down
41 changes: 28 additions & 13 deletions x/rewards/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const (
listSeparator = ","
expeditedFlagName = "expedited"
minIprpcCostFlagName = "min-cost"
titleFlagName = "title"
descriptionFlagName = "description"
addIprpcSubscriptionsFlagName = "add-subscriptions"
removeIprpcSubscriptionsFlagName = "remove-subscriptions"
)
Expand Down Expand Up @@ -80,16 +82,6 @@ $ %s tx gov submit-legacy-proposal set-iprpc-data --min-cost 0ulava --add-subscr
return err
}

// get min cost
costStr, err := cmd.Flags().GetString(minIprpcCostFlagName)
if err != nil {
return err
}
cost, err := sdk.ParseCoinNormalized(costStr)
if err != nil {
return err
}

// get current iprpc subscriptions
q := types.NewQueryClient(clientCtx)
res, err := q.ShowIprpcData(context.Background(), &types.QueryShowIprpcDataRequest{})
Expand All @@ -98,6 +90,19 @@ $ %s tx gov submit-legacy-proposal set-iprpc-data --min-cost 0ulava --add-subscr
}
subs := res.IprpcSubscriptions

// get min cost
costStr, err := cmd.Flags().GetString(minIprpcCostFlagName)
if err != nil {
return err
}
cost := res.MinCost
if costStr != "" {
cost, err = sdk.ParseCoinNormalized(costStr)
if err != nil {
return err
}
}

// add from msg
subsToAdd, err := cmd.Flags().GetStringSlice(addIprpcSubscriptionsFlagName)
if err != nil {
Expand Down Expand Up @@ -135,18 +140,28 @@ $ %s tx gov submit-legacy-proposal set-iprpc-data --min-cost 0ulava --add-subscr
MinIprpcCost: cost,
}

submitPropMsg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, from.String(), "", "Set IPRPC data", "Set IPRPC data", isExpedited)
title, err := cmd.Flags().GetString(titleFlagName)
if err != nil {
return err
}

description, err := cmd.Flags().GetString(descriptionFlagName)
if err != nil {
return err
}
submitPropMsg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, from.String(), "", title, description, isExpedited)
if err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), submitPropMsg)
},
}
cmd.Flags().String(minIprpcCostFlagName, "0ulava", "set minimum iprpc cost")
cmd.Flags().String(minIprpcCostFlagName, "", "set minimum iprpc cost")
cmd.Flags().String(titleFlagName, "Set IPRPC data", "proposal title")
cmd.Flags().String(descriptionFlagName, "Set IPRPC data", "proposal description")
cmd.Flags().StringSlice(addIprpcSubscriptionsFlagName, []string{}, "add iprpc eligible subscriptions")
cmd.Flags().StringSlice(removeIprpcSubscriptionsFlagName, []string{}, "remove iprpc eligible subscriptions")
cmd.Flags().Bool(expeditedFlagName, false, "set to true to make the spec proposal expedited")
cmd.MarkFlagRequired(minIprpcCostFlagName)
return cmd
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func CmdEstimatedValidatorsRewards() *cobra.Command {
cmd := &cobra.Command{
Use: "estimated--validator-rewards [validator] {optional: amount/delegator}",
Use: "estimated-validator-rewards [validator] {optional: amount/delegator}",
Short: "calculates the rewards estimation for a validator delegation",
Long: `Query to estimate the rewards a delegator will get for 1 month from the validator, if used without optional args the calculations will be for the validator itself.
optional args can be amount for new delegation or address for an existing one.
Expand Down
2 changes: 1 addition & 1 deletion x/subscription/keeper/grpc_query_tracked_usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (k Keeper) TrackedUsage(goCtx context.Context, req *types.QuerySubscription
sub, _ := k.GetSubscription(ctx, req.Subscription)

res.Subscription = &sub
res.Usage, res.TotalUsage = k.GetSubTrackedCuInfo(ctx, req.Subscription, uint64(ctx.BlockHeader().Height))
res.Usage, res.TotalUsage = k.GetSubTrackedCuInfo(ctx, req.Subscription, sub.Block)

return &res, nil
}

0 comments on commit 0d98df3

Please sign in to comment.