From f58ac63c5a107b1eb8cc2ae59366cad470bf2a0b Mon Sep 17 00:00:00 2001 From: franz Date: Fri, 8 Dec 2023 12:57:56 +0100 Subject: [PATCH] chain param optional --- modules/beethoven/balancer-sdk.gql | 2 +- modules/beethoven/balancer-sdk.resolvers.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/beethoven/balancer-sdk.gql b/modules/beethoven/balancer-sdk.gql index a2d9e8d26..161c685a7 100644 --- a/modules/beethoven/balancer-sdk.gql +++ b/modules/beethoven/balancer-sdk.gql @@ -1,6 +1,6 @@ extend type Query { sorGetSwaps( - chain: GqlChain! + chain: GqlChain tokenIn: String! tokenOut: String! swapType: GqlSorSwapType! diff --git a/modules/beethoven/balancer-sdk.resolvers.ts b/modules/beethoven/balancer-sdk.resolvers.ts index ccedce89b..cab3456ca 100644 --- a/modules/beethoven/balancer-sdk.resolvers.ts +++ b/modules/beethoven/balancer-sdk.resolvers.ts @@ -4,10 +4,18 @@ import { tokenService } from '../token/token.service'; import { sorService } from '../sor/sor.service'; import { getTokenAmountHuman } from '../sor/utils'; import { GraphTraversalConfig } from '../sor/types'; +import { headerChain } from '../context/header-chain'; const balancerSdkResolvers: Resolvers = { Query: { sorGetSwaps: async (parent, args, context) => { + const currentChain = headerChain(); + if (!args.chain && currentChain) { + args.chain = currentChain; + } else if (!args.chain) { + throw new Error('poolGetPool error: Provide "chain" param'); + } + const chain = args.chain; const tokenIn = args.tokenIn.toLowerCase(); const tokenOut = args.tokenOut.toLowerCase(); const amountToken = args.swapType === 'EXACT_IN' ? tokenIn : tokenOut; @@ -18,6 +26,7 @@ const balancerSdkResolvers: Resolvers = { const swaps = await sorService.getBeetsSwaps({ ...args, + chain, tokenIn, tokenOut, graphTraversalConfig,