EveripediaNetwork / wagmi-magic-connector

wagmi connector to connect with Magic SDK
https://www.npmjs.com/package/@everipedia/wagmi-magic-connector
MIT License
70 stars 40 forks source link

UserRejectedRequestError #54

Closed PovedaAqui closed 1 year ago

PovedaAqui commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

When I logging using email, I get UserRejectedRequestError

UserRejectedRequestError: User rejected request
    at MagicConnectConnector.connect (magicConnectConnector.js?97d5:72:1)
    at async connect (chunk-55IO54NW.js?d062:727:1)

Additional context Add any other context about the problem here.

I've asked Magic.Link support and they said the problem is unlikely to be happening from their side.

package.json

"@everipedia/wagmi-magic-connector": "^0.9.1",
"@rainbow-me/rainbowkit": "^0.8.1",
"@wagmi/chains": "^0.2.6",
"ethers": "^5.7.2",
"next": "^13.1.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"wagmi": "^0.11.4"

MagicConnector.js

import { MagicAuthConnector, MagicConnectConnector } from "@everipedia/wagmi-magic-connector";

// Define the rainbowMagicConnector function that will be used to create the Magic connector
export const rainbowMagicConnector = ({ chains }) => ({

  id: "magic",
  name: "Sign in with Email",
  iconUrl: "https://svgshare.com/i/pXA.svg",
  iconBackground: "white",
  createConnector: () => ({
    connector: new MagicConnectConnector({
      chains,
      options: {
        // Get the API key from the .env file
        apiKey: `${process.env.NEXT_PUBLIC_MAGIC_KEY}`,
        oauthOptions: {
          providers: ["google"], // Add the Google provider
        },
        isDarkMode: true,
        magicSdkConfiguration: {
          network: {
            rpcUrl: "https://polygon-rpc.com",
            chainId: 137,
          },
        },
      },
    }),
  }),
});
caichi-t commented 1 year ago

Hi. I had the same issue. I think the issue is due to an update of magicSDK.

In my case, I changed

await magic.auth.loginWithEmailOTP({ email: output.email, });

in lines 76~78 of magicConnectConnector.ts to

await magic.wallet.connectWithUI();

and the issue was solved at least.

I'm sure other parts need to be fixed, but at least it works. I hope this helps you.

PovedaAqui commented 1 year ago

I just got a response from the Magic's Team:

We did recently change the naming convention of the Magic Connect methods to magic.wallet

LyghtCode commented 1 year ago

Okay so what do we need to do to fix this?

PovedaAqui commented 1 year ago

Update to the latest dependency using either yarn or npm, it should be working again #55

npm install @everipedia/wagmi-magic-connector@latest