diff --git a/.eslintrc.js b/.eslintrc.js index 059ea29..f8c69a3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -54,13 +54,6 @@ module.exports = { }, }, ], - "prettier/prettier": [ - "error", - { - "singleQuote": true, - "trailingComma": "all", - "arrowParens": "avoid" - } - ] + "prettier/prettier": [ "error" ] }, }; diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..9be2883 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "arrowParens": "avoid" +} \ No newline at end of file diff --git a/src/modules/subgraph/graphql-client-adapter.service.ts b/src/modules/subgraph/graphql-client-adapter.service.ts index b704374..374d4fa 100644 --- a/src/modules/subgraph/graphql-client-adapter.service.ts +++ b/src/modules/subgraph/graphql-client-adapter.service.ts @@ -1,4 +1,5 @@ import { Injectable } from '@nestjs/common'; +import { ConfigService } from '@nestjs/config'; import axios from 'axios'; export type SubgraphBalanceChangeEntity = { @@ -12,6 +13,11 @@ export type SubgraphBalanceChangeEntity = { }; @Injectable() export class GraphqlClientAdapterService { + private origin; + constructor(readonly configService: ConfigService) { + this.origin = + this.configService.get('SUBGRAPH_DOMAIN') || 'https://giveth.io'; + } async getBalanceChanges(params: { subgraphUrl: string; contractAddress: string; @@ -56,7 +62,15 @@ export class GraphqlClientAdapterService { } `; - const result = await axios.post(subgraphUrl, { query }); + const result = await axios.post( + subgraphUrl, + { query }, + { + headers: { + Origin: this.origin, + }, + }, + ); const { balanceChanges, _meta } = result.data.data; return { balanceChanges, diff --git a/src/modules/subgraph/subgraph.module.ts b/src/modules/subgraph/subgraph.module.ts index e24abf3..f8475ad 100644 --- a/src/modules/subgraph/subgraph.module.ts +++ b/src/modules/subgraph/subgraph.module.ts @@ -1,9 +1,10 @@ import { Module } from '@nestjs/common'; +import { ConfigModule, ConfigService } from '@nestjs/config'; import { GraphqlClientAdapterService } from 'src/modules/subgraph/graphql-client-adapter.service'; @Module({ - imports: [], - providers: [GraphqlClientAdapterService], + imports: [ConfigModule], + providers: [GraphqlClientAdapterService, ConfigService], exports: [GraphqlClientAdapterService], }) export class SubgraphModule {}