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

Update rainbowKit example for Rainbowkit / wagmi V2 #23

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

johnashu
Copy link

[FIX] iconUrl -> Magic

THe example for RAinbowKit was not working.. This will..

Maffaz added 2 commits March 28, 2024 02:21
@Adebesin-Cell
Copy link

Hey @johnashu, did you get it to work with rainbow kit?
I was trying the other day to make it work but app state (wagmi.store) was getting reset to null, no idea why in setup but here's how I worked it.

import { env } from '@/env'
import { dedicatedWalletConnector } from '@magiclabs/wagmi-connector'
import type { Wallet } from '@rainbow-me/rainbowkit'
import type { Chain } from 'viem'
import { polygon } from 'viem/chains'
import { createConnector } from 'wagmi'

export const createMagicConnector = ({ chain }: { chain: Chain }): Wallet => ({
  id: 'magic',
  name: 'Magic',
  iconUrl: 'https://svgshare.com/i/pXA.svg',
  iconBackground: '#fff',
  installed: true,
  iconAccent: '#b4acfc',

  createConnector: (walletDetails) => {
    const magicConnector = dedicatedWalletConnector({
      chains: [chain],
      options: {
        customLogo: 'https://iq.social/images/iq-logo.svg',
        apiKey: env.NEXT_PUBLIC_MAGIC_API_KEY,
        accentColor: '#ea3b87',
        oauthOptions: {
          providers: ['google', 'facebook', 'twitter', 'discord'],
        },
        isDarkMode: false,
        magicSdkConfiguration: {
          network: {
            chainId: chain.id,
            rpcUrl: chain.rpcUrls.default.http[0],
          },
        },
      },
    })

    return createConnector((config) => ({
      ...magicConnector(config),
      ...walletDetails,
    }))
  },
})

export const magicWallet = () => createMagicConnector({ chain: polygon })

@Adebesin-Cell
Copy link

Happens on page refresh, would be great if you could share a minimal production of your solution if it works great, thanks 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants