Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove temporary mainnet RPC and subgraph environment variables #722

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ MIXPANEL_LOG=
MIXPANEL_ENV=
MIXPANEL_KEY=
NEXT_PUBLIC_MIXPANEL_KEY=
TEMPORARY_MAINNET_SUBGRAPH=
TEMPORARY_MAINNET_RPC=
# disables the swap widget (empty component) to speed up dev
NEXT_PUBLIC_SWAP_WIDGET_ONBOARDING_HIDDEN=
# disables all but metamask wallets to speed up dev
Expand Down
7 changes: 2 additions & 5 deletions apps/earn-protocol/app/api/rpcGateway/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NetworkNames } from '@summerfi/app-types'
import { type NetworkNames } from '@summerfi/app-types'
import { type NextRequest, NextResponse } from 'next/server'

import { REVALIDATION_TIMES } from '@/constants/revalidations'
Expand All @@ -17,10 +17,7 @@ export async function POST(req: NextRequest) {
}

const networkName = networkQuery.toString() as NetworkNames
const rpcGatewayUrl =
networkName === NetworkNames.ethereumMainnet && process.env.TEMPORARY_MAINNET_RPC
? process.env.TEMPORARY_MAINNET_RPC
: await getRpcGatewayUrl(networkName)
const rpcGatewayUrl = await getRpcGatewayUrl(networkName)

marcinciarka marked this conversation as resolved.
Show resolved Hide resolved
if (!rpcGatewayUrl) {
return NextResponse.json({ error: 'Invalid network or RPC Config is missing' }, { status: 400 })
Expand Down
38 changes: 16 additions & 22 deletions apps/earn-protocol/app/server-handlers/position-history/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,27 @@ export async function getPositionHistory({ network, address, vault }: GetPositio
},
})

const clients = {
[SDKNetwork.Mainnet]: new GraphQLClient(
process.env.TEMPORARY_MAINNET_SUBGRAPH
? process.env.TEMPORARY_MAINNET_SUBGRAPH
: `${process.env.SUBGRAPH_BASE}/summer-protocol`,
{
fetch: customFetchCache,
},
),
[SDKNetwork.Base]: new GraphQLClient(`${process.env.SUBGRAPH_BASE}/summer-protocol-base`, {
fetch: customFetchCache,
}),
[SDKNetwork.ArbitrumOne]: new GraphQLClient(
`${process.env.SUBGRAPH_BASE}/summer-protocol-arbitrum`,
{
fetch: customFetchCache,
},
),
}

const isProperNetwork = (net: string): net is keyof typeof clients => net in clients
const subgraphsMap = process.env.NEXT_PUBLIC_IS_PRE_LAUNCH_VERSION
? {
[SDKNetwork.Mainnet]: `${process.env.SUBGRAPH_BASE}/summer-protocol`,
[SDKNetwork.Base]: `${process.env.SUBGRAPH_BASE}/summer-protocol-base`,
[SDKNetwork.ArbitrumOne]: `${process.env.SUBGRAPH_BASE}/summer-protocol-arbitrum`,
}
: {
[SDKNetwork.Mainnet]: `${process.env.SUBGRAPH_BASE}/summer-protocol/version/1.0.0-test-deployment/api`,
[SDKNetwork.Base]: `${process.env.SUBGRAPH_BASE}/summer-protocol-base/version/1.0.0-test-deployment/api`,
[SDKNetwork.ArbitrumOne]: `${process.env.SUBGRAPH_BASE}/summer-protocol-arbitrum/version/1.0.0-test-deployment/api`,
}

const isProperNetwork = (net: string): net is keyof typeof subgraphsMap => net in subgraphsMap

if (!isProperNetwork(network)) {
throw new Error(`getPositionHistory: No endpoint found for network: ${network}`)
}

const networkGraphQlClient = clients[network as keyof typeof clients]
const networkGraphQlClient = new GraphQLClient(subgraphsMap[SDKNetwork.ArbitrumOne], {
fetch: customFetchCache,
})
const request = await networkGraphQlClient.request<GetPositionHistoryQuery>(
GetPositionHistoryDocument,
{
Expand Down
4 changes: 0 additions & 4 deletions apps/earn-protocol/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ ARG FUNCTIONS_API_URL \
CONFIG_URL_RAYS \
EARN_MIXPANEL_KEY \
SUBGRAPH_BASE \
TEMPORARY_MAINNET_SUBGRAPH \
TEMPORARY_MAINNET_RPC \
NEXT_PUBLIC_EARN_MIXPANEL_KEY \
SDK_API_URL \
ACCOUNT_KIT_API_KEY \
Expand Down Expand Up @@ -48,8 +46,6 @@ ENV FUNCTIONS_API_URL=$FUNCTIONS_API_URL \
CONFIG_URL_RAYS=$CONFIG_URL_RAYS \
EARN_MIXPANEL_KEY=$EARN_MIXPANEL_KEY \
SUBGRAPH_BASE=$SUBGRAPH_BASE \
TEMPORARY_MAINNET_SUBGRAPH=$TEMPORARY_MAINNET_SUBGRAPH \
TEMPORARY_MAINNET_RPC=$TEMPORARY_MAINNET_RPC \
NEXT_PUBLIC_EARN_MIXPANEL_KEY=$NEXT_PUBLIC_EARN_MIXPANEL_KEY \
SDK_API_URL=$SDK_API_URL \
ACCOUNT_KIT_API_KEY=$ACCOUNT_KIT_API_KEY \
Expand Down
2 changes: 0 additions & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"globalDependencies": ["**/.env.*local"],
"globalEnv": [
"SUBGRAPH_BASE",
"TEMPORARY_MAINNET_SUBGRAPH",
"TEMPORARY_MAINNET_RPC",
"DEBANK_API_KEY",
"DEBANK_API_URL",
"RPC_GATEWAY",
Expand Down
Loading