-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a sync way to check if an app is run inside gnosis safe #263
Comments
Suggestion from @taylorjdawson
|
Since there is a requirement to auto-login with gnosis (if you want to release your app into gnosis apps) I would expect the straight-forward approach how to detect the gnosis provider availability. If I am trying to |
getInfo() uses Could you share the code? The problem must be somewhere else |
Oh, srry. it is probably trouble with Sentry integration.... :/ |
Ok, so the error is not related to the gnosis safe info. But when I am trying to get safe info, there is no error, but the app is just stuck. |
could you share the code? |
I just checked, and other apps are working, so we'd need a reproduction case to check it. |
The code is very simple, before I mount the app I am waiting for this try-catch statement. And it looks that the Promise is never resolved. try {
const gnosisSdk = new SafeAppsSDK()
const safeInfo = await gnosisSdk.safe.getInfo()
return safeInfo
} catch (e) {
console.log('Gnosis Safe is not detected', e)
} |
It's expected to never resolve if you run it outside the Safe because there's no handler for this request. You need to add a timeout. Check the example here: |
ok, thanks |
Hi, this feature would be useful for me: I work in an App that uses Gnosis, but 99% of our users don't use a multisig, so this is for very limited users. We also use I understand that these packages are required, but I'd like to be able to know if I'm in Gnosis context so I can only load them in these scenarios, and not for all users. Thanks! edit: currently, to detect if I'm in Gnosis context, I use const { connector: currentConnector } = useWeb3React()
if (currentConnector instanceof SafeAppConnector) { but by importing |
There's an async approach above that may help. Unfortunately, synchronous is not possible because browsers do not have such a mechanism |
I've just got reminded that it's possible with query params @dasanra |
how's the query params approach? The async approach still requires importing |
Query params approach isn't possible at the moment. If you import the SDK only when the app is loaded in an iframe, the chances are high that the iframe is coming from the safe |
Hey all! Wondering if anyone has found a definitive solution to this since. We're having this exact problem now — we want to support being a Safe App in our frontend, but also have the same app support standalone usage. The solution linked by @mikhailxyz works, but I really don't like the idea of delaying our app load by 200ms for everyone, especially given we expect the vast majority of sessions to not be within a safe. I can also imagine making an environment variable that puts the app into "safe mode" and deploying our app twice — once with it on, once off (for the main deployment). But this just seems like a lot of effort. |
We got a request for easy detection if the app is loaded as a safe app that doesn't require loading the SDK - in the web version, one can use desktop.referrer, but not on the desktop. It could be done with the query params.
The text was updated successfully, but these errors were encountered: