Skip to content

Conversation

brtkx
Copy link
Contributor

@brtkx brtkx commented Jun 25, 2025

No description provided.

@cla-bot cla-bot bot added the cla-signed label Jun 25, 2025
Copy link

vercel bot commented Jun 25, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
arbitrum-token-bridge Error Error Sep 3, 2025 3:07pm

@@ -0,0 +1,30 @@
import { createClient } from '@ponder/client'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check with @douglance what we actually need here

const { isFeatureDisabled } = useDisabledFeatures()
const isTxHistoryEnabled = !isFeatureDisabled(DisabledFeatures.TX_HISTORY)

const indexerResult = useIndexerHistory(address)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to only run indexer with the feature flag enabled. We return indexerResult if indexer flag is true, otherwise legacy results.

We also use the indexer flag when fetching indexer and legacy results so that:

  • we only fetch legacy if indexer === false || indexer === undefined
  • we only fetch indexer if indexer === true

parentChainId: number
}

type EthIndexerTransfer = PartialTransfer & {
Copy link
Contributor Author

@brtkx brtkx Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mirrored whatever indexer was returning, but maybe we can now get types from some package @douglance?

If not then we have to keep them defined here.


type IndexerTransfer = EthIndexerTransfer | Erc20IndexerTransfer

function getIndexerTransferStatus(tx: IndexerTransfer) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took from indexer some time ago but these may have changed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to map them to whatever we use in our UI

}
}

function getIndexerDepositStatus(tx: IndexerTransfer): DepositStatus {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, may have changed

}
}

type TokenDetails = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indexer only gives us token address because it would take a long time to fetch token data and store it. We need to fetch the token data ourselves.

see L162

decimals: number
}

function transformIndexerTransfer(params: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some overrides for ETH or ERC20

async ([_indexerTransactions, _tokensFromLists]) => {
const result: { [key in string]: TokenDetails } = {}

for (let i = 0; i < _indexerTransactions.length; i++) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not great but I did it just for PoC to work.

Basically as mentioned before, indexer is not giving us ERC20 data, so we fetch ourselves. We need to do it for each ERC20 transaction we get from indexer. We may be able to do something smarter here.

}, [pendingTransfers, completedTransfers])

// todo: cache
const { data: tokenDetailsMap } = useSWRImmutable(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ERC20 data because indexer doesn't have it.

}
)

const { data: transactions = [] } = useSWR(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final data which includes token data for ERC20 transactions

([_indexerTransactions, _tokenDetailsMap]) => {
return _indexerTransactions.map(tx => {
if (tx.type === 'ETH') {
return transformIndexerTransfer({ tx })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With overrides we can use the same function for ETH and ERC20. The only difference is if it's ERC20 then tokenDetails is required, otherwise it needs to be skipped for ETH.

const isIndexerEnabled = isExperimentalFeatureEnabled('indexer')

if (isIndexerEnabled) {
return { ...indexerResult, addPendingTransaction, updatePendingTransaction }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addPendingTransaction and updatePendingTransaction stays as is because it's a different useSWR key with it's own mutator

'addPendingTransaction' | 'updatePendingTransaction'
> => {
const isIndexerEnabled = isExperimentalFeatureEnabled('indexer')
// todo: allow undefined in indexer and return empty
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useArbitrumIndexer doesn't allow undefined address so we need to pass empty string. Would be nice if indexer let us pass undefined, but it's just nice to have

loading: isLoading,
// TODO: This will need to be based on pagination
completed: !isLoading,
failedChainPairs: [],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can't really do failedChainPairs with indexer

completed: !isLoading,
failedChainPairs: [],
error,
pause: () => {},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pause and resume N/A for indexer

return {
transactions,
loading: isLoading,
// TODO: This will need to be based on pagination
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to do any pagination for v1. We can just fetch first 1000 results like we do for CCTP, and it should be sufficient for vast majority of users for now.

@fionnachan fionnachan changed the base branch from master to bump-react-19 September 3, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants