Update wallet code for token transfer using android embedded webview #36

Merged
nabarun merged 15 commits from as-android-transfer into nym-vpn-app 2025-07-01 04:53:35 +00:00
Showing only changes of commit b1cc35d4e0 - Show all commits
+12 -2
View File
@@ -1,4 +1,4 @@
import { useEffect, useCallback } from 'react';
import { useEffect, useCallback, useState } from 'react';
import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
@@ -8,6 +8,9 @@ import { StackParamsList } from '../types';
import useGetOrCreateAccounts from './useGetOrCreateAccounts';
export const useWebViewHandler = () => {
const [isReady, setIsReady] = useState(false);
useGetOrCreateAccounts();
// Navigation and context hooks
const navigation = useNavigation<NativeStackNavigationProp<StackParamsList>>();
const { selectedNetwork } = useNetworks();
@@ -19,6 +22,13 @@ export const useWebViewHandler = () => {
// Core navigation handler
const navigateToSignRequest = useCallback((message: string) => {
try {
// Wait for accounts to be ready
if (!isReady) {
console.log('Accounts not yet ready');
window.Android?.onSignatureError?.('Accounts not yet ready');
return;
}
// Validation checks
if (!selectedNetwork?.namespace || !selectedNetwork?.chainId) {
window.Android?.onSignatureError?.('Invalid network configuration');
@@ -68,7 +78,7 @@ export const useWebViewHandler = () => {
} catch (error) {
window.Android?.onSignatureError?.(`Navigation error: ${error}`);
}
}, [selectedNetwork, accounts, currentIndex, navigation]);
}, [selectedNetwork, accounts, currentIndex, navigation, isReady]);
useEffect(() => {
// Assign the function to the window object