File tree Expand file tree Collapse file tree 4 files changed +15
-4
lines changed Expand file tree Collapse file tree 4 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,17 @@ func (c *Client) getKey() string {
52
52
53
53
// New initialize a new etherscan API client
54
54
// please use pre-defined network value
55
- func New (network Network , APIKeys []string ) * Client {
55
+ func New (network Network , APIKeys string ) * Client {
56
+ return NewCustomized (Customization {
57
+ Timeout : 30 * time .Second ,
58
+ Keys : []string {APIKeys },
59
+ BaseURL : fmt .Sprintf (`https://%s.etherscan.io/api?` , network .SubDomain ()),
60
+ })
61
+ }
62
+
63
+ // New initialize a new etherscan API client
64
+ // please use pre-defined network value
65
+ func NewMultiKey (network Network , APIKeys []string ) * Client {
56
66
return NewCustomized (Customization {
57
67
Timeout : 30 * time .Second ,
58
68
Keys : APIKeys ,
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import (
12
12
)
13
13
14
14
func TestClient_craftURL (t * testing.T ) {
15
- c := New (Ropsten , [] string { "abc123" } )
15
+ c := New (Ropsten , "abc123" )
16
16
17
17
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`
18
18
output := c .craftURL ("testing" , "craftURL" , M {
Original file line number Diff line number Diff line change 1
- module github.com/nanmu42 /etherscan-api
1
+ module github.com/NFEL /etherscan-api-multikey
2
2
3
3
go 1.13
4
4
Original file line number Diff line number Diff line change @@ -41,7 +41,8 @@ func init() {
41
41
}
42
42
bucket = NewBucket (500 * time .Millisecond )
43
43
44
- api = New (Mainnet , []string {apiKey , backupApiKey })
44
+ api = New (Mainnet , apiKey )
45
+ api = NewMultiKey (Mainnet , []string {apiKey , backupApiKey })
45
46
api .Verbose = true
46
47
api .BeforeRequest = func (module string , action string , param map [string ]interface {}) error {
47
48
bucket .Take ()
You can’t perform that action at this time.
0 commit comments