Giter VIP home page Giter VIP logo

wagmi-magic-connector's People

Contributors

nasdf avatar

Watchers

 avatar

wagmi-magic-connector's Issues

Type issues and Login method undefined

I'm using a Vite app with RainbowKit.

Errors:

  1. Type issues
[{
	"resource": ".../src/config/wagmi.ts",
	"owner": "typescript",
	"code": "2322",
	"severity": 8,
	"message": "Type '{ id: string; name: string; iconUrl: string; iconBackground: string; createConnector: () => { connector: MagicConnector; }; }' is not assignable to type 'Wallet<Connector<any, any, any>>'.\n  The types of 'createConnector().connector' are incompatible between these types.\n    Type 'MagicConnector' is not assignable to type 'Connector<any, any, any>'.\n      Property 'onAccountsChanged' is protected but type 'MagicConnector' is not a class derived from 'Connector<Provider, Options, Signer>'.",
	"source": "ts",
	"startLineNumber": 115,
	"startColumn": 7,
	"endLineNumber": 115,
	"endColumn": 40
}]
  1. Login method undefined after 'npm start' then clicking on the magic button on the RainbowKit modal:
act_devtools_backend_compact.js:2367 Error: login method undefined
    at _a.connect (index.ts:49:31)
    at async connect (chunk-VQG3VKOR.js:727:18)
o

And my code:

import { MagicConnector } from '@nasdf/wagmi-magic-connector'

const apiKey = import.meta.env.VITE_YOUR_MAGIC_CONNECT_API_KEY;

if (!apiKey) {
    throw new Error('API key not found. Please check your environment variables.');
  }

const network = {
  rpcUrl: 'https://poly-mainnet.gateway.pokt.network/v1/lb/f3ebd729f40522b268bd0bc5', // your ethereum, polygon, or optimism mainnet/testnet rpc URL
  chainId: 137,
}

const rainbowMagicConnector = ({ chains }: any) => ({
  id: 'magic',
  name: 'Email',
  iconUrl: 'https://svgshare.com/i/iJK.svg',
  iconBackground: '#fff',
  createConnector: () => {
    const connector = new MagicConnector({
      chains: chains,
      options: {
        apiKey: apiKey as string,
        network: network,
      },
    })
    return {
      connector,
    };
  },
});

export const { chains, provider } = configureChains([polygon], [
  jsonRpcProvider({
    rpc: (chain) => {
      switch (chain.id) {
        case 1:
          return {
            http: "https://eth-mainnet.gateway.pokt.network/v1/lb/f3ebd729f40522b268bd0bc5",
          };
        case 5:
          return {
            http: "https://eth-goerli.gateway.pokt.network/v1/lb/f3ebd729f40522b268bd0bc5",
          };
        case 137:
          return {
            http: "https://poly-mainnet.gateway.pokt.network/v1/lb/f3ebd729f40522b268bd0bc5",
          };
        case 43114:
          return {
            http: "https://avax-mainnet.gateway.pokt.network/v1/lb/f3ebd729f40522b268bd0bc5",
          };
        default:
          return {
            http: "https://eth-mainnet.gateway.pokt.network/v1/lb/f3ebd729f40522b268bd0bc5",
          };
      }
    },
  }),
]);

export const connectors = connectorsForWallets([
  {
    groupName: "Recommended",
    wallets: [
      coinbaseWallet({ appName: "Trelis Pay", chains }),
      metaMaskWallet({ chains, shimDisconnect: true }),
      walletConnectWallet({ chains }),
      rainbowMagicConnector({ chains }),
    ],
  },...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.