diff --git a/pkg/tendermint/tendermint.go b/pkg/tendermint/tendermint.go index 5c1ace5..e90005c 100644 --- a/pkg/tendermint/tendermint.go +++ b/pkg/tendermint/tendermint.go @@ -7,8 +7,6 @@ import ( "main/pkg/types" "main/pkg/utils" - cosmosTypes "github.com/cosmos/cosmos-sdk/types" - distributionTypes "github.com/cosmos/cosmos-sdk/x/distribution/types" "github.com/rs/zerolog" ) @@ -126,10 +124,8 @@ func (rpc *RPC) GetSingleDelegation(validator, wallet string) (*types.Amount, *t return &types.Amount{}, &info, fmt.Errorf("expected code 0, but got %d", response.Code) } - return &types.Amount{ - Amount: utils.StrToFloat64(response.DelegationResponse.Balance.Amount), - Denom: response.DelegationResponse.Balance.Denom, - }, &info, nil + amount := response.DelegationResponse.Balance.ToAmount() + return &amount, &info, nil } func (rpc *RPC) GetAllValidators() (*types.ValidatorsResponse, *types.QueryInfo, error) { @@ -164,17 +160,14 @@ func (rpc *RPC) GetValidatorCommission(address string) ([]types.Amount, *types.Q address, ) - var response *distributionTypes.QueryValidatorCommissionResponse + var response *types.CommissionResponse info, err := rpc.Client.Get(url, &response) if err != nil { return []types.Amount{}, &info, err } - return utils.Map(response.Commission.Commission, func(balance cosmosTypes.DecCoin) types.Amount { - return types.Amount{ - Amount: balance.Amount.MustFloat64(), - Denom: balance.Denom, - } + return utils.Map(response.Commission.Commission, func(amount types.ResponseAmount) types.Amount { + return amount.ToAmount() }), &info, nil } diff --git a/pkg/types/tendermint.go b/pkg/types/tendermint.go index 9871d69..dc7292f 100644 --- a/pkg/types/tendermint.go +++ b/pkg/types/tendermint.go @@ -172,3 +172,10 @@ type RewardsResponse struct { Code int `json:"code"` Rewards []ResponseAmount `json:"rewards"` } + +type CommissionResponse struct { + Code int `json:"code"` + Commission struct { + Commission []ResponseAmount `json:"commission"` + } `json:"commission"` +}