mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-02-03 00:32:49 +00:00
a7ec3d8da8
* Add license & copyright declarations for add-watcher. * Add copyright declarations for cache. * Add copyright declarations for erc20-watcher. * Add copyright declarations for ipld-eth-client. * Add copyright declarations for tracing-client. * Add copyright declarations for uni-watcher. * Add copyright declarations for solidity-mapper. * Add copyright declarations for uni-info-watcher. * Add copyright declarations for util. * Add copyright declarations for lighthouse-watcher. * Change license identifier in .sol files. Co-authored-by: prathamesh0 <prathamesh.musale0@gmail.com>
29 lines
626 B
TypeScript
29 lines
626 B
TypeScript
//
|
|
// Copyright 2021 Vulcanize, Inc.
|
|
//
|
|
|
|
import { gql } from '@apollo/client/core';
|
|
import { GraphQLClient, GraphQLConfig } from '@vulcanize/ipld-eth-client';
|
|
|
|
import { subscribeEvents } from './queries';
|
|
|
|
export class Client {
|
|
_config: GraphQLConfig;
|
|
_client: GraphQLClient;
|
|
|
|
constructor (config: GraphQLConfig) {
|
|
this._config = config;
|
|
|
|
this._client = new GraphQLClient(config);
|
|
}
|
|
|
|
async watchEvents (onNext: (value: any) => void): Promise<ZenObservable.Subscription> {
|
|
return this._client.subscribe(
|
|
gql(subscribeEvents),
|
|
({ data }) => {
|
|
onNext(data.onEvent);
|
|
}
|
|
);
|
|
}
|
|
}
|