import { Injectable } from '@nestjs/common'; import { request, gql } from 'graphql-request'; import { AccountInfo } from '../types/everscale.types'; import { InitEverscaleClientParams } from './everscale-client.base.service'; @Injectable() export class EverscaleAccountInfoService { EVERSCALE_API_URL: string | undefined; init({ everscaleClientConfig }: InitEverscaleClientParams) { if (!everscaleClientConfig?.everscaleApiUrl) { throw new Error(`Everscale client configuration is invalid!`); } this.EVERSCALE_API_URL = everscaleClientConfig.everscaleApiUrl; } public async getAccountInfo(address: string): Promise { const query = gql` query { blockchain { account(address: "${address}") { info { address acc_type balance last_paid last_trans_lt boc data code library data_hash code_hash library_hash } } } } `; const res = await request<{ blockchain: { account: { info: AccountInfo } } }>({ url: this.EVERSCALE_API_URL!, document: query, }); return res.blockchain.account.info; } }