Skip to content

Fix tx transaction leap direction show bug#9

Open
sfsf332 wants to merge 12 commits into
RGBPlusPlus:developfrom
sfsf332:develop
Open

Fix tx transaction leap direction show bug#9
sfsf332 wants to merge 12 commits into
RGBPlusPlus:developfrom
sfsf332:develop

Conversation

@sfsf332
Copy link
Copy Markdown

@sfsf332 sfsf332 commented Oct 24, 2025

What kind of change does this PR introduce? (check at least one)

  • [✅ ] Bugfix

The PR fulfills these requirements:

  • [ ✅ ] It's submitted to the develop branch(or to a previous version branch), not the main branch
  • [ ✅ ] All tests are passing
  • [ ✅ ] Build success

Other information:

@netlify
Copy link
Copy Markdown

netlify Bot commented Oct 24, 2025

Deploy Preview for superb-frangollo-b2dbc3 ready!

Name Link
🔨 Latest commit aa1add4
🔍 Latest deploy log https://app.netlify.com/projects/superb-frangollo-b2dbc3/deploys/695b78e3c5c7bb000887a08e
😎 Deploy Preview https://deploy-preview-9--superb-frangollo-b2dbc3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Oct 24, 2025

Deploy Preview for rgbpp-explorer-testnet ready!

Name Link
🔨 Latest commit aa1add4
🔍 Latest deploy log https://app.netlify.com/projects/rgbpp-explorer-testnet/deploys/695b78e3b99e710008a4de07
😎 Deploy Preview https://deploy-preview-9--rgbpp-explorer-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @sfsf332, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request delivers a critical bug fix for displaying Bitcoin transaction details and resolving transaction layer types, ensuring data accuracy and consistent user experience. Concurrently, it introduces a robust, configurable API proxy system with caching capabilities. This new proxy infrastructure is designed to enhance performance, provide better control over external API interactions, and offer detailed monitoring, laying the groundwork for more resilient and efficient data fetching across the application.

Highlights

  • Transaction Display Fix: Corrected the field used to identify transactions (tx.hash to tx.txHash) in the BTC transaction list component, resolving a bug in displaying transaction details.
  • Layer Type Resolution Enhancement: Activated logic to correctly determine the layer type ('l2') for CKB network transactions that lack a specified direction, improving data accuracy.
  • New API Proxy System: Introduced a comprehensive API proxy with configurable caching, health checks, status monitoring, and a demo page, designed to optimize and manage external API calls.
  • Dynamic tRPC Routing: Updated the tRPC client to conditionally route requests through the new proxy based on an environment variable, allowing for flexible API call management.
  • Image Component Refactor: Replaced the next/image component with a standard img tag in the footer, potentially simplifying image rendering or addressing specific build/performance concerns.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request fixes a bug related to transaction direction display by changing a property access and uncommenting a line of logic. The main part of this PR, however, is the introduction of a comprehensive API proxy system with caching, health checks, and status endpoints. My review focuses on this new proxy feature. I've found a critical issue with the in-memory caching strategy which is not suitable for serverless environments, a high-severity bug in how API routes call each other, and several medium-severity issues related to type safety, configuration consistency, and logging. It would be beneficial to split such large new features from bug fixes into separate pull requests in the future.

Comment on lines +3 to +4
// 简单的内存缓存(与代理路由共享)
const cache = new Map<string, { data: any; timestamp: number; ttl: number }>()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The use of a module-level Map for caching will not work as expected in a serverless environment (like Vercel). Each serverless function invocation can be a separate, short-lived instance with its own memory space. This means the cache will not be shared across requests, leading to a very low hit rate and making the cache ineffective. For caching to work correctly in a serverless architecture, you should use an external, shared caching service like Redis, Memcached, or Vercel's Data Cache.


// 获取目标API URL
const getTargetUrl = () => {
const baseUrl = process.env.NEXT_PUBLIC_TRPC_API_URL || 'https://web3-api.magickbase.com/api/trpc'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The default target URL here is https://web3-api.magickbase.com/api/trpc, which seems to be a production or mainnet URL. However, other files in this PR (e.g., health/route.ts, trpc.ts) use https://web3-api-testnet.magickbase.com/api/trpc as the default. This inconsistency can lead to bugs where different parts of the application target different environments by default. Please unify the default URL to the testnet one for consistency.

Suggested change
const baseUrl = process.env.NEXT_PUBLIC_TRPC_API_URL || 'https://web3-api.magickbase.com/api/trpc'
const baseUrl = process.env.NEXT_PUBLIC_TRPC_API_URL || 'https://web3-api-testnet.magickbase.com/api/trpc'

Comment on lines +13 to +19
// 测试健康检查
const healthResponse = await fetch('/api/proxy/health')
const healthData = await healthResponse.json()

// 测试一个简单的代理请求
const testResponse = await fetch('/api/proxy/rgbpp.marketCap')
const testData = await testResponse.json()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The fetch calls with relative paths ('/api/proxy/health' and '/api/proxy/rgbpp.marketCap') will fail when executed on the server. API routes run in a server-side context that doesn't know the application's domain.

To fix this, you need to:

  1. Modify the GET function signature to accept the request object: export async function GET(request: NextRequest).
  2. Import NextRequest from next/server.
  3. Construct absolute URLs for the fetch calls using request.url, for example: new URL('/api/proxy/health', request.url).

@@ -15,7 +15,7 @@ export default function BtcTxList({ address }: { address: string }) {
return (
<VStack w="100%" gap="30px">
{addressTransactions.data.map((tx: any) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The transaction object tx is typed as any. To improve type safety and code clarity, it's better to define a specific interface or type for the transaction object based on the API response structure. For example: interface BtcTransaction { txHash: string; /* ... other properties */ }.

Suggested change
{addressTransactions.data.map((tx: any) => {
{addressTransactions.data.map((tx: { txHash: string }) => {

Comment on lines +1 to +4
export const metadata = {
title: 'Next.js',
description: 'Generated by Next.js',
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The metadata for this layout is generic ("Next.js", "Generated by Next.js"). While this is for an API route and may not be user-facing, it's good practice to provide more descriptive metadata relevant to your application.

Suggested change
export const metadata = {
title: 'Next.js',
description: 'Generated by Next.js',
}
export const metadata = {
title: 'API - RGB++ Explorer',
description: 'API for the RGB++ Explorer',
}

"testRequest": { ... },
"targetUrl": "https://web3-api-testnet.magickbase.com/api/trpc",
"proxyEndpoint": "/api/proxy",
"timestamp": "2024-01-05T10:30:00Z"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The example responses in the documentation contain hardcoded timestamps (e.g., "2024-01-05T10:30:00Z"). It would be clearer to replace these with a placeholder like "<timestamp>" to indicate that this value is dynamic. This applies to other examples in this file as well.

Suggested change
"timestamp": "2024-01-05T10:30:00Z"
"timestamp": "<timestamp>"

target: {
url: string
status: string
response: any
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The response property in the ProxyStatus.target interface is typed as any. Based on the implementation in /api/proxy/status/route.ts, you can use a more specific type to improve type safety.

Suggested change
response: any
response: { status: number; statusText: string; ok: boolean; } | { error: string; code?: string; } | null

Comment on lines +14 to +20
if (isProxyOn) {
console.log('Using proxy for tRPC requests')
return '/api/proxy'
} else {
console.log('Using direct tRPC URL')
return process.env.NEXT_PUBLIC_TRPC_API_URL || 'https://web3-api-testnet.magickbase.com/api/trpc/'
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

There are console.log statements used for debugging. While the Next.js config is set to remove them in production, it's a better practice to use a dedicated logging library (like pino or winston) or a conditional logging utility. This provides more control over log levels and output across different environments and avoids cluttering the console during development.

vercel Bot and others added 2 commits January 5, 2026 08:39
Updated dependencies to fix Next.js and React CVE vulnerabilities.

The fix-react2shell-next tool automatically updated the following packages to their secure versions:
- next
- react-server-dom-webpack
- react-server-dom-parcel  
- react-server-dom-turbopack

All package.json files have been scanned and vulnerable versions have been patched to the correct fixed versions based on the official React advisory.

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
…-vu-iz66of

Fix React Server Components CVE vulnerabilities
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants