|
1 |
| -import request from 'graphql-request' |
| 1 | +import type { ConfigQuery, ConfigQueryVariables } from 'graphql' |
| 2 | +import request, { gql } from 'graphql-request' |
2 | 3 | import { LRUCache } from 'lru-cache'
|
3 | 4 | import { createContext } from 'react'
|
4 | 5 | import invariant from 'ts-invariant'
|
5 | 6 | import {
|
| 7 | + Chain, |
6 | 8 | arbitrum,
|
7 | 9 | arbitrumSepolia,
|
8 | 10 | bsc,
|
9 | 11 | bscTestnet,
|
10 |
| - Chain, |
11 | 12 | mainnet as ethereumMainnet,
|
12 | 13 | sepolia as ethereumSepolia,
|
13 | 14 | neonDevnet,
|
@@ -180,23 +181,25 @@ const cache = new LRUCache({
|
180 | 181 | : 0, // no ttl, user need to refresh the page
|
181 | 182 | fetchMethod: async (key: string) => {
|
182 | 183 | invariant(key === 'config', 'Invalid key')
|
183 |
| - const { config } = await request<{ config: RemoteConfig }>( |
| 184 | + const { config } = await request<ConfigQuery, ConfigQueryVariables>( |
184 | 185 | `${
|
185 | 186 | process.env.NEXT_PUBLIC_LITEFLOW_BASE_URL || 'https://api.liteflow.com'
|
186 | 187 | }/${process.env.NEXT_PUBLIC_LITEFLOW_API_KEY}/graphql`,
|
187 |
| - `query Config { |
188 |
| - config { |
189 |
| - name |
190 |
| - hasLazyMint |
191 |
| - maxRoyaltiesPerTenThousand |
192 |
| - offerValiditySeconds |
193 |
| - metadata |
| 188 | + gql` |
| 189 | + query Config { |
| 190 | + config { |
| 191 | + name |
| 192 | + hasLazyMint |
| 193 | + maxRoyaltiesPerTenThousand |
| 194 | + offerValiditySeconds |
| 195 | + metadata |
| 196 | + } |
194 | 197 | }
|
195 |
| - }`, |
| 198 | + `, |
196 | 199 | undefined,
|
197 | 200 | [['origin', process.env.NEXT_PUBLIC_BASE_URL || '']],
|
198 | 201 | )
|
199 |
| - return config |
| 202 | + return config satisfies RemoteConfig |
200 | 203 | },
|
201 | 204 | })
|
202 | 205 |
|
|
0 commit comments