Skip to content
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

Safe connector not working, throwing a SafeAppProvider is not a constructor error #4364

Closed
1 task done
iceanddust opened this issue Oct 24, 2024 · 4 comments · Fixed by #4371
Closed
1 task done
Labels
Good First Issue Misc: Good First Issue

Comments

@iceanddust
Copy link
Contributor

Check existing issues

Describe the bug

I'm trying to open my Vite dApp as a Safe app, it works well inside the Safe wallet context, but the Safe connector will not connect. After digging for a bit and doing some debugging I found out there is a SafeAppProvider is not a constructor error thrown by the connector.

I see there has been similar issues fixed for other connectors before, like this one, so perhaps the solution for this connector is similar

Link to Minimal Reproducible Example

https://github.com/iceanddust/wagmi-safe-connector-issue

Steps To Reproduce

  • Install packages and run dev server
  • Go to https://app.safe.global/ and select (or open) a safe
  • Go to the Apps tab, and then to My custom apps tab
  • Click Add custom Safe App, and enter the URL (Should be http://localhost:5173/ if you're running locally)
  • Check the checkbox and click Add, then open the Safe app
  • Inside the app, click on the Safe connector and see the error pop up, the connector will never connect

What Wagmi package(s) are you using?

wagmi

Wagmi Package(s) Version(s)

2.12.25

Viem Version

2.21.34

TypeScript Version

No response

Anything else?

No response

@tmm tmm added the Good First Issue Misc: Good First Issue label Oct 24, 2024
@1997roylee
Copy link
Contributor

It seems that Vite is encountering a bug when importing the Safe Global Provider SDK

@1997roylee
Copy link
Contributor

You should try to replace the config by this:

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

// https://vitejs.dev/config/
export default defineConfig({
  root: "src",
  envDir: "./",
  build: {
    outDir: "./dist",
  },
  plugins: [react()],
  optimizeDeps: {
    include: ["@safe-global/safe-apps-provider"],
  },
});

@iceanddust
Copy link
Contributor Author

iceanddust commented Nov 4, 2024

Thanks, that worked, although I had to write it like this for Vite to detect the dependency
include: ['wagmi > @safe-global/safe-apps-provider']
I faced a couple more of the known Safe connector issues, but was able to fix/bypass them

@tmm tmm closed this as completed in #4371 Nov 5, 2024
Copy link
Contributor

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Wagmi version. If you have any questions or comments you can create a new discussion thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Good First Issue Misc: Good First Issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@tmm @1997roylee @iceanddust and others