Add support for multiple rpcs (hmy, eth)

pull/238/head
Sebastian Johnsson 4 years ago
parent fe5160ab2c
commit e603dddebe
  1. 6
      cmd/subcommands/balance.go
  2. 4
      cmd/subcommands/delegation.go
  3. 12
      cmd/subcommands/root.go
  4. 2
      cmd/subcommands/staking.go
  5. 2
      cmd/subcommands/transfer.go
  6. 1
      cmd/subcommands/values.go
  7. 24
      go.mod
  8. 575
      go.sum
  9. 72
      pkg/rpc/common/methods.go
  10. 73
      pkg/rpc/eth/methods.go
  11. 200
      pkg/rpc/methods.go
  12. 73
      pkg/rpc/v1/methods.go

@ -1,8 +1,8 @@
package cmd
import (
"fmt"
"bytes"
"fmt"
"net"
"strings"
@ -19,7 +19,7 @@ func init() {
Long: "Query for the latest account balance given a Harmony Address",
Args: cobra.ExactArgs(1),
PreRunE: validateAddress,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
if checkNodeInput(node) {
balanceRPCReply, err := rpc.Request(rpc.Method.GetBalance, node, []interface{}{addr.address, "latest"})
if err != nil {
@ -55,7 +55,7 @@ func init() {
}
// Check if input for --node is an IP address
func checkNodeInput(node string) bool{
func checkNodeInput(node string) bool {
removePrefix := strings.TrimPrefix(node, "http://")
removePrefix = strings.TrimPrefix(removePrefix, "https://")
possibleIP := strings.Split(removePrefix, ":")[0]

@ -11,7 +11,7 @@ var (
Short: "Get all delegations by a delegator",
Args: cobra.ExactArgs(1),
PreRunE: validateAddress,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
noLatest = true
return request(rpc.Method.GetDelegationsByDelegator, []interface{}{addr.address})
},
@ -20,7 +20,7 @@ var (
Short: "Get all delegations for a validator",
Args: cobra.ExactArgs(1),
PreRunE: validateAddress,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
noLatest = true
return request(rpc.Method.GetDelegationsByValidator, []interface{}{addr.address})
},

@ -13,6 +13,8 @@ import (
color "github.com/fatih/color"
"github.com/harmony-one/go-sdk/pkg/common"
"github.com/harmony-one/go-sdk/pkg/rpc"
rpcEth "github.com/harmony-one/go-sdk/pkg/rpc/eth"
rpcV1 "github.com/harmony-one/go-sdk/pkg/rpc/v1"
"github.com/harmony-one/go-sdk/pkg/sharding"
"github.com/harmony-one/go-sdk/pkg/store"
"github.com/pkg/errors"
@ -26,6 +28,7 @@ var (
noLatest bool
noPrettyOutput bool
node string
rpcPrefix string
keyStoreDir string
givenFilePath string
endpoint = regexp.MustCompile(`https://api\.s[0-9]\..*\.hmny\.io`)
@ -54,6 +57,14 @@ var (
if verbose {
common.EnableAllVerbose()
}
switch rpcPrefix {
case "hmy":
rpc.Method = rpcV1.Method
case "eth":
rpc.Method = rpcEth.Method
default:
rpc.Method = rpcV1.Method
}
if strings.HasPrefix(node, "https://") || strings.HasPrefix(node, "http://") ||
strings.HasPrefix(node, "ws://") {
//No op, already has protocol, respect protocol default ports.
@ -111,6 +122,7 @@ func init() {
vS := "dump out debug information, same as env var HMY_ALL_DEBUG=true"
RootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, vS)
RootCmd.PersistentFlags().StringVarP(&node, "node", "n", defaultNodeAddr, "<host>")
RootCmd.PersistentFlags().StringVarP(&rpcPrefix, "rpc-prefix", "r", defaultRpcPrefix, "<rpc>")
RootCmd.PersistentFlags().BoolVar(
&noLatest, "no-latest", false, "Do not add 'latest' to RPC params",
)

@ -99,7 +99,7 @@ func createStakingTransaction(nonce uint64, f staking.StakeMsgFulfiller) (*staki
var gLimit uint64
if gasLimit == "" {
isCreateValidator := directive == staking.DirectiveCreateValidator
gLimit, err = core.IntrinsicGas(data, false, true, isCreateValidator)
gLimit, err = core.IntrinsicGas(data, false, true, true, isCreateValidator)
if err != nil {
return nil, err
}

@ -145,7 +145,7 @@ func handlerForTransaction(txLog *transactionLog) error {
var gLimit uint64
if gasLimit == "" {
gLimit, err = core.IntrinsicGas([]byte(""), false, true, false)
gLimit, err = core.IntrinsicGas([]byte(""), false, true, true, false)
if handlerForError(txLog, err) != nil {
return err
}

@ -9,6 +9,7 @@ import (
const (
hmyDocsDir = "hmy-docs"
defaultNodeAddr = "http://localhost:9500"
defaultRpcPrefix = "hmy"
defaultMainnetEndpoint = "https://api.s0.t.hmny.io/"
)

@ -4,21 +4,33 @@ go 1.14
require (
github.com/aristanetworks/goarista v0.0.0-20191023202215-f096da5361bb // indirect
github.com/btcsuite/btcd v0.20.1-beta
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d
github.com/btcsuite/btcd v0.21.0-beta
github.com/btcsuite/btcutil v1.0.2
github.com/cosmos/cosmos-sdk v0.37.0
github.com/davidlazar/go-crypto v0.0.0-20190912175916-7055855a373f // indirect
github.com/deckarep/golang-set v1.7.1
github.com/ethereum/go-ethereum v1.8.27
github.com/fatih/color v1.7.0
github.com/ethereum/go-ethereum v1.9.21
github.com/fatih/color v1.9.0
github.com/gorilla/handlers v1.4.0 // indirect
github.com/harmony-one/bls v0.0.7-0.20191214005344-88c23f91a8a9
github.com/harmony-one/harmony v1.9.1-0.20200708165817-a168517dfc0b
github.com/harmony-one/harmony v1.10.1-0.20210118195726-e5252cf15909
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365 // indirect
github.com/ipfs/go-todocounter v0.0.2 // indirect
github.com/jackpal/gateway v1.0.6 // indirect
github.com/karalabe/hid v1.0.0
github.com/libp2p/go-libp2p-host v0.1.0 // indirect
github.com/libp2p/go-libp2p-net v0.1.0 // indirect
github.com/libp2p/go-libp2p-routing v0.1.0 // indirect
github.com/libp2p/go-sockaddr v0.1.0 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v0.0.5
github.com/tyler-smith/go-bip39 v1.0.2
github.com/uber/jaeger-client-go v2.20.1+incompatible // indirect
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
github.com/valyala/fasthttp v1.2.0
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
github.com/wangjia184/sortedset v0.0.0-20160527075905-f5d03557ba30 // indirect
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
)
replace github.com/ethereum/go-ethereum => github.com/ethereum/go-ethereum v1.9.9

575
go.sum

File diff suppressed because it is too large Load Diff

@ -0,0 +1,72 @@
package common
type RpcMethod = string
type RpcEnumList struct {
GetShardingStructure RpcMethod
GetBlockByHash RpcMethod
GetBlockByNumber RpcMethod
GetBlockTransactionCountByHash RpcMethod
GetBlockTransactionCountByNumber RpcMethod
GetCode RpcMethod
GetTransactionByBlockHashAndIndex RpcMethod
GetTransactionByBlockNumberAndIndex RpcMethod
GetTransactionByHash RpcMethod
GetStakingTransactionByHash RpcMethod
GetTransactionReceipt RpcMethod
Syncing RpcMethod
PeerCount RpcMethod
GetBalance RpcMethod
GetStorageAt RpcMethod
GetTransactionCount RpcMethod
SendTransaction RpcMethod
SendRawTransaction RpcMethod
Subscribe RpcMethod
GetPastLogs RpcMethod
GetWork RpcMethod
GetProof RpcMethod
GetFilterChanges RpcMethod
NewPendingTransactionFilter RpcMethod
NewBlockFilter RpcMethod
NewFilter RpcMethod
Call RpcMethod
EstimateGas RpcMethod
GasPrice RpcMethod
BlockNumber RpcMethod
UnSubscribe RpcMethod
NetVersion RpcMethod
ProtocolVersion RpcMethod
GetNodeMetadata RpcMethod
GetLatestBlockHeader RpcMethod
SendRawStakingTransaction RpcMethod
GetElectedValidatorAddresses RpcMethod
GetAllValidatorAddresses RpcMethod
GetValidatorInformation RpcMethod
GetAllValidatorInformation RpcMethod
GetValidatorInformationByBlockNumber RpcMethod
GetAllValidatorInformationByBlockNumber RpcMethod
GetDelegationsByDelegator RpcMethod
GetDelegationsByValidator RpcMethod
GetCurrentTransactionErrorSink RpcMethod
GetMedianRawStakeSnapshot RpcMethod
GetCurrentStakingErrorSink RpcMethod
GetTransactionsHistory RpcMethod
GetPendingTxnsInPool RpcMethod
GetPendingCrosslinks RpcMethod
GetPendingCXReceipts RpcMethod
GetCurrentUtilityMetrics RpcMethod
ResendCX RpcMethod
GetSuperCommmittees RpcMethod
GetCurrentBadBlocks RpcMethod
GetShardID RpcMethod
GetLastCrossLinks RpcMethod
GetLatestChainHeaders RpcMethod
}
// ValidatedMethod checks if given method is known
func ValidatedMethod(m RpcMethod) string {
switch m := RpcMethod(m); m {
default:
return string(m)
}
}

@ -0,0 +1,73 @@
package v1
import (
"fmt"
rpcCommon "github.com/harmony-one/go-sdk/pkg/rpc/common"
)
const (
prefix = "eth"
)
// Method is a list of known RPC methods
var Method = rpcCommon.RpcEnumList{
GetShardingStructure: fmt.Sprintf("%s_getShardingStructure", prefix),
GetNodeMetadata: fmt.Sprintf("%s_getNodeMetadata", prefix),
GetLatestBlockHeader: fmt.Sprintf("%s_latestHeader", prefix),
GetBlockByHash: fmt.Sprintf("%s_getBlockByHash", prefix),
GetBlockByNumber: fmt.Sprintf("%s_getBlockByNumber", prefix),
GetBlockTransactionCountByHash: fmt.Sprintf("%s_getBlockTransactionCountByHash", prefix),
GetBlockTransactionCountByNumber: fmt.Sprintf("%s_getBlockTransactionCountByNumber", prefix),
GetCode: fmt.Sprintf("%s_getCode", prefix),
GetTransactionByBlockHashAndIndex: fmt.Sprintf("%s_getTransactionByBlockHashAndIndex", prefix),
GetTransactionByBlockNumberAndIndex: fmt.Sprintf("%s_getTransactionByBlockNumberAndIndex", prefix),
GetTransactionByHash: fmt.Sprintf("%s_getTransactionByHash", prefix),
GetStakingTransactionByHash: fmt.Sprintf("%s_getStakingTransactionByHash", prefix),
GetTransactionReceipt: fmt.Sprintf("%s_getTransactionReceipt", prefix),
Syncing: fmt.Sprintf("%s_syncing", prefix),
PeerCount: "net_peerCount",
GetBalance: fmt.Sprintf("%s_getBalance", prefix),
GetStorageAt: fmt.Sprintf("%s_getStorageAt", prefix),
GetTransactionCount: fmt.Sprintf("%s_getTransactionCount", prefix),
SendTransaction: fmt.Sprintf("%s_sendTransaction", prefix),
SendRawTransaction: fmt.Sprintf("%s_sendRawTransaction", prefix),
Subscribe: fmt.Sprintf("%s_subscribe", prefix),
GetPastLogs: fmt.Sprintf("%s_getLogs", prefix),
GetWork: fmt.Sprintf("%s_getWork", prefix),
GetProof: fmt.Sprintf("%s_getProof", prefix),
GetFilterChanges: fmt.Sprintf("%s_getFilterChanges", prefix),
NewPendingTransactionFilter: fmt.Sprintf("%s_newPendingTransactionFilter", prefix),
NewBlockFilter: fmt.Sprintf("%s_newBlockFilter", prefix),
NewFilter: fmt.Sprintf("%s_newFilter", prefix),
Call: fmt.Sprintf("%s_call", prefix),
EstimateGas: fmt.Sprintf("%s_estimateGas", prefix),
GasPrice: fmt.Sprintf("%s_gasPrice", prefix),
BlockNumber: fmt.Sprintf("%s_blockNumber", prefix),
UnSubscribe: fmt.Sprintf("%s_unsubscribe", prefix),
NetVersion: "net_version",
ProtocolVersion: fmt.Sprintf("%s_protocolVersion", prefix),
SendRawStakingTransaction: fmt.Sprintf("%s_sendRawStakingTransaction", prefix),
GetElectedValidatorAddresses: fmt.Sprintf("%s_getElectedValidatorAddresses", prefix),
GetAllValidatorAddresses: fmt.Sprintf("%s_getAllValidatorAddresses", prefix),
GetValidatorInformation: fmt.Sprintf("%s_getValidatorInformation", prefix),
GetAllValidatorInformation: fmt.Sprintf("%s_getAllValidatorInformation", prefix),
GetValidatorInformationByBlockNumber: fmt.Sprintf("%s_getValidatorInformationByBlockNumber", prefix),
GetAllValidatorInformationByBlockNumber: fmt.Sprintf("%s_getAllValidatorInformationByBlockNumber", prefix),
GetDelegationsByDelegator: fmt.Sprintf("%s_getDelegationsByDelegator", prefix),
GetDelegationsByValidator: fmt.Sprintf("%s_getDelegationsByValidator", prefix),
GetCurrentTransactionErrorSink: fmt.Sprintf("%s_getCurrentTransactionErrorSink", prefix),
GetMedianRawStakeSnapshot: fmt.Sprintf("%s_getMedianRawStakeSnapshot", prefix),
GetCurrentStakingErrorSink: fmt.Sprintf("%s_getCurrentStakingErrorSink", prefix),
GetTransactionsHistory: fmt.Sprintf("%s_getTransactionsHistory", prefix),
GetPendingTxnsInPool: fmt.Sprintf("%s_pendingTransactions", prefix),
GetPendingCrosslinks: fmt.Sprintf("%s_getPendingCrossLinks", prefix),
GetPendingCXReceipts: fmt.Sprintf("%s_getPendingCXReceipts", prefix),
GetCurrentUtilityMetrics: fmt.Sprintf("%s_getCurrentUtilityMetrics", prefix),
ResendCX: fmt.Sprintf("%s_resendCx", prefix),
GetSuperCommmittees: fmt.Sprintf("%s_getSuperCommittees", prefix),
GetCurrentBadBlocks: fmt.Sprintf("%s_getCurrentBadBlocks", prefix),
GetShardID: fmt.Sprintf("%s_getShardID", prefix),
GetLastCrossLinks: fmt.Sprintf("%s_getLastCrossLinks", prefix),
GetLatestChainHeaders: fmt.Sprintf("%s_getLatestChainHeaders", prefix),
}

@ -3,147 +3,77 @@ package rpc
import (
"fmt"
rpcCommon "github.com/harmony-one/go-sdk/pkg/rpc/common"
"github.com/pkg/errors"
)
// Using alias for now
type method = string
type errorCode int
type rpcEnumList struct {
GetShardingStructure method
GetBlockByHash method
GetBlockByNumber method
GetBlockTransactionCountByHash method
GetBlockTransactionCountByNumber method
GetCode method
GetTransactionByBlockHashAndIndex method
GetTransactionByBlockNumberAndIndex method
GetTransactionByHash method
GetStakingTransactionByHash method
GetTransactionReceipt method
Syncing method
PeerCount method
GetBalance method
GetStorageAt method
GetTransactionCount method
SendTransaction method
SendRawTransaction method
Subscribe method
GetPastLogs method
GetWork method
GetProof method
GetFilterChanges method
NewPendingTransactionFilter method
NewBlockFilter method
NewFilter method
Call method
EstimateGas method
GasPrice method
BlockNumber method
UnSubscribe method
NetVersion method
ProtocolVersion method
GetNodeMetadata method
GetLatestBlockHeader method
SendRawStakingTransaction method
GetElectedValidatorAddresses method
GetAllValidatorAddresses method
GetValidatorInformation method
GetAllValidatorInformation method
GetValidatorInformationByBlockNumber method
GetAllValidatorInformationByBlockNumber method
GetDelegationsByDelegator method
GetDelegationsByValidator method
GetCurrentTransactionErrorSink method
GetMedianRawStakeSnapshot method
GetCurrentStakingErrorSink method
GetTransactionsHistory method
GetPendingTxnsInPool method
GetPendingCrosslinks method
GetPendingCXReceipts method
GetCurrentUtilityMetrics method
ResendCX method
GetSuperCommmittees method
GetCurrentBadBlocks method
GetShardID method
GetLastCrossLinks method
GetLatestChainHeaders method
}
// Method is a list of known RPC methods
var Method = rpcEnumList{
GetShardingStructure: "hmy_getShardingStructure",
GetNodeMetadata: "hmy_getNodeMetadata",
GetLatestBlockHeader: "hmy_latestHeader",
GetBlockByHash: "hmy_getBlockByHash",
GetBlockByNumber: "hmy_getBlockByNumber",
GetBlockTransactionCountByHash: "hmy_getBlockTransactionCountByHash",
GetBlockTransactionCountByNumber: "hmy_getBlockTransactionCountByNumber",
GetCode: "hmy_getCode",
GetTransactionByBlockHashAndIndex: "hmy_getTransactionByBlockHashAndIndex",
GetTransactionByBlockNumberAndIndex: "hmy_getTransactionByBlockNumberAndIndex",
GetTransactionByHash: "hmy_getTransactionByHash",
GetStakingTransactionByHash: "hmy_getStakingTransactionByHash",
GetTransactionReceipt: "hmy_getTransactionReceipt",
Syncing: "hmy_syncing",
PeerCount: "net_peerCount",
GetBalance: "hmy_getBalance",
GetStorageAt: "hmy_getStorageAt",
GetTransactionCount: "hmy_getTransactionCount",
SendTransaction: "hmy_sendTransaction",
SendRawTransaction: "hmy_sendRawTransaction",
Subscribe: "hmy_subscribe",
GetPastLogs: "hmy_getLogs",
GetWork: "hmy_getWork",
GetProof: "hmy_getProof",
GetFilterChanges: "hmy_getFilterChanges",
NewPendingTransactionFilter: "hmy_newPendingTransactionFilter",
NewBlockFilter: "hmy_newBlockFilter",
NewFilter: "hmy_newFilter",
Call: "hmy_call",
EstimateGas: "hmy_estimateGas",
GasPrice: "hmy_gasPrice",
BlockNumber: "hmy_blockNumber",
UnSubscribe: "hmy_unsubscribe",
NetVersion: "net_version",
ProtocolVersion: "hmy_protocolVersion",
SendRawStakingTransaction: "hmy_sendRawStakingTransaction",
GetElectedValidatorAddresses: "hmy_getElectedValidatorAddresses",
GetAllValidatorAddresses: "hmy_getAllValidatorAddresses",
GetValidatorInformation: "hmy_getValidatorInformation",
GetAllValidatorInformation: "hmy_getAllValidatorInformation",
GetValidatorInformationByBlockNumber: "hmy_getValidatorInformationByBlockNumber",
GetAllValidatorInformationByBlockNumber: "hmy_getAllValidatorInformationByBlockNumber",
GetDelegationsByDelegator: "hmy_getDelegationsByDelegator",
GetDelegationsByValidator: "hmy_getDelegationsByValidator",
GetCurrentTransactionErrorSink: "hmy_getCurrentTransactionErrorSink",
GetMedianRawStakeSnapshot: "hmy_getMedianRawStakeSnapshot",
GetCurrentStakingErrorSink: "hmy_getCurrentStakingErrorSink",
GetTransactionsHistory: "hmy_getTransactionsHistory",
GetPendingTxnsInPool: "hmy_pendingTransactions",
GetPendingCrosslinks: "hmy_getPendingCrossLinks",
GetPendingCXReceipts: "hmy_getPendingCXReceipts",
GetCurrentUtilityMetrics: "hmy_getCurrentUtilityMetrics",
ResendCX: "hmy_resendCx",
GetSuperCommmittees: "hmy_getSuperCommittees",
GetCurrentBadBlocks: "hmy_getCurrentBadBlocks",
GetShardID: "hmy_getShardID",
GetLastCrossLinks: "hmy_getLastCrossLinks",
GetLatestChainHeaders: "hmy_getLatestChainHeaders",
}
// TODO Use Reflection here to avoid typing out the cases
var (
RPCPrefix = "hmy"
Method rpcCommon.RpcEnumList
)
// ValidatedMethod checks if given method is known
func ValidatedMethod(m method) string {
switch m := method(m); m {
default:
return string(m)
}
type RpcEnumList struct {
GetShardingStructure rpcCommon.RpcMethod
GetBlockByHash rpcCommon.RpcMethod
GetBlockByNumber rpcCommon.RpcMethod
GetBlockTransactionCountByHash rpcCommon.RpcMethod
GetBlockTransactionCountByNumber rpcCommon.RpcMethod
GetCode rpcCommon.RpcMethod
GetTransactionByBlockHashAndIndex rpcCommon.RpcMethod
GetTransactionByBlockNumberAndIndex rpcCommon.RpcMethod
GetTransactionByHash rpcCommon.RpcMethod
GetStakingTransactionByHash rpcCommon.RpcMethod
GetTransactionReceipt rpcCommon.RpcMethod
Syncing rpcCommon.RpcMethod
PeerCount rpcCommon.RpcMethod
GetBalance rpcCommon.RpcMethod
GetStorageAt rpcCommon.RpcMethod
GetTransactionCount rpcCommon.RpcMethod
SendTransaction rpcCommon.RpcMethod
SendRawTransaction rpcCommon.RpcMethod
Subscribe rpcCommon.RpcMethod
GetPastLogs rpcCommon.RpcMethod
GetWork rpcCommon.RpcMethod
GetProof rpcCommon.RpcMethod
GetFilterChanges rpcCommon.RpcMethod
NewPendingTransactionFilter rpcCommon.RpcMethod
NewBlockFilter rpcCommon.RpcMethod
NewFilter rpcCommon.RpcMethod
Call rpcCommon.RpcMethod
EstimateGas rpcCommon.RpcMethod
GasPrice rpcCommon.RpcMethod
BlockNumber rpcCommon.RpcMethod
UnSubscribe rpcCommon.RpcMethod
NetVersion rpcCommon.RpcMethod
ProtocolVersion rpcCommon.RpcMethod
GetNodeMetadata rpcCommon.RpcMethod
GetLatestBlockHeader rpcCommon.RpcMethod
SendRawStakingTransaction rpcCommon.RpcMethod
GetElectedValidatorAddresses rpcCommon.RpcMethod
GetAllValidatorAddresses rpcCommon.RpcMethod
GetValidatorInformation rpcCommon.RpcMethod
GetAllValidatorInformation rpcCommon.RpcMethod
GetValidatorInformationByBlockNumber rpcCommon.RpcMethod
GetAllValidatorInformationByBlockNumber rpcCommon.RpcMethod
GetDelegationsByDelegator rpcCommon.RpcMethod
GetDelegationsByValidator rpcCommon.RpcMethod
GetCurrentTransactionErrorSink rpcCommon.RpcMethod
GetMedianRawStakeSnapshot rpcCommon.RpcMethod
GetCurrentStakingErrorSink rpcCommon.RpcMethod
GetTransactionsHistory rpcCommon.RpcMethod
GetPendingTxnsInPool rpcCommon.RpcMethod
GetPendingCrosslinks rpcCommon.RpcMethod
GetPendingCXReceipts rpcCommon.RpcMethod
GetCurrentUtilityMetrics rpcCommon.RpcMethod
ResendCX rpcCommon.RpcMethod
GetSuperCommmittees rpcCommon.RpcMethod
GetCurrentBadBlocks rpcCommon.RpcMethod
GetShardID rpcCommon.RpcMethod
GetLastCrossLinks rpcCommon.RpcMethod
GetLatestChainHeaders rpcCommon.RpcMethod
}
type errorCode int
type rpcErrorCodeList struct {
rpcInvalidRequest errorCode
rpcMethodNotFound errorCode

@ -0,0 +1,73 @@
package v1
import (
"fmt"
rpcCommon "github.com/harmony-one/go-sdk/pkg/rpc/common"
)
const (
prefix = "hmy"
)
// Method is a list of known RPC methods
var Method = rpcCommon.RpcEnumList{
GetShardingStructure: fmt.Sprintf("%s_getShardingStructure", prefix),
GetNodeMetadata: fmt.Sprintf("%s_getNodeMetadata", prefix),
GetLatestBlockHeader: fmt.Sprintf("%s_latestHeader", prefix),
GetBlockByHash: fmt.Sprintf("%s_getBlockByHash", prefix),
GetBlockByNumber: fmt.Sprintf("%s_getBlockByNumber", prefix),
GetBlockTransactionCountByHash: fmt.Sprintf("%s_getBlockTransactionCountByHash", prefix),
GetBlockTransactionCountByNumber: fmt.Sprintf("%s_getBlockTransactionCountByNumber", prefix),
GetCode: fmt.Sprintf("%s_getCode", prefix),
GetTransactionByBlockHashAndIndex: fmt.Sprintf("%s_getTransactionByBlockHashAndIndex", prefix),
GetTransactionByBlockNumberAndIndex: fmt.Sprintf("%s_getTransactionByBlockNumberAndIndex", prefix),
GetTransactionByHash: fmt.Sprintf("%s_getTransactionByHash", prefix),
GetStakingTransactionByHash: fmt.Sprintf("%s_getStakingTransactionByHash", prefix),
GetTransactionReceipt: fmt.Sprintf("%s_getTransactionReceipt", prefix),
Syncing: fmt.Sprintf("%s_syncing", prefix),
PeerCount: "net_peerCount",
GetBalance: fmt.Sprintf("%s_getBalance", prefix),
GetStorageAt: fmt.Sprintf("%s_getStorageAt", prefix),
GetTransactionCount: fmt.Sprintf("%s_getTransactionCount", prefix),
SendTransaction: fmt.Sprintf("%s_sendTransaction", prefix),
SendRawTransaction: fmt.Sprintf("%s_sendRawTransaction", prefix),
Subscribe: fmt.Sprintf("%s_subscribe", prefix),
GetPastLogs: fmt.Sprintf("%s_getLogs", prefix),
GetWork: fmt.Sprintf("%s_getWork", prefix),
GetProof: fmt.Sprintf("%s_getProof", prefix),
GetFilterChanges: fmt.Sprintf("%s_getFilterChanges", prefix),
NewPendingTransactionFilter: fmt.Sprintf("%s_newPendingTransactionFilter", prefix),
NewBlockFilter: fmt.Sprintf("%s_newBlockFilter", prefix),
NewFilter: fmt.Sprintf("%s_newFilter", prefix),
Call: fmt.Sprintf("%s_call", prefix),
EstimateGas: fmt.Sprintf("%s_estimateGas", prefix),
GasPrice: fmt.Sprintf("%s_gasPrice", prefix),
BlockNumber: fmt.Sprintf("%s_blockNumber", prefix),
UnSubscribe: fmt.Sprintf("%s_unsubscribe", prefix),
NetVersion: "net_version",
ProtocolVersion: fmt.Sprintf("%s_protocolVersion", prefix),
SendRawStakingTransaction: fmt.Sprintf("%s_sendRawStakingTransaction", prefix),
GetElectedValidatorAddresses: fmt.Sprintf("%s_getElectedValidatorAddresses", prefix),
GetAllValidatorAddresses: fmt.Sprintf("%s_getAllValidatorAddresses", prefix),
GetValidatorInformation: fmt.Sprintf("%s_getValidatorInformation", prefix),
GetAllValidatorInformation: fmt.Sprintf("%s_getAllValidatorInformation", prefix),
GetValidatorInformationByBlockNumber: fmt.Sprintf("%s_getValidatorInformationByBlockNumber", prefix),
GetAllValidatorInformationByBlockNumber: fmt.Sprintf("%s_getAllValidatorInformationByBlockNumber", prefix),
GetDelegationsByDelegator: fmt.Sprintf("%s_getDelegationsByDelegator", prefix),
GetDelegationsByValidator: fmt.Sprintf("%s_getDelegationsByValidator", prefix),
GetCurrentTransactionErrorSink: fmt.Sprintf("%s_getCurrentTransactionErrorSink", prefix),
GetMedianRawStakeSnapshot: fmt.Sprintf("%s_getMedianRawStakeSnapshot", prefix),
GetCurrentStakingErrorSink: fmt.Sprintf("%s_getCurrentStakingErrorSink", prefix),
GetTransactionsHistory: fmt.Sprintf("%s_getTransactionsHistory", prefix),
GetPendingTxnsInPool: fmt.Sprintf("%s_pendingTransactions", prefix),
GetPendingCrosslinks: fmt.Sprintf("%s_getPendingCrossLinks", prefix),
GetPendingCXReceipts: fmt.Sprintf("%s_getPendingCXReceipts", prefix),
GetCurrentUtilityMetrics: fmt.Sprintf("%s_getCurrentUtilityMetrics", prefix),
ResendCX: fmt.Sprintf("%s_resendCx", prefix),
GetSuperCommmittees: fmt.Sprintf("%s_getSuperCommittees", prefix),
GetCurrentBadBlocks: fmt.Sprintf("%s_getCurrentBadBlocks", prefix),
GetShardID: fmt.Sprintf("%s_getShardID", prefix),
GetLastCrossLinks: fmt.Sprintf("%s_getLastCrossLinks", prefix),
GetLatestChainHeaders: fmt.Sprintf("%s_getLatestChainHeaders", prefix),
}
Loading…
Cancel
Save