-
Notifications
You must be signed in to change notification settings - Fork 97
Description
Hey Team,
Currently the iframe of llamaswap only works on desktop, as the mobile version does not really detect window.ethereum without an "iframe proxy" like the one it looks like you use for smolrefuel.
I have made a quick MVP https://gist.github.com/8times4/9a153159630989e7cd306aa0e87d0ffa that can be imported into _document.js as a script tag, then WalletProvider/index.ts can have something like this:
const isInIframe = typeof window !== "undefined" && window.self !== window.top;
// Get wallets configuration - prepend injectedWallet when in iframe
const getWallets = () => {
if (!isInIframe) return undefined; // Use default wallets when not in iframe
const defaultWallets = getDefaultWallets({ appName, projectId });
// Prepend injectedWallet to ensure it's first for iframe compatibility
if (defaultWallets.wallets.length > 0) {
defaultWallets.wallets[0].wallets.unshift(injectedWallet);
}
return defaultWallets.wallets;
};which is a non breaking change (as it just adds the injectedProvider when we're in an iframe, since window.ethereum doesn't get grabbed properly) but then with proper parent code, the iframe's connect wallet button can directly interact with eg. Dawn from Safari, or within Rabby browser with Rabby itself. (just a few tests I did)
here's a simple html code with the parent code, https://gist.github.com/8times4/c68cc239f6059b16c5ae55ffdd8f2ce4.
The reason I'm bringing this up as an issue and not a PR is that you probably wish to have a better control/security around the iframe proxy on llamaswap side, so this would be just opening up a discussion here.