diff options
author | Wei-Ning Huang <w@byzantine-lab.io> | 2019-10-07 18:08:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-07 18:08:38 +0800 |
commit | 5244bb6d79fc118bfdabeb367b645608ea05003a (patch) | |
tree | 8ebca1a767c92c680ef3339334961ba607b5c903 /dex/api.go | |
parent | d3e0eca00b8bf09b491b7404004dbc67e3eb904d (diff) | |
download | go-tangerine-5244bb6d79fc118bfdabeb367b645608ea05003a.tar go-tangerine-5244bb6d79fc118bfdabeb367b645608ea05003a.tar.gz go-tangerine-5244bb6d79fc118bfdabeb367b645608ea05003a.tar.bz2 go-tangerine-5244bb6d79fc118bfdabeb367b645608ea05003a.tar.lz go-tangerine-5244bb6d79fc118bfdabeb367b645608ea05003a.tar.xz go-tangerine-5244bb6d79fc118bfdabeb367b645608ea05003a.tar.zst go-tangerine-5244bb6d79fc118bfdabeb367b645608ea05003a.zip |
dex: add missing eth public API (#8)
Diffstat (limited to 'dex/api.go')
-rw-r--r-- | dex/api.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/dex/api.go b/dex/api.go index 1209e6583..7ca1a4622 100644 --- a/dex/api.go +++ b/dex/api.go @@ -22,6 +22,7 @@ import ( "errors" "fmt" "io" + "math/big" "os" "strings" @@ -38,6 +39,36 @@ import ( "github.com/tangerine-network/go-tangerine/trie" ) +// PublicEthereumAPI provides an API to access Ethereum full node-related +// information. +type PublicEthereumAPI struct { + dex *Tangerine +} + +// NewPublicEthereumAPI creates a new Ethereum protocol API for full nodes. +func NewPublicEthereumAPI(e *Tangerine) *PublicEthereumAPI { + return &PublicEthereumAPI{e} +} + +// Etherbase is the address that mining rewards will be send to +func (api *PublicEthereumAPI) Etherbase() (common.Address, error) { + return api.dex.Etherbase(), nil +} + +// Coinbase is the address that mining rewards will be send to (alias for Etherbase) +func (api *PublicEthereumAPI) Coinbase() (common.Address, error) { + return api.dex.Etherbase(), nil +} + +// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config. +func (api *PublicEthereumAPI) ChainId() hexutil.Uint64 { + chainID := new(big.Int) + if config := api.dex.chainConfig; config.IsEIP155(api.dex.blockchain.CurrentBlock().Number()) { + chainID = config.ChainID + } + return (hexutil.Uint64)(chainID.Uint64()) +} + // PrivateAdminAPI is the collection of Ethereum full node-related APIs // exposed over the private admin endpoint. type PrivateAdminAPI struct { |