Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
60 changes: 37 additions & 23 deletions .github/workflows/ai-pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: ⚡ Flash PR Review

on:
pull_request_target:
types: [opened, synchronize]
types: [opened, synchronize, reopened, ready_for_review]

permissions:
contents: read
Expand All @@ -22,49 +22,61 @@ jobs:
github.event.pull_request.user.login != 'dependabot[bot]'

steps:
- name: Checkout PR Head
# SECURITY: Check out the BASE ref so we run trusted scripts only.
# The fork's code is never checked out — we only fetch its diff via git.
- name: Checkout Base (trusted scripts)
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
ref: ${{ github.event.pull_request.base.sha }}
persist-credentials: false

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Get PR Diff
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git fetch origin ${{ github.base_ref }} --depth=1
git diff origin/${{ github.base_ref }}...HEAD > pr.diff
# Fetch the diff via GitHub API — no fork checkout needed
gh api \
repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} \
-H "Accept: application/vnd.github.v3.diff" \
> pr.diff

DIFF_SIZE=$(wc -c < pr.diff)
echo "diff_size=$DIFF_SIZE" >> $GITHUB_ENV
echo "📄 Diff size: $DIFF_SIZE bytes"

# Extract changed file list
git diff --name-only origin/${{ github.base_ref }}...HEAD > changed-files.txt
# Extract changed file list from the diff
grep -E '^\+\+\+ b/' pr.diff | sed 's|^\+\+\+ b/||' > changed-files.txt || true
echo "📁 Changed files:"
cat changed-files.txt

- name: Skip if diff too small
if: env.diff_size == '0'
run: echo "Empty diff, skipping review"

# SECURITY: Build PR context JSON safely via Node.js to avoid
# shell injection from untrusted PR titles / branch names.
- name: Get PR Context
if: env.diff_size != '0'
run: |
# Save PR body to file (avoids shell escaping issues)
cat > pr-context.json << 'PREOF'
{
"title": "${{ github.event.pull_request.title }}",
"author": "${{ github.event.pull_request.user.login }}",
"number": ${{ github.event.pull_request.number }},
"base": "${{ github.base_ref }}",
"head": "${{ github.head_ref }}",
"action": "${{ github.event.action }}"
}
PREOF
uses: actions/github-script@v7
with:
script: |
const fs = require('fs')
const pr = context.payload.pull_request
const meta = {
title: pr.title,
author: pr.user.login,
number: pr.number,
base: pr.base.ref,
head: pr.head.ref,
action: context.payload.action,
}
fs.writeFileSync('pr-context.json', JSON.stringify(meta, null, 2))
console.log('📋 PR context written safely')

- name: Run Flash Review
if: env.diff_size != '0'
Expand All @@ -73,7 +85,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
REPO_NAME: ${{ github.event.pull_request.base.repo.name }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: node scripts/ai-review/review.js

Expand Down Expand Up @@ -139,12 +151,14 @@ jobs:
return
}

const headSha = '${{ github.event.pull_request.head.sha }}'

// Post as a pull request review with inline comments
try {
await github.rest.pulls.createReview({
...context.repo,
pull_number: context.issue.number,
commit_id: '${{ github.event.pull_request.head.sha }}',
commit_id: headSha,
event: 'COMMENT',
comments: comments.map((c) => ({
path: c.path,
Expand All @@ -162,7 +176,7 @@ jobs:
await github.rest.pulls.createReviewComment({
...context.repo,
pull_number: context.issue.number,
commit_id: '${{ github.event.pull_request.head.sha }}',
commit_id: headSha,
path: c.path,
line: c.line,
body: c.body,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: ✅ CI

on:
pull_request:
types: [opened, synchronize]
types: [opened, synchronize, reopened, ready_for_review]

concurrency:
group: ci-${{ github.event.pull_request.number }}
Expand Down
6 changes: 5 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const eslintConfig = defineConfig([
destructuredArrayIgnorePattern: "^_",
},
],
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/ban-ts-comment": "warn",
},
},
// Override default ignores of eslint-config-next.
Expand All @@ -25,8 +27,10 @@ const eslintConfig = defineConfig([
"out/**",
"build/**",
"next-env.d.ts",
// Non-Next.js files
// Non-source directories
"scripts/**",
"documentation/**",
"inspiration/**",
]),
]);

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,5 @@
"tw-animate-css": "^1.4.0",
"typescript": "^5",
"vitest": "^4.1.2"
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
}
2 changes: 1 addition & 1 deletion src/app/api/transactions/initiate/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const initiateSchema = z.object({
fromAmount: z.string(),
toAmount: z.string(),
provider: z.string().default('lifi'),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
route: z.any(),
toAddress: z.string().optional(), // receiver wallet for P2P direct hits (android)
})
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/v1/webhooks/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ export async function GET(req: NextRequest) {
// Fetch delivery stats for all endpoints in two queries
const endpointIds = (endpoints || []).map((ep: { id: string }) => ep.id)

let totalsByEndpoint: Record<string, number> = {}
let successByEndpoint: Record<string, number> = {}
const totalsByEndpoint: Record<string, number> = {}
const successByEndpoint: Record<string, number> = {}

if (endpointIds.length > 0) {
const { data: allDeliveries } = await supabase
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/webhooks/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ export async function GET(req: NextRequest) {
// Fetch delivery stats for all endpoints in one query
const endpointIds = (endpoints || []).map((ep: { id: string }) => ep.id)

let totalsByEndpoint: Record<string, number> = {}
let successByEndpoint: Record<string, number> = {}
const totalsByEndpoint: Record<string, number> = {}
const successByEndpoint: Record<string, number> = {}

if (endpointIds.length > 0) {
const { data: allDeliveries } = await supabase
Expand Down
2 changes: 1 addition & 1 deletion src/app/docs/redirects/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function DocsRedirectsPage() {
and after 3 seconds, they will be automatically redirected to your URL.
</p>
<p>
This allows you to verify the payment status and show a "Thank You" page on your own domain.
This allows you to verify the payment status and show a &ldquo;Thank You&rdquo; page on your own domain.
</p>
</DocSection>

Expand Down
5 changes: 2 additions & 3 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ export default function Home() {
const { isConnected } = useAppKitAccount()
const [mounted, setMounted] = useState(false)

useEffect(() => {
setMounted(true)
}, [])
// eslint-disable-next-line react-hooks/set-state-in-effect -- standard hydration guard
useEffect(() => { setMounted(true) }, [])

// Only trust wallet state after hydration to prevent SSR mismatch
const walletReady = mounted && isConnected
Expand Down
4 changes: 3 additions & 1 deletion src/components/Dither.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ class RetroEffectImpl extends Effect {
}
}

const WrappedRetroEffect = wrapEffect(RetroEffectImpl);

const RetroEffect = forwardRef<RetroEffectImpl, { colorNum: number; pixelSize: number }>((props, ref) => {
const { colorNum, pixelSize } = props;
const WrappedRetroEffect = wrapEffect(RetroEffectImpl);
return <WrappedRetroEffect ref={ref} colorNum={colorNum} pixelSize={pixelSize} />;
});

Expand Down Expand Up @@ -264,6 +265,7 @@ function DitheredWaves({
<shaderMaterial
vertexShader={waveVertexShader}
fragmentShader={waveFragmentShader}
// eslint-disable-next-line react-hooks/refs -- ref is initialized inline, always available
uniforms={waveUniformsRef.current}
/>
</mesh>
Expand Down
5 changes: 2 additions & 3 deletions src/components/docs/MobileDocsNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ export function MobileDocsNav() {
const pathname = usePathname()

// Close menu when route changes
useEffect(() => {
setOpen(false)
}, [pathname])
// eslint-disable-next-line react-hooks/set-state-in-effect -- intentional: close menu on navigation
useEffect(() => { setOpen(false) }, [pathname])

// Lock body scroll when menu is open
useEffect(() => {
Expand Down
5 changes: 2 additions & 3 deletions src/hooks/useTransactionExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export function useTransactionExecutor() {
if (swapResponse.error) throw new Error(swapResponse.error)

const requestId = swapResponse.requestId
let tx = swapResponse.tx
const tx = swapResponse.tx

if (!tx) throw new Error('Failed to get transaction data from Rango')

Expand Down Expand Up @@ -356,9 +356,8 @@ export function useTransactionExecutor() {
throw new Error('Solana wallet does not support signAndSendTransaction')
}

let txHash: string
const result = await solana.signAndSendTransaction(transaction)
txHash = typeof result === 'string' ? result : result?.signature || result?.toString()
const txHash = typeof result === 'string' ? result : result?.signature || result?.toString()

setTxHash(txHash)
setStatus('completed')
Expand Down
4 changes: 2 additions & 2 deletions src/lib/stealth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function generateStealthAddress({
const viewingKeyNode = deserializeHDKey(viewingKeyNodeSerialized)

// Generate ephemeral key from viewing node + nonce
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const { ephemeralPrivateKey } = generateEphemeralPrivateKey({
viewingPrivateKeyNode: viewingKeyNode as any,
nonce: BigInt(nonce),
Expand Down Expand Up @@ -186,7 +186,7 @@ function deserializeHDKey(serialized: string): any {
const data = JSON.parse(serialized)

// Reconstruct using @scure/bip32 HDKey directly
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { HDKey } = require('@scure/bip32')

const hasPrivateKey = !!data.privateKey
Expand Down
Loading