Skip to content

Commit

Permalink
Examples use useIndexerClient
Browse files Browse the repository at this point in the history
  • Loading branch information
corbanbrook committed Apr 29, 2024
1 parent 671bf71 commit 4dca70c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 2 additions & 8 deletions examples/next/src/app/components/Connected.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ import {
import { Header } from './Header'
import { delay } from '@/utils'
import { formatUnits, parseUnits } from 'viem'
import {
getNetworkConfigAndClients,
signEthAuthProof,
useOpenConnectModal,
useWaasFeeOptions,
validateEthProof
} from '@0xsequence/kit'
import { signEthAuthProof, useIndexerClient, useOpenConnectModal, useWaasFeeOptions, validateEthProof } from '@0xsequence/kit'
import { useOpenWalletModal } from '@0xsequence/kit-wallet'
import { useCheckoutModal, CheckoutSettings } from '@0xsequence/kit-checkout'
import { ConnectionMode, isDebugMode } from '../config'
Expand Down Expand Up @@ -66,7 +60,7 @@ export const Connected = () => {

const chainId = useChainId()

const { indexerClient } = getNetworkConfigAndClients(chainId)
const indexerClient = useIndexerClient(chainId)

const [feeOptionBalances, setFeeOptionBalances] = useState<{ tokenName: string; decimals: number; balance: string }[]>([])

Expand Down
4 changes: 2 additions & 2 deletions examples/react/src/components/Homepage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
validateEthProof,
useTheme as useKitTheme,
useWaasFeeOptions,
getNetworkConfigAndClients
useIndexerClient
} from '@0xsequence/kit'
import { useOpenWalletModal } from '@0xsequence/kit-wallet'
import { useCheckoutModal } from '@0xsequence/kit-checkout'
Expand Down Expand Up @@ -99,7 +99,7 @@ export const Homepage = () => {

const chainId = useChainId()

const { indexerClient } = getNetworkConfigAndClients(chainId)
const indexerClient = useIndexerClient(chainId)

const [feeOptionBalances, setFeeOptionBalances] = React.useState<{ tokenName: string; decimals: number; balance: string }[]>([])

Expand Down
8 changes: 7 additions & 1 deletion packages/kit/src/hooks/useIndexerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ export const useIndexerClient = (chainId: ChainId) => {
indexerClients.set(chainId, new SequenceIndexer(indexerURL(network.name), projectAccessKey))
}

return indexerClients.get(chainId)
const indexerClient = indexerClients.get(chainId)

if (!indexerClient) {
throw new Error('Indexer client not found')
}

return indexerClient
}

0 comments on commit 4dca70c

Please sign in to comment.