error when trying to load the @walletconnect/web3-provider lib in an iframe
See original GitHub issueI’m building a dApp which uses the @walletconnect/web3-provider
lib indirectly. Locally and during testing everything works great, the issue comes when I deploy the app as it gets executed in an iframe:
main.js:formatted:134093 Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
I traced back the exception to the storage utility class of this monorepo.
I believe the problem comes from this part:
export function unsafeGetFromWindow<T>(name: string): T | undefined {
let res: T | undefined = undefined;
if (typeof window !== "undefined" && typeof window[name] !== "undefined") {
res = window[name];
}
return res;
}
As that is compiled down to:
"undefined" != typeof window && void 0 !== window.localStorage && (a = window.localStorage),
Which ends up throwing the exception.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Wallet Connect / Web3 Provider showing a lot of errors just by ...
I want to use "@walletconnect/web3-provider" JS library in my project, ... Here is the part of the error message as it appears in...
Read more >How to Use Web3React in Your Next Project - Linum Labs
This is used internally in the library when errors happen - web3react will call setError and try to reload. You can also use...
Read more >framehq/general - Gitter
I'm developing a browser in Electron. Can it create a window which loads Frame's index.html with all its functionalities? @floating.
Read more >Error - Can't resolve '@walletconnect/web3-provider'
When walletconnect is installed I can't deploy code successfully to cloud. So I removed walletconnect and deployed successfully.
Read more >Web3Modal Demo - CodePen Embed
"use strict"; /** * Example JavaScript code that interacts with the page and ... the wallet const web3 = new Web3(provider); console.log("Web3 instance...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Safari blocks storing anything in local storage within an iframe. web3 use to use local storage without try catching it and this did not allow you to be able to use web3 in an iframe supporting every browser. A try-catch will solve this but if the lib needs local storage it should probably look into the new storage API which safari now supports - https://developer.mozilla.org/en-US/docs/Web/API/Storage_Access_API to allow this to support iframes in safari (which quite a lot of wallet integrations would be using to add protection between cross-site domains and holding the private key in memory without the integrator being able to get to it).
Hey @ramirotw, @wswarren12 are either one of you still experiencing this issue?