mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-22 04:27:56 +00:00
Fix ESLint errors: remove any types, fix console statements, remove unused vars
This commit is contained in:
@@ -14,15 +14,22 @@ import {
|
||||
} from 'react-native';
|
||||
import { useFocusEffect } from '@react-navigation/native';
|
||||
import { LinearGradient } from 'expo-linear-gradient';
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
import { useNavigation, NavigationProp, ParamListBase } from '@react-navigation/native';
|
||||
import { useAuth } from '../contexts/AuthContext';
|
||||
import { useTheme } from '../contexts/ThemeContext';
|
||||
import { KurdistanColors } from '../theme/colors';
|
||||
import { supabase } from '../lib/supabase';
|
||||
import AvatarPickerModal from '../components/AvatarPickerModal';
|
||||
|
||||
// Alert button type for cross-platform compatibility
|
||||
interface AlertButton {
|
||||
text: string;
|
||||
onPress?: () => void;
|
||||
style?: 'default' | 'cancel' | 'destructive';
|
||||
}
|
||||
|
||||
// Cross-platform alert helper
|
||||
const showAlert = (title: string, message: string, buttons?: Array<{text: string; onPress?: () => void; style?: string}>) => {
|
||||
const showAlert = (title: string, message: string, buttons?: AlertButton[]) => {
|
||||
if (Platform.OS === 'web') {
|
||||
if (buttons && buttons.length > 1) {
|
||||
const result = window.confirm(`${title}\n\n${message}`);
|
||||
@@ -33,7 +40,7 @@ const showAlert = (title: string, message: string, buttons?: Array<{text: string
|
||||
window.alert(`${title}\n\n${message}`);
|
||||
}
|
||||
} else {
|
||||
Alert.alert(title, message, buttons as any);
|
||||
Alert.alert(title, message, buttons);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -83,7 +90,7 @@ interface ProfileData {
|
||||
}
|
||||
|
||||
const ProfileScreen: React.FC = () => {
|
||||
const navigation = useNavigation<any>();
|
||||
const navigation = useNavigation<NavigationProp<ParamListBase>>();
|
||||
const { user, signOut } = useAuth();
|
||||
const { isDarkMode, colors, fontScale } = useTheme();
|
||||
const [profileData, setProfileData] = useState<ProfileData | null>(null);
|
||||
@@ -235,7 +242,7 @@ const ProfileScreen: React.FC = () => {
|
||||
icon="👥"
|
||||
title="Referrals"
|
||||
value={`${profileData?.referral_count || 0} people`}
|
||||
onPress={() => (navigation as any).navigate('Referral')}
|
||||
onPress={() => navigation.navigate('Referral')}
|
||||
testID="profile-card-referrals"
|
||||
/>
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ const SignInScreen: React.FC<SignInScreenProps> = ({ onSignIn, onNavigateToSignU
|
||||
onPress={onNavigateToSignUp}
|
||||
>
|
||||
<Text style={styles.signUpPromptText}>
|
||||
Don't have an account?{' '}
|
||||
Don't have an account?{' '}
|
||||
<Text style={styles.signUpLink}>Sign Up</Text>
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
@@ -70,8 +70,10 @@ export default function StakingScreen() {
|
||||
const scores = await getAllScores(api, selectedAccount.address);
|
||||
|
||||
// 3. Get Current Era
|
||||
const currentEraOpt = await api.query.staking.currentEra() as any;
|
||||
const currentEra = currentEraOpt.unwrapOrDefault().toNumber();
|
||||
const currentEraOpt = await api.query.staking.currentEra();
|
||||
const currentEra = currentEraOpt.isSome
|
||||
? (currentEraOpt as unknown as { unwrap: () => { toNumber: () => number } }).unwrap().toNumber()
|
||||
: 0;
|
||||
|
||||
// Calculations
|
||||
const stakedAmount = stakingInfo.bonded;
|
||||
|
||||
@@ -8,27 +8,25 @@ import {
|
||||
TouchableOpacity,
|
||||
TextInput,
|
||||
Modal,
|
||||
ActivityIndicator,
|
||||
Alert,
|
||||
Platform,
|
||||
Image,
|
||||
ImageSourcePropType,
|
||||
} from 'react-native';
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
import { KurdistanColors } from '../theme/colors';
|
||||
import { usePezkuwi } from '../contexts/PezkuwiContext';
|
||||
import { KurdistanSun } from '../components/KurdistanSun';
|
||||
|
||||
// Standardized token logos
|
||||
const hezLogo = require('../../../shared/images/hez_token_512.png');
|
||||
const pezLogo = require('../../../shared/images/pez_token_512.png');
|
||||
const usdtLogo = require('../../../shared/images/USDT(hez)logo.png');
|
||||
import hezLogo from '../../../shared/images/hez_token_512.png';
|
||||
import pezLogo from '../../../shared/images/pez_token_512.png';
|
||||
import usdtLogo from '../../../shared/images/USDT(hez)logo.png';
|
||||
|
||||
interface TokenInfo {
|
||||
symbol: string;
|
||||
name: string;
|
||||
assetId: number;
|
||||
decimals: number;
|
||||
logo: any;
|
||||
logo: ImageSourcePropType;
|
||||
}
|
||||
|
||||
const TOKENS: TokenInfo[] = [
|
||||
@@ -40,7 +38,6 @@ const TOKENS: TokenInfo[] = [
|
||||
type TransactionStatus = 'idle' | 'signing' | 'submitting' | 'success' | 'error';
|
||||
|
||||
const SwapScreen: React.FC = () => {
|
||||
const navigation = useNavigation<any>();
|
||||
const { api, isApiReady, selectedAccount, getKeyPair } = usePezkuwi();
|
||||
|
||||
const [fromToken, setFromToken] = useState<TokenInfo>(TOKENS[0]);
|
||||
@@ -64,7 +61,6 @@ const SwapScreen: React.FC = () => {
|
||||
const [isDexAvailable, setIsDexAvailable] = useState(false);
|
||||
|
||||
const [txStatus, setTxStatus] = useState<TransactionStatus>('idle');
|
||||
const [errorMessage, setErrorMessage] = useState('');
|
||||
|
||||
const [showTokenSelector, setShowTokenSelector] = useState<'from' | 'to' | null>(null);
|
||||
const [showSettings, setShowSettings] = useState(false);
|
||||
@@ -78,28 +74,32 @@ const SwapScreen: React.FC = () => {
|
||||
// Fetch From Token Balance
|
||||
try {
|
||||
if (fromToken.symbol === 'HEZ') {
|
||||
const accountInfo = await api.query.system.account(selectedAccount.address) as any;
|
||||
setFromBalance(accountInfo.data.free.toString());
|
||||
const accountInfo = await api.query.system.account(selectedAccount.address);
|
||||
const accountData = accountInfo.toJSON() as { data?: { free?: string } } | null;
|
||||
setFromBalance(accountData?.data?.free?.toString() || '0');
|
||||
} else {
|
||||
const balanceData = await api.query.assets.account(fromToken.assetId, selectedAccount.address) as any;
|
||||
setFromBalance(balanceData.isSome ? balanceData.unwrap().balance.toString() : '0');
|
||||
const balanceData = await api.query.assets.account(fromToken.assetId, selectedAccount.address);
|
||||
const assetBalance = balanceData.toJSON() as { balance?: string } | null;
|
||||
setFromBalance(assetBalance?.balance?.toString() || '0');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch from balance:', error);
|
||||
} catch (_error) {
|
||||
if (__DEV__) console.error('Failed to fetch from balance:', _error);
|
||||
setFromBalance('0');
|
||||
}
|
||||
|
||||
// Fetch To Token Balance
|
||||
try {
|
||||
if (toToken.symbol === 'HEZ') {
|
||||
const accountInfo = await api.query.system.account(selectedAccount.address) as any;
|
||||
setToBalance(accountInfo.data.free.toString());
|
||||
const accountInfo = await api.query.system.account(selectedAccount.address);
|
||||
const accountData = accountInfo.toJSON() as { data?: { free?: string } } | null;
|
||||
setToBalance(accountData?.data?.free?.toString() || '0');
|
||||
} else {
|
||||
const balanceData = await api.query.assets.account(toToken.assetId, selectedAccount.address) as any;
|
||||
setToBalance(balanceData.isSome ? balanceData.unwrap().balance.toString() : '0');
|
||||
const balanceData = await api.query.assets.account(toToken.assetId, selectedAccount.address);
|
||||
const assetBalance = balanceData.toJSON() as { balance?: string } | null;
|
||||
setToBalance(assetBalance?.balance?.toString() || '0');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch to balance:', error);
|
||||
} catch (_error) {
|
||||
if (__DEV__) console.error('Failed to fetch to balance:', _error);
|
||||
setToBalance('0');
|
||||
}
|
||||
};
|
||||
@@ -112,7 +112,7 @@ const SwapScreen: React.FC = () => {
|
||||
if (api && isApiReady) {
|
||||
const hasAssetConversion = api.tx.assetConversion !== undefined;
|
||||
setIsDexAvailable(hasAssetConversion);
|
||||
if (__DEV__ && !hasAssetConversion) {
|
||||
if (!hasAssetConversion && __DEV__) {
|
||||
console.warn('AssetConversion pallet not available in runtime');
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,7 @@ const SwapScreen: React.FC = () => {
|
||||
const reserve1 = Number(BigInt(balance1Hex)) / (10 ** decimals1);
|
||||
|
||||
if (__DEV__) {
|
||||
console.log('Pool reserves found:', { reserve0, reserve1, asset1, asset2 });
|
||||
console.warn('Pool reserves found:', { reserve0, reserve1, asset1, asset2 });
|
||||
}
|
||||
|
||||
// Store pool reserves for AMM calculation
|
||||
@@ -274,7 +274,7 @@ const SwapScreen: React.FC = () => {
|
||||
const amountOut = numerator / denominator;
|
||||
|
||||
if (__DEV__) {
|
||||
console.log('AMM calculation:', {
|
||||
console.warn('AMM calculation:', {
|
||||
amountIn,
|
||||
reserveIn,
|
||||
reserveOut,
|
||||
@@ -348,7 +348,6 @@ const SwapScreen: React.FC = () => {
|
||||
|
||||
setTxStatus('signing');
|
||||
setShowConfirm(false);
|
||||
setErrorMessage('');
|
||||
|
||||
try {
|
||||
const keypair = await getKeyPair(selectedAccount.address);
|
||||
@@ -426,7 +425,6 @@ const SwapScreen: React.FC = () => {
|
||||
if (status.isInBlock) {
|
||||
if (dispatchError) {
|
||||
const errorMsg = dispatchError.toString();
|
||||
setErrorMessage(errorMsg);
|
||||
setTxStatus('error');
|
||||
Alert.alert('Transaction Failed', errorMsg);
|
||||
} else {
|
||||
@@ -440,11 +438,11 @@ const SwapScreen: React.FC = () => {
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error('Swap failed:', error);
|
||||
setErrorMessage(error.message || 'Transaction failed');
|
||||
} catch (error: unknown) {
|
||||
if (__DEV__) console.error('Swap failed:', error);
|
||||
setTxStatus('error');
|
||||
Alert.alert('Error', error.message || 'Swap transaction failed');
|
||||
const errorMessage = error instanceof Error ? error.message : 'Swap transaction failed';
|
||||
Alert.alert('Error', errorMessage);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ import {
|
||||
Platform,
|
||||
Clipboard,
|
||||
Share,
|
||||
ImageSourcePropType,
|
||||
} from 'react-native';
|
||||
import { LinearGradient } from 'expo-linear-gradient';
|
||||
import { useNavigation } from '@react-navigation/native';
|
||||
import { useNavigation, NavigationProp, ParamListBase } from '@react-navigation/native';
|
||||
import QRCode from 'react-native-qrcode-svg';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import * as SecureStore from 'expo-secure-store';
|
||||
@@ -27,8 +27,8 @@ import { usePezkuwi, NetworkType, NETWORKS } from '../contexts/PezkuwiContext';
|
||||
import { AddTokenModal } from '../components/wallet/AddTokenModal';
|
||||
import { QRScannerModal } from '../components/wallet/QRScannerModal';
|
||||
// Token logo PNG files are used directly instead of SVG components
|
||||
import { decodeAddress, checkAddress, encodeAddress } from '@pezkuwi/util-crypto';
|
||||
import { fetchAllTokens, TokenInfo, subscribeToTokenBalances, KNOWN_TOKENS, TOKEN_LOGOS } from '../services/TokenService';
|
||||
import { decodeAddress, checkAddress } from '@pezkuwi/util-crypto';
|
||||
import { fetchAllTokens, TokenInfo, KNOWN_TOKENS, TOKEN_LOGOS } from '../services/TokenService';
|
||||
|
||||
// Secure storage helper - same as in PezkuwiContext
|
||||
const secureStorage = {
|
||||
@@ -41,8 +41,15 @@ const secureStorage = {
|
||||
},
|
||||
};
|
||||
|
||||
// Alert button type for cross-platform compatibility
|
||||
interface AlertButton {
|
||||
text: string;
|
||||
onPress?: () => void;
|
||||
style?: 'default' | 'cancel' | 'destructive';
|
||||
}
|
||||
|
||||
// Cross-platform alert helper
|
||||
const showAlert = (title: string, message: string, buttons?: Array<{text: string; onPress?: () => void; style?: string}>) => {
|
||||
const showAlert = (title: string, message: string, buttons?: AlertButton[]) => {
|
||||
if (Platform.OS === 'web') {
|
||||
if (buttons && buttons.length > 1) {
|
||||
const result = window.confirm(`${title}\n\n${message}`);
|
||||
@@ -56,20 +63,15 @@ const showAlert = (title: string, message: string, buttons?: Array<{text: string
|
||||
if (buttons?.[0]?.onPress) buttons[0].onPress();
|
||||
}
|
||||
} else {
|
||||
Alert.alert(title, message, buttons as any);
|
||||
Alert.alert(title, message, buttons);
|
||||
}
|
||||
};
|
||||
|
||||
// Token Images - From shared/images
|
||||
// Standardized token logos
|
||||
const hezLogo = require('../../../shared/images/hez_token_512.png');
|
||||
const pezLogo = require('../../../shared/images/pez_token_512.png');
|
||||
const usdtLogo = require('../../../shared/images/USDT(hez)logo.png');
|
||||
const dotLogo = require('../../../shared/images/dot.png');
|
||||
const btcLogo = require('../../../shared/images/bitcoin.png');
|
||||
const ethLogo = require('../../../shared/images/etherium.png');
|
||||
const bnbLogo = require('../../../shared/images/BNB_logo.png');
|
||||
const adaLogo = require('../../../shared/images/ADAlogo.png');
|
||||
// Standardized token logos (only used ones imported)
|
||||
import hezLogo from '../../../shared/images/hez_token_512.png';
|
||||
import pezLogo from '../../../shared/images/pez_token_512.png';
|
||||
import usdtLogo from '../../../shared/images/USDT(hez)logo.png';
|
||||
|
||||
interface Token {
|
||||
symbol: string;
|
||||
@@ -77,7 +79,7 @@ interface Token {
|
||||
balance: string;
|
||||
value: string;
|
||||
change: string;
|
||||
logo: any; // Image source
|
||||
logo: ImageSourcePropType;
|
||||
assetId?: number;
|
||||
isLive: boolean;
|
||||
}
|
||||
@@ -95,28 +97,25 @@ interface Transaction {
|
||||
}
|
||||
|
||||
const WalletScreen: React.FC = () => {
|
||||
const navigation = useNavigation<any>();
|
||||
const navigation = useNavigation<NavigationProp<ParamListBase>>();
|
||||
const {
|
||||
api,
|
||||
isApiReady,
|
||||
accounts,
|
||||
selectedAccount,
|
||||
setSelectedAccount,
|
||||
connectWallet,
|
||||
disconnectWallet,
|
||||
createWallet,
|
||||
deleteWallet,
|
||||
getKeyPair,
|
||||
currentNetwork,
|
||||
switchNetwork,
|
||||
error: pezkuwiError
|
||||
} = usePezkuwi();
|
||||
|
||||
const [selectedToken, setSelectedToken] = useState<Token | null>(null);
|
||||
const [sendModalVisible, setSendModalVisible] = useState(false);
|
||||
const [receiveModalVisible, setReceiveModalVisible] = useState(false);
|
||||
const [createWalletModalVisible, setCreateWalletModalVisible] = useState(false);
|
||||
const [importWalletModalVisible, setImportWalletModalVisible] = useState(false);
|
||||
const [_createWalletModalVisible, _setCreateWalletModalVisible] = useState(false);
|
||||
const [_importWalletModalVisible, _setImportWalletModalVisible] = useState(false);
|
||||
const [backupModalVisible, setBackupModalVisible] = useState(false);
|
||||
const [networkSelectorVisible, setNetworkSelectorVisible] = useState(false);
|
||||
const [walletSelectorVisible, setWalletSelectorVisible] = useState(false);
|
||||
@@ -128,16 +127,16 @@ const WalletScreen: React.FC = () => {
|
||||
const [hiddenTokens, setHiddenTokens] = useState<string[]>([]);
|
||||
const [recipientAddress, setRecipientAddress] = useState('');
|
||||
const [sendAmount, setSendAmount] = useState('');
|
||||
const [walletName, setWalletName] = useState('');
|
||||
const [walletName, _setWalletName] = useState('');
|
||||
const [importMnemonic, setImportMnemonic] = useState('');
|
||||
const [importWalletName, setImportWalletName] = useState('');
|
||||
const [_importWalletName, _setImportWalletName] = useState('');
|
||||
const [userMnemonic, setUserMnemonic] = useState<string>('');
|
||||
const [isSending, setIsSending] = useState(false);
|
||||
const [isLoadingBalances, setIsLoadingBalances] = useState(false);
|
||||
|
||||
// Transaction History State
|
||||
const [transactions, setTransactions] = useState<Transaction[]>([]);
|
||||
const [isLoadingHistory, setIsLoadingHistory] = useState(false);
|
||||
// Transaction History State (TODO: implement transaction history display)
|
||||
const [_transactions, _setTransactions] = useState<Transaction[]>([]);
|
||||
const [_isLoadingHistory, _setIsLoadingHistory] = useState(false);
|
||||
|
||||
const [balances, setBalances] = useState<{ [key: string]: string }>({
|
||||
HEZ: '0.00',
|
||||
@@ -221,43 +220,48 @@ const WalletScreen: React.FC = () => {
|
||||
setIsLoadingBalances(true);
|
||||
try {
|
||||
// 1. Fetch Balances - decode address to raw bytes to avoid SS58 encoding issues
|
||||
let accountId: Uint8Array;
|
||||
let accountId: Uint8Array | string;
|
||||
try {
|
||||
accountId = decodeAddress(selectedAccount.address);
|
||||
} catch (e) {
|
||||
console.warn('[Wallet] Failed to decode address, using raw:', e);
|
||||
accountId = selectedAccount.address as any;
|
||||
} catch (_e) {
|
||||
if (__DEV__) console.warn('[Wallet] Failed to decode address, using raw:', _e);
|
||||
accountId = selectedAccount.address;
|
||||
}
|
||||
|
||||
const accountInfo = await api.query.system.account(accountId) as any;
|
||||
const hezBalance = (Number(accountInfo.data.free.toString()) / 1e12).toFixed(2);
|
||||
const accountInfo = await api.query.system.account(accountId);
|
||||
const accountData = accountInfo.toJSON() as { data?: { free?: string | number } } | null;
|
||||
const freeBalance = accountData?.data?.free ?? 0;
|
||||
const hezBalance = (Number(freeBalance) / 1e12).toFixed(2);
|
||||
|
||||
let pezBalance = '0.00';
|
||||
try {
|
||||
if (api.query.assets?.account) {
|
||||
const pezAsset = await api.query.assets.account(1, accountId) as any;
|
||||
if (pezAsset.isSome) pezBalance = (Number(pezAsset.unwrap().balance.toString()) / 1e12).toFixed(2);
|
||||
const pezAsset = await api.query.assets.account(1, accountId);
|
||||
const pezData = pezAsset.toJSON() as { balance?: string | number } | null;
|
||||
if (pezData?.balance) pezBalance = (Number(pezData.balance) / 1e12).toFixed(2);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Wallet] PEZ balance fetch failed:', e);
|
||||
} catch (_e) {
|
||||
if (__DEV__) console.warn('[Wallet] PEZ balance fetch failed:', _e);
|
||||
}
|
||||
|
||||
let usdtBalance = '0.00';
|
||||
try {
|
||||
if (api.query.assets?.account) {
|
||||
// Check ID 1000 first (as per constants), fallback to 2 just in case
|
||||
let usdtAsset = await api.query.assets.account(1000, accountId) as any;
|
||||
if (usdtAsset.isNone) {
|
||||
usdtAsset = await api.query.assets.account(2, accountId) as any;
|
||||
let usdtAsset = await api.query.assets.account(1000, accountId);
|
||||
let usdtData = usdtAsset.toJSON() as { balance?: string | number } | null;
|
||||
if (!usdtData?.balance) {
|
||||
usdtAsset = await api.query.assets.account(2, accountId);
|
||||
usdtData = usdtAsset.toJSON() as { balance?: string | number } | null;
|
||||
}
|
||||
|
||||
if (usdtAsset.isSome) {
|
||||
if (usdtData?.balance) {
|
||||
// USDT uses 6 decimals usually, checking constants or assuming standard
|
||||
usdtBalance = (Number(usdtAsset.unwrap().balance.toString()) / 1e6).toFixed(2);
|
||||
usdtBalance = (Number(usdtData.balance) / 1e6).toFixed(2);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Wallet] USDT balance fetch failed:', e);
|
||||
} catch (_e) {
|
||||
if (__DEV__) console.warn('[Wallet] USDT balance fetch failed:', _e);
|
||||
}
|
||||
|
||||
setBalances({ HEZ: hezBalance, PEZ: pezBalance, USDT: usdtBalance });
|
||||
@@ -270,7 +274,7 @@ const WalletScreen: React.FC = () => {
|
||||
setTransactions([]);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Fetch error:', error);
|
||||
if (__DEV__) console.error('Fetch error:', error);
|
||||
} finally {
|
||||
setIsLoadingBalances(false);
|
||||
setIsLoadingHistory(false);
|
||||
@@ -296,10 +300,10 @@ const WalletScreen: React.FC = () => {
|
||||
unsubscribe = await api.query.system.account(accountId, (accountInfo: any) => {
|
||||
const hezBalance = (Number(accountInfo.data.free.toString()) / 1e12).toFixed(2);
|
||||
setBalances(prev => ({ ...prev, HEZ: hezBalance }));
|
||||
console.log('[Wallet] Balance updated via subscription:', hezBalance, 'HEZ');
|
||||
if (__DEV__) console.warn('[Wallet] Balance updated via subscription:', hezBalance, 'HEZ');
|
||||
}) as unknown as () => void;
|
||||
} catch (e) {
|
||||
console.warn('[Wallet] Subscription failed, falling back to polling:', e);
|
||||
if (__DEV__) console.warn('[Wallet] Subscription failed, falling back to polling:', e);
|
||||
// Fallback to polling if subscription fails
|
||||
fetchData();
|
||||
}
|
||||
@@ -326,9 +330,9 @@ const WalletScreen: React.FC = () => {
|
||||
try {
|
||||
const tokens = await fetchAllTokens(api, selectedAccount.address);
|
||||
setAllTokens(tokens);
|
||||
console.log('[Wallet] Loaded', tokens.length, 'tokens from blockchain');
|
||||
if (__DEV__) console.warn('[Wallet] Loaded', tokens.length, 'tokens from blockchain');
|
||||
} catch (error) {
|
||||
console.error('[Wallet] Failed to load tokens:', error);
|
||||
if (__DEV__) console.error('[Wallet] Failed to load tokens:', error);
|
||||
} finally {
|
||||
setIsLoadingTokens(false);
|
||||
}
|
||||
@@ -415,7 +419,7 @@ const WalletScreen: React.FC = () => {
|
||||
setSavedAddresses(JSON.parse(stored));
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Wallet] Failed to load address book:', e);
|
||||
if (__DEV__) console.warn('[Wallet] Failed to load address book:', e);
|
||||
}
|
||||
};
|
||||
loadAddressBook();
|
||||
@@ -434,7 +438,7 @@ const WalletScreen: React.FC = () => {
|
||||
await AsyncStorage.setItem('@pezkuwi_address_book', JSON.stringify(updated));
|
||||
showAlert('Saved', `Address "${name}" saved to address book`);
|
||||
} catch (e) {
|
||||
console.warn('[Wallet] Failed to save address:', e);
|
||||
if (__DEV__) console.warn('[Wallet] Failed to save address:', e);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -445,7 +449,7 @@ const WalletScreen: React.FC = () => {
|
||||
setSavedAddresses(updated);
|
||||
await AsyncStorage.setItem('@pezkuwi_address_book', JSON.stringify(updated));
|
||||
} catch (e) {
|
||||
console.warn('[Wallet] Failed to delete address:', e);
|
||||
if (__DEV__) console.warn('[Wallet] Failed to delete address:', e);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -502,7 +506,7 @@ const WalletScreen: React.FC = () => {
|
||||
const feeInHez = (Number(paymentInfo.partialFee.toString()) / 1e12).toFixed(6);
|
||||
setEstimatedFee(feeInHez);
|
||||
} catch (e) {
|
||||
console.warn('[Wallet] Fee estimation failed:', e);
|
||||
if (__DEV__) console.warn('[Wallet] Fee estimation failed:', e);
|
||||
setEstimatedFee('~0.001'); // Fallback estimate
|
||||
} finally {
|
||||
setIsEstimatingFee(false);
|
||||
@@ -568,7 +572,7 @@ const WalletScreen: React.FC = () => {
|
||||
|
||||
await tx.signAndSend(keypair, ({ status, events }) => {
|
||||
if (status.isInBlock) {
|
||||
console.log('[Wallet] Transaction in block:', status.asInBlock.toHex());
|
||||
if (__DEV__) console.warn('[Wallet] Transaction in block:', status.asInBlock.toHex());
|
||||
}
|
||||
if (status.isFinalized) {
|
||||
setSendModalVisible(false);
|
||||
@@ -650,7 +654,7 @@ const WalletScreen: React.FC = () => {
|
||||
showAlert('No Backup', 'Mnemonic not found in secure storage. It may have been imported from another device.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error retrieving mnemonic:', error);
|
||||
if (__DEV__) console.error('Error retrieving mnemonic:', error);
|
||||
showAlert('Error', 'Failed to retrieve mnemonic from secure storage.');
|
||||
}
|
||||
};
|
||||
@@ -662,8 +666,8 @@ const WalletScreen: React.FC = () => {
|
||||
await Share.share({
|
||||
message: `My Pezkuwichain Address:\n${selectedAccount.address}`,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} catch (_e) {
|
||||
if (__DEV__) console.error(_e);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user