Skip to content

Commit

Permalink
feat: update apps
Browse files Browse the repository at this point in the history
  • Loading branch information
wellitongervickas committed Dec 8, 2023
1 parent 3f935fd commit fbebc03
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 31 deletions.
7 changes: 3 additions & 4 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ NEXT_PUBLIC_NETWORK_DEFAULT_ID="43113"

# network http rpcs
NEXT_PUBLIC_NETWORK_43113_HTTP_RPC=""
NEXT_PUBLIC_NETWORK_420_HTTP_RPC=""
NEXT_PUBLIC_NETWORK_80001_HTTP_RPC=""

# network wss rpcs
NEXT_PUBLIC_NETWORK_43113_WS_RPC=""
NEXT_PUBLIC_NETWORK_420_WS_RPC=""

NEXT_PUBLIC_NETWORK_80001_WS_RPC=""

#subgraphs
NEXT_PUBLIC_NETWORK_43113_SUBGRAPH=""
NEXT_PUBLIC_NETWORK_420_SUBGRAPH=""
NEXT_PUBLIC_NETWORK_80001_SUBGRAPH=""

2 changes: 1 addition & 1 deletion app/[locale]/apps/components/list/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const List = ({ apps, ...props }: ListProps) => {
return (
<ul className='grid grid-cols-4 gap-6' {...props}>
{apps.length === 0 ? (
<li>{t('FEEDBACK.NO_APPS_FOUND')}</li>
<li className='col-span-4'>{t('FEEDBACK.NO_APPS_FOUND')}</li>
) : (
<>
{Children.toArray(
Expand Down
18 changes: 9 additions & 9 deletions app/config/chains.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { avalancheFuji, optimismGoerli } from 'wagmi/chains'
import { avalancheFuji, polygonMumbai } from 'wagmi/chains'
import { merge } from 'lodash'
import { Chain } from './types'

Expand Down Expand Up @@ -31,30 +31,30 @@ export const avalancheFujiChain: Chain = merge(avalancheFuji, {
}
})

export const optimismGoerliChain: Chain = merge(optimismGoerli, {
export const polygonMumbaiChain: Chain = merge(polygonMumbai, {
blockExplorers: {
thegraph: {
name: 'crosschain-nft-ccip-v2-optimis',
url: process.env.NEXT_PUBLIC_NETWORK_420_SUBGRAPH!
name: 'crosschain-nft-ccip-v2',
url: process.env.NEXT_PUBLIC_NETWORK_80001_SUBGRAPH!
}
},
rpcUrls: {
protocol: {
http: [process.env.NEXT_PUBLIC_NETWORK_420_HTTP_RPC!],
websocket: [process.env.NEXT_PUBLIC_NETWORK_420_WS_RPC!]
http: [process.env.NEXT_PUBLIC_NETWORK_80001_HTTP_RPC!],
websocket: [process.env.NEXT_PUBLIC_NETWORK_80001_WS_RPC!]
}
},
contracts: {
accessManagement: {
address: '0x483E5D5a59EeB5dB9c2AAC502Da40fab173b8DF2',
address: '0xBbd6d4dC3BF45fdbc286a01916eb7611b727957c',
blockCreated: 0
},
hub: {
address: '0x27aAd1692fD0F11C39c69c5412E52cCEf15045BD',
address: '0xE69cEa099bde1f729a13C4D9eD41E0E6C5b8873b',
blockCreated: 0
},
ccipCrossChainBridge: {
address: '0x99302F8a76B6668F54D7eE16E035d948305ACeE1',
address: '0xC6E1156D6047E7980e3c581d5c16c979b8406467',
blockCreated: 0
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/config/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { reduce } from 'lodash'
import { avalancheFujiChain, optimismGoerliChain } from './chains'
import { avalancheFujiChain, polygonMumbaiChain } from './chains'
import { Chain } from './types'

export const allowedChains = [avalancheFujiChain, optimismGoerliChain]
export const allowedChains = [avalancheFujiChain, polygonMumbaiChain]

export const allowedChainsConfig = reduce(
allowedChains,
Expand Down
22 changes: 7 additions & 15 deletions app/headless/thegraph/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,23 @@ import { allowedChains, allowedChainsConfig } from '@/app/config/config'
import { reduce } from 'lodash'
import { Chain } from '@/app/config/types'

// Default client based on environment variable
const defaultClient: keyof typeof clients =
+process.env.NEXT_PUBLIC_NETWORK_DEFAULT_ID!

const clients = reduce(
allowedChains,
(acc, chain: Chain) => {
const API_URL = allowedChainsConfig[chain.id].blockExplorers.thegraph.url
acc[chain.id] = new HttpLink({ uri: API_URL })
return acc
},
{} as Record<keyof typeof allowedChains, HttpLink>
{} as Record<keyof typeof allowedChainsConfig, HttpLink>
)

// Default client based on environment variable
const defaultClient: keyof typeof clients =
+process.env.NEXT_PUBLIC_NETWORK_DEFAULT_ID!

// Function to create a link for a specific client
const createClientLink = (chainId: keyof typeof clients): ApolloLink => {
return new ApolloLink((operation, forward) =>
clients[chainId].request(operation, forward)
)
}

// Create a link that resolves the appropriate client based on the operation context
const httpLink = new ApolloLink((operation, forward) => {
const chainId = operation.getContext().chainId || defaultClient.toString()
return createClientLink(chainId).request(operation, forward)
const chainId = operation.getContext().chainId || +defaultClient
return clients[chainId].request(operation, forward)
})

const retryLink = new RetryLink({
Expand Down

0 comments on commit fbebc03

Please sign in to comment.