Skip to content
Closed
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
Binary file modified android/.yarn/install-state.gz
Binary file not shown.
587 changes: 185 additions & 402 deletions android/App.js

Large diffs are not rendered by default.

45 changes: 29 additions & 16 deletions android/components/BalancesTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,28 +102,41 @@ export const BalancesTableRow = ({

// Fetch real SOL price from REST API if GraphQL price is $1 or less
useEffect(() => {
// Only fetch if this is SOL and API price is suspiciously low
if (symbol !== "SOL" || apiPrice > 1) {
return;
}

const abortController = new AbortController();
const timeoutId = setTimeout(() => abortController.abort(), 3000); // 3s timeout

const fetchRealPrice = async () => {
// Check if this is SOL and API price is suspiciously low
if (symbol === "SOL" && apiPrice <= 1) {
try {
// Use a sample Solana address to fetch current SOL price from REST API
const response = await fetch(
"http://162.250.126.66:4000/wallet/So11111111111111111111111111111111111111112?providerId=SOLANA-mainnet"
);
const data = await response.json();
// Extract SOL price from first token in response
const solPrice = data?.tokens?.[0]?.price;
if (solPrice && solPrice > 0) {
setRealPrice(solPrice);
}
} catch (error) {
console.error("Failed to fetch SOL price from REST API:", error);
// Keep using API price as fallback
try {
const response = await fetch(
"http://162.250.126.66:4000/wallet/So11111111111111111111111111111111111111112?providerId=SOLANA-mainnet",
{ signal: abortController.signal }
);
const data = await response.json();
const solPrice = data?.tokens?.[0]?.price;
if (solPrice && solPrice > 0) {
setRealPrice(solPrice);
}
} catch (error) {
if (error.name !== 'AbortError') {
console.error("Failed to fetch SOL price:", error);
}
// Keep using API price as fallback
} finally {
clearTimeout(timeoutId);
}
};

fetchRealPrice();

return () => {
clearTimeout(timeoutId);
abortController.abort();
};
}, [symbol, apiPrice]);

// Use real price (fetched or API)
Expand Down
113 changes: 113 additions & 0 deletions android/components/SimpleBottomSheet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import React, { useState, useImperativeHandle, forwardRef } from 'react';
import {
Modal,
View,
TouchableOpacity,
StyleSheet,
Animated,
Dimensions,
ScrollView,
TouchableWithoutFeedback,
} from 'react-native';

const { height: SCREEN_HEIGHT } = Dimensions.get('window');

export interface SimpleBottomSheetProps {
children: React.ReactNode;
snapPoints?: (string | number)[];
enablePanDownToClose?: boolean;
index?: number;
onChange?: (index: number) => void;
backdropComponent?: any;
}

export interface SimpleBottomSheetRef {
close: () => void;
expand: () => void;
snapToIndex: (index: number) => void;
}

const SimpleBottomSheet = forwardRef<SimpleBottomSheetRef, SimpleBottomSheetProps>(
({ children, snapPoints = ['50%'], index = -1, onChange }, ref) => {
const [visible, setVisible] = useState(index >= 0);

useImperativeHandle(ref, () => ({
close: () => {
setVisible(false);
onChange?.(-1);
},
expand: () => {
setVisible(true);
onChange?.(0);
},
snapToIndex: (idx: number) => {
setVisible(idx >= 0);
onChange?.(idx);
},
}));

return (
<Modal
visible={visible}
transparent
animationType="slide"
onRequestClose={() => {
setVisible(false);
onChange?.(-1);
}}
>
<TouchableWithoutFeedback
onPress={() => {
setVisible(false);
onChange?.(-1);
}}
>
<View style={styles.backdrop}>
<TouchableWithoutFeedback>
<View style={styles.bottomSheet}>{children}</View>
</TouchableWithoutFeedback>
</View>
</TouchableWithoutFeedback>
</Modal>
);
}
);

export const SimpleBottomSheetView: React.FC<{ children: React.ReactNode; style?: any }> = ({
children,
style,
}) => <View style={[styles.content, style]}>{children}</View>;

export const SimpleBottomSheetScrollView: React.FC<{
children: React.ReactNode;
contentContainerStyle?: any;
}> = ({ children, contentContainerStyle }) => (
<ScrollView style={styles.scrollView} contentContainerStyle={contentContainerStyle}>
{children}
</ScrollView>
);

export const SimpleBottomSheetBackdrop: React.FC<any> = () => null;

const styles = StyleSheet.create({
backdrop: {
flex: 1,
backgroundColor: 'rgba(0, 0, 0, 0.7)',
justifyContent: 'flex-end',
},
bottomSheet: {
backgroundColor: '#1a1a1a',
borderTopLeftRadius: 20,
borderTopRightRadius: 20,
maxHeight: SCREEN_HEIGHT * 0.9,
paddingBottom: 20,
},
content: {
padding: 16,
},
scrollView: {
maxHeight: SCREEN_HEIGHT * 0.8,
},
});

export default SimpleBottomSheet;
1 change: 1 addition & 0 deletions android/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "react-native-reanimated";
import "react-native-get-random-values";
import { Buffer } from "@craftzdog/react-native-buffer";
global.Buffer = Buffer;
Expand Down
Loading
Loading