mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
rpc/generator: make generated code deterministically ordered
This commit is contained in:
parent
e9fbabd895
commit
553d501df7
2 changed files with 365 additions and 336 deletions
653
rpc/genapi.go
653
rpc/genapi.go
|
|
@ -5,46 +5,344 @@ import (
|
|||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/compiler"
|
||||
"github.com/ethereum/go-ethereum/rpc/comms"
|
||||
)
|
||||
|
||||
type GenApi struct {
|
||||
Admin *Admin
|
||||
Db *Db
|
||||
Debug *Debug
|
||||
Eth *Eth
|
||||
Miner *Miner
|
||||
Web3 *Web3
|
||||
Net *Net
|
||||
Personal *Personal
|
||||
Shh *Shh
|
||||
Admin *Admin
|
||||
Debug *Debug
|
||||
Txpool *Txpool
|
||||
Eth *Eth
|
||||
Web3 *Web3
|
||||
}
|
||||
|
||||
func NewGenApi(xeth *Xeth) *GenApi {
|
||||
func NewGenApi(client comms.EthereumClient) *GenApi {
|
||||
xeth := NewXeth(client)
|
||||
|
||||
return &GenApi{
|
||||
Admin: &Admin{xeth},
|
||||
Db: &Db{xeth},
|
||||
Debug: &Debug{xeth},
|
||||
Eth: &Eth{xeth},
|
||||
Miner: &Miner{xeth},
|
||||
Net: &Net{xeth},
|
||||
Personal: &Personal{xeth},
|
||||
Shh: &Shh{xeth},
|
||||
Db: &Db{xeth},
|
||||
Miner: &Miner{xeth},
|
||||
Web3: &Web3{xeth},
|
||||
Debug: &Debug{xeth},
|
||||
Txpool: &Txpool{xeth},
|
||||
Eth: &Eth{xeth},
|
||||
Admin: &Admin{xeth},
|
||||
Web3: &Web3{xeth},
|
||||
}
|
||||
}
|
||||
|
||||
type Admin struct {
|
||||
xeth *Xeth
|
||||
}
|
||||
|
||||
func (self *Admin) AddPeer(url string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_addPeer", []interface{}{url})
|
||||
}
|
||||
func (self *Admin) ChainSyncStatus() (interface{}, error) {
|
||||
return self.xeth.Call("admin_chainSyncStatus", nil)
|
||||
}
|
||||
func (self *Admin) Datadir() (interface{}, error) {
|
||||
return self.xeth.Call("admin_datadir", nil)
|
||||
}
|
||||
func (self *Admin) EnableUserAgent() (interface{}, error) {
|
||||
return self.xeth.Call("admin_enableUserAgent", nil)
|
||||
}
|
||||
func (self *Admin) ExportChain() (interface{}, error) {
|
||||
return self.xeth.Call("admin_exportChain", nil)
|
||||
}
|
||||
func (self *Admin) GetContractInfo(contract string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_getContractInfo", []interface{}{contract})
|
||||
}
|
||||
func (self *Admin) HttpGet(uri string, path string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_httpGet", []interface{}{uri, path})
|
||||
}
|
||||
func (self *Admin) ImportChain() (interface{}, error) {
|
||||
return self.xeth.Call("admin_importChain", nil)
|
||||
}
|
||||
func (self *Admin) NodeInfo() (interface{}, error) {
|
||||
return self.xeth.Call("admin_nodeInfo", nil)
|
||||
}
|
||||
func (self *Admin) Peers() (interface{}, error) {
|
||||
return self.xeth.Call("admin_peers", nil)
|
||||
}
|
||||
func (self *Admin) Register(sender string, address string, contentHashHex string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_register", []interface{}{sender, address, contentHashHex})
|
||||
}
|
||||
func (self *Admin) RegisterUrl(sender string, contentHash string, url string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_registerUrl", []interface{}{sender, contentHash, url})
|
||||
}
|
||||
func (self *Admin) SaveInfo(contractInfo compiler.ContractInfo, filename string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_saveInfo", []interface{}{contractInfo, filename})
|
||||
}
|
||||
func (self *Admin) SetGlobalRegistrar(nameReg string, contractAddress string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_setGlobalRegistrar", []interface{}{nameReg, contractAddress})
|
||||
}
|
||||
func (self *Admin) SetHashReg(hashReg string, sender string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_setHashReg", []interface{}{hashReg, sender})
|
||||
}
|
||||
func (self *Admin) SetSolc(path string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_setSolc", []interface{}{path})
|
||||
}
|
||||
func (self *Admin) SetUrlHint(urlHint string, sender string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_setUrlHint", []interface{}{urlHint, sender})
|
||||
}
|
||||
func (self *Admin) Sleep(s int) (interface{}, error) {
|
||||
return self.xeth.Call("admin_sleep", []interface{}{s})
|
||||
}
|
||||
func (self *Admin) SleepBlocks(n int64, timeout int64) (interface{}, error) {
|
||||
return self.xeth.Call("admin_sleepBlocks", []interface{}{n, timeout})
|
||||
}
|
||||
func (self *Admin) StartNatSpec() (interface{}, error) {
|
||||
return self.xeth.Call("admin_startNatSpec", nil)
|
||||
}
|
||||
func (self *Admin) StartRPC(listenAddress string, listenPort uint, corsDomain string, apis string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_startRPC", []interface{}{listenAddress, listenPort, corsDomain, apis})
|
||||
}
|
||||
func (self *Admin) StopNatSpec() (interface{}, error) {
|
||||
return self.xeth.Call("admin_stopNatSpec", nil)
|
||||
}
|
||||
func (self *Admin) StopRPC() (interface{}, error) {
|
||||
return self.xeth.Call("admin_stopRPC", nil)
|
||||
}
|
||||
func (self *Admin) Verbosity(level int) (interface{}, error) {
|
||||
return self.xeth.Call("admin_verbosity", []interface{}{level})
|
||||
}
|
||||
|
||||
type Db struct {
|
||||
xeth *Xeth
|
||||
}
|
||||
|
||||
func (self *Db) GetHex() (interface{}, error) {
|
||||
return self.xeth.Call("db_getHex", nil)
|
||||
}
|
||||
func (self *Db) GetString() (interface{}, error) {
|
||||
return self.xeth.Call("db_getString", nil)
|
||||
}
|
||||
func (self *Db) PutHex() (interface{}, error) {
|
||||
return self.xeth.Call("db_putHex", nil)
|
||||
}
|
||||
func (self *Db) PutString() (interface{}, error) {
|
||||
return self.xeth.Call("db_putString", nil)
|
||||
}
|
||||
|
||||
type Debug struct {
|
||||
xeth *Xeth
|
||||
}
|
||||
|
||||
func (self *Debug) DumpBlock() (interface{}, error) {
|
||||
return self.xeth.Call("debug_dumpBlock", nil)
|
||||
}
|
||||
func (self *Debug) GetBlockRlp() (interface{}, error) {
|
||||
return self.xeth.Call("debug_getBlockRlp", nil)
|
||||
}
|
||||
func (self *Debug) Metrics(raw bool) (interface{}, error) {
|
||||
return self.xeth.Call("debug_metrics", []interface{}{raw})
|
||||
}
|
||||
func (self *Debug) PrintBlock() (interface{}, error) {
|
||||
return self.xeth.Call("debug_printBlock", nil)
|
||||
}
|
||||
func (self *Debug) ProcessBlock() (interface{}, error) {
|
||||
return self.xeth.Call("debug_processBlock", nil)
|
||||
}
|
||||
func (self *Debug) SeedHash() (interface{}, error) {
|
||||
return self.xeth.Call("debug_seedHash", nil)
|
||||
}
|
||||
func (self *Debug) SetHead() (interface{}, error) {
|
||||
return self.xeth.Call("debug_setHead", nil)
|
||||
}
|
||||
|
||||
type Eth struct {
|
||||
xeth *Xeth
|
||||
}
|
||||
|
||||
func (self *Eth) Accounts() (interface{}, error) {
|
||||
return self.xeth.Call("eth_accounts", nil)
|
||||
}
|
||||
func (self *Eth) BlockNumber() (interface{}, error) {
|
||||
return self.xeth.Call("eth_blockNumber", nil)
|
||||
}
|
||||
func (self *Eth) Call(from string, to string, value *big.Int, gas *big.Int, gasPrice *big.Int, data string, blockNumber int64) (interface{}, error) {
|
||||
return self.xeth.Call("eth_call", []interface{}{from, to, value, gas, gasPrice, data, blockNumber})
|
||||
}
|
||||
func (self *Eth) Coinbase() (interface{}, error) {
|
||||
return self.xeth.Call("eth_coinbase", nil)
|
||||
}
|
||||
func (self *Eth) CompileSolidity() (interface{}, error) {
|
||||
return self.xeth.Call("eth_compileSolidity", nil)
|
||||
}
|
||||
func (self *Eth) EstimateGas() (interface{}, error) {
|
||||
return self.xeth.Call("eth_estimateGas", nil)
|
||||
}
|
||||
func (self *Eth) Flush() (interface{}, error) {
|
||||
return self.xeth.Call("eth_flush", nil)
|
||||
}
|
||||
func (self *Eth) GasPrice(price string) (interface{}, error) {
|
||||
return self.xeth.Call("eth_gasPrice", []interface{}{price})
|
||||
}
|
||||
func (self *Eth) GetBalance(address string, blockNumber int64) (interface{}, error) {
|
||||
return self.xeth.Call("eth_getBalance", []interface{}{address, blockNumber})
|
||||
}
|
||||
func (self *Eth) GetBlockByHash(blockHash string, includeTxs bool) (interface{}, error) {
|
||||
return self.xeth.Call("eth_getBlockByHash", []interface{}{blockHash, includeTxs})
|
||||
}
|
||||
func (self *Eth) GetBlockByNumber(blockNumber int64, includeTxs bool) (interface{}, error) {
|
||||
return self.xeth.Call("eth_getBlockByNumber", []interface{}{blockNumber, includeTxs})
|
||||
}
|
||||
func (self *Eth) GetBlockTransactionCountByHash() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getBlockTransactionCountByHash", nil)
|
||||
}
|
||||
func (self *Eth) GetBlockTransactionCountByNumber() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getBlockTransactionCountByNumber", nil)
|
||||
}
|
||||
func (self *Eth) GetCode(address string, blockNumber int64) (interface{}, error) {
|
||||
return self.xeth.Call("eth_getCode", []interface{}{address, blockNumber})
|
||||
}
|
||||
func (self *Eth) GetCompilers() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getCompilers", nil)
|
||||
}
|
||||
func (self *Eth) GetData(address string, blockNumber int64) (interface{}, error) {
|
||||
return self.xeth.Call("eth_getData", []interface{}{address, blockNumber})
|
||||
}
|
||||
func (self *Eth) GetFilterChanges() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getFilterChanges", nil)
|
||||
}
|
||||
func (self *Eth) GetFilterLogs() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getFilterLogs", nil)
|
||||
}
|
||||
func (self *Eth) GetLogs() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getLogs", nil)
|
||||
}
|
||||
func (self *Eth) GetStorage(address string, blockNumber int64) (interface{}, error) {
|
||||
return self.xeth.Call("eth_getStorage", []interface{}{address, blockNumber})
|
||||
}
|
||||
func (self *Eth) GetStorageAt(address string, blockNumber int64, key string) (interface{}, error) {
|
||||
return self.xeth.Call("eth_getStorageAt", []interface{}{address, blockNumber, key})
|
||||
}
|
||||
func (self *Eth) GetTransactionByBlockHashAndIndex() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getTransactionByBlockHashAndIndex", nil)
|
||||
}
|
||||
func (self *Eth) GetTransactionByBlockNumberAndIndex() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getTransactionByBlockNumberAndIndex", nil)
|
||||
}
|
||||
func (self *Eth) GetTransactionByHash() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getTransactionByHash", nil)
|
||||
}
|
||||
func (self *Eth) GetTransactionCount() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getTransactionCount", nil)
|
||||
}
|
||||
func (self *Eth) GetTransactionReceipt() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getTransactionReceipt", nil)
|
||||
}
|
||||
func (self *Eth) GetUncleByBlockHashAndIndex() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getUncleByBlockHashAndIndex", nil)
|
||||
}
|
||||
func (self *Eth) GetUncleByBlockNumberAndIndex() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getUncleByBlockNumberAndIndex", nil)
|
||||
}
|
||||
func (self *Eth) GetUncleCountByBlockHash() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getUncleCountByBlockHash", nil)
|
||||
}
|
||||
func (self *Eth) GetUncleCountByBlockNumber() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getUncleCountByBlockNumber", nil)
|
||||
}
|
||||
func (self *Eth) GetWork() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getWork", nil)
|
||||
}
|
||||
func (self *Eth) Hashrate() (interface{}, error) {
|
||||
return self.xeth.Call("eth_hashrate", nil)
|
||||
}
|
||||
func (self *Eth) Mining() (interface{}, error) {
|
||||
return self.xeth.Call("eth_mining", nil)
|
||||
}
|
||||
func (self *Eth) NewBlockFilter() (interface{}, error) {
|
||||
return self.xeth.Call("eth_newBlockFilter", nil)
|
||||
}
|
||||
func (self *Eth) NewFilter() (interface{}, error) {
|
||||
return self.xeth.Call("eth_newFilter", nil)
|
||||
}
|
||||
func (self *Eth) NewPendingTransactionFilter() (interface{}, error) {
|
||||
return self.xeth.Call("eth_newPendingTransactionFilter", nil)
|
||||
}
|
||||
func (self *Eth) PendingTransactions() (interface{}, error) {
|
||||
return self.xeth.Call("eth_pendingTransactions", nil)
|
||||
}
|
||||
func (self *Eth) ProtocolVersion() (interface{}, error) {
|
||||
return self.xeth.Call("eth_protocolVersion", nil)
|
||||
}
|
||||
func (self *Eth) SendRawTransaction() (interface{}, error) {
|
||||
return self.xeth.Call("eth_sendRawTransaction", nil)
|
||||
}
|
||||
func (self *Eth) SendTransaction() (interface{}, error) {
|
||||
return self.xeth.Call("eth_sendTransaction", nil)
|
||||
}
|
||||
func (self *Eth) Sign() (interface{}, error) {
|
||||
return self.xeth.Call("eth_sign", nil)
|
||||
}
|
||||
func (self *Eth) StorageAt(address string, blockNumber int64) (interface{}, error) {
|
||||
return self.xeth.Call("eth_storageAt", []interface{}{address, blockNumber})
|
||||
}
|
||||
func (self *Eth) SubmitHashrate() (interface{}, error) {
|
||||
return self.xeth.Call("eth_submitHashrate", nil)
|
||||
}
|
||||
func (self *Eth) SubmitWork(nonce uint64, header string, digest string) (interface{}, error) {
|
||||
return self.xeth.Call("eth_submitWork", []interface{}{nonce, header, digest})
|
||||
}
|
||||
func (self *Eth) Transact() (interface{}, error) {
|
||||
return self.xeth.Call("eth_transact", nil)
|
||||
}
|
||||
func (self *Eth) UninstallFilter() (interface{}, error) {
|
||||
return self.xeth.Call("eth_uninstallFilter", nil)
|
||||
}
|
||||
|
||||
type Miner struct {
|
||||
xeth *Xeth
|
||||
}
|
||||
|
||||
func (self *Miner) Hashrate() (interface{}, error) {
|
||||
return self.xeth.Call("miner_hashrate", nil)
|
||||
}
|
||||
func (self *Miner) MakeDAG(blockNumber int64) (interface{}, error) {
|
||||
return self.xeth.Call("miner_makeDAG", []interface{}{blockNumber})
|
||||
}
|
||||
func (self *Miner) SetEtherbase(etherbase common.Address) (interface{}, error) {
|
||||
return self.xeth.Call("miner_setEtherbase", []interface{}{etherbase})
|
||||
}
|
||||
func (self *Miner) SetExtra(data string) (interface{}, error) {
|
||||
return self.xeth.Call("miner_setExtra", []interface{}{data})
|
||||
}
|
||||
func (self *Miner) SetGasPrice() (interface{}, error) {
|
||||
return self.xeth.Call("miner_setGasPrice", nil)
|
||||
}
|
||||
func (self *Miner) Start(threads int) (interface{}, error) {
|
||||
return self.xeth.Call("miner_start", []interface{}{threads})
|
||||
}
|
||||
func (self *Miner) StartAutoDAG() (interface{}, error) {
|
||||
return self.xeth.Call("miner_startAutoDAG", nil)
|
||||
}
|
||||
func (self *Miner) Stop() (interface{}, error) {
|
||||
return self.xeth.Call("miner_stop", nil)
|
||||
}
|
||||
func (self *Miner) StopAutoDAG() (interface{}, error) {
|
||||
return self.xeth.Call("miner_stopAutoDAG", nil)
|
||||
}
|
||||
|
||||
type Net struct {
|
||||
xeth *Xeth
|
||||
}
|
||||
|
||||
func (self *Net) PeerCount() (interface{}, error) {
|
||||
return self.xeth.Call("net_peerCount", nil)
|
||||
}
|
||||
func (self *Net) Listening() (interface{}, error) {
|
||||
return self.xeth.Call("net_listening", nil)
|
||||
}
|
||||
func (self *Net) PeerCount() (interface{}, error) {
|
||||
return self.xeth.Call("net_peerCount", nil)
|
||||
}
|
||||
func (self *Net) Version() (interface{}, error) {
|
||||
return self.xeth.Call("net_version", nil)
|
||||
}
|
||||
|
|
@ -59,9 +357,6 @@ func (self *Personal) ListAccounts() (interface{}, error) {
|
|||
func (self *Personal) NewAccount(passphrase string) (interface{}, error) {
|
||||
return self.xeth.Call("personal_newAccount", []interface{}{passphrase})
|
||||
}
|
||||
func (self *Personal) DeleteAccount(address string, passphrase string) (interface{}, error) {
|
||||
return self.xeth.Call("personal_deleteAccount", []interface{}{address, passphrase})
|
||||
}
|
||||
func (self *Personal) UnlockAccount(address string, passphrase string, duration int) (interface{}, error) {
|
||||
return self.xeth.Call("personal_unlockAccount", []interface{}{address, passphrase, duration})
|
||||
}
|
||||
|
|
@ -70,112 +365,29 @@ type Shh struct {
|
|||
xeth *Xeth
|
||||
}
|
||||
|
||||
func (self *Shh) Version() (interface{}, error) {
|
||||
return self.xeth.Call("shh_version", nil)
|
||||
func (self *Shh) GetFilterChanges() (interface{}, error) {
|
||||
return self.xeth.Call("shh_getFilterChanges", nil)
|
||||
}
|
||||
func (self *Shh) Post() (interface{}, error) {
|
||||
return self.xeth.Call("shh_post", nil)
|
||||
func (self *Shh) GetMessages() (interface{}, error) {
|
||||
return self.xeth.Call("shh_getMessages", nil)
|
||||
}
|
||||
func (self *Shh) HasIdentity() (interface{}, error) {
|
||||
return self.xeth.Call("shh_hasIdentity", nil)
|
||||
}
|
||||
func (self *Shh) NewFilter() (interface{}, error) {
|
||||
return self.xeth.Call("shh_newFilter", nil)
|
||||
}
|
||||
func (self *Shh) NewIdentity() (interface{}, error) {
|
||||
return self.xeth.Call("shh_newIdentity", nil)
|
||||
}
|
||||
func (self *Shh) NewFilter() (interface{}, error) {
|
||||
return self.xeth.Call("shh_newFilter", nil)
|
||||
func (self *Shh) Post() (interface{}, error) {
|
||||
return self.xeth.Call("shh_post", nil)
|
||||
}
|
||||
func (self *Shh) UninstallFilter() (interface{}, error) {
|
||||
return self.xeth.Call("shh_uninstallFilter", nil)
|
||||
}
|
||||
func (self *Shh) GetFilterChanges() (interface{}, error) {
|
||||
return self.xeth.Call("shh_getFilterChanges", nil)
|
||||
}
|
||||
|
||||
type Db struct {
|
||||
xeth *Xeth
|
||||
}
|
||||
|
||||
func (self *Db) GetString() (interface{}, error) {
|
||||
return self.xeth.Call("db_getString", nil)
|
||||
}
|
||||
func (self *Db) PutString() (interface{}, error) {
|
||||
return self.xeth.Call("db_putString", nil)
|
||||
}
|
||||
func (self *Db) GetHex() (interface{}, error) {
|
||||
return self.xeth.Call("db_getHex", nil)
|
||||
}
|
||||
func (self *Db) PutHex() (interface{}, error) {
|
||||
return self.xeth.Call("db_putHex", nil)
|
||||
}
|
||||
|
||||
type Miner struct {
|
||||
xeth *Xeth
|
||||
}
|
||||
|
||||
func (self *Miner) Hashrate() (interface{}, error) {
|
||||
return self.xeth.Call("miner_hashrate", nil)
|
||||
}
|
||||
func (self *Miner) MakeDAG(blockNumber int64) (interface{}, error) {
|
||||
return self.xeth.Call("miner_makeDAG", []interface{}{blockNumber})
|
||||
}
|
||||
func (self *Miner) SetExtra(data string) (interface{}, error) {
|
||||
return self.xeth.Call("miner_setExtra", []interface{}{data})
|
||||
}
|
||||
func (self *Miner) SetGasPrice() (interface{}, error) {
|
||||
return self.xeth.Call("miner_setGasPrice", nil)
|
||||
}
|
||||
func (self *Miner) SetEtherbase(etherbase common.Address) (interface{}, error) {
|
||||
return self.xeth.Call("miner_setEtherbase", []interface{}{etherbase})
|
||||
}
|
||||
func (self *Miner) StartAutoDAG() (interface{}, error) {
|
||||
return self.xeth.Call("miner_startAutoDAG", nil)
|
||||
}
|
||||
func (self *Miner) Start(threads int) (interface{}, error) {
|
||||
return self.xeth.Call("miner_start", []interface{}{threads})
|
||||
}
|
||||
func (self *Miner) StopAutoDAG() (interface{}, error) {
|
||||
return self.xeth.Call("miner_stopAutoDAG", nil)
|
||||
}
|
||||
func (self *Miner) Stop() (interface{}, error) {
|
||||
return self.xeth.Call("miner_stop", nil)
|
||||
}
|
||||
|
||||
type Web3 struct {
|
||||
xeth *Xeth
|
||||
}
|
||||
|
||||
func (self *Web3) Sha3(data string) (interface{}, error) {
|
||||
return self.xeth.Call("web3_sha3", []interface{}{data})
|
||||
}
|
||||
func (self *Web3) ClientVersion() (interface{}, error) {
|
||||
return self.xeth.Call("web3_clientVersion", nil)
|
||||
}
|
||||
|
||||
type Debug struct {
|
||||
xeth *Xeth
|
||||
}
|
||||
|
||||
func (self *Debug) DumpBlock() (interface{}, error) {
|
||||
return self.xeth.Call("debug_dumpBlock", nil)
|
||||
}
|
||||
func (self *Debug) GetBlockRlp() (interface{}, error) {
|
||||
return self.xeth.Call("debug_getBlockRlp", nil)
|
||||
}
|
||||
func (self *Debug) PrintBlock() (interface{}, error) {
|
||||
return self.xeth.Call("debug_printBlock", nil)
|
||||
}
|
||||
func (self *Debug) ProcessBlock() (interface{}, error) {
|
||||
return self.xeth.Call("debug_processBlock", nil)
|
||||
}
|
||||
func (self *Debug) SeedHash() (interface{}, error) {
|
||||
return self.xeth.Call("debug_seedHash", nil)
|
||||
}
|
||||
func (self *Debug) SetHead() (interface{}, error) {
|
||||
return self.xeth.Call("debug_setHead", nil)
|
||||
}
|
||||
func (self *Debug) Metrics(raw bool) (interface{}, error) {
|
||||
return self.xeth.Call("debug_metrics", []interface{}{raw})
|
||||
func (self *Shh) Version() (interface{}, error) {
|
||||
return self.xeth.Call("shh_version", nil)
|
||||
}
|
||||
|
||||
type Txpool struct {
|
||||
|
|
@ -186,222 +398,13 @@ func (self *Txpool) Status() (interface{}, error) {
|
|||
return self.xeth.Call("txpool_status", nil)
|
||||
}
|
||||
|
||||
type Eth struct {
|
||||
type Web3 struct {
|
||||
xeth *Xeth
|
||||
}
|
||||
|
||||
func (self *Eth) Accounts() (interface{}, error) {
|
||||
return self.xeth.Call("eth_accounts", nil)
|
||||
func (self *Web3) ClientVersion() (interface{}, error) {
|
||||
return self.xeth.Call("web3_clientVersion", nil)
|
||||
}
|
||||
func (self *Eth) BlockNumber() (interface{}, error) {
|
||||
return self.xeth.Call("eth_blockNumber", nil)
|
||||
}
|
||||
func (self *Eth) GetBalance(address string, blockNumber int64) (interface{}, error) {
|
||||
return self.xeth.Call("eth_getBalance", []interface{}{address, blockNumber})
|
||||
}
|
||||
func (self *Eth) ProtocolVersion() (interface{}, error) {
|
||||
return self.xeth.Call("eth_protocolVersion", nil)
|
||||
}
|
||||
func (self *Eth) Coinbase() (interface{}, error) {
|
||||
return self.xeth.Call("eth_coinbase", nil)
|
||||
}
|
||||
func (self *Eth) Mining() (interface{}, error) {
|
||||
return self.xeth.Call("eth_mining", nil)
|
||||
}
|
||||
func (self *Eth) GasPrice(price string) (interface{}, error) {
|
||||
return self.xeth.Call("eth_gasPrice", []interface{}{price})
|
||||
}
|
||||
func (self *Eth) GetStorage(address string, blockNumber int64) (interface{}, error) {
|
||||
return self.xeth.Call("eth_getStorage", []interface{}{address, blockNumber})
|
||||
}
|
||||
func (self *Eth) StorageAt(address string, blockNumber int64) (interface{}, error) {
|
||||
return self.xeth.Call("eth_storageAt", []interface{}{address, blockNumber})
|
||||
}
|
||||
func (self *Eth) GetStorageAt(address string, blockNumber int64, key string) (interface{}, error) {
|
||||
return self.xeth.Call("eth_getStorageAt", []interface{}{address, blockNumber, key})
|
||||
}
|
||||
func (self *Eth) GetTransactionCount() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getTransactionCount", nil)
|
||||
}
|
||||
func (self *Eth) GetBlockTransactionCountByHash() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getBlockTransactionCountByHash", nil)
|
||||
}
|
||||
func (self *Eth) GetBlockTransactionCountByNumber() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getBlockTransactionCountByNumber", nil)
|
||||
}
|
||||
func (self *Eth) GetUncleCountByBlockHash() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getUncleCountByBlockHash", nil)
|
||||
}
|
||||
func (self *Eth) GetUncleCountByBlockNumber() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getUncleCountByBlockNumber", nil)
|
||||
}
|
||||
func (self *Eth) GetData(address string, blockNumber int64) (interface{}, error) {
|
||||
return self.xeth.Call("eth_getData", []interface{}{address, blockNumber})
|
||||
}
|
||||
func (self *Eth) GetCode(address string, blockNumber int64) (interface{}, error) {
|
||||
return self.xeth.Call("eth_getCode", []interface{}{address, blockNumber})
|
||||
}
|
||||
func (self *Eth) Sign() (interface{}, error) {
|
||||
return self.xeth.Call("eth_sign", nil)
|
||||
}
|
||||
func (self *Eth) SendRawTransaction() (interface{}, error) {
|
||||
return self.xeth.Call("eth_sendRawTransaction", nil)
|
||||
}
|
||||
func (self *Eth) SendTransaction() (interface{}, error) {
|
||||
return self.xeth.Call("eth_sendTransaction", nil)
|
||||
}
|
||||
func (self *Eth) Transact() (interface{}, error) {
|
||||
return self.xeth.Call("eth_transact", nil)
|
||||
}
|
||||
func (self *Eth) EstimateGas() (interface{}, error) {
|
||||
return self.xeth.Call("eth_estimateGas", nil)
|
||||
}
|
||||
func (self *Eth) Call(from string, to string, value *big.Int, gas *big.Int, gasPrice *big.Int, data string, blockNumber int64) (interface{}, error) {
|
||||
return self.xeth.Call("eth_call", []interface{}{from, to, value, gas, gasPrice, data, blockNumber})
|
||||
}
|
||||
func (self *Eth) Flush() (interface{}, error) {
|
||||
return self.xeth.Call("eth_flush", nil)
|
||||
}
|
||||
func (self *Eth) GetBlockByHash(blockHash string, includeTxs bool) (interface{}, error) {
|
||||
return self.xeth.Call("eth_getBlockByHash", []interface{}{blockHash, includeTxs})
|
||||
}
|
||||
func (self *Eth) GetBlockByNumber(blockNumber int64, includeTxs bool) (interface{}, error) {
|
||||
return self.xeth.Call("eth_getBlockByNumber", []interface{}{blockNumber, includeTxs})
|
||||
}
|
||||
func (self *Eth) GetTransactionByHash() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getTransactionByHash", nil)
|
||||
}
|
||||
func (self *Eth) GetTransactionByBlockNumberAndIndex() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getTransactionByBlockNumberAndIndex", nil)
|
||||
}
|
||||
func (self *Eth) GetTransactionByBlockHashAndIndex() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getTransactionByBlockHashAndIndex", nil)
|
||||
}
|
||||
func (self *Eth) GetUncleByBlockHashAndIndex() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getUncleByBlockHashAndIndex", nil)
|
||||
}
|
||||
func (self *Eth) GetUncleByBlockNumberAndIndex() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getUncleByBlockNumberAndIndex", nil)
|
||||
}
|
||||
func (self *Eth) GetCompilers() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getCompilers", nil)
|
||||
}
|
||||
func (self *Eth) CompileSolidity() (interface{}, error) {
|
||||
return self.xeth.Call("eth_compileSolidity", nil)
|
||||
}
|
||||
func (self *Eth) NewFilter() (interface{}, error) {
|
||||
return self.xeth.Call("eth_newFilter", nil)
|
||||
}
|
||||
func (self *Eth) NewBlockFilter() (interface{}, error) {
|
||||
return self.xeth.Call("eth_newBlockFilter", nil)
|
||||
}
|
||||
func (self *Eth) NewPendingTransactionFilter() (interface{}, error) {
|
||||
return self.xeth.Call("eth_newPendingTransactionFilter", nil)
|
||||
}
|
||||
func (self *Eth) UninstallFilter() (interface{}, error) {
|
||||
return self.xeth.Call("eth_uninstallFilter", nil)
|
||||
}
|
||||
func (self *Eth) GetFilterChanges() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getFilterChanges", nil)
|
||||
}
|
||||
func (self *Eth) GetFilterLogs() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getFilterLogs", nil)
|
||||
}
|
||||
func (self *Eth) GetLogs() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getLogs", nil)
|
||||
}
|
||||
func (self *Eth) Hashrate() (interface{}, error) {
|
||||
return self.xeth.Call("eth_hashrate", nil)
|
||||
}
|
||||
func (self *Eth) GetWork() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getWork", nil)
|
||||
}
|
||||
func (self *Eth) SubmitWork(nonce uint64, header string, digest string) (interface{}, error) {
|
||||
return self.xeth.Call("eth_submitWork", []interface{}{nonce, header, digest})
|
||||
}
|
||||
func (self *Eth) SubmitHashrate() (interface{}, error) {
|
||||
return self.xeth.Call("eth_submitHashrate", nil)
|
||||
}
|
||||
func (self *Eth) PendingTransactions() (interface{}, error) {
|
||||
return self.xeth.Call("eth_pendingTransactions", nil)
|
||||
}
|
||||
func (self *Eth) GetTransactionReceipt() (interface{}, error) {
|
||||
return self.xeth.Call("eth_getTransactionReceipt", nil)
|
||||
}
|
||||
|
||||
type Admin struct {
|
||||
xeth *Xeth
|
||||
}
|
||||
|
||||
func (self *Admin) AddPeer(url string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_addPeer", []interface{}{url})
|
||||
}
|
||||
func (self *Admin) Peers() (interface{}, error) {
|
||||
return self.xeth.Call("admin_peers", nil)
|
||||
}
|
||||
func (self *Admin) NodeInfo() (interface{}, error) {
|
||||
return self.xeth.Call("admin_nodeInfo", nil)
|
||||
}
|
||||
func (self *Admin) ExportChain() (interface{}, error) {
|
||||
return self.xeth.Call("admin_exportChain", nil)
|
||||
}
|
||||
func (self *Admin) ImportChain() (interface{}, error) {
|
||||
return self.xeth.Call("admin_importChain", nil)
|
||||
}
|
||||
func (self *Admin) Verbosity(level int) (interface{}, error) {
|
||||
return self.xeth.Call("admin_verbosity", []interface{}{level})
|
||||
}
|
||||
func (self *Admin) ChainSyncStatus() (interface{}, error) {
|
||||
return self.xeth.Call("admin_chainSyncStatus", nil)
|
||||
}
|
||||
func (self *Admin) SetSolc(path string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_setSolc", []interface{}{path})
|
||||
}
|
||||
func (self *Admin) Datadir() (interface{}, error) {
|
||||
return self.xeth.Call("admin_datadir", nil)
|
||||
}
|
||||
func (self *Admin) StartRPC(listenAddress string, listenPort uint, corsDomain string, apis string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_startRPC", []interface{}{listenAddress, listenPort, corsDomain, apis})
|
||||
}
|
||||
func (self *Admin) StopRPC() (interface{}, error) {
|
||||
return self.xeth.Call("admin_stopRPC", nil)
|
||||
}
|
||||
func (self *Admin) SetGlobalRegistrar(nameReg string, contractAddress string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_setGlobalRegistrar", []interface{}{nameReg, contractAddress})
|
||||
}
|
||||
func (self *Admin) SetHashReg(hashReg string, sender string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_setHashReg", []interface{}{hashReg, sender})
|
||||
}
|
||||
func (self *Admin) SetUrlHint(urlHint string, sender string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_setUrlHint", []interface{}{urlHint, sender})
|
||||
}
|
||||
func (self *Admin) SaveInfo(contractInfo compiler.ContractInfo, filename string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_saveInfo", []interface{}{contractInfo, filename})
|
||||
}
|
||||
func (self *Admin) Register(sender string, address string, contentHashHex string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_register", []interface{}{sender, address, contentHashHex})
|
||||
}
|
||||
func (self *Admin) RegisterUrl(sender string, contentHash string, url string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_registerUrl", []interface{}{sender, contentHash, url})
|
||||
}
|
||||
func (self *Admin) StartNatSpec() (interface{}, error) {
|
||||
return self.xeth.Call("admin_startNatSpec", nil)
|
||||
}
|
||||
func (self *Admin) StopNatSpec() (interface{}, error) {
|
||||
return self.xeth.Call("admin_stopNatSpec", nil)
|
||||
}
|
||||
func (self *Admin) GetContractInfo(contract string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_getContractInfo", []interface{}{contract})
|
||||
}
|
||||
func (self *Admin) HttpGet(uri string, path string) (interface{}, error) {
|
||||
return self.xeth.Call("admin_httpGet", []interface{}{uri, path})
|
||||
}
|
||||
func (self *Admin) SleepBlocks(n int64, timeout int64) (interface{}, error) {
|
||||
return self.xeth.Call("admin_sleepBlocks", []interface{}{n, timeout})
|
||||
}
|
||||
func (self *Admin) Sleep(s int) (interface{}, error) {
|
||||
return self.xeth.Call("admin_sleep", []interface{}{s})
|
||||
}
|
||||
func (self *Admin) EnableUserAgent() (interface{}, error) {
|
||||
return self.xeth.Call("admin_enableUserAgent", nil)
|
||||
func (self *Web3) Sha3(data string) (interface{}, error) {
|
||||
return self.xeth.Call("web3_sha3", []interface{}{data})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,12 @@ import (
|
|||
"go/ast"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
|
|
@ -59,12 +61,14 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatalf("Failed to collect API declarations: %v", err)
|
||||
}
|
||||
// Create the collectors for the sobmodules
|
||||
modules := make(map[string][]*Endpoint)
|
||||
// Create the collectors for the submodules
|
||||
modules := []string{}
|
||||
methods := make(map[string][]*Endpoint)
|
||||
|
||||
// Iterate over all the API mappings, and locate the RPC function associations
|
||||
for variable, val := range values {
|
||||
if strings.HasSuffix(variable, "Mapping") {
|
||||
// Iterate over all the exposed functionality and extract them
|
||||
for _, mapping := range val.(*ast.CompositeLit).Elts {
|
||||
// Fetch the name of the RPC function, and the associated argument definition
|
||||
call := strings.Trim(mapping.(*ast.KeyValueExpr).Key.(*ast.BasicLit).Value, "\"")
|
||||
|
|
@ -105,36 +109,58 @@ func main() {
|
|||
paramList = append(paramList, variable)
|
||||
}
|
||||
}
|
||||
// Append the function to the sobmodule collection
|
||||
modules[module] = append(modules[module], &Endpoint{
|
||||
// Insert the function to the submodule collection (alphabetically)
|
||||
endpoint := &Endpoint{
|
||||
Method: call,
|
||||
Function: fmt.Sprintf("%s(%s)", function, strings.Join(params, ",")),
|
||||
Argument: args,
|
||||
Params: paramList,
|
||||
})
|
||||
}
|
||||
for i := 0; i < len(methods[module]); i++ {
|
||||
if methods[module][i].Function > endpoint.Function {
|
||||
methods[module] = append(methods[module], nil)
|
||||
copy(methods[module][i+1:], methods[module][i:])
|
||||
methods[module][i] = endpoint
|
||||
|
||||
endpoint = nil
|
||||
break
|
||||
}
|
||||
}
|
||||
if endpoint != nil {
|
||||
methods[module] = append(methods[module], endpoint)
|
||||
}
|
||||
// Register the module if first occurance
|
||||
if len(methods[module]) == 1 {
|
||||
modules = append(modules, module)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sort.Strings(modules)
|
||||
|
||||
// Start generating the client API
|
||||
client := "package rpc\n"
|
||||
|
||||
// Generate the client struct with all its submodules
|
||||
client += fmt.Sprintf("type GenApi struct {\n")
|
||||
for module, _ := range modules {
|
||||
for _, module := range modules {
|
||||
client += fmt.Sprintf("%s *%s\n", module, module)
|
||||
}
|
||||
client += fmt.Sprintf("}\n")
|
||||
|
||||
// Generate the API constructor to create the individual submodules
|
||||
client += fmt.Sprint("func NewGenApi(xeth *Xeth) *GenApi {\n")
|
||||
client += fmt.Sprint("func NewGenApi(client comms.EthereumClient) *GenApi {\n")
|
||||
client += fmt.Sprint("xeth := NewXeth(client)\n\n")
|
||||
client += fmt.Sprint("return &GenApi{\n")
|
||||
for module, _ := range modules {
|
||||
for _, module := range modules {
|
||||
client += fmt.Sprintf("%s: &%s{xeth},\n", module, module)
|
||||
}
|
||||
client += fmt.Sprintf("}}\n")
|
||||
|
||||
// Generate each of the client API calls
|
||||
for module, endpoints := range modules {
|
||||
for _, module := range modules {
|
||||
endpoints := methods[module]
|
||||
|
||||
client += fmt.Sprintf("\ntype %s struct {\n xeth *Xeth\n}\n", module)
|
||||
for _, endpoint := range endpoints {
|
||||
client += fmt.Sprintf("func (self *%s) %s (interface{}, error) {\n", module, endpoint.Function)
|
||||
|
|
@ -149,8 +175,8 @@ func main() {
|
|||
// Format the final code and output
|
||||
if blob, err := imports.Process("", []byte(client), nil); err != nil {
|
||||
log.Fatalf("Failed to format output code: %v", err)
|
||||
} else {
|
||||
fmt.Println(string(blob))
|
||||
} else if err := ioutil.WriteFile("../genapi.go", blob, 0600); err != nil {
|
||||
log.Fatalf("Failed to write output code: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue