Skip to content

Commit

Permalink
fix urls (#76)
Browse files Browse the repository at this point in the history
* fix urls

* nit
  • Loading branch information
dhrubabasu authored Feb 2, 2022
1 parent 2928e42 commit 9b64b35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 1 addition & 5 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package client

import (
"context"
"fmt"
"math/big"
"strings"

Expand All @@ -16,8 +15,6 @@ import (
// Interface compliance
var _ Client = &client{}

const prefixEth = "/ext/bc/C/rpc"

type Client interface {
IsBootstrapped(context.Context, string) (bool, error)
ChainID(context.Context) (*big.Int, error)
Expand Down Expand Up @@ -51,9 +48,8 @@ type client struct {
// NewClient returns a new client for Avalanche APIs
func NewClient(endpoint string) (Client, error) {
endpoint = strings.TrimSuffix(endpoint, "/")
endpointURL := fmt.Sprintf("%s%s", endpoint, prefixEth)

eth, err := NewEthClient(endpointURL)
eth, err := NewEthClient(endpoint)
if err != nil {
return nil, err
}
Expand Down
8 changes: 6 additions & 2 deletions client/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package client

import (
"context"
"fmt"

"github.com/ava-labs/avalanchego/utils/rpc"
"github.com/ava-labs/coreth/ethclient"
Expand All @@ -10,6 +11,7 @@ import (

var (
tracerTimeout = "180s"
prefixEth = "/ext/bc/C/rpc"
)

// EthClient provides access to Coreth API
Expand All @@ -20,15 +22,17 @@ type EthClient struct {
}

// NewEthClient returns a new EVM client
func NewEthClient(endpointURL string) (*EthClient, error) {
func NewEthClient(endpoint string) (*EthClient, error) {
endpointURL := fmt.Sprintf("%s%s", endpoint, prefixEth)

c, err := ethclient.Dial(endpointURL)
if err != nil {
return nil, err
}

return &EthClient{
Client: c,
rpc: rpc.NewRPCRequester(endpointURL),
rpc: rpc.NewRPCRequester(endpoint),
traceConfig: &tracers.TraceConfig{
Timeout: &tracerTimeout,
Tracer: &jsTracer,
Expand Down

0 comments on commit 9b64b35

Please sign in to comment.