Watch contact updates (#127)

* Downcase all arguments for contact watching

* ABI retrieval from test networks
This commit is contained in:
Matt K
2018-01-08 15:59:47 -06:00
committed by GitHub
parent 14e1fc4213
commit 70cfa20c68
11 changed files with 66 additions and 21 deletions
+13
View File
@@ -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)
+17
View File
@@ -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"))
})
})
})
})
+1 -1
View File
@@ -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(),