Skip to content

Commit 2c77010

Browse files
authored
Merge pull request #1 from NFEL/myrepo
Myrepo
2 parents 217c1e2 + f0fcbd0 commit 2c77010

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

client.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,17 @@ func (c *Client) getKey() string {
5252

5353
// New initialize a new etherscan API client
5454
// 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 {
5666
return NewCustomized(Customization{
5767
Timeout: 30 * time.Second,
5868
Keys: APIKeys,

client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
func TestClient_craftURL(t *testing.T) {
15-
c := New(Ropsten, []string{"abc123"})
15+
c := New(Ropsten, "abc123")
1616

1717
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`
1818
output := c.craftURL("testing", "craftURL", M{

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/nanmu42/etherscan-api
1+
module github.com/NFEL/etherscan-api-multikey
22

33
go 1.13
44

setup_e2e_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ func init() {
4141
}
4242
bucket = NewBucket(500 * time.Millisecond)
4343

44-
api = New(Mainnet, []string{apiKey, backupApiKey})
44+
api = New(Mainnet, apiKey)
45+
api = NewMultiKey(Mainnet, []string{apiKey, backupApiKey})
4546
api.Verbose = true
4647
api.BeforeRequest = func(module string, action string, param map[string]interface{}) error {
4748
bucket.Take()

0 commit comments

Comments
 (0)