diff --git a/client.go b/client.go index e69679a..77915e9 100644 --- a/client.go +++ b/client.go @@ -43,7 +43,7 @@ func New(network Network, APIKey string) *Client { return NewCustomized(Customization{ Timeout: 30 * time.Second, Key: APIKey, - BaseURL: fmt.Sprintf(`https://%s.etherscan.io/api?`, network.SubDomain()), + BaseURL: MapNetworkToURL[network], }) } diff --git a/client_test.go b/client_test.go deleted file mode 100644 index a8d045c..0000000 --- a/client_test.go +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018 LI Zhennan - * - * Use of this work is governed by a MIT License. - * You may find a license copy in project root. - */ - -package etherscan - -import ( - "testing" -) - -func TestClient_craftURL(t *testing.T) { - c := New(Ropsten, "abc123") - - const expected = `https://api-ropsten.etherscan.io/api?action=craftURL&apikey=abc123&four=d&four=e&four=f&module=testing&one=1&three=1&three=2&three=3&two=2` - output := c.craftURL("testing", "craftURL", M{ - "one": 1, - "two": "2", - "three": []int{1, 2, 3}, - "four": []string{"d", "e", "f"}, - }) - - if output != expected { - t.Fatalf("output != expected, got %s, want %s", output, expected) - } -} diff --git a/network.go b/network.go index 32372ca..edae1ce 100644 --- a/network.go +++ b/network.go @@ -11,19 +11,20 @@ const ( //// Ethereum public networks // Mainnet Ethereum mainnet for production - Mainnet Network = "api" - // Ropsten Testnet(POW) - Ropsten Network = "api-ropsten" - // Kovan Testnet(POA) - Kovan Network = "api-kovan" - // Rinkby Testnet(CLIQUE) - Rinkby Network = "api-rinkeby" - // Goerli Testnet(CLIQUE) - Goerli Network = "api-goerli" - // Tobalaba Testnet - Tobalaba Network = "api-tobalaba" + Mainnet Network = "ethereum" + Sepolia Network = "sepolia" + + Polygon Network = "polygon" + PolygonAmoy Network = "amoy" ) +var MapNetworkToURL = map[Network]string{ + Mainnet: "https://api.etherscan.io/api?", + Sepolia: "https://api-sepolia.etherscan.io/api?", + Polygon: "https://api.polygonscan.com/api?", + PolygonAmoy: "https://api-amoy.polygonscan.com/api?", +} + // Network is ethereum network type (mainnet, ropsten, etc) type Network string