Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ethclient/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ type Client struct {
c *rpc.Client
}

// SimulateV1 calls the eth_simulateV1 RPC method.
func (ec *Client) SimulateV1(ctx context.Context, opts map[string]interface{}, blockParam string) (map[string]interface{}, error) {
var result map[string]interface{}
err := ec.c.CallContext(ctx, &result, "eth_simulateV1", opts, blockParam)
return result, err
}

// Dial connects a client to the given URL.
func Dial(rawurl string) (*Client, error) {
return DialContext(context.Background(), rawurl)
Expand Down
25 changes: 25 additions & 0 deletions ethclient/ethclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,3 +754,28 @@
// revert: 08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000a75736572206572726f72
// message: user error
}

// Test for SimulateV1
func TestSimulateV1(t *testing.T) {
client := ethclient.NewClient(rpc.DialContext)

Check failure on line 760 in ethclient/ethclient_test.go

View workflow job for this annotation

GitHub Actions / Lint

cannot use rpc.DialContext (value of type func(ctx context.Context, rawurl string) (*rpc.Client, error)) as *rpc.Client value in argument to ethclient.NewClient (typecheck)
opts := map[string]interface{}{
"traceTransfers": true,
"validation": true,
"blockStateCalls": []interface{}{
map[string]interface{}{
"calls": []interface{}{
map[string]interface{}{
"from": "0x...",
"to": "0x...",
"data": "0x...",
},
},
},
},
}
resp, err := client.SimulateV1(context.Background(), opts, "latest")
if err != nil {
t.Fatalf("SimulateV1 failed: %v", err)
}
t.Logf("Response: %+v", resp)
}
Loading