-
Notifications
You must be signed in to change notification settings - Fork 33
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
[DNM] test #3238 #3240
[DNM] test #3238 #3240
Changes from 6 commits
5c3686c
c63eb6e
327a3a4
aab8e56
c167cf0
8311329
6dc151c
4b49879
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,14 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [0.3.8](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-07) | ||
|
||
**Note:** Version bump only for package @synapsecns/bridge-docs | ||
|
||
|
||
|
||
|
||
|
||
## [0.3.7](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-05) | ||
|
||
**Note:** Version bump only for package @synapsecns/bridge-docs | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Routes from '@site/src/components/Routes' | ||
|
||
# Chains & Tokens | ||
|
||
This page contains a list of supported tokens, listed per-chain. For a given pair, use the [Synapse Bridge](https://synapseprotocol.com) to see if a route between them exists. | ||
|
||
<Routes /> |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,10 @@ | ||
import { BRIDGABLE_TOKENS, CHAINS } from '@synapsecns/synapse-constants' | ||
|
||
const CHAINS_BY_ID = {} | ||
|
||
for (const { chainImg, id, name } of Object.values(CHAINS)) { | ||
if (id && name) { | ||
CHAINS_BY_ID[id] = { name, chainImg } | ||
} | ||
} | ||
|
||
export default () => | ||
Object.entries(BRIDGABLE_TOKENS).map(([id, tokens]) => { | ||
const chain = CHAINS_BY_ID[id] | ||
const chainImg = chain.chainImg({ width: 28, height: 28 }) | ||
const chain = CHAINS.CHAINS_BY_ID[id] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Incorrect usage of The
🔗 Analysis chainIncorrect chain access method The current implementation attempts to access Consider reverting to the previous access method or ensure that the -const chain = CHAINS.CHAINS_BY_ID[id]
+const chain = CHAINS_BY_ID[id] If To verify the correct structure, we can check the contents of the constants file: Constants file not found The shell script did not locate a constants file containing Failed to locate The previous shell script failed to recognize the 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check the structure of CHAINS in the constants file
# Find the constants file
constants_file=$(fd -e ts -e js -e tsx -e jsx -t f synapse-constants)
if [ -n "$constants_file" ]; then
echo "Contents of the constants file:"
cat "$constants_file"
else
echo "Constants file not found."
fi
Length of output: 149 Script: #!/bin/bash
# Description: Find the definition of CHAINS and CHAINS_BY_ID in the codebase
# Search for CHAINS definition
echo "Searching for 'CHAINS' definition:"
rg 'CHAINS\s*=' --type ts --type tsx --type js --type jsx
# Search for 'CHAINS_BY_ID' definition
echo "Searching for 'CHAINS_BY_ID' definition:"
rg 'CHAINS_BY_ID\s*=' --type ts --type tsx --type js --type jsx
Length of output: 363 Script: #!/bin/bash
# Description: Find the definition of CHAINS and CHAINS_BY_ID in the codebase without specifying file types
# Search for CHAINS definition
echo "Searching for 'CHAINS' definition:"
rg 'CHAINS\s*='
# Search for 'CHAINS_BY_ID' definition:
rg 'CHAINS_BY_ID\s*='
Length of output: 1524 |
||
const chainImg = chain.chainImg | ||
|
||
return ( | ||
<section key={id}> | ||
<h2 | ||
|
@@ -22,16 +15,10 @@ export default () => | |
alignItems: 'center', | ||
}} | ||
> | ||
{chainImg} {chain.name} <code>{id}</code> | ||
<img width="28" height="28" src={chainImg} alt={chain.name} /> | ||
{chain.name} <code>{id}</code> | ||
</h2> | ||
{Object.values(tokens).map((token) => { | ||
const tokenImg = | ||
typeof token.icon === 'string' ? ( | ||
<img width="16" height="16" src={token.icon} /> | ||
) : ( | ||
token.icon({ width: 16, height: 16 }) | ||
) | ||
|
||
return ( | ||
<span | ||
key={token.addresses[id]} | ||
|
@@ -42,7 +29,8 @@ export default () => | |
padding: '.25rem .5rem', | ||
}} | ||
> | ||
{tokenImg} {token.symbol} | ||
<img width="16" height="16" src={token.icon} alt={token.symbol} />{' '} | ||
{token.symbol} | ||
</span> | ||
) | ||
})} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,14 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [1.0.6](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-07) | ||
|
||
**Note:** Version bump only for package @synapsecns/rfq-indexer-api | ||
|
||
|
||
|
||
|
||
|
||
## [1.0.5](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-10-03) | ||
|
||
**Note:** Version bump only for package @synapsecns/rfq-indexer-api | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Request, Response } from 'express' | ||
|
||
import { db } from '../db' | ||
import { qDisputes } from '../queries' | ||
import { nest_results } from '../utils/nestResults' | ||
|
||
export const disputesController = async (req: Request, res: Response) => { | ||
try { | ||
const query = db | ||
.with('disputes', () => qDisputes({activeOnly: true})) | ||
.selectFrom('disputes') | ||
.selectAll() | ||
.orderBy('blockTimestamp_dispute', 'desc') | ||
Comment on lines
+9
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider optimizing the query by selecting only necessary columns. The query construction looks good overall, using a CTE and proper ordering. However, selecting all columns ( Consider modifying the query to select only the columns that are actually needed by the client. This can improve query performance and reduce data transfer. For example: .selectFrom('disputes')
.select(['id', 'status', 'blockTimestamp_dispute', /* other necessary columns */]) This change would require knowing which specific columns are needed for the disputes data in your application. |
||
|
||
const results = await query.execute() | ||
const disputes = nest_results(results) | ||
|
||
if (disputes && disputes.length > 0) { | ||
res.json(disputes) | ||
} else { | ||
res.status(200).json({ message: 'No active disputes found' }) | ||
} | ||
Comment on lines
+18
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider making the response structure consistent for both cases. The response handling covers both cases (disputes found and not found) appropriately. However, the response structure is inconsistent between the two cases. To improve API consistency, consider using the same structure for both cases. Here's a suggested modification: if (disputes && disputes.length > 0) {
res.json({ disputes })
} else {
res.json({ disputes: [], message: 'No active disputes found' })
} This change ensures that the client always receives an object with a |
||
} catch (error) { | ||
console.error('Error fetching active disputes:', error) | ||
res.status(500).json({ message: 'Internal server error' }) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
import { Request, Response } from 'express' | ||
|
||
import { db } from '../db' | ||
import { qDeposits, qRelays, qProofs, qClaims, qRefunds } from '../queries' | ||
import { | ||
qDeposits, | ||
qRelays, | ||
qProofs, | ||
qClaims, | ||
qRefunds, | ||
qDisputes, | ||
} from '../queries' | ||
import { nest_results } from '../utils/nestResults' | ||
|
||
const sevenDaysAgo = Math.floor(Date.now() / 1000) - 7 * 24 * 60 * 60 | ||
|
||
Comment on lines
+14
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider defining constants for time calculations for better readability. To enhance readability and maintainability, consider defining constants for time units used in time calculations. Example: const SECONDS_IN_A_DAY = 86400; // 24 * 60 * 60
const sevenDaysAgo = Math.floor(Date.now() / 1000) - 7 * SECONDS_IN_A_DAY; |
||
export const pendingTransactionsMissingClaimController = async ( | ||
req: Request, | ||
res: Response | ||
|
@@ -12,7 +21,7 @@ export const pendingTransactionsMissingClaimController = async ( | |
const query = db | ||
.with('deposits', () => qDeposits()) | ||
.with('relays', () => qRelays()) | ||
.with('proofs', () => qProofs()) | ||
.with('proofs', () => qProofs({activeOnly: true})) | ||
.with('claims', () => qClaims()) | ||
.with('combined', (qb) => | ||
qb | ||
|
@@ -45,7 +54,6 @@ export const pendingTransactionsMissingClaimController = async ( | |
} | ||
} | ||
|
||
|
||
export const pendingTransactionsMissingProofController = async ( | ||
req: Request, | ||
res: Response | ||
|
@@ -54,7 +62,7 @@ export const pendingTransactionsMissingProofController = async ( | |
const query = db | ||
.with('deposits', () => qDeposits()) | ||
.with('relays', () => qRelays()) | ||
.with('proofs', () => qProofs()) | ||
.with('proofs', () => qProofs({activeOnly: true})) | ||
.with('combined', (qb) => | ||
qb | ||
.selectFrom('deposits') | ||
|
@@ -111,6 +119,52 @@ export const pendingTransactionsMissingRelayController = async ( | |
.selectFrom('combined') | ||
.selectAll() | ||
.orderBy('blockTimestamp_deposit', 'desc') | ||
.where('blockTimestamp_deposit', '>', sevenDaysAgo) | ||
|
||
const results = await query.execute() | ||
const nestedResults = nest_results(results) | ||
|
||
if (nestedResults && nestedResults.length > 0) { | ||
res.json(nestedResults) | ||
} else { | ||
res | ||
.status(404) | ||
.json({ message: 'No pending transactions missing relay found' }) | ||
} | ||
} catch (error) { | ||
console.error('Error fetching pending transactions missing relay:', error) | ||
res.status(500).json({ message: 'Internal server error' }) | ||
} | ||
Comment on lines
+135
to
+137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Differentiate error messages for clearer debugging. The error messages in the catch blocks are identical across controllers. To facilitate easier debugging, update the error messages to reflect the specific controller's context. Suggested changes: In - console.error('Error fetching pending transactions missing relay:', error)
+ console.error('Error fetching pending transactions missing relay exceeding deadline:', error) And update the response message in the - .json({ message: 'No pending transactions missing relay found' })
+ .json({ message: 'No pending transactions missing relay exceeding deadline found' }) Also applies to: 166-167 |
||
} | ||
|
||
export const pendingTransactionsMissingRelayExceedDeadlineController = async ( | ||
req: Request, | ||
res: Response | ||
) => { | ||
try { | ||
const query = db | ||
.with('deposits', () => qDeposits()) | ||
.with('relays', () => qRelays()) | ||
.with('refunds', () => qRefunds()) | ||
.with( | ||
'combined', | ||
(qb) => | ||
qb | ||
.selectFrom('deposits') | ||
.selectAll('deposits') | ||
.leftJoin('relays', 'transactionId_deposit', 'transactionId_relay') | ||
.leftJoin( | ||
'refunds', | ||
'transactionId_deposit', | ||
'transactionId_refund' | ||
) | ||
.where('transactionId_relay', 'is', null) // is not relayed | ||
.where('transactionId_refund', 'is', null) // is not refunded | ||
) | ||
.selectFrom('combined') | ||
.selectAll() | ||
.orderBy('blockTimestamp_deposit', 'desc') | ||
.where('blockTimestamp_deposit', '<=', sevenDaysAgo) | ||
Comment on lines
+140
to
+167
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider refactoring to reduce code duplication between controllers. The |
||
|
||
const results = await query.execute() | ||
const nestedResults = nest_results(results) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Invalid link detected in documentation.
The link
/docs/About/Routes
indocs/bridge/docs/02-Bridge/index.md
does not point to an existing documentation page. Please update the link todocs/bridge/docs/01-About/03-Routes.md
to ensure it directs to the correct location.🔗 Analysis chain
Approve link update with verification request.
The update to the documentation link appears to be an improvement in the overall structure. However, please ensure that the new link '/docs/About/Routes' is valid and leads to the correct page containing information about the supported blockchains.
To verify the existence of the new documentation page, please run the following script:
If the script doesn't find the file, please create it or update the link to the correct location.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 128
Script:
Length of output: 58