Skip to content

Commit

Permalink
add chains and update imports
Browse files Browse the repository at this point in the history
  • Loading branch information
samepant committed Jan 2, 2024
1 parent f0215d8 commit dd376bb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
22 changes: 21 additions & 1 deletion frontend/src/chains.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { SequenceIndexerServices } from "@0xsequence/indexer"
import {
mainnet,
goerli,
Expand All @@ -25,6 +24,27 @@ export type ChainId = keyof typeof CHAINS

export const DEFAULT_CHAIN = CHAINS[5]

export enum SequenceIndexerServices {
MAINNET = "https://mainnet-indexer.sequence.app",

POLYGON = "https://polygon-indexer.sequence.app",
POLYGON_MUMBAI = "https://mumbai-indexer.sequence.app",

POLYGON_ZKEVM = "https://polygon-zkevm-indexer.sequence.app",

ARBITRUM = "https://arbitrum-indexer.sequence.app",
ARBITRUM_NOVA = "https://arbitrum-nova-indexer.sequence.app",

OPTIMISM = "https://optimism-indexer.sequence.app",
AVALANCHE = "https://avalanche-indexer.sequence.app",
GNOSIS = "https://gnosis-indexer.sequence.app",

BSC = "https://bsc-indexer.sequence.app",
BSC_TESTNET = "https://bsc-testnet-indexer.sequence.app",

GOERLI = "https://goerli-indexer.sequence.app",
}

export const SEQUENCER_ENDPOINTS: Record<ChainId, SequenceIndexerServices> = {
1: SequenceIndexerServices.MAINNET,
5: SequenceIndexerServices.GOERLI,
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/hooks/useTokenBalances.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
SequenceIndexerClient,
SequenceIndexer,
TokenBalance,
ContractType,
} from "@0xsequence/indexer"
Expand All @@ -13,6 +13,8 @@ interface Props {
tokenId?: string
}

const API_KEY = process.env.REACT_APP_SEQUENCE_API_KEY || ""

const useTokenBalances = ({
accountAddress,
chainId,
Expand All @@ -24,8 +26,9 @@ const useTokenBalances = ({
const [error, setError] = useState<any>(null)

useEffect(() => {
const indexer = new SequenceIndexerClient(
SEQUENCER_ENDPOINTS[chainId as ChainId]
const indexer = new SequenceIndexer(
SEQUENCER_ENDPOINTS[chainId as ChainId],
API_KEY
)
const fetchData = async () => {
try {
Expand Down

0 comments on commit dd376bb

Please sign in to comment.