Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worldchain explorer updates #3351

Merged
merged 17 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/explorer-ui/components/ChainChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ export const OverviewChart: React.FC<OverviewChartProps> = ({
stackId="a"
fill={loading ? 'rgba(255, 255, 255, 0.1)' : '#000000'}
/>
<Bar
isAnimationActive={false}
dataKey="worldchain"
stackId="a"
fill={loading ? 'rgba(255, 255, 255, 0.1)' : '#FFFFFF'}
/>
Comment on lines +323 to +328
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider adjusting the worldchain bar color for better visibility

The white fill color (#FFFFFF) might make the bar difficult to see on light backgrounds. Consider using a more distinctive color that maintains good contrast across different background colors.

Apply this change to improve visibility:

-                fill={loading ? 'rgba(255, 255, 255, 0.1)' : '#FFFFFF'}
+                fill={loading ? 'rgba(255, 255, 255, 0.1)' : '#4A90E2'}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Bar
isAnimationActive={false}
dataKey="worldchain"
stackId="a"
fill={loading ? 'rgba(255, 255, 255, 0.1)' : '#FFFFFF'}
/>
<Bar
isAnimationActive={false}
dataKey="worldchain"
stackId="a"
fill={loading ? 'rgba(255, 255, 255, 0.1)' : '#4A90E2'}
/>

Comment on lines +323 to +328
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Consider using a more distinctive color for better visibility

The white fill color (#FFFFFF) for the worldchain bar should be changed since:

  1. The chart appears to be using a dark theme (evidenced by white YAxis stroke color stroke="#ffffff")
  2. Other chains use distinctive colors that contrast well with the background (e.g., Linea uses black #000000, Scroll uses #FFEEDA, etc.)
  3. The loading state already uses a semi-transparent white rgba(255, 255, 255, 0.1)

Consider using a unique, contrasting color like other chains in the chart to ensure the worldchain data is clearly visible against the dark background.

🔗 Analysis chain

Consider adjusting the fill color for better visibility.

The white fill color (#FFFFFF) might have visibility issues on light backgrounds. Consider using a more distinctive color that maintains good contrast across different themes.

Let's verify the worldchain data integration:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if worldchain data is properly integrated in the chart data structure
rg -A 5 "worldchain.*interface|type.*worldchain" --type typescript

Length of output: 103


Script:

#!/bin/bash
# Let's try different approaches to verify the worldchain integration

# Check for worldchain-related code patterns
rg -i "worldchain" -A 5 -B 5

# Look for data transformation or preparation related to worldchain
ast-grep --pattern 'const $_ = $$$worldchain$$$'

# Check the component's props and interfaces
ast-grep --pattern 'interface $_ {
  $$$
  worldchain
  $$$
}'

# Look for worldchain in data mapping or processing
ast-grep --pattern '$_.worldchain'

Length of output: 74044


Script:

#!/bin/bash
# Let's check the theme/styling context around the chart component
rg -B 10 -A 10 "ChainChart.*theme|theme.*ChainChart" --type typescript

# Look for other bar colors in the chart for comparison
ast-grep --pattern 'fill={$_}'

# Check if there's any dark theme or background color definition
rg -i "background.*dark|dark.*background|theme.*dark|dark.*theme"

Length of output: 5157


Script:

#!/bin/bash
# Let's check the specific file content around the Bar components
rg -B 15 -A 15 "dataKey=\"worldchain\"" packages/explorer-ui/components/ChainChart/index.tsx

# Look for any theme or background color definitions in the ChainChart component
cat packages/explorer-ui/components/ChainChart/index.tsx

Length of output: 10816

</>
)}
</BarChart>
Expand Down
12 changes: 12 additions & 0 deletions packages/rfq-indexer/api/src/constants/networkConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
linea,
bsc,
blast,
worldchain,
} from 'viem/chains'

import { FastBridgeV2Abi } from './abis/FastBridgeV2'
Expand Down Expand Up @@ -114,4 +115,15 @@ export const networkConfig: NetworkConfig = {
transport: http(),
}),
},
480: {
name: 'Worldchain',
FastBridgeV2: {
address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E',
abi: FastBridgeV2Abi,
},
client: createPublicClient({
chain: worldchain,
transport: http(),
}),
},
} as const
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const conflictingProofsController = async (
const query = db
.with('deposits', () => qDeposits())
.with('relays', () => qRelays())
.with('proofs', () => qProofs({activeOnly: true}))
.with('proofs', () => qProofs({ activeOnly: true }))
.with('combined', (qb) =>
qb
.selectFrom('deposits')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { nest_results } from '../utils/nestResults'
export const disputesController = async (req: Request, res: Response) => {
try {
const query = db
.with('disputes', () => qDisputes({activeOnly: true}))
.with('disputes', () => qDisputes({ activeOnly: true }))
.selectFrom('disputes')
.selectAll()
.orderBy('blockTimestamp_dispute', 'desc')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { Request, Response } from 'express'

import { db } from '../db'
import {
qDeposits,
qRelays,
qProofs,
qClaims,
qRefunds,
qDisputes,
} from '../queries'
import { qDeposits, qRelays, qProofs, qClaims, qRefunds } from '../queries'
import { nest_results } from '../utils/nestResults'

const sevenDaysAgo = Math.floor(Date.now() / 1000) - 7 * 24 * 60 * 60
Expand All @@ -21,7 +14,7 @@ export const pendingTransactionsMissingClaimController = async (
const query = db
.with('deposits', () => qDeposits())
.with('relays', () => qRelays())
.with('proofs', () => qProofs({activeOnly: true}))
.with('proofs', () => qProofs({ activeOnly: true }))
.with('claims', () => qClaims())
.with('combined', (qb) =>
qb
Expand All @@ -45,7 +38,7 @@ export const pendingTransactionsMissingClaimController = async (
res.json(nestedResults)
} else {
res
.status(404)
.status(200)
.json({ message: 'No pending transactions missing claim found' })
}
} catch (error) {
Expand All @@ -62,7 +55,7 @@ export const pendingTransactionsMissingProofController = async (
const query = db
.with('deposits', () => qDeposits())
.with('relays', () => qRelays())
.with('proofs', () => qProofs({activeOnly: true}))
.with('proofs', () => qProofs({ activeOnly: true }))
.with('combined', (qb) =>
qb
.selectFrom('deposits')
Expand All @@ -83,7 +76,7 @@ export const pendingTransactionsMissingProofController = async (
res.json(nestedResults)
} else {
res
.status(404)
.status(200)
.json({ message: 'No pending transactions missing proof found' })
}
} catch (error) {
Expand Down Expand Up @@ -128,7 +121,7 @@ export const pendingTransactionsMissingRelayController = async (
res.json(nestedResults)
} else {
res
.status(404)
.status(200)
.json({ message: 'No pending transactions missing relay found' })
}
} catch (error) {
Expand Down Expand Up @@ -173,7 +166,7 @@ export const pendingTransactionsMissingRelayExceedDeadlineController = async (
res.json(nestedResults)
} else {
res
.status(404)
.status(200)
.json({ message: 'No pending transactions missing relay found' })
}
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { Request, Response } from 'express'

import { db } from '../db'
import { qDeposits, qRelays, qProofs, qClaims, qRefunds, qDisputes } from '../queries'
import {
qDeposits,
qRelays,
qProofs,
qClaims,
qRefunds,
qDisputes,
} from '../queries'
import { nest_results } from '../utils/nestResults'

export const getTransactionById = async (req: Request, res: Response) => {
Expand All @@ -18,16 +25,20 @@ export const getTransactionById = async (req: Request, res: Response) => {
)
)
.with('relays', () => qRelays())
.with('proofs', () => qProofs({activeOnly: false})) // display proofs even if they have been invalidated/replaced by a dispute
.with('disputes', () => qDisputes({activeOnly: true})) // do not show disputes that have been invalidated/replaced by a proof
.with('proofs', () => qProofs({ activeOnly: false })) // display proofs even if they have been invalidated/replaced by a dispute
.with('disputes', () => qDisputes({ activeOnly: true })) // do not show disputes that have been invalidated/replaced by a proof
.with('claims', () => qClaims())
.with('refunds', () => qRefunds())
.with('combined', (qb) =>
qb
.selectFrom('deposits')
.leftJoin('relays', 'transactionId_deposit', 'transactionId_relay')
.leftJoin('proofs', 'transactionId_deposit', 'transactionId_proof')
.leftJoin('disputes', 'transactionId_deposit', 'transactionId_dispute')
.leftJoin(
'disputes',
'transactionId_deposit',
'transactionId_dispute'
)
.leftJoin('claims', 'transactionId_deposit', 'transactionId_claim')
.leftJoin('refunds', 'transactionId_deposit', 'transactionId_refund')
.selectAll('deposits')
Expand Down
1 change: 1 addition & 0 deletions packages/rfq-indexer/api/src/graphql/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const qDeposits = () => {
'BridgeRequestEvents.originAmountFormatted',
'BridgeRequestEvents.destAmountFormatted',
'BridgeRequestEvents.sender',
'BridgeRequestEvents.request',
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Schema compatibility verified, but GraphQL type needs update

The database schema in ponder.schema.ts shows that the request field exists in the BridgeRequestEvents table as a string type, but it's missing from the GraphQL type definition. This needs to be addressed to maintain schema compatibility.

  • Add the request: String! field to the BridgeRequestEvent type in packages/rfq-indexer/api/src/graphql/types/events.graphql
🔗 Analysis chain

Verify GraphQL schema compatibility.

The new field BridgeRequestEvents.request has been added to the SQL query. While the AI summary confirms the schema update, please ensure that:

  1. The GraphQL schema type BridgeRequestEvent includes this field
  2. The field type matches between the database and GraphQL schema

Let me gather more information about the schema definition to see if the request field is defined further down.


Let me try another command to get the complete schema definition:


Let me check the database schema definition to understand the field structure:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify GraphQL schema compatibility
# Test: Check if the field is properly defined in the GraphQL schema
rg -A 5 "type BridgeRequestEvent" packages/rfq-indexer/api/src/graphql/types/

Length of output: 578


Script:

#!/bin/bash
# Description: Check complete BridgeRequestEvent type definition
rg -A 15 "type BridgeRequestEvent" packages/rfq-indexer/api/src/graphql/types/events.graphql

Length of output: 1637


Script:

#!/bin/bash
# Description: Get the complete content of the events.graphql file
cat packages/rfq-indexer/api/src/graphql/types/events.graphql

Length of output: 2827


Script:

#!/bin/bash
# Description: Check the database schema definition for BridgeRequestEvents
cat packages/rfq-indexer/indexer/ponder.schema.ts

Length of output: 2531

'BridgeRequestEvents.sendChainGas',
Comment on lines +23 to 24
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider adding null handling for the request field.

The new field might be null in existing records. Consider adding explicit null handling in the nest_results function or documenting if null values are acceptable.

-      'BridgeRequestEvents.request',
+      sql`COALESCE(BridgeRequestEvents.request, '{}') as request`.as('request'),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
'BridgeRequestEvents.request',
'BridgeRequestEvents.sendChainGas',
sql`COALESCE(BridgeRequestEvents.request, '{}') as request`.as('request'),
'BridgeRequestEvents.sendChainGas',

])
.where('BridgeRequestEvents.blockTimestamp', '>', 1722729600)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ scalar BigInt
destAmountFormatted: String!
destChainId: Int!
destChain: String!
request: String!
sendChainGas: Boolean!
}

Expand Down
1 change: 1 addition & 0 deletions packages/rfq-indexer/api/src/queries/depositsQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const qDeposits = () => {
'BridgeRequestEvents.originAmountFormatted',
'BridgeRequestEvents.destAmountFormatted',
'BridgeRequestEvents.sender',
'BridgeRequestEvents.request',
'BridgeRequestEvents.sendChainGas',
])
.where('BridgeRequestEvents.blockTimestamp', '>', 1722729600)
Expand Down
11 changes: 1 addition & 10 deletions packages/rfq-indexer/api/src/routes/conflictingProofsRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const router = express.Router()
* description: Retrieves a list of transactions where the relayer in the proof differs from the relayer in the relay event
* responses:
* 200:
* description: Successful response
* description: Successful response (may be an empty array if no conflicting proofs found)
* content:
* application/json:
* schema:
Expand Down Expand Up @@ -41,15 +41,6 @@ const router = express.Router()
* BridgeDispute:
* type: object
* description: Dispute information (if available)
* 404:
* description: No conflicting proofs found
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* 500:
* description: Server error
* content:
Expand Down
11 changes: 1 addition & 10 deletions packages/rfq-indexer/api/src/routes/disputesRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const router = express.Router()
* description: Retrieves a list of all active disputes
* responses:
* 200:
* description: Successful response
* description: Successful response (may be an empty array)
* content:
* application/json:
* schema:
Expand Down Expand Up @@ -41,15 +41,6 @@ const router = express.Router()
* BridgeDispute:
* type: object
* description: Dispute information (if available)
* 404:
* description: No disputes found
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* 500:
* description: Server error
* content:
Expand Down
11 changes: 1 addition & 10 deletions packages/rfq-indexer/api/src/routes/invalidRelaysRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const router = express.Router()
* description: Retrieves a list of recent invalid relay events from the past 2 weeks
* responses:
* 200:
* description: Successful response
* description: Successful response (may be an empty array)
* content:
* application/json:
* schema:
Expand Down Expand Up @@ -41,15 +41,6 @@ const router = express.Router()
* BridgeDispute:
* type: object
* description: Dispute information (if available)
* 404:
* description: No recent invalid relays found
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* 500:
* description: Server error
* content:
Expand Down
44 changes: 4 additions & 40 deletions packages/rfq-indexer/api/src/routes/pendingTransactionsRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const router = express.Router()
* description: Retrieves a list of transactions that have been deposited, relayed, and proven, but not yet claimed
* responses:
* 200:
* description: Successful response
* description: Successful response (may be an empty array)
* content:
* application/json:
* schema:
Expand Down Expand Up @@ -46,15 +46,6 @@ const router = express.Router()
* BridgeDispute:
* type: object
* description: Dispute information (if available)
* 404:
* description: No pending transactions missing claim found
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* 500:
* description: Server error
* content:
Expand All @@ -75,7 +66,7 @@ router.get('/missing-claim', pendingTransactionsMissingClaimController)
* description: Retrieves a list of transactions that have been deposited and relayed, but not yet proven
* responses:
* 200:
* description: Successful response
* description: Successful response (may be an empty array)
* content:
* application/json:
* schema:
Expand All @@ -87,15 +78,6 @@ router.get('/missing-claim', pendingTransactionsMissingClaimController)
* type: object
* relay:
* type: object
* 404:
* description: No pending transactions missing proof found
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* 500:
* description: Server error
* content:
Expand All @@ -116,7 +98,7 @@ router.get('/missing-proof', pendingTransactionsMissingProofController)
* description: Retrieves a list of transactions that have been deposited, but not yet relayed or refunded
* responses:
* 200:
* description: Successful response
* description: Successful response (may be an empty array)
* content:
* application/json:
* schema:
Expand All @@ -126,15 +108,6 @@ router.get('/missing-proof', pendingTransactionsMissingProofController)
* properties:
* deposit:
* type: object
* 404:
* description: No pending transactions missing relay found
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* 500:
* description: Server error
* content:
Expand All @@ -155,7 +128,7 @@ router.get('/missing-relay', pendingTransactionsMissingRelayController)
* description: Retrieves a list of transactions that have been deposited, but not yet relayed or refunded and have exceeded the deadline
* responses:
* 200:
* description: Successful response
* description: Successful response (may be an empty array)
* content:
* application/json:
* schema:
Expand All @@ -165,15 +138,6 @@ router.get('/missing-relay', pendingTransactionsMissingRelayController)
* properties:
* deposit:
* type: object
* 404:
* description: No pending transactionst that exceed the deadline found
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* 500:
* description: Server error
* content:
Expand Down
11 changes: 1 addition & 10 deletions packages/rfq-indexer/api/src/routes/refundedAndRelayedRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const router = express.Router()
* description: Retrieves a list of transactions that have been both refunded and relayed
* responses:
* 200:
* description: Successful response
* description: Successful response (may be an empty array)
* content:
* application/json:
* schema:
Expand Down Expand Up @@ -41,15 +41,6 @@ const router = express.Router()
* BridgeDispute:
* type: object
* description: Dispute information (if available)
* 404:
* description: No refunded and relayed transactions found
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* 500:
* description: Server error
* content:
Expand Down
Loading
Loading