Skip to content

Commit

Permalink
NewEtherscan created with corresponding apiKey (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
arturo-source committed Mar 12, 2024
1 parent 68e48cf commit 878b71a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion etherscan/etherscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewEtherscanFromNetwork(n ethgo.Network, apiKey string) (*Etherscan, error)

// NewEtherscan creates a new Etherscan service from a url
func NewEtherscan(url, apiKey string) *Etherscan {
return &Etherscan{url: url}
return &Etherscan{url: url, apiKey: apiKey}
}

type proxyResponse struct {
Expand Down
8 changes: 8 additions & 0 deletions etherscan/etherscan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ func testEtherscanMainnet(t *testing.T) *Etherscan {
return &Etherscan{url: "https://api.etherscan.io", apiKey: apiKey}
}

func TestNewEtherscan(t *testing.T) {
wantUrl := "http://test.url/"
wantApiKey := "abc123"
e := NewEtherscan(wantUrl, wantApiKey)
assert.Equal(t, wantUrl, e.url)
assert.Equal(t, wantApiKey, e.apiKey)
}

func TestBlockByNumber(t *testing.T) {
e := testEtherscanMainnet(t)
n, err := e.BlockNumber()
Expand Down

0 comments on commit 878b71a

Please sign in to comment.