Skip to content
Open
Show file tree
Hide file tree
Changes from 86 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
6c1372f
feat: enhance Earn Home and Network Avatar components
Charon-Fan Oct 28, 2025
ea12dc9
feat: enhance Earn module with new components
Charon-Fan Oct 29, 2025
df689ce
feat: enhance Earn feature with new protocols page and navigation
Charon-Fan Oct 29, 2025
8ee45d7
Merge branch 'x' into feat/earn-redesign
Charon-Fan Oct 30, 2025
b002d9a
feat: refactor Earn module to improve navigation and UI componentsd l…
Charon-Fan Oct 30, 2025
cc62c9a
feat: enhance Earn components with improved layout and logo URI handling
Charon-Fan Oct 31, 2025
3758963
Merge branch 'x' into feat/earn-redesign
Charon-Fan Oct 31, 2025
420f34f
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 1, 2025
3c6e385
feat: enhance Earn and Staking features with new hooks and components
Charon-Fan Nov 1, 2025
6813b83
fix: rename loading prop to isAccountsLoading for clarity in Earn com…
Charon-Fan Nov 3, 2025
82372d8
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 3, 2025
78f0653
feat: add HeaderRight component for history action in ManagePosition …
Charon-Fan Nov 3, 2025
892f895
feat: update TableList and Earn components for improved layout and re…
Charon-Fan Nov 3, 2025
06d6a3b
feat: refactor Earn components and hooks for improved data handling a…
Charon-Fan Nov 4, 2025
8d54ae4
feat: implement v2 investment and asset handling in Earn module
Charon-Fan Nov 4, 2025
1510ca6
Merge remote-tracking branch 'origin/x' into feat/earn-redesign
Charon-Fan Nov 4, 2025
440263d
feat: refactor Earn module to improve account and portfolio handling
Charon-Fan Nov 5, 2025
6e3b0df
feat: refactor Earn module components and hooks for improved structur…
Charon-Fan Nov 5, 2025
1f49131
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 5, 2025
11f320e
feat: refactor ProtocolDetailsPage to improve data handling and remov…
Charon-Fan Nov 5, 2025
710d59c
feat: add 'link' variant to Button component and refactor PortfolioTa…
Charon-Fan Nov 5, 2025
062003f
feat: enhance staking and earn modules with airdrop support, metadata…
Charon-Fan Nov 6, 2025
d0efd9b
feat: add airdrop investment support and refactor related components …
Charon-Fan Nov 6, 2025
e8e75da
feat: implement manage page functionality and enhance staking data ha…
Charon-Fan Nov 7, 2025
5ce802c
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 7, 2025
9b117e2
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 7, 2025
0837483
feat: add row press handling for portfolio items and optimize batch u…
Charon-Fan Nov 7, 2025
0b5e4ee
feat: enhance staking functionality with new portfolio action handlin…
Charon-Fan Nov 7, 2025
e4405bb
feat: enhance WrappedActionButton and usePortfolioAction to support r…
Charon-Fan Nov 7, 2025
cb89224
export EarnHomeWithProvider
huhuanming Nov 7, 2025
79d0234
feat: add alerts handling to manage position page and update response…
Charon-Fan Nov 7, 2025
98d0237
feat: add check for token price before estimating gas fee in claim fu…
Charon-Fan Nov 7, 2025
b9fa1e7
feat: add approve information to protocol data in useManagePage hook
Charon-Fan Nov 7, 2025
c142ee6
feat: add IEarnSummaryV2 interface and getEarnSummaryV2 method to Ser…
Charon-Fan Nov 8, 2025
1cd756d
feat: enhance Overview component with rebate data handling and display
Charon-Fan Nov 10, 2025
649313d
chore: fix uniswap connect (#8903)
ByteZhang1024 Nov 7, 2025
0f1b495
fix: cloud backup bugs (#8904)
sidmorizon Nov 7, 2025
648f134
fix: some swap issue (#8905)
ezailWang Nov 7, 2025
ee21a43
partial onboarding i18n & animation fine turning (#8906)
franco-chan Nov 7, 2025
cb2765e
fix: transfer events (#8908)
sidmorizon Nov 7, 2025
451f70c
feat: integrate backup mnemonic page && add flow error monitoring (#8…
huhuanming Nov 8, 2025
0a5cb7e
chore: fix image compression & clear code (#8912)
ByteZhang1024 Nov 8, 2025
e3183fd
fix: optimize transfer events (#8910)
sidmorizon Nov 8, 2025
4243162
feat: add IP table support for App client (#8907)
originalix Nov 8, 2025
ea0dde5
Feat/bifrost dot (#8914)
ByteZhang1024 Nov 8, 2025
e97340e
optimize: non backed up empty view & receive token modal OK-44402 OK-…
weatherstar Nov 8, 2025
4a801a0
fix: add perp deposit event (#8913)
ezailWang Nov 8, 2025
5de2e24
fix: improve account existence check in useEarnAccounts hook
Charon-Fan Nov 10, 2025
d06f38c
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 10, 2025
118d5e9
fix: enhance handleHistoryPress to fetch current earn account details
Charon-Fan Nov 10, 2025
bbb4f30
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 10, 2025
1351b9f
fix: improve layout and responsiveness in PortfolioTabContent and Tab…
Charon-Fan Nov 10, 2025
ff4ffec
feat: add event bus support for refreshing earn portfolio items
Charon-Fan Nov 10, 2025
8cdfc98
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 12, 2025
dfed9d1
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 12, 2025
a96b17a
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 12, 2025
cda0375
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 12, 2025
06c5939
feat: add portfolioSymbol to claim actions and refresh logic
Charon-Fan Nov 10, 2025
83d266d
feat: refactor EarnMainTabs and PortfolioTabContent for improved mobi…
Charon-Fan Nov 11, 2025
68ec1b4
feat: add event bus support for refreshing earn portfolio and improve…
Charon-Fan Nov 11, 2025
f1a3fc3
feat: add APY history response interfaces and implement getApyHistory…
Charon-Fan Nov 11, 2025
b620084
feat: Implement ApyChart component for displaying APY history
Charon-Fan Nov 12, 2025
749cb0b
feat: EarnProtocolDetails share
Charon-Fan Nov 12, 2025
d80b299
feat: refactor EarnProtocolDetails to improve navigation and add foot…
Charon-Fan Nov 12, 2025
f5e5ec8
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 12, 2025
8b0de1c
feat: enhance portfolio actions with stakedSymbol support for airdrop…
Charon-Fan Nov 12, 2025
07b4535
feat: add validation for required data in StakeSection and WithdrawSe…
Charon-Fan Nov 12, 2025
6efa192
feat: i18n
Charon-Fan Nov 12, 2025
77465ea
feat: improve loading state handling in PortfolioTabContent
Charon-Fan Nov 12, 2025
9f5f1f9
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 12, 2025
643aa22
feat: adjust padding for Overview component based on screen size
Charon-Fan Nov 12, 2025
2c8bc64
feat: add account and address validation to disable action buttons in…
Charon-Fan Nov 12, 2025
84db51d
feat: update navigation for Earn protocols and enhance conditional re…
Charon-Fan Nov 12, 2025
4f6086d
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 13, 2025
1fccfb3
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 13, 2025
f52e71e
feat: add recommended tokens functionality to earn context and compon…
Charon-Fan Nov 13, 2025
f08e362
feat: add banner management functionality to earn context and components
Charon-Fan Nov 13, 2025
fa2300a
feat: rename fetchEarnHomePageData to fetchEarnHomePageBannerList for…
Charon-Fan Nov 13, 2025
a77ec0f
feat: replace useAllNetworkId hook with direct getNetworkIdsMap usage…
Charon-Fan Nov 13, 2025
13be888
feat: refactor RecommendedItem to use memoization and pass account de…
Charon-Fan Nov 13, 2025
23f70b6
Merge branch 'x' into feat/earn-redesign
Charon-Fan Nov 13, 2025
49dfcb3
feat: update investment filtering to exclude zero-value investments, …
Charon-Fan Nov 13, 2025
c1c74f7
feat: refactor ApyChart to track mouse position for popover and add P…
Charon-Fan Nov 13, 2025
75ef05b
feat: enhance Earn and Staking components with new header and footer …
Charon-Fan Nov 14, 2025
df3c6e4
feat: implement LightweightChart component
Charon-Fan Nov 14, 2025
a84502e
feat: enhance Earn and ManagePosition components to support tab navig…
Charon-Fan Nov 14, 2025
7e8d6ed
feat: earn i18n
Charon-Fan Nov 14, 2025
b622012
feat: add useProtocolDetailBreadcrumb
Charon-Fan Nov 14, 2025
56746ac
feat: enhance Earn and ManagePosition components with improved loadin…
Charon-Fan Nov 14, 2025
24fd9d0
feat: wrap Overview component in XStack for improved layout
Charon-Fan Nov 14, 2025
b17e359
feat: update route types and add new action icon for Earn details
Charon-Fan Nov 14, 2025
022fb3e
feat: remove revalidateOnFocus option and update accountId reference …
Charon-Fan Nov 15, 2025
bcbd06c
feat: add popover position calculation and update accountId reference…
Charon-Fan Nov 15, 2025
0c5d840
feat: refactor ManagePosition components for improved structure and r…
Charon-Fan Nov 15, 2025
aa13f36
feat: implement USDe handling in ManagePosition components and relate…
Charon-Fan Nov 15, 2025
4a41c5a
feat: refactor ManagePosition and ManagePositionContent for USDe prot…
Charon-Fan Nov 15, 2025
b233eaf
feat: remove unused accordion trigger text in UniversalStake and Univ…
Charon-Fan Nov 15, 2025
3763b42
feat: update layout in Overview component for improved responsiveness
Charon-Fan Nov 15, 2025
80ccba3
feat: add rewardSymbol support in portfolio actions and hooks for imp…
Charon-Fan Nov 15, 2025
1d821b3
feat: enhance navigation handling in ManagePositionContent for modal …
Charon-Fan Nov 15, 2025
b19e846
feat: enhance withdrawal navigation handling in ManagePositionContent…
Charon-Fan Nov 15, 2025
6ee7054
feat: refactor navigation handling in ManagePositionContent, StakeSec…
Charon-Fan Nov 15, 2025
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
3 changes: 3 additions & 0 deletions packages/components/src/content/Breadcrumb/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const BreadcrumbItem = styled(XStack, {
alignItems: 'center',
cursor: 'pointer',
userSelect: 'none',
borderRadius: '$2',
px: '$2',
py: '$1',
pressStyle: {
bg: '$bgHover',
},
Expand Down
10 changes: 9 additions & 1 deletion packages/components/src/primitives/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import type { IIconProps, IKeyOfIcons } from '../Icon';
export interface IButtonProps extends ThemeableStackProps {
type?: ButtonHTMLAttributes<HTMLButtonElement>['type'];
size?: 'small' | 'medium' | 'large';
variant?: 'secondary' | 'tertiary' | 'primary' | 'destructive';
variant?: 'secondary' | 'tertiary' | 'primary' | 'destructive' | 'link';
icon?: IKeyOfIcons;
iconAfter?: IKeyOfIcons;
disabled?: boolean;
Expand Down Expand Up @@ -95,6 +95,14 @@ const BUTTON_VARIANTS: Record<
activeBg: '$bgStrongActive',
focusRingColor: '$focusRing',
},
link: {
color: '$textInfo',
iconColor: '$iconInfo',
bg: '$transparent',
hoverBg: '$transparent',
activeBg: '$transparent',
focusRingColor: '$focusRing',
},
};

export const getSharedButtonStyles = ({
Expand Down
157 changes: 154 additions & 3 deletions packages/kit-bg/src/services/ServiceStaking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import type {
ECheckAmountActionType,
EInternalDappEnum,
IAllowanceOverview,
IApyHistoryResponse,
IAvailableAsset,
IBabylonPortfolioItem,
IBuildPermit2ApproveSignDataParams,
Expand All @@ -45,14 +46,18 @@ import type {
IEarnAccountResponse,
IEarnAccountToken,
IEarnAccountTokenResponse,
IEarnAirdropInvestmentItemV2,
IEarnBabylonTrackingItem,
IEarnEstimateAction,
IEarnEstimateFeeResp,
IEarnFAQList,
IEarnInvestmentItem,
IEarnInvestmentItemV2,
IEarnManagePageResponse,
IEarnPermit2ApproveSignData,
IEarnRegisterSignMessageResponse,
IEarnSummary,
IEarnSummaryV2,
IEarnUnbondingDelegationList,
IGetPortfolioParams,
IRecommendAsset,
Expand Down Expand Up @@ -112,6 +117,20 @@ interface IAvailableAssetsResponse {
data: { assets: IAvailableAsset[] };
}

interface IAvailableAssetsResponseV2 {
code: string;
message?: string;
data: {
assets: {
type: 'normal' | 'airdrop';
networkId: string;
provider: string;
symbol: string;
vault?: string;
}[];
};
}

@backgroundClass()
class ServiceStaking extends ServiceBase {
constructor({ backgroundApi }: { backgroundApi: any }) {
Expand Down Expand Up @@ -163,6 +182,26 @@ class ServiceStaking extends ServiceBase {
return response.data.data;
}

@backgroundMethod()
async getEarnSummaryV2({
accountAddress,
networkId,
}: {
accountAddress: string;
networkId: string;
}): Promise<IEarnSummaryV2> {
const client = await this.getClient(EServiceEndpointEnum.Earn);
const response = await client.get<{
data: IEarnSummaryV2;
}>('/earn/v2/rebate', {
params: {
accountAddress,
networkId,
},
});
return response.data.data;
}

@backgroundMethod()
public async fetchLocalStakingHistory({
accountId,
Expand Down Expand Up @@ -623,6 +662,32 @@ class ServiceStaking extends ServiceBase {
return result as unknown as IStakeEarnDetail;
}

@backgroundMethod()
async getManagePage(params: {
networkId: string;
provider: string;
symbol: string;
vault?: string;
accountAddress: string;
publicKey?: string;
}) {
const client = await this.getClient(EServiceEndpointEnum.Earn);
const requestParams = {
networkId: params.networkId,
provider: params.provider.toLowerCase(),
symbol: params.symbol,
accountAddress: params.accountAddress,
...(params.vault && { vault: params.vault }),
...(params.publicKey && { publicKey: params.publicKey }),
};

const resp = await client.get<{ data: IEarnManagePageResponse }>(
'/earn/v1/manage-page',
{ params: requestParams },
);
return resp.data.data;
}

@backgroundMethod()
async getTransactionConfirmation(params: {
networkId: string;
Expand Down Expand Up @@ -1028,6 +1093,44 @@ class ServiceStaking extends ServiceBase {
return response.data.data;
}

@backgroundMethod()
async fetchInvestmentDetailV2(params: {
publicKey?: string | undefined;
vault?: string | undefined;
accountAddress: string;
networkId: string;
provider: string;
symbol: string;
}) {
const client = await this.getClient(EServiceEndpointEnum.Earn);

const response = await client.get<{ data: IEarnInvestmentItemV2 }>(
`/earn/v2/investment/detail`,
{ params },
);

return response.data.data;
}

@backgroundMethod()
async fetchAirdropInvestmentDetail(params: {
publicKey?: string | undefined;
vault?: string | undefined;
accountAddress: string;
networkId: string;
provider: string;
symbol: string;
}) {
const client = await this.getClient(EServiceEndpointEnum.Earn);

const response = await client.get<{ data: IEarnAirdropInvestmentItemV2 }>(
`/earn/v1/investment/airdrop-detail`,
{ params },
);

return response.data.data;
}

Comment on lines +1097 to +1133
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 | 🟠 Major

Lowercase provider before calling the v2 detail APIs.

Both fetchInvestmentDetailV2 and fetchAirdropInvestmentDetail forward the provider string without normalization. A mixed-case provider (for example "Babylon") slips through here, the backend lookup fails, and the returned V2 payload is empty. Please mirror the normalization already used in getManagePage / getApyHistory and force the provider to lowercase before issuing these requests.

Apply this diff:

   @backgroundMethod()
   async fetchInvestmentDetailV2(params: {
     publicKey?: string | undefined;
     vault?: string | undefined;
     accountAddress: string;
     networkId: string;
     provider: string;
     symbol: string;
   }) {
     const client = await this.getClient(EServiceEndpointEnum.Earn);

-    const response = await client.get<{ data: IEarnInvestmentItemV2 }>(
-      `/earn/v2/investment/detail`,
-      { params },
-    );
+    const requestParams = {
+      ...params,
+      provider: params.provider.toLowerCase(),
+    };
+
+    const response = await client.get<{ data: IEarnInvestmentItemV2 }>(
+      `/earn/v2/investment/detail`,
+      { params: requestParams },
+    );

     return response.data.data;
   }

   @backgroundMethod()
   async fetchAirdropInvestmentDetail(params: {
     publicKey?: string | undefined;
     vault?: string | undefined;
     accountAddress: string;
     networkId: string;
     provider: string;
     symbol: string;
   }) {
     const client = await this.getClient(EServiceEndpointEnum.Earn);

-    const response = await client.get<{ data: IEarnAirdropInvestmentItemV2 }>(
-      `/earn/v1/investment/airdrop-detail`,
-      { params },
-    );
+    const response = await client.get<{ data: IEarnAirdropInvestmentItemV2 }>(
+      `/earn/v1/investment/airdrop-detail`,
+      {
+        params: {
+          ...params,
+          provider: params.provider.toLowerCase(),
+        },
+      },
+    );

     return response.data.data;
   }
🤖 Prompt for AI Agents
In packages/kit-bg/src/services/ServiceStaking.ts around lines 1097 to 1133,
both fetchInvestmentDetailV2 and fetchAirdropInvestmentDetail pass the provider
string as-is; normalize it to lowercase before calling the backend to avoid
lookup failures for mixed-case provider names. Update each method to copy/modify
the params (or set params.provider) to params.provider =
params.provider?.toLowerCase() (or construct a new paramsLower = { ...params,
provider: params.provider?.toLowerCase() }) and then pass that normalized params
object to client.get.

_getAvailableAssets = memoizee(
async ({ type }: { type?: EAvailableAssetsTypeEnum }) => {
const client = await this.getRawDataClient(EServiceEndpointEnum.Earn);
Expand Down Expand Up @@ -1062,6 +1165,21 @@ class ServiceStaking extends ServiceBase {
void this._getAvailableAssets.clear();
}

@backgroundMethod()
async getAvailableAssetsV2() {
const client = await this.getRawDataClient(EServiceEndpointEnum.Earn);
const resp = await client.get<
IAvailableAssetsResponseV2,
IAxiosResponse<IAvailableAssetsResponseV2>
>(`/earn/v2/available-assets`);

this.handleServerError({
...resp.data,
requestId: resp.$requestId,
});
return resp.data.data.assets;
}

handleServerError(data: {
code?: string | number;
message?: string;
Expand Down Expand Up @@ -1322,11 +1440,11 @@ class ServiceStaking extends ServiceBase {
}

@backgroundMethod()
fetchEarnHomePageData() {
return this._fetchEarnHomePageData();
fetchEarnHomePageBannerList() {
return this._fetchEarnHomePageBannerList();
}

_fetchEarnHomePageData = memoizee(
_fetchEarnHomePageBannerList = memoizee(
async () => {
const client = await this.getClient(EServiceEndpointEnum.Utility);
const res = await client.get<{ data: IDiscoveryBanner[] }>(
Expand Down Expand Up @@ -1705,6 +1823,39 @@ class ServiceStaking extends ServiceBase {
return null;
}
}

@backgroundMethod()
async getApyHistory(params: {
networkId: string;
provider: string;
symbol: string;
vault?: string;
}) {
const client = await this.getClient(EServiceEndpointEnum.Earn);
const requestParams: {
networkId: string;
provider: string;
symbol: string;
vault?: string;
} = {
networkId: params.networkId,
provider: params.provider.toLowerCase(),
symbol: params.symbol,
};

if (params.vault) {
requestParams.vault = params.vault;
}

const response = await client.get<IApyHistoryResponse>(
'/earn/v1/apy/history',
{
params: requestParams,
},
);

return response.data.data;
}
}

export default ServiceStaking;
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';

import { View } from 'react-native';
import WebView from 'react-native-webview';

import { Stack } from '@onekeyhq/components';

import { useChartConfig } from './hooks/useChartConfig';
import { generateChartHTML } from './utils/htmlTemplate';

import type { IChartMessage, ILightweightChartProps } from './types';
import type { WebViewMessageEvent } from 'react-native-webview';

export function LightweightChart({
data,
height,
lineColor,
topColor,
bottomColor,
onHover,
}: ILightweightChartProps) {
const webViewRef = useRef<WebView>(null);
const [webViewReady, setWebViewReady] = useState(false);

const chartConfig = useChartConfig({
data,
lineColor,
topColor,
bottomColor,
});
const htmlContent = useMemo(
() => generateChartHTML(chartConfig),
[chartConfig],
);

const handleMessage = useCallback(
(event: WebViewMessageEvent) => {
try {
const message = JSON.parse(event.nativeEvent.data) as IChartMessage;

if (message.type === 'ready') {
setWebViewReady(true);
} else if (message.type === 'hover' && onHover) {
onHover({
time: message.time ? Number(message.time) : undefined,
price: message.price ? Number(message.price) : undefined,
x: message.x,
y: message.y,
});
}
} catch (error) {
console.error(
'LightweightChart: Error parsing WebView message:',
error,
);
}
},
[onHover],
);

// Update chart when data changes
useEffect(() => {
if (webViewReady && webViewRef.current) {
const updateScript = `
(function() {
const newConfig = ${JSON.stringify(chartConfig)};
if (window.series) {
window.series.setData(newConfig.data);
window.chart.timeScale().fitContent();
}
})();
true;
`;
webViewRef.current.injectJavaScript(updateScript);
}
}, [chartConfig, webViewReady]);
Comment on lines +62 to +76
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 | 🔴 Critical

🧩 Analysis chain

Check serialized config size and injection performance.

Line 66 serializes the entire chartConfig with JSON.stringify on every data update. For large datasets, this could impact performance. Additionally, no error handling exists if injectJavaScript fails.

Consider:

  1. Measuring the typical size of chartConfig.data arrays
  2. Adding error handling for injection failures
  3. Potentially debouncing updates if data changes rapidly

🏁 Script executed:

#!/bin/bash
# Check typical usage patterns of LightweightChart to assess data size
rg -A 5 -B 2 '<LightweightChart' --type=tsx --type=ts

Length of output: 27



---

🏁 Script executed:

```shell
#!/bin/bash
# Find LightweightChart usage with corrected syntax
rg -A 5 -B 2 '<LightweightChart' -g '*.ts' -g '*.tsx'

Length of output: 812


🏁 Script executed:

#!/bin/bash
# Look for error handling patterns around injectJavaScript
rg -n 'injectJavaScript' -C 4 -g '*.ts' -g '*.tsx'

Length of output: 7246


🏁 Script executed:

#!/bin/bash
# Check if debounce or throttle is used anywhere in the component file
rg -n 'debounce|throttle|memo|useMemo|useCallback' packages/kit/src/components/LightweightChart/LightweightChart.native.tsx

Length of output: 150


🏁 Script executed:

#!/bin/bash
# Examine the full LightweightChart.native.tsx file around the useEffect
cat packages/kit/src/components/LightweightChart/LightweightChart.native.tsx | head -100

Length of output: 2758


Add error handling for injectJavaScript call.

Line 74 lacks a try-catch wrapper. Other injectJavaScript calls in the codebase (explorerUtils.ts, Browser.native.tsx, discovery/actions.ts) wrap this in try-catch because the call can fail—especially on mobile orientation changes—and crash the app. Apply the same pattern here.

For JSON serialization and update frequency: the component already uses useMemo for the HTML content. Monitor actual usage patterns in production before optimizing further, but error handling is mandatory now.

🤖 Prompt for AI Agents
In packages/kit/src/components/LightweightChart/LightweightChart.native.tsx
around lines 62 to 76, the webViewRef.current.injectJavaScript call is not
wrapped in error handling and can throw (e.g. on orientation changes); wrap the
injectJavaScript invocation in a try-catch, catch any thrown error, and handle
it consistently with other parts of the codebase (log the error via the existing
logger or console.error with context) so the app does not crash; ensure the try
block only contains the injectJavaScript call and keep the existing logic
otherwise unchanged.


return (
<Stack position="relative" height={height} width="100%">
<View style={{ flex: 1 }}>
<WebView
ref={webViewRef}
source={{ html: htmlContent }}
onMessage={handleMessage}
scrollEnabled={false}
showsVerticalScrollIndicator={false}
showsHorizontalScrollIndicator={false}
bounces={false}
style={{ backgroundColor: 'transparent' }}
androidLayerType="hardware"
originWhitelist={['*']}
allowFileAccess={false}
allowUniversalAccessFromFileURLs={false}
mixedContentMode="never"
/>
</View>
</Stack>
);
}
Loading
Loading