Skip to content

Conversation

@chad1blakely
Copy link
Collaborator

@chad1blakely chad1blakely commented Aug 27, 2025

This pull request create a working bridge between the main app thread and a shadow WebView to handle wallet calls.

  • The script that runs in the shadow WebView is a separate static web project located in the wallet folder. The main built file is in wallet/dist/index.tml and is loaded in a webview.
  • The object webviewComingEvent and the method sendWebViewEvent are exposed to communicate with the webview.
  • The object webviewComingEvent capture the event property sent from the webview, and the method sendWebViewEvent sends an event to the webview to execute specific method within the webview code.

@sirdeggen sirdeggen requested a review from Copilot August 28, 2025 17:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR creates a working bridge between the main app thread and a shadow WebView to handle wallet calls by introducing an invisible WebView architecture that separates wallet operations from the main UI thread.

  • Complete wallet WebView project setup with webpack, TypeScript compilation, and proper module configuration
  • Bridge communication system between React Native and WebView through event managers and message passing
  • Removal of iOS notification service extension and related configurations

Reviewed Changes

Copilot reviewed 31 out of 37 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
wallet/* New WebView project with authentication, event management, and wallet initialization logic
context/WalletWebViewContext.tsx Complete context replacement implementing WebView communication bridge
app/* Updated imports to use new WebView-based wallet context throughout the application
ios/* Removed notification service extension and simplified iOS configuration
package.json Added babel plugin for HTML import transformation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +120 to +126
this.setSelectedWabUrl,
this.recoveryKeySaver,
this.passwordRetriever
)

if (!this.adminOriginator || !this.selectedStorageUrl || !this.selectedNetwork ||
!this.setSelectedWabUrl || !this.recoveryKeySaver || !this.passwordRetriever) {
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

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

This should be this.selectedWabUrl instead of this.setSelectedWabUrl. The method setSelectedWabUrl is not defined, but the property selectedWabUrl is.

Suggested change
this.setSelectedWabUrl,
this.recoveryKeySaver,
this.passwordRetriever
)
if (!this.adminOriginator || !this.selectedStorageUrl || !this.selectedNetwork ||
!this.setSelectedWabUrl || !this.recoveryKeySaver || !this.passwordRetriever) {
this.selectedWabUrl,
this.recoveryKeySaver,
this.passwordRetriever
)
if (!this.adminOriginator || !this.selectedStorageUrl || !this.selectedNetwork ||
!this.selectedWabUrl || !this.recoveryKeySaver || !this.passwordRetriever) {

Copilot uses AI. Check for mistakes.
import { logWithTimestamp } from '@/utils/logging'
import WebView from 'react-native-webview'
import { TouchableOpacity, View, Text } from 'react-native'
import webviewSource from '../wallet/dist/index.html';
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

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

The import points to ../wallet/dist/index.html but the webpack configuration outputs to wallet/dist/index.js and uses index.html as a template. This path may not exist or contain the correct bundled content.

Suggested change
import webviewSource from '../wallet/dist/index.html';
// For react-native-webview, use a static asset or a URI. Example:
// const webviewSource = require('../wallet/dist/index.html');
// Or, if loading from a remote server:
// const webviewSource = { uri: 'https://your-server.com/wallet/index.html' };

Copilot uses AI. Check for mistakes.
Comment on lines +75 to +80
// When main thread reject key, reject
this.keySaverRejecter = reject;

// TODO:Send key as string to main thread
// setRecoveryKey(keyAsStr)
// setOpen(true)
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

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

These TODO comments indicate incomplete implementation of recovery key saving functionality. The function creates a promise but doesn't implement the actual key saving mechanism.

Suggested change
// When main thread reject key, reject
this.keySaverRejecter = reject;
// TODO:Send key as string to main thread
// setRecoveryKey(keyAsStr)
// setOpen(true)
// When main thread rejects key, reject
this.keySaverRejecter = reject;
// Emit event to main thread/UI to save the recovery key
EventManager.emit('saveRecoveryKey', { key: keyAsStr });

Copilot uses AI. Check for mistakes.
Comment on lines +92 to +94
// TODO: Send password_reason event to main thread
// Actions to perform
// setReason(reason)
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

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

Multiple TODO comments indicate incomplete password retrieval implementation. The function sets up promise handlers but doesn't implement the actual communication with the main thread.

Copilot uses AI. Check for mistakes.
Comment on lines +547 to +550
console.log(script, webviewLoaded);
setTimeout(() => {
shadowWebviewRef.current?.injectJavaScript(script);
}, 3000);
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

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

The hardcoded 3-second timeout is arbitrary and may cause race conditions. Consider using the webviewLoaded state or implementing a proper ready state check instead of a fixed delay.

Copilot uses AI. Check for mistakes.
@sirdeggen
Copy link
Contributor

See #27

@sirdeggen sirdeggen closed this Aug 28, 2025
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