Skip to content

Commit

Permalink
fix: Use custom query when passed. Update broken tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
johngrantuk committed Jul 5, 2024
1 parent 9c4e62d commit 8e9d8de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// yarn test:only ./src/modules/data/liquidity-gauges/multicall.spec.ts
import { expect } from 'chai';
import { JsonRpcProvider } from '@ethersproject/providers';
import { Zero } from '@ethersproject/constants';
Expand Down Expand Up @@ -65,7 +66,7 @@ describe('Liquidity gauge multicall', () => {
const fetcher = new LiquidityGaugesMulticallRepository(multicall, 1);

const gauges = new LiquidityGaugesSubgraphRepository(
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gauges'
'https://api.studio.thegraph.com/query/75376/balancer-gauges/version/latest'
);

let gaugeAddresses: string[];
Expand Down
5 changes: 4 additions & 1 deletion balancer-js/src/modules/data/pool/subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class PoolsSubgraphRepository
public skip = 0;
private blockHeight: undefined | (() => Promise<number | undefined>);
private query: GraphQLQuery;
private isCustomQuery: boolean;

/**
* Repository with optional lazy loaded blockHeight
Expand All @@ -60,7 +61,7 @@ export class PoolsSubgraphRepository
},
},
};

this.isCustomQuery = !!options.query;
const args = Object.assign({}, options.query?.args || defaultArgs);
const attrs = Object.assign({}, options.query?.attrs || {});

Expand Down Expand Up @@ -128,6 +129,8 @@ export class PoolsSubgraphRepository
* @returns
*/
async find(id: string, refresh = false): Promise<Pool | undefined> {
if(this.isCustomQuery)

Check failure on line 132 in balancer-js/src/modules/data/pool/subgraph.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `(this.isCustomQuery)⏎·····` with `·(this.isCustomQuery)`
return await this.findBy('id', id);
// If we're not refreshing and the pool exists in caches then return
if (!refresh && this.pools) {
const cachedPool = (await this.pools).find((pool) => pool.id === id);
Expand Down
3 changes: 2 additions & 1 deletion balancer-js/src/modules/pools/apr/apr.integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const usdStable =
const auraBALveBAL =
'0x3dd0843a028c86e0b760b1a76929d1c5ef93a2dd000200000000000000000249';

describe('APR tests', () => {
// APRs are offered via API now

Check failure on line 26 in balancer-js/src/modules/pools/apr/apr.integration.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
describe.skip('APR tests', () => {
describe('pool with yield tokens', () => {
it('has tokenAprs', async () => {
const pool = await pools.find(ethStEth);
Expand Down

0 comments on commit 8e9d8de

Please sign in to comment.