mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-01-09 12:58:06 +00:00
56 lines
1.2 KiB
TypeScript
56 lines
1.2 KiB
TypeScript
//
|
|
// Copyright 2021 Vulcanize, Inc.
|
|
//
|
|
|
|
import { gql } from '@apollo/client/core';
|
|
import { GraphQLClient, GraphQLConfig } from '@cerc-io/ipld-eth-client';
|
|
|
|
import { queryName, queryDecimals, queryTotalSupply, querySymbol } from './queries';
|
|
|
|
export class Client {
|
|
_config: GraphQLConfig;
|
|
_client: GraphQLClient;
|
|
|
|
constructor (config: GraphQLConfig) {
|
|
this._config = config;
|
|
|
|
this._client = new GraphQLClient(config);
|
|
}
|
|
|
|
async getSymbol (blockHash: string, token: string): Promise<any> {
|
|
const { symbol } = await this._client.query(
|
|
gql(querySymbol),
|
|
{ blockHash, token }
|
|
);
|
|
|
|
return symbol;
|
|
}
|
|
|
|
async getName (blockHash: string, token: string): Promise<any> {
|
|
const { name } = await this._client.query(
|
|
gql(queryName),
|
|
{ blockHash, token }
|
|
);
|
|
|
|
return name;
|
|
}
|
|
|
|
async getTotalSupply (blockHash: string, token: string): Promise<any> {
|
|
const { totalSupply } = await this._client.query(
|
|
gql(queryTotalSupply),
|
|
{ blockHash, token }
|
|
);
|
|
|
|
return totalSupply;
|
|
}
|
|
|
|
async getDecimals (blockHash: string, token: string): Promise<any> {
|
|
const { decimals } = await this._client.query(
|
|
gql(queryDecimals),
|
|
{ blockHash, token }
|
|
);
|
|
|
|
return decimals;
|
|
}
|
|
}
|