forked from cerc-io/ipld-eth-server
Watch contact updates (#127)
* Downcase all arguments for contact watching * ABI retrieval from test networks
This commit is contained in:
@@ -38,6 +38,19 @@ func NewEtherScanClient(url string) *EtherScanApi {
|
||||
|
||||
}
|
||||
|
||||
func GenUrl(network string) string {
|
||||
switch network {
|
||||
case "ropsten":
|
||||
return "https://ropsten.etherscan.io"
|
||||
case "kovan":
|
||||
return "https://kovan.etherscan.io"
|
||||
case "rinkeby":
|
||||
return "https://rinkeby.etherscan.io"
|
||||
default:
|
||||
return "https://api.etherscan.io"
|
||||
}
|
||||
}
|
||||
|
||||
//https://api.etherscan.io/api?module=contract&action=getabi&address=%s
|
||||
func (e *EtherScanApi) GetAbi(contractHash string) (string, error) {
|
||||
target := new(Response)
|
||||
|
||||
@@ -101,5 +101,22 @@ var _ = Describe("ABI files", func() {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Generating etherscan endpoints based on network", func() {
|
||||
It("should return the main endpoint as the default", func() {
|
||||
url := geth.GenUrl("")
|
||||
Expect(url).To(Equal("https://api.etherscan.io"))
|
||||
})
|
||||
|
||||
It("generates various test network endpoint if test network is supplied", func() {
|
||||
ropstenUrl := geth.GenUrl("ropsten")
|
||||
rinkebyUrl := geth.GenUrl("rinkeby")
|
||||
kovanUrl := geth.GenUrl("kovan")
|
||||
|
||||
Expect(ropstenUrl).To(Equal("https://ropsten.etherscan.io"))
|
||||
Expect(kovanUrl).To(Equal("https://kovan.etherscan.io"))
|
||||
Expect(rinkebyUrl).To(Equal("https://rinkeby.etherscan.io"))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -25,7 +25,7 @@ func ToCoreBlock(gethBlock *types.Block, client GethClient) core.Block {
|
||||
GasLimit: gethBlock.GasLimit().Int64(),
|
||||
GasUsed: gethBlock.GasUsed().Int64(),
|
||||
Hash: gethBlock.Hash().Hex(),
|
||||
Miner: gethBlock.Coinbase().Hex(),
|
||||
Miner: strings.ToLower(gethBlock.Coinbase().Hex()),
|
||||
Nonce: hexutil.Encode(gethBlock.Header().Nonce[:]),
|
||||
Number: gethBlock.Number().Int64(),
|
||||
ParentHash: gethBlock.ParentHash().Hex(),
|
||||
|
||||
Reference in New Issue
Block a user