laconicd-deprecated/rpc/namespaces/web3/api.go

30 lines
742 B
Go
Raw Normal View History

package web3
2018-08-09 10:36:47 +00:00
import (
"fmt"
2018-08-09 10:36:47 +00:00
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/cosmos/cosmos-sdk/version"
2018-08-09 10:36:47 +00:00
)
2018-08-09 10:36:47 +00:00
// PublicWeb3API is the web3_ prefixed set of APIs in the Web3 JSON-RPC spec.
type PublicWeb3API struct{}
2018-08-09 10:36:47 +00:00
// NewAPI creates an instance of the Web3 API.
func NewAPI() *PublicWeb3API {
2018-08-09 10:36:47 +00:00
return &PublicWeb3API{}
}
// ClientVersion returns the client version in the Web3 user agent format.
func (PublicWeb3API) ClientVersion() string {
info := version.NewInfo()
return fmt.Sprintf("%s-%s", info.Name, info.Version)
2018-08-09 10:36:47 +00:00
}
// Sha3 returns the keccak-256 hash of the passed-in input.
func (PublicWeb3API) Sha3(input hexutil.Bytes) hexutil.Bytes {
2018-08-09 10:36:47 +00:00
return crypto.Keccak256(input)
}