diff --git a/pkg/serve/api.go b/pkg/serve/api.go index 8cf3d43f..8d1177bc 100644 --- a/pkg/serve/api.go +++ b/pkg/serve/api.go @@ -20,6 +20,7 @@ import ( "context" "github.com/ethereum/go-ethereum/rpc" + "github.com/ethereum/go-ethereum/statediff/types" log "github.com/sirupsen/logrus" "github.com/vulcanize/ipld-eth-server/pkg/eth" @@ -33,13 +34,15 @@ const APIVersion = "0.0.1" // PublicServerAPI is the public api for the watcher type PublicServerAPI struct { - w Server + w Server + rpc *rpc.Client } // NewPublicServerAPI creates a new PublicServerAPI with the provided underlying Server process -func NewPublicServerAPI(w Server) *PublicServerAPI { +func NewPublicServerAPI(w Server, client *rpc.Client) *PublicServerAPI { return &PublicServerAPI{ - w: w, + w: w, + rpc: client, } } @@ -81,3 +84,13 @@ func (api *PublicServerAPI) Stream(ctx context.Context, params eth.SubscriptionS return rpcSub, nil } + +// WatchAddress makes a geth WatchAddress API call with the given operation and args +func (api *PublicServerAPI) WatchAddress(operation types.OperationType, args []types.WatchAddressArg) error { + err := api.rpc.Call(nil, "statediff_watchAddress", operation, args) + if err != nil { + return err + } + + return nil +} diff --git a/pkg/serve/service.go b/pkg/serve/service.go index 1704ea64..91606073 100644 --- a/pkg/serve/service.go +++ b/pkg/serve/service.go @@ -129,7 +129,7 @@ func (sap *Service) APIs() []rpc.API { { Namespace: APIName, Version: APIVersion, - Service: NewPublicServerAPI(sap), + Service: NewPublicServerAPI(sap, sap.client), Public: true, }, {