Skip to content

Commit f0fcbd0

Browse files
committed
Fixed Broken Method of New -> NewMultiKey [Added]
1 parent f644dc7 commit f0fcbd0

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
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{

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)