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

Open
1 task done
iceanddust opened this issue Oct 24, 2024 · 3 comments · May be fixed by #4371
Open
1 task done

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

iceanddust opened this issue Oct 24, 2024 · 3 comments · May be fixed by #4371
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

@iceanddust iceanddust linked a pull request Oct 29, 2024 that will close this issue
@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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