Skip to content

Commit

Permalink
fix missing dapp metadata for eth actions
Browse files Browse the repository at this point in the history
  • Loading branch information
walmat committed Sep 6, 2024
1 parent 228e714 commit 5864ab3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
43 changes: 33 additions & 10 deletions src/components/MobileWalletProtocolListener.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,44 @@ import { logger, RainbowError } from '@/logger';
import { IS_ANDROID, IS_DEV } from '@/env';

export const MobileWalletProtocolListener = () => {
const { message, handleRequestUrl, sendFailureToClient, ...mwpProps } = useMobileWalletProtocolHost();
const { message, handleRequestUrl, sendFailureToClient, session, ...mwpProps } = useMobileWalletProtocolHost();
const lastMessageUuidRef = useRef<string | null>(null);
const pendingMessageRef = useRef<typeof message | null>(null);

useEffect(() => {
if (message && lastMessageUuidRef.current !== message.uuid) {
lastMessageUuidRef.current = message.uuid;
try {
handleMobileWalletProtocolRequest({ request: message, ...mwpProps });
} catch (error) {
logger.error(new RainbowError('Error handling Mobile Wallet Protocol request'), {
error,
});
const handleMessage = async () => {
if (message && lastMessageUuidRef.current !== message.uuid) {
console.log('message', message);
lastMessageUuidRef.current = message.uuid;

// Check if it's a handshake request
const isHandshake = message.actions.some(action => action.kind === 'handshake');

if (isHandshake || session) {
try {
await handleMobileWalletProtocolRequest({ request: message, session, ...mwpProps });
} catch (error) {
logger.error(new RainbowError('Error handling Mobile Wallet Protocol request'), {
error,
});
}
} else {
// Store the message to process once we have a valid session
pendingMessageRef.current = message;
}
}
};

handleMessage();
}, [message, session, mwpProps]);

useEffect(() => {
if (session && pendingMessageRef.current) {
const pendingMessage = pendingMessageRef.current;
pendingMessageRef.current = null;
handleMobileWalletProtocolRequest({ request: pendingMessage, session, ...mwpProps });
}
}, [message, mwpProps]);
}, [session, mwpProps]);

useEffect(() => {
if (IS_DEV) {
Expand Down
2 changes: 0 additions & 2 deletions src/screens/SignTransactionSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ export const SignTransactionSheet = () => {
source,
} = routeParams;

console.log({ specifiedAddress });

const addressToUse = specifiedAddress ?? accountAddress;

const { provider, nativeAsset } = useProviderSetup(chainId, addressToUse);
Expand Down

0 comments on commit 5864ab3

Please sign in to comment.