Skip to content

Commit

Permalink
chore: enable solana email and socials (#2736)
Browse files Browse the repository at this point in the history
Co-authored-by: Enes <enesozturk.d@gmail.com>
  • Loading branch information
zoruka and enesozturk authored Aug 23, 2024
1 parent 8e91107 commit 9fcc69c
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 16 deletions.
46 changes: 46 additions & 0 deletions apps/laboratory/src/pages/library/solana-email.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { createWeb3Modal, defaultSolanaConfig } from '@web3modal/solana/react'

import { ThemeStore } from '../../utils/StoreUtil'
import { solana, solanaDevnet, solanaTestnet } from '../../utils/ChainsUtil'
import { AppKitButtons } from '../../components/AppKitButtons'
import { ConstantsUtil } from '../../utils/ConstantsUtil'
import { SolanaTests } from '../../components/Solana/SolanaTests'
import { SolflareWalletAdapter } from '@solana/wallet-adapter-wallets'

const chains = [solana, solanaTestnet, solanaDevnet]

export const solanaConfig = defaultSolanaConfig({
chains,
projectId: ConstantsUtil.ProjectId,
metadata: ConstantsUtil.Metadata,
auth: {
email: true,
socials: ['google', 'x', 'discord', 'farcaster', 'github', 'apple', 'facebook'],
walletFeatures: true,
showWallets: true
}
})

const modal = createWeb3Modal({
solanaConfig,
projectId: ConstantsUtil.ProjectId,
metadata: ConstantsUtil.Metadata,
chains,
enableAnalytics: false,
termsConditionsUrl: 'https://walletconnect.com/terms',
privacyPolicyUrl: 'https://walletconnect.com/privacy',
customWallets: ConstantsUtil.CustomWallets,
enableSwaps: false,
wallets: [new SolflareWalletAdapter()]
})

ThemeStore.setModal(modal)

export default function Solana() {
return (
<>
<AppKitButtons />
<SolanaTests />
</>
)
}
5 changes: 5 additions & 0 deletions apps/laboratory/src/utils/DataUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,10 @@ export const solanaSdkOptions = [
title: 'Default',
link: '/library/solana',
description: 'Basic configuration using solana as a driving library'
},
{
title: 'Email and Social',
link: '/library/solana-email/',
description: 'Configuration using solana and implementing email and social login'
}
]
9 changes: 2 additions & 7 deletions packages/base/adapters/solana/web3js/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,8 @@ export class SolanaWeb3JsClient {
this.initializeProviders({
relayUrl: 'wss://relay.walletconnect.com',
metadata: clientOptions.metadata,
projectId: options.projectId

/**
* Auth configuration will be disabled until secure site is updated
*
* ...clientOptions.solanaConfig.auth
*/
projectId: options.projectId,
...clientOptions.solanaConfig.auth
})

this.syncRequestedNetworks(chains, this.options?.chainImages)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function defaultSolanaConfig(options: ConfigOptions) {

let injectedProvider: Provider | undefined = undefined

const providers: ProviderType = { metadata }
const providers: ProviderType = { metadata, auth: options.auth }

function getInjectedProvider() {
if (injectedProvider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ export class W3mEmailLoginWidget extends LitElement {
}

private async onSubmitEmail(event: Event) {
const isActiveChainEVM = ChainController.state.activeChain === ConstantsUtil.CHAIN.EVM
const availableChains = [ConstantsUtil.CHAIN.EVM, ConstantsUtil.CHAIN.SOLANA]
const isAvailableChain = availableChains.find(
chain => chain === ChainController.state.activeChain
)

if (!isActiveChainEVM) {
if (!isAvailableChain) {
RouterController.push('SwitchActiveChain', {
switchToChain: ConstantsUtil.CHAIN.EVM
})
Expand Down
7 changes: 1 addition & 6 deletions packages/scaffold-utils/src/solana/SolanaTypesUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ export type ProviderType = {
email?: boolean
EIP6963?: boolean
metadata: Metadata

/**
* Auth configuration will be disabled until secure site is updated
*
* auth?: Provider['auth']
*/
auth?: Provider['auth']
}

export interface RequestArguments {
Expand Down

0 comments on commit 9fcc69c

Please sign in to comment.