Skip to content

Commit

Permalink
Merge PR: add ethclient (#139)
Browse files Browse the repository at this point in the history
* add evmclient.ethclient

* add ethclient.go

* keep same with master

* add rpc interface

* fix callContext

* fix code rule

* rename main() in sample

* del unusable code

* wrapped rpcClient

* fix sample

* move samples
  • Loading branch information
chengzhinei authored Jul 7, 2021
1 parent 87a4af6 commit 0b39da9
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 41 deletions.
23 changes: 23 additions & 0 deletions ethclient.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package gosdk

import (
"context"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/rpc"
)

type rpcClient struct {
*rpc.Client
}

type ethClient struct {
*ethclient.Client
*rpcClient
}
func NewEthClient(ctx context.Context, rawurl string) (*ethClient, error) {
c, err := rpc.DialContext(ctx, rawurl)
if err != nil {
return nil, err
}
return &ethClient{ethclient.NewClient(c), &rpcClient{c}}, nil
}
Loading

0 comments on commit 0b39da9

Please sign in to comment.