* remove legacy appmodule boiler plate * remove legacy code * remove legacy gov rest routes * remove staking querier * fix legacy * remove unused test * add upgrading and changelog entry * Update UPGRADING.md Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com> * fix tests Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
33 lines
917 B
Go
33 lines
917 B
Go
package common
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
|
)
|
|
|
|
// QueryDelegationRewards queries a delegation rewards between a delegator and a
|
|
// validator.
|
|
func QueryDelegationRewards(clientCtx client.Context, delAddr, valAddr string) ([]byte, int64, error) {
|
|
delegatorAddr, err := sdk.AccAddressFromBech32(delAddr)
|
|
if err != nil {
|
|
return nil, 0, err
|
|
}
|
|
|
|
validatorAddr, err := sdk.ValAddressFromBech32(valAddr)
|
|
if err != nil {
|
|
return nil, 0, err
|
|
}
|
|
|
|
params := types.NewQueryDelegationRewardsParams(delegatorAddr, validatorAddr)
|
|
bz, err := clientCtx.LegacyAmino.MarshalJSON(params)
|
|
if err != nil {
|
|
return nil, 0, fmt.Errorf("failed to marshal params: %w", err)
|
|
}
|
|
|
|
route := fmt.Sprintf("custom/%s/%s", types.ModuleName, types.QueryDelegationRewards)
|
|
return clientCtx.QueryWithData(route, bz)
|
|
}
|