Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
ba2000af
Commit
ba2000af
authored
Sep 23, 2024
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refetch csrf token after login and fix connect wallet from contract page
parent
8ef67799
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
7 deletions
+24
-7
useGetCsrfToken.tsx
lib/hooks/useGetCsrfToken.tsx
+1
-1
ContractConnectWallet.tsx
ui/address/contract/methods/ContractConnectWallet.tsx
+17
-3
AuthModal.tsx
ui/snippets/auth/AuthModal.tsx
+4
-1
UserWalletDesktop.tsx
ui/snippets/user/wallet/UserWalletDesktop.tsx
+2
-2
No files found.
lib/hooks/useGetCsrfToken.tsx
View file @
ba2000af
...
@@ -10,7 +10,7 @@ import useFetch from 'lib/hooks/useFetch';
...
@@ -10,7 +10,7 @@ import useFetch from 'lib/hooks/useFetch';
export
default
function
useGetCsrfToken
()
{
export
default
function
useGetCsrfToken
()
{
const
nodeApiFetch
=
useFetch
();
const
nodeApiFetch
=
useFetch
();
useQuery
({
return
useQuery
({
queryKey
:
getResourceKey
(
'
csrf
'
),
queryKey
:
getResourceKey
(
'
csrf
'
),
queryFn
:
async
()
=>
{
queryFn
:
async
()
=>
{
if
(
!
isNeedProxy
())
{
if
(
!
isNeedProxy
())
{
...
...
ui/address/contract/methods/ContractConnectWallet.tsx
View file @
ba2000af
...
@@ -5,15 +5,29 @@ import config from 'configs/app';
...
@@ -5,15 +5,29 @@ import config from 'configs/app';
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useWeb3Wallet
from
'
lib/web3/useWallet
'
;
import
useWeb3Wallet
from
'
lib/web3/useWallet
'
;
import
AddressEntity
from
'
ui/shared/entities/address/AddressEntity
'
;
import
AddressEntity
from
'
ui/shared/entities/address/AddressEntity
'
;
import
useIsAuth
from
'
ui/snippets/auth/useIsAuth
'
;
import
useSignInWithWallet
from
'
ui/snippets/auth/useSignInWithWallet
'
;
interface
Props
{
interface
Props
{
isLoading
?:
boolean
;
isLoading
?:
boolean
;
}
}
const
ContractConnectWallet
=
({
isLoading
}:
Props
)
=>
{
const
ContractConnectWallet
=
({
isLoading
}:
Props
)
=>
{
const
signInWithWallet
=
useSignInWithWallet
({
source
:
'
Smart contracts
'
});
const
isAuth
=
useIsAuth
();
const
web3Wallet
=
useWeb3Wallet
({
source
:
'
Smart contracts
'
});
const
web3Wallet
=
useWeb3Wallet
({
source
:
'
Smart contracts
'
});
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
const
shouldSignIn
=
config
.
features
.
account
.
isEnabled
&&
!
isAuth
;
const
handleConnectClick
=
React
.
useCallback
(()
=>
{
if
(
shouldSignIn
)
{
signInWithWallet
.
start
();
}
else
{
web3Wallet
.
connect
();
}
},
[
signInWithWallet
,
web3Wallet
,
shouldSignIn
]);
const
content
=
(()
=>
{
const
content
=
(()
=>
{
if
(
!
web3Wallet
.
isConnected
)
{
if
(
!
web3Wallet
.
isConnected
)
{
return
(
return
(
...
@@ -21,13 +35,13 @@ const ContractConnectWallet = ({ isLoading }: Props) => {
...
@@ -21,13 +35,13 @@ const ContractConnectWallet = ({ isLoading }: Props) => {
<
span
>
Disconnected
</
span
>
<
span
>
Disconnected
</
span
>
<
Button
<
Button
ml=
{
3
}
ml=
{
3
}
onClick=
{
web3Wallet
.
connect
}
onClick=
{
handleConnectClick
}
size=
"sm"
size=
"sm"
variant=
"outline"
variant=
"outline"
isLoading=
{
web3Wallet
.
isOpen
}
isLoading=
{
shouldSignIn
?
signInWithWallet
.
isPending
:
web3Wallet
.
isOpen
}
loadingText=
"Connect wallet"
loadingText=
"Connect wallet"
>
>
Connect wallet
Connect wallet
</
Button
>
</
Button
>
</>
</>
);
);
...
...
ui/snippets/auth/AuthModal.tsx
View file @
ba2000af
...
@@ -4,6 +4,7 @@ import React from 'react';
...
@@ -4,6 +4,7 @@ import React from 'react';
import
type
{
Screen
,
ScreenSuccess
}
from
'
./types
'
;
import
type
{
Screen
,
ScreenSuccess
}
from
'
./types
'
;
import
useGetCsrfToken
from
'
lib/hooks/useGetCsrfToken
'
;
import
*
as
mixpanel
from
'
lib/mixpanel
'
;
import
*
as
mixpanel
from
'
lib/mixpanel
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
...
@@ -34,6 +35,7 @@ const AuthModal = ({ initialScreen, onClose, mixpanelConfig }: Props) => {
...
@@ -34,6 +35,7 @@ const AuthModal = ({ initialScreen, onClose, mixpanelConfig }: Props) => {
const
router
=
useRouter
();
const
router
=
useRouter
();
const
profileQuery
=
useProfileQuery
();
const
profileQuery
=
useProfileQuery
();
const
csrfQuery
=
useGetCsrfToken
();
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
if
(
'
isAuth
'
in
initialScreen
&&
initialScreen
.
isAuth
)
{
if
(
'
isAuth
'
in
initialScreen
&&
initialScreen
.
isAuth
)
{
...
@@ -79,11 +81,12 @@ const AuthModal = ({ initialScreen, onClose, mixpanelConfig }: Props) => {
...
@@ -79,11 +81,12 @@ const AuthModal = ({ initialScreen, onClose, mixpanelConfig }: Props) => {
}
}
const
{
data
}
=
await
profileQuery
.
refetch
();
const
{
data
}
=
await
profileQuery
.
refetch
();
await
csrfQuery
.
refetch
();
if
(
data
)
{
if
(
data
)
{
onNextStep
({
...
screen
,
profile
:
data
});
onNextStep
({
...
screen
,
profile
:
data
});
}
}
// TODO @tom2drum handle error case
// TODO @tom2drum handle error case
},
[
initialScreen
,
mixpanelConfig
?.
account_link_info
.
source
,
onNextStep
,
profileQuery
]);
},
[
initialScreen
,
mixpanelConfig
?.
account_link_info
.
source
,
onNextStep
,
profileQuery
,
csrfQuery
]);
const
onModalClose
=
React
.
useCallback
(()
=>
{
const
onModalClose
=
React
.
useCallback
(()
=>
{
onClose
(
isSuccess
);
onClose
(
isSuccess
);
...
...
ui/snippets/user/wallet/UserWalletDesktop.tsx
View file @
ba2000af
...
@@ -14,7 +14,7 @@ interface Props {
...
@@ -14,7 +14,7 @@ interface Props {
buttonVariant
?:
ButtonProps
[
'
variant
'
];
buttonVariant
?:
ButtonProps
[
'
variant
'
];
}
}
const
WalletDesktop
=
({
buttonSize
,
buttonVariant
=
'
header
'
}:
Props
)
=>
{
const
User
WalletDesktop
=
({
buttonSize
,
buttonVariant
=
'
header
'
}:
Props
)
=>
{
const
walletMenu
=
useDisclosure
();
const
walletMenu
=
useDisclosure
();
const
web3Wallet
=
useWeb3Wallet
({
source
:
'
Header
'
});
const
web3Wallet
=
useWeb3Wallet
({
source
:
'
Header
'
});
...
@@ -65,4 +65,4 @@ const WalletDesktop = ({ buttonSize, buttonVariant = 'header' }: Props) => {
...
@@ -65,4 +65,4 @@ const WalletDesktop = ({ buttonSize, buttonVariant = 'header' }: Props) => {
);
);
};
};
export
default
React
.
memo
(
WalletDesktop
);
export
default
React
.
memo
(
User
WalletDesktop
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment