Skip to content

Commit

Permalink
update packages, fix initial wagmi state
Browse files Browse the repository at this point in the history
  • Loading branch information
on47sky committed Nov 20, 2024
1 parent d32d5ce commit 2fe0756
Show file tree
Hide file tree
Showing 8 changed files with 1,878 additions and 2,930 deletions.
9 changes: 1 addition & 8 deletions local_modules/wallet/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,9 @@ const wagmiConfig = createConfig({
[chiliz.id]: http(constants.rpcByChains[chiliz.id]),
[spicy.id]: http(constants.rpcByChains[spicy.id]),
},
connectors: [
injectedConnector,
walletConnectConnector,
],
ssr: true,
ssr: false,
syncConnectedChain: true,
multiInjectedProviderDiscovery: true,
storage: createStorage({
storage: cookieStorage,
}),
})

declare module 'wagmi' {
Expand Down
7 changes: 5 additions & 2 deletions local_modules/wallet/utils/useWallet.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
'use client'

import { usePrivy } from '@privy-io/react-auth'
import { useChains } from 'wagmi'
import { useAccount } from '@azuro-org/sdk-social-aa-connector'
import { ConnectorName } from 'wallet'


export const useWallet = () => {
const { address, connector, isConnected, isConnecting, isReconnecting, chain, chainId, isAAWallet } = useAccount()
const { authenticated, user } = usePrivy()
const { address, connector, isConnected, isConnecting, isReconnecting, chain, chainId, isAAWallet, isReady } = useAccount()
const chains = useChains()

const isWalletConnect = connector?.name === ConnectorName.WalletConnect
Expand All @@ -19,8 +21,9 @@ export const useWallet = () => {
chainId,
isConnected,
isConnecting,
isReconnecting,
isReconnecting: isReconnecting || !isReady || (authenticated && !address),
isWalletConnect,
isAAWallet,
isReady,
}
}
4 changes: 0 additions & 4 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ const nextConfig = {

config.externals.push('pino-pretty', 'lokijs', 'encoding')

if (config.name === 'client') {
config.target = [ 'web', 'es7' ]
}

config.plugins.push(
new webpack.DefinePlugin({
'__CLIENT__': !isServer,
Expand Down
4,755 changes: 1,856 additions & 2,899 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
},
"dependencies": {
"@apollo/client": "^3.11.1",
"@azuro-org/dictionaries": "^3.0.20",
"@azuro-org/sdk": "^5.3.0",
"@azuro-org/sdk-social-aa-connector": "^1.0.0",
"@azuro-org/dictionaries": "^3.0.21",
"@azuro-org/sdk": "^5.3.2",
"@azuro-org/sdk-social-aa-connector": "^1.0.4",
"@floating-ui/react-dom-interactions": "^0.13.3",
"@glidejs/glide": "^3.6.2",
"@headlessui/react": "1.7.19",
Expand Down
6 changes: 3 additions & 3 deletions src/app/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import User from 'compositions/profile/User/User'


export default function ProfilePage() {
const { account, isReconnecting } = useWallet()
const { account, isConnecting, isReconnecting } = useWallet()
const router = useRouter()

useEffect(() => {
if (!isReconnecting && !account) {
if (!isConnecting && !isReconnecting && !account) {
router.push('/')
}
}, [ isReconnecting, account ])
}, [ isConnecting, isReconnecting, account ])

if (!account) {
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React, { useEffect, useRef, useState } from 'react'
import { usePathname } from 'next/navigation'
// import { openModal } from '@locmod/modal'
import { useAccount } from '@azuro-org/sdk-social-aa-connector'
import { useWallet } from 'wallet'
import { usePrivy } from '@privy-io/react-auth'
import { useFreezeBodyScroll } from 'hooks'

Expand All @@ -27,9 +27,9 @@ const Content: React.FC = () => {
}

const Header: React.FC = () => {
const { address } = useAccount()
const { account, isReconnecting, isConnecting } = useWallet()
const pathname = usePathname()
const { connectOrCreateWallet, ready } = usePrivy()
const { connectOrCreateWallet } = usePrivy()
const [ isVisible, setVisibility ] = useState(false)
const containerRef = useRef<HTMLDivElement>(null)

Expand Down Expand Up @@ -72,14 +72,14 @@ const Header: React.FC = () => {
<Logo className="h-4" />
</div>
{
Boolean(address) ? (
Boolean(account) ? (
<Controls />
) : (
<Button
className="ml-auto"
title={buttonMessages.connectWallet}
size={32}
loading={!ready}
loading={isConnecting || isReconnecting}
onClick={() => connectOrCreateWallet()}
/>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use client'

import React from 'react'

// import { openModal } from '@locmod/modal'
import { useAccount } from '@azuro-org/sdk-social-aa-connector'
import { usePrivy } from '@privy-io/react-auth'
import { useWallet } from 'wallet'

import { Button, buttonMessages } from 'components/inputs'
import TabbedBetslip from 'compositions/TabbedBetslip/TabbedBetslip'
Expand All @@ -13,21 +12,21 @@ import Controls from '../Controls/Controls'


const RightSidebar: React.FC = () => {
const { address } = useAccount()
const { connectOrCreateWallet, ready } = usePrivy()
const { account, isReconnecting, isConnecting } = useWallet()
const { connectOrCreateWallet } = usePrivy()

return (
<>
<div className="px-6 py-3 sticky top-0 z-20">
{
Boolean(address) ? (
Boolean(account) ? (
<Controls className="ml-auto" />
) : (
<Button
className="ml-auto"
title={buttonMessages.connectWallet}
size={40}
loading={!ready}
loading={isConnecting || isReconnecting}
onClick={() => connectOrCreateWallet()}
/>
)
Expand Down

0 comments on commit 2fe0756

Please sign in to comment.