Skip to content

Commit 878b71a

Browse files
NewEtherscan created with corresponding apiKey (#260)
1 parent 68e48cf commit 878b71a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

etherscan/etherscan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func NewEtherscanFromNetwork(n ethgo.Network, apiKey string) (*Etherscan, error)
4242

4343
// NewEtherscan creates a new Etherscan service from a url
4444
func NewEtherscan(url, apiKey string) *Etherscan {
45-
return &Etherscan{url: url}
45+
return &Etherscan{url: url, apiKey: apiKey}
4646
}
4747

4848
type proxyResponse struct {

etherscan/etherscan_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ func testEtherscanMainnet(t *testing.T) *Etherscan {
1616
return &Etherscan{url: "https://api.etherscan.io", apiKey: apiKey}
1717
}
1818

19+
func TestNewEtherscan(t *testing.T) {
20+
wantUrl := "http://test.url/"
21+
wantApiKey := "abc123"
22+
e := NewEtherscan(wantUrl, wantApiKey)
23+
assert.Equal(t, wantUrl, e.url)
24+
assert.Equal(t, wantApiKey, e.apiKey)
25+
}
26+
1927
func TestBlockByNumber(t *testing.T) {
2028
e := testEtherscanMainnet(t)
2129
n, err := e.BlockNumber()

0 commit comments

Comments
 (0)