Change staking rpc to one addresses

pull/1951/head
Rongjian Lan 5 years ago
parent 1a119186b5
commit fd43690f41
  1. 14
      internal/hmyapi/blockchain.go
  2. 10
      internal/hmyapi/types.go

@ -4,6 +4,8 @@ import (
"context"
"fmt"
address2 "github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/harmony/numeric"
"math/big"
@ -559,8 +561,8 @@ func (s *PublicBlockChainAPI) GetDelegationsByDelegator(ctx context.Context, add
})
}
result = append(result, &RPCDelegation{
validators[i],
delegatorAddress,
address2.ToBech32(validators[i]),
address2.ToBech32(delegatorAddress),
delegation.Amount,
delegation.Reward,
undelegations,
@ -585,8 +587,8 @@ func (s *PublicBlockChainAPI) GetDelegationsByValidator(ctx context.Context, add
})
}
result = append(result, &RPCDelegation{
validatorAddress,
delegation.DelegatorAddress,
address2.ToBech32(validatorAddress),
address2.ToBech32(delegation.DelegatorAddress),
delegation.Amount,
delegation.Reward,
undelegations,
@ -615,8 +617,8 @@ func (s *PublicBlockChainAPI) GetDelegationByDelegatorAndValidator(ctx context.C
})
}
return &RPCDelegation{
validatorAddress,
delegatorAddress,
address2.ToBech32(validatorAddress),
address2.ToBech32(delegatorAddress),
delegation.Amount,
delegation.Reward,
undelegations,

@ -6,6 +6,8 @@ import (
"strings"
"time"
"github.com/harmony-one/go-sdk/pkg/address"
"github.com/harmony-one/harmony/shard"
types2 "github.com/harmony-one/harmony/staking/types"
@ -83,7 +85,7 @@ type HeaderInformation struct {
// RPCValidator represents a validator
type RPCValidator struct {
Address common.Address `json:"address"`
Address string `json:"address"`
SlotPubKeys []shard.BlsPublicKey `json:"slot_pub_keys"`
SlotShardIDs []int `json:"slot_shard_ids"`
UnbondingHeight *big.Int `json:"unbonding_height"`
@ -100,8 +102,8 @@ type RPCValidator struct {
// RPCDelegation represents a particular delegation to a validator
type RPCDelegation struct {
ValidatorAddress common.Address `json:"validator_address" yaml:"validator_address"`
DelegatorAddress common.Address `json:"delegator_address" yaml:"delegator_address"`
ValidatorAddress string `json:"validator_address" yaml:"validator_address"`
DelegatorAddress string `json:"delegator_address" yaml:"delegator_address"`
Amount *big.Int `json:"amount" yaml:"amount"`
Reward *big.Int `json:"reward" yaml:"reward"`
Undelegations []RPCUndelegation `json:"Undelegations" yaml:"Undelegations"`
@ -173,7 +175,7 @@ func newRPCCXReceipt(cx *types.CXReceipt, blockHash common.Hash, blockNumber uin
func newRPCValidator(validator *types2.Validator) *RPCValidator {
return &RPCValidator{
validator.Address,
address.ToBech32(validator.Address),
validator.SlotPubKeys,
nil,
validator.UnbondingHeight,

Loading…
Cancel
Save