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

adds get info call to generate new wallet #39

Merged
merged 3 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slimy-cobras-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@magiclabs/wagmi-connector": patch
---

Fixes case where new wallet needs to be generated upon switching chains
5 changes: 3 additions & 2 deletions src/lib/connectors/dedicatedWalletConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
type MagicOptions,
magicConnector,
} from './magicConnector'
import { UserRejectedRequestError, getAddress } from 'viem'
import { type Address, UserRejectedRequestError, getAddress } from 'viem'
import { createModal } from '../modal/view'
import { RPCProviderModule } from '@magic-sdk/provider/dist/types/modules/rpc-provider'
import { normalizeChainId } from '../utils'
Expand Down Expand Up @@ -294,7 +294,8 @@ export function dedicatedWalletConnector({
this.getProvider = getProvider
this.onAccountsChanged = onAccountsChanged

const account = await this.getAccount()
const metadata = await this.magic?.user.getInfo()
const account = metadata?.publicAddress as Address

registerProviderEventListeners(
this.magic!.rpcProvider,
Expand Down