Skip to content

Commit

Permalink
feat: magic
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRalee committed Sep 16, 2024
1 parent f962094 commit 7e7caec
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
40 changes: 23 additions & 17 deletions layer/store/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ export const useSharedWalletStore = defineStore('sharedWallet', {
walletStore.walletConnectStatus = WalletConnectStatus.idle
await walletStrategy.setWallet(walletStore.wallet)

// if (walletStore.wallet === Wallet.Magic && !walletStore.isUserConnected) {
// await walletStore.connectMagic()
// }
if (walletStore.wallet === Wallet.Magic && !walletStore.isUserConnected) {
await walletStore.connectMagic()
}

if (walletStore.isAutoSignEnabled) {
walletStore.connectWallet(Wallet.PrivateKey, {
Expand Down Expand Up @@ -675,24 +675,30 @@ export const useSharedWalletStore = defineStore('sharedWallet', {

await walletStore.connectWallet(Wallet.Magic)

const addresses = await getAddresses({ email, provider })
try {
const addresses = await getAddresses({ email, provider })

if (!addresses.length) {
return
}
if (!addresses.length) {
return
}

const [address] = addresses
const session = await walletStrategy.getSessionOrConfirm(address)
const [address] = addresses
const session = await walletStrategy.getSessionOrConfirm(address)

walletStore.$patch({
address,
addresses,
addressConfirmation: await walletStrategy.getSessionOrConfirm(address),
injectiveAddress: address,
session
})
walletStore.$patch({
address,
addresses,
addressConfirmation: await walletStrategy.getSessionOrConfirm(
address
),
injectiveAddress: address,
session
})

await walletStore.onConnect()
await walletStore.onConnect()
} catch {
walletStore.walletConnectStatus = WalletConnectStatus.idle
}
},

async connectAddress(injectiveAddress: string) {
Expand Down
1 change: 1 addition & 0 deletions layer/utils/constant/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export const PROXY_DETECTION_API_KEY =
import.meta.env.VITE_PROXY_DETECTION_API_KEY || ''
export const HOTJAR_KEY = import.meta.env.VITE_HOTJAR_KEY_DEV as string
export const MIXPANEL_KEY = import.meta.env.VITE_MIXPANEL_KEY || ''
export const MAGIC_APK_KEY = import.meta.env.VITE_MAGIC_APK_KEY || ''
export const GOOGLE_MAPS_KEY = import.meta.env.VITE_GOOGLE_MAPS_KEY || ''

export const VPN_CHECKS_ENABLED: boolean =
Expand Down
10 changes: 3 additions & 7 deletions layer/wallet/wallet-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CHAIN_ID,
IS_MAINNET,
ALCHEMY_KEY,
MAGIC_APK_KEY,
ETHEREUM_CHAIN_ID,
ALCHEMY_SEPOLIA_KEY
} from './../utils/constant'
Expand All @@ -14,11 +15,6 @@ import {
WALLET_CONNECT_PROJECT_ID
} from './../utils/constant'

console.log(ENDPOINTS.rpc)

const HUNTER_API = 'pk_live_8D40A7E251F283ED'
const INJECTIVE_API = 'pk_live_E1CB10CF489E800D'

export const walletStrategy = new WalletStrategy({
chainId: CHAIN_ID,
ethereumOptions: {
Expand All @@ -28,8 +24,8 @@ export const walletStrategy = new WalletStrategy({
options: {
metadata: {
magic: {
rpcEndpoint: ENDPOINTS.rpc as string,
apiKey: INJECTIVE_API
apiKey: MAGIC_APK_KEY as string,
rpcEndpoint: ENDPOINTS.rpc as string
},
name: APP_NAME,
url: APP_BASE_URL,
Expand Down

0 comments on commit 7e7caec

Please sign in to comment.