Skip to content

Commit

Permalink
Dev: review comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
dewanshparashar committed Jun 11, 2024
1 parent df4ad74 commit ccb94ae
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ function getCacheKeyFromTransaction(
}

// remove the duplicates from the transactions passed
function dedupeTransactions(txns: Transfer[]) {
function dedupeTransactions(txs: Transfer[]) {
return Array.from(
new Map(txns.map(tx => [getCacheKeyFromTransaction(tx), tx])).values()
new Map(txs.map(tx => [getCacheKeyFromTransaction(tx), tx])).values()
)
}

Expand Down
6 changes: 1 addition & 5 deletions packages/arb-token-bridge-ui/src/pages/api/teleports/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from '../../../api-utils/ServerSubgraphUtils'
import { getInboxAddressFromOrbitChainId } from '../../../util/orbitChainsList'
import { FetchEthTeleportsFromSubgraphResult } from '../../../util/teleports/fetchEthTeleportsFromSubgraph'
import { ChainId } from '../../../util/networks'

// Extending the standard NextJs request with Deposit-params
type NextApiRequestWithDepositParams = NextApiRequest & {
Expand Down Expand Up @@ -38,14 +37,11 @@ export default async function handler(
const {
sender,
receiver,
search = '',
l1ChainId,
l2ChainId,
l3ChainId,
page = '0',
pageSize = '10',
fromBlock,
toBlock
pageSize = '10'
} = req.query

// validate method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ async function tryGetInboxFromRouter(
provider: Provider
): Promise<string | undefined> {
if (!(await addressIsSmartContract(address, provider))) {
throw new Error('Not a contract')
throw new Error(
'[tryGetInboxFromRouter]: address passed is not a smart contract'
)
}

const maybeRouter = L1GatewayRouter__factory.connect(address, provider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type FetchDepositsFromSubgraphResult = {
* Fetches initiated deposits (ETH + Tokens) from subgraph in range of [fromBlock, toBlock] and pageParams.
*
* @param query Query params
* @param query.sender Address that initiated the withdrawal
* @param query.sender Address that initiated the deposit
* @param query.receiver Address that received the funds
* @param query.fromBlock Start at this block number (including)
* @param query.toBlock Stop at this block number (including)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ export type FetchErc20TeleportsFromSubgraphResult = {
* Fetches initiated ETH Teleports from subgraph in range of [fromBlock, toBlock] and pageParams.
*
* @param query Query params
* @param query.sender Address that initiated the withdrawal
* @param query.receiver Address that received the funds
* @param query.sender Address that initiated the teleport
* @param query.fromBlock Start at this block number (including)
* @param query.toBlock Stop at this block number (including)
* @param query.l1ChainId Chain id for the L2 network
* @param query.pageSize Fetch these many records from subgraph
* @param query.pageNumber Fetch records starting [pageNumber * pageSize] records
* @param query.searchString Searches records through the l1TxHash
*/

export const fetchErc20TeleportsFromSubgraph = async ({
Expand All @@ -39,13 +37,11 @@ export const fetchErc20TeleportsFromSubgraph = async ({
pageNumber = 0
}: {
sender?: string
receiver?: string
fromBlock: number
toBlock?: number
l1ChainId: number
pageSize?: number
pageNumber?: number
searchString?: string
}): Promise<FetchErc20TeleportsFromSubgraphResult[]> => {
if (toBlock && fromBlock >= toBlock) {
// if fromBlock > toBlock or both are equal / 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type FetchEthTeleportsFromSubgraphResult = {
* Fetches initiated ETH Teleports from subgraph in range of [fromBlock, toBlock] and pageParams.
*
* @param query Query params
* @param query.sender Address that initiated the withdrawal
* @param query.sender Address that initiated the teleport
* @param query.receiver Address that received the funds
* @param query.fromBlock Start at this block number (including)
* @param query.toBlock Stop at this block number (including)
Expand Down
10 changes: 4 additions & 6 deletions packages/arb-token-bridge-ui/src/util/teleports/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import { fetchErc20Data } from '../TokenUtils'
export function isTransferTeleportFromSubgraph(
tx: Transfer
): tx is TeleportFromSubgraph {
// @ts-ignore: `teleport_type` is present only in teleport-from-subgraph types, we ignore it for other types
return typeof tx.teleport_type !== 'undefined'
return typeof (tx as TeleportFromSubgraph).teleport_type !== 'undefined'
}

export function isTransactionEthTeleportFromSubgraph(
function isTransactionEthTeleportFromSubgraph(
tx: TeleportFromSubgraph
): tx is FetchEthTeleportsFromSubgraphResult {
return tx.teleport_type === 'eth'
Expand Down Expand Up @@ -53,9 +52,8 @@ export async function transformTeleportFromSubgraph(
status: 'pending',
direction: 'deposit',
source: 'subgraph',
value: utils.formatUnits(
depositParameters.l2l3TicketData.l2CallValue.toString() || 0,
18
value: utils.formatEther(
depositParameters.l2l3TicketData.l2CallValue.toString() || 0
),
txID: tx.transactionHash,
tokenAddress: '',
Expand Down

0 comments on commit ccb94ae

Please sign in to comment.