forked from cerc-io/laconicd-deprecated
Implements net_version for Ethers (#121)
This commit is contained in:
parent
a61f3b892d
commit
5a19ae5706
1
go.mod
1
go.mod
@ -53,6 +53,7 @@ require (
|
||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7
|
||||
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb // indirect
|
||||
golang.org/x/text v0.3.2 // indirect
|
||||
google.golang.org/appengine v1.4.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20190708153700-3bdd9d9f5532 // indirect
|
||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
|
||||
gopkg.in/yaml.v2 v2.2.2
|
||||
|
@ -36,5 +36,11 @@ func GetRPCAPIs(cliCtx context.CLIContext, key emintcrypto.PrivKeySecp256k1) []r
|
||||
Service: NewPublicFilterAPI(cliCtx),
|
||||
Public: true,
|
||||
},
|
||||
{
|
||||
Namespace: "net",
|
||||
Version: "1.0",
|
||||
Service: NewPublicNetAPI(cliCtx),
|
||||
Public: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
34
rpc/net_api.go
Normal file
34
rpc/net_api.go
Normal file
@ -0,0 +1,34 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// PublicNetAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.
|
||||
type PublicNetAPI struct {
|
||||
networkVersion uint64
|
||||
}
|
||||
|
||||
// NewPersonalEthAPI creates an instance of the public ETH Web3 API.
|
||||
func NewPublicNetAPI(cliCtx context.CLIContext) *PublicNetAPI {
|
||||
chainID := viper.GetString(flags.FlagChainID)
|
||||
// parse the chainID from a integer string
|
||||
intChainID, err := strconv.ParseUint(chainID, 0, 64)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("Invalid chainID: %s, must be integer format", chainID))
|
||||
}
|
||||
|
||||
return &PublicNetAPI{
|
||||
networkVersion: intChainID,
|
||||
}
|
||||
}
|
||||
|
||||
// Version returns the current ethereum protocol version.
|
||||
func (s *PublicNetAPI) Version() string {
|
||||
return fmt.Sprintf("%d", s.networkVersion)
|
||||
}
|
@ -427,7 +427,7 @@ func GenerateFromArgs(args args.SendTxArgs, ctx context.CLIContext) (msg *Ethere
|
||||
if args.Gas == nil {
|
||||
// Estimate the gas usage if necessary.
|
||||
// TODO: Set gas based on estimate when simulating txs are setup
|
||||
gasLimit = 22000
|
||||
gasLimit = 60000
|
||||
} else {
|
||||
gasLimit = (uint64)(*args.Gas)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user