Skip to content

Commit

Permalink
Merge c167cf0 into 4c073ff
Browse files Browse the repository at this point in the history
  • Loading branch information
trajan0x authored Oct 7, 2024
2 parents 4c073ff + c167cf0 commit 698ba5b
Show file tree
Hide file tree
Showing 26 changed files with 380 additions and 86 deletions.
1 change: 1 addition & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"draftPR": true,
"cloneSubmodules": true,
"forkProcessing": "enabled",
"ignorePaths": ["packages/contracts-core/**"],
"packageRules": [
{
"matchUpdateTypes": [
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,10 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }} # Optional
filesizelimit: 15MB

- name: Add 'fe-release' label
if: github.event.pull_request.base.ref == 'fe-release'
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: 'fe-release'
7 changes: 7 additions & 0 deletions docs/bridge/docs/01-About/03-Routes.md
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 />
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
sidebar_label: Sample Code
sidebar_label: Examples
---

# Sample Code
# Example Code

Example SDK & API implementations

Expand Down
14 changes: 0 additions & 14 deletions docs/bridge/docs/02-Bridge/05-Supported-Routes.md

This file was deleted.

17 changes: 0 additions & 17 deletions docs/bridge/docs/02-Bridge/_05-Supported-Routes.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/bridge/docs/02-Bridge/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import SVGBridge from '@site/src/components/SVGBridge'

# Synapse Bridge

The [Synapse Bridge](https://synapseprotocol.com) and [Solana Bridge](https://solana.synapseprotocol.com/) seamlessly swap on-chain assets between [20+ EVM and non-EVM blockchains](./Supported-Routes) in a safe and secure manner.
The [Synapse Bridge](https://synapseprotocol.com) and [Solana Bridge](https://solana.synapseprotocol.com/) seamlessly swap on-chain assets between [20+ EVM and non-EVM blockchains](/docs/About/Routes) in a safe and secure manner.

<br />

Expand Down
26 changes: 7 additions & 19 deletions docs/bridge/src/components/Routes.tsx
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]
const chainImg = chain.chainImg

return (
<section key={id}>
<h2
Expand All @@ -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]}
Expand All @@ -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>
)
})}
Expand Down
8 changes: 8 additions & 0 deletions packages/rfq-indexer/api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/rfq-indexer-api@1.0.5...@synapsecns/rfq-indexer-api@1.0.6) (2024-10-07)

**Note:** Version bump only for package @synapsecns/rfq-indexer-api





## [1.0.5](https://github.com/synapsecns/sanguine/compare/@synapsecns/rfq-indexer-api@1.0.4...@synapsecns/rfq-indexer-api@1.0.5) (2024-10-03)

**Note:** Version bump only for package @synapsecns/rfq-indexer-api
Expand Down
26 changes: 16 additions & 10 deletions packages/rfq-indexer/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,40 @@ To make requests, use: https://triumphant-magic-production.up.railway.app , and

## API Calls

1. GET /api/hello
- Description: A simple hello world endpoint
- Example: `curl http://localhost:3001/api/hello`

2. GET /api/pending-transactions-missing-relay
All API calls can be viewed in Swagger:

[Swagger Documentation](http://localhost:3001/api-docs)

1. GET /api/pending-transactions-missing-relay
- Description: Retrieves pending transactions that are missing relay events
- Example:
```
curl http://localhost:3001/api/pending-transactions-missing-relay
curl http://localhost:3001/api/pending-transactions/missing-relay
```

3. GET /api/pending-transactions-missing-proof
2. GET /api/pending-transactions-missing-proof
- Description: Retrieves pending transactions that are missing proof events
- Example:
```
curl http://localhost:3001/api/pending-transactions-missing-proof
curl http://localhost:3001/api/pending-transactions/missing-proof
```

4. GET /api/pending-transactions-missing-claim
3. GET /api/pending-transactions-missing-claim
- Description: Retrieves pending transactions that are missing claim events
- Example:
```
curl http://localhost:3001/api/pending-transactions-missing-claim
curl http://localhost:3001/api/pending-transactions/missing-claim
```

5. GraphQL endpoint: /graphql
4. GraphQL endpoint: /graphql
- Description: Provides a GraphQL interface for querying indexed data, the user is surfaced an interface to query the data via GraphiQL

## Env Vars

- **NODE_ENV**: Set to `"development"` for localhost testing.
- **DATABASE_URL**: PostgreSQL connection URL for the ponder index.

## Important Scripts

- `yarn dev:local`: Runs the API in development mode using local environment variables
Expand Down
2 changes: 1 addition & 1 deletion packages/rfq-indexer/api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@synapsecns/rfq-indexer-api",
"private": true,
"version": "1.0.5",
"version": "1.0.6",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
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())
.with('proofs', () => qProofs({activeOnly: true}))
.with('combined', (qb) =>
qb
.selectFrom('deposits')
Expand Down Expand Up @@ -41,10 +41,10 @@ export const conflictingProofsController = async (
if (conflictingProofs && conflictingProofs.length > 0) {
res.json(conflictingProofs)
} else {
res.status(200).json({ message: 'No conflicting proofs found' })
res.status(200).json({ message: 'No active conflicting proofs found' })
}
} catch (error) {
console.error('Error fetching conflicting proofs:', error)
console.error('Error fetching active conflicting proofs:', error)
res.status(500).json({ message: 'Internal server error' })
}
}
27 changes: 27 additions & 0 deletions packages/rfq-indexer/api/src/controllers/disputesController.ts
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')

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' })
}
} 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

export const pendingTransactionsMissingClaimController = async (
req: Request,
res: Response
Expand All @@ -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
Expand Down Expand Up @@ -45,7 +54,6 @@ export const pendingTransactionsMissingClaimController = async (
}
}


export const pendingTransactionsMissingProofController = async (
req: Request,
res: Response
Expand All @@ -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')
Expand Down Expand Up @@ -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' })
}
}

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)

const results = await query.execute()
const nestedResults = nest_results(results)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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'

export const getTransactionById = async (req: Request, res: Response) => {
Expand All @@ -13,19 +13,22 @@ export const getTransactionById = async (req: Request, res: Response) => {
qDeposits().where('transactionId', '=', transactionId as string)
)
.with('relays', () => qRelays())
.with('proofs', () => qProofs())
.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('claims', 'transactionId_deposit', 'transactionId_claim')
.leftJoin('refunds', 'transactionId_deposit', 'transactionId_refund')
.selectAll('deposits')
.selectAll('relays')
.selectAll('proofs')
.selectAll('disputes')
.selectAll('claims')
.selectAll('refunds')
)
Expand Down
Loading

0 comments on commit 698ba5b

Please sign in to comment.