Skip to content
Merged
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
16 changes: 13 additions & 3 deletions connectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ function connectors(environment: Environment): ClientWithChain {
walletConnectWallet({ chains, projectId }),
braveWallet({ chains, shimDisconnect }),
environment.MAGIC_API_KEY
? emailConnector({ chains, apiKey: environment.MAGIC_API_KEY })
? emailConnector({
chains,
apiKey: environment.MAGIC_API_KEY,
alchemyApiKey: environment.ALCHEMY_API_KEY,
})
: undefined,
].filter(Boolean),
},
Expand Down Expand Up @@ -95,10 +99,16 @@ function connectors(environment: Environment): ClientWithChain {
function emailConnector({
chains,
apiKey,
alchemyApiKey,
}: {
chains: Chain[]
apiKey: string
alchemyApiKey: string | undefined
}): Wallet {
if (!alchemyApiKey)
throw new Error(
'env NEXT_PUBLIC_ALCHEMY_API_KEY is required for email connector',
)
return {
id: 'magic',
name: 'Magic',
Expand All @@ -112,8 +122,8 @@ function emailConnector({
networks: chains.map((chain) => ({
chainId: chain.id,
rpcUrl:
chain.id === 1 // the default provider for Ethereum Mainnet (cloudflare) is not working with Magic
? 'https://rpc.ankr.com/eth'
chain.id === 1 // the default provider for Ethereum Mainnet is not working with Magic, only Alchemy is
? 'https://eth-mainnet.g.alchemy.com/v2/' + alchemyApiKey
: chain.rpcUrls.default.http[0]!,
})),
},
Expand Down
Loading