diff --git a/client.go b/client.go index 2e842eb..dc42968 100644 --- a/client.go +++ b/client.go @@ -52,7 +52,17 @@ func (c *Client) getKey() string { // New initialize a new etherscan API client // please use pre-defined network value -func New(network Network, APIKeys []string) *Client { +func New(network Network, APIKeys string) *Client { + return NewCustomized(Customization{ + Timeout: 30 * time.Second, + Keys: []string{APIKeys}, + BaseURL: fmt.Sprintf(`https://%s.etherscan.io/api?`, network.SubDomain()), + }) +} + +// New initialize a new etherscan API client +// please use pre-defined network value +func NewMultiKey(network Network, APIKeys []string) *Client { return NewCustomized(Customization{ Timeout: 30 * time.Second, Keys: APIKeys, diff --git a/client_test.go b/client_test.go index 4f34b1f..a8d045c 100644 --- a/client_test.go +++ b/client_test.go @@ -12,7 +12,7 @@ import ( ) func TestClient_craftURL(t *testing.T) { - c := New(Ropsten, []string{"abc123"}) + 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{ diff --git a/go.mod b/go.mod index db8ee5b..5837de6 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/NFEL/etherscan-api-multikey +module github.com/nanmu42/etherscan-api go 1.13 diff --git a/setup_e2e_test.go b/setup_e2e_test.go index 3573d26..c262e8f 100644 --- a/setup_e2e_test.go +++ b/setup_e2e_test.go @@ -41,7 +41,8 @@ func init() { } bucket = NewBucket(500 * time.Millisecond) - api = New(Mainnet, []string{apiKey, backupApiKey}) + api = New(Mainnet, apiKey) + api = NewMultiKey(Mainnet, []string{apiKey, backupApiKey}) api.Verbose = true api.BeforeRequest = func(module string, action string, param map[string]interface{}) error { bucket.Take()