Skip to content

Commit c44a816

Browse files
committed
feat: changes to network config, more complex scenario
1 parent c3d0400 commit c44a816

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
type Client struct {
2424
coon *http.Client
2525
key string
26+
network Network
2627
baseURL string
2728

2829
// Verbose when true, talks a lot

network.go

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,37 @@
77

88
package etherscan
99

10-
const (
11-
// // Ethereum public networks
12-
10+
var (
1311
// EthMainnet Ethereum mainnet for production
14-
EthMainnet Network = "https://api.etherscan.io/api?"
12+
EthMainnet Network = Network{"Ethereum", "main", "https://api.etherscan.io/api?"}
1513
// EthRopsten Testnet(POW)
16-
EthRopsten Network = "https://api-ropsten.etherscan.io/api?"
14+
EthRopsten Network = Network{"Ethereum Ropsten", "test", "https://api-ropsten.etherscan.io/api?"}
1715
// EthKovan Testnet(POA)
18-
EthKovan Network = "https://api-kovan.etherscan.io/api?"
16+
EthKovan Network = Network{"Ethereum Kovan", "test", "https://api-kovan.etherscan.io/api?"}
1917
// EthRinkby Testnet(CLIQUE)
20-
EthRinkby Network = "https://api-rinkeby.etherscan.io/api?"
18+
EthRinkby Network = Network{"Ethereum Rinkby", "test", "https://api-rinkeby.etherscan.io/api?"}
2119
// EthGoerli Testnet(CLIQUE)
22-
EthGoerli Network = "https://api-goerli.etherscan.io/api?"
20+
EthGoerli Network = Network{"Ethereum Goerli", "test", "https://api-goerli.etherscan.io/api?"}
2321
// EthTobalaba Testnet
24-
EthTobalaba Network = "https://api-tobalaba.etherscan.io/api?"
22+
EthTobalaba Network = Network{"Ethereum Tobalaba", "test", "https://api-tobalaba.etherscan.io/api?"}
2523
// MaticMainnet Matic mainnet for production
26-
MaticMainnet Network = "https://api.polygonscan.com/api?"
24+
MaticMainnet Network = Network{"Polygon", "main", "https://api.polygonscan.com/api?"}
2725
// MaticTestnet Matic testnet for development
28-
MaticTestnet Network = "https://api-testnet.polygonscan.com/api?"
26+
MaticTestnet Network = Network{"Polygon Mumbai", "test", "https://api-testnet.polygonscan.com/api?"}
2927
// BscMainnet Bsc mainnet for production
30-
BscMainnet Network = "https://api.bscscan.com/api?"
28+
BscMainnet Network = Network{"Binance", "main", "https://api.bscscan.com/api?"}
3129
// BscTestnet Bsc testnet for development
32-
BscTestnet Network = "https://api-testnet.bscscan.com/api?"
30+
BscTestnet Network = Network{"Binance test", "test", "https://api-testnet.bscscan.com/api?"}
3331
)
3432

3533
// Network is ethereum network type (mainnet, ropsten, etc)
36-
type Network string
34+
type Network struct {
35+
Name string
36+
Type string
37+
BaseURL string
38+
}
3739

38-
// SubDomain returns the subdomain of etherscan API
39-
// via n provided.
40+
// Domain returns the subdomain of etherscan API via n provided.
4041
func (n Network) Domain() (sub string) {
41-
return string(n)
42+
return n.BaseURL
4243
}

0 commit comments

Comments
 (0)