create-openfort 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.js +16 -16
- package/package.json +1 -1
- package/template/backend/package.json +7 -1
- package/template/backend/pnpm-lock.yaml +187 -33
- package/template/backend/src/app.ts +1 -1
- package/template/openfort-templates/firebase/biome.json +3 -3
- package/template/openfort-templates/firebase/package.json +1 -1
- package/template/openfort-templates/firebase/src/App.tsx +10 -10
- package/template/openfort-templates/firebase/src/components/cards/head.tsx +157 -145
- package/template/openfort-templates/firebase/src/components/cards/main.tsx +63 -52
- package/template/openfort-templates/firebase/src/components/ui/Sheet.tsx +14 -16
- package/template/openfort-templates/firebase/src/components/ui/Tabs.tsx +46 -36
- package/template/openfort-templates/firebase/src/components/ui/TruncateData.tsx +14 -8
- package/template/openfort-templates/firebase/src/integrations/firebase/client.ts +6 -6
- package/template/openfort-templates/firebase/src/integrations/firebase/components/FirebaseAuthCard.tsx +74 -46
- package/template/openfort-templates/firebase/src/integrations/firebase/errors.ts +57 -37
- package/template/openfort-templates/firebase/src/integrations/firebase/index.ts +3 -3
- package/template/openfort-templates/firebase/src/integrations/openfort/index.ts +1 -1
- package/template/openfort-templates/firebase/src/integrations/openfort/providers.tsx +23 -11
- package/template/openfort-templates/firebase/src/ui/openfort/blockchain/ActionsCard.tsx +47 -35
- package/template/openfort-templates/firebase/src/ui/openfort/blockchain/SignCard.tsx +30 -28
- package/template/openfort-templates/firebase/src/ui/openfort/index.ts +4 -6
- package/template/openfort-templates/firebase/src/ui/openfort/profile/UserProfileCard.tsx +32 -20
- package/template/openfort-templates/firebase/src/ui/openfort/wallets/WalletCreation.tsx +51 -27
- package/template/openfort-templates/firebase/src/ui/openfort/wallets/WalletListCard.tsx +66 -40
- package/template/openfort-templates/firebase/src/ui/openfort/wallets/WalletPasswordSheets.tsx +65 -41
- package/template/openfort-templates/firebase/vite.config.ts +3 -3
- package/template/openfort-templates/headless/biome.json +3 -3
- package/template/openfort-templates/headless/package.json +1 -1
- package/template/openfort-templates/headless/src/components/cards/auth.tsx +2 -2
- package/template/openfort-templates/headless/src/components/cards/profile.tsx +1 -3
- package/template/openfort-templates/headless/src/components/providers.tsx +4 -1
- package/template/openfort-templates/headless/src/index.css +10 -4
- package/template/openfort-templates/openfort-ui/biome.json +3 -3
- package/template/openfort-templates/openfort-ui/package.json +1 -1
- package/template/openfort-templates/openfort-ui/src/App.tsx +1 -3
- package/template/openfort-templates/openfort-ui/src/components/cards/auth.tsx +9 -11
- package/template/openfort-templates/openfort-ui/src/components/cards/head.tsx +157 -145
- package/template/openfort-templates/openfort-ui/src/components/cards/main.tsx +50 -41
- package/template/openfort-templates/openfort-ui/src/components/cards/profile.tsx +29 -35
- package/template/openfort-templates/openfort-ui/src/components/cards/sign.tsx +35 -49
- package/template/openfort-templates/openfort-ui/src/components/cards/wallets.tsx +51 -37
- package/template/openfort-templates/openfort-ui/src/components/createWallet.tsx +63 -30
- package/template/openfort-templates/openfort-ui/src/components/passwordRecovery.tsx +61 -56
- package/template/openfort-templates/openfort-ui/src/components/providers.tsx +14 -15
- package/template/openfort-templates/openfort-ui/src/components/ui/Sheet.tsx +14 -16
- package/template/openfort-templates/openfort-ui/src/components/ui/Tabs.tsx +46 -36
- package/template/openfort-templates/openfort-ui/src/components/ui/TruncateData.tsx +14 -8
- package/template/openfort-templates/openfort-ui/vite.config.ts +2 -2
|
@@ -1,47 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
FingerPrintIcon,
|
|
3
|
+
KeyIcon,
|
|
4
|
+
LockClosedIcon,
|
|
5
|
+
} from '@heroicons/react/24/outline'
|
|
6
|
+
import { RecoveryMethod, useWallets } from '@openfort/react'
|
|
7
|
+
import { useState } from 'react'
|
|
4
8
|
|
|
5
|
-
import { Sheet } from
|
|
6
|
-
import { CreateWalletPasswordSheet } from
|
|
9
|
+
import { Sheet } from '../../../components/ui/Sheet'
|
|
10
|
+
import { CreateWalletPasswordSheet } from './WalletPasswordSheets'
|
|
7
11
|
|
|
8
12
|
type CreateWalletSheetProps = {
|
|
9
|
-
open: boolean
|
|
10
|
-
onClose: () => void
|
|
11
|
-
onWalletCreated?: () => void
|
|
12
|
-
}
|
|
13
|
+
open: boolean
|
|
14
|
+
onClose: () => void
|
|
15
|
+
onWalletCreated?: () => void
|
|
16
|
+
}
|
|
13
17
|
|
|
14
|
-
export function CreateWalletSheet({
|
|
18
|
+
export function CreateWalletSheet({
|
|
19
|
+
open,
|
|
20
|
+
onClose,
|
|
21
|
+
onWalletCreated,
|
|
22
|
+
}: CreateWalletSheetProps) {
|
|
15
23
|
return (
|
|
16
24
|
<Sheet
|
|
17
25
|
open={open}
|
|
18
26
|
onClose={() => {
|
|
19
|
-
onClose()
|
|
27
|
+
onClose()
|
|
20
28
|
}}
|
|
21
29
|
title="Create Wallet"
|
|
22
30
|
description="Please choose a recovery method for your new wallet."
|
|
23
31
|
>
|
|
24
32
|
<CreateWallet
|
|
25
33
|
onWalletCreated={() => {
|
|
26
|
-
onClose()
|
|
27
|
-
onWalletCreated?.()
|
|
34
|
+
onClose()
|
|
35
|
+
onWalletCreated?.()
|
|
28
36
|
}}
|
|
29
37
|
/>
|
|
30
38
|
</Sheet>
|
|
31
|
-
)
|
|
39
|
+
)
|
|
32
40
|
}
|
|
33
41
|
|
|
34
|
-
export function CreateWallet({
|
|
35
|
-
|
|
42
|
+
export function CreateWallet({
|
|
43
|
+
onWalletCreated,
|
|
44
|
+
}: {
|
|
45
|
+
onWalletCreated?: () => void
|
|
46
|
+
}) {
|
|
47
|
+
const [passwordSheetOpen, setPasswordSheetOpen] = useState(false)
|
|
36
48
|
|
|
37
49
|
const { isCreating, createWallet, error } = useWallets({
|
|
38
50
|
onSuccess: () => {
|
|
39
|
-
onWalletCreated?.()
|
|
51
|
+
onWalletCreated?.()
|
|
40
52
|
},
|
|
41
|
-
})
|
|
53
|
+
})
|
|
42
54
|
|
|
43
55
|
if (isCreating) {
|
|
44
|
-
return <div>Creating wallet...</div
|
|
56
|
+
return <div>Creating wallet...</div>
|
|
45
57
|
}
|
|
46
58
|
|
|
47
59
|
return (
|
|
@@ -60,7 +72,9 @@ export function CreateWallet({ onWalletCreated }: { onWalletCreated?: () => void
|
|
|
60
72
|
<FingerPrintIcon />
|
|
61
73
|
<div className="flex flex-col text-start">
|
|
62
74
|
<h4>Passkey</h4>
|
|
63
|
-
<p className="text-sm hover-description">
|
|
75
|
+
<p className="text-sm hover-description">
|
|
76
|
+
Secure your wallet with biometric authentication.
|
|
77
|
+
</p>
|
|
64
78
|
</div>
|
|
65
79
|
</button>
|
|
66
80
|
<button
|
|
@@ -76,28 +90,38 @@ export function CreateWallet({ onWalletCreated }: { onWalletCreated?: () => void
|
|
|
76
90
|
<LockClosedIcon />
|
|
77
91
|
<div className="flex flex-col text-start">
|
|
78
92
|
<h4>Automatic recovery</h4>
|
|
79
|
-
<p className="text-sm hover-description">
|
|
93
|
+
<p className="text-sm hover-description">
|
|
94
|
+
Uses encryption session to recover your wallet.
|
|
95
|
+
</p>
|
|
80
96
|
</div>
|
|
81
97
|
</button>
|
|
82
|
-
<button
|
|
98
|
+
<button
|
|
99
|
+
className="wallet-option cursor-pointer"
|
|
100
|
+
onClick={() => setPasswordSheetOpen(true)}
|
|
101
|
+
>
|
|
83
102
|
<KeyIcon />
|
|
84
103
|
<div className="flex flex-col text-start">
|
|
85
104
|
<h4>Password</h4>
|
|
86
|
-
<p className="text-sm hover-description">
|
|
105
|
+
<p className="text-sm hover-description">
|
|
106
|
+
Create a strong password to secure your wallet.
|
|
107
|
+
</p>
|
|
87
108
|
</div>
|
|
88
109
|
</button>
|
|
89
110
|
</div>
|
|
90
|
-
{error &&
|
|
111
|
+
{error && (
|
|
112
|
+
<p className="text-red-500 text-sm mb-2">Error: {error.message}</p>
|
|
113
|
+
)}
|
|
91
114
|
<p className="mb-4 text-xs text-zinc-400">
|
|
92
|
-
Disclaimer: This is a demo of Openfort recovery methods. In production,
|
|
115
|
+
Disclaimer: This is a demo of Openfort recovery methods. In production,
|
|
116
|
+
it's best to choose one method for a smoother user experience.
|
|
93
117
|
</p>
|
|
94
118
|
<CreateWalletPasswordSheet
|
|
95
119
|
open={passwordSheetOpen}
|
|
96
120
|
onClose={() => setPasswordSheetOpen(false)}
|
|
97
121
|
onCreateWallet={() => {
|
|
98
|
-
onWalletCreated?.()
|
|
122
|
+
onWalletCreated?.()
|
|
99
123
|
}}
|
|
100
124
|
/>
|
|
101
125
|
</>
|
|
102
|
-
)
|
|
126
|
+
)
|
|
103
127
|
}
|
|
@@ -1,28 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import {
|
|
2
|
+
FingerPrintIcon,
|
|
3
|
+
KeyIcon,
|
|
4
|
+
LockClosedIcon,
|
|
5
|
+
} from '@heroicons/react/24/outline'
|
|
6
|
+
import {
|
|
7
|
+
RecoveryMethod,
|
|
8
|
+
type UserWallet,
|
|
9
|
+
useSignOut,
|
|
10
|
+
useUser,
|
|
11
|
+
useWallets,
|
|
12
|
+
} from '@openfort/react'
|
|
13
|
+
import { useState } from 'react'
|
|
14
|
+
import { useAccount } from 'wagmi'
|
|
15
|
+
import { CreateWallet, CreateWalletSheet } from './WalletCreation'
|
|
16
|
+
import { WalletRecoverPasswordSheet } from './WalletPasswordSheets'
|
|
8
17
|
|
|
9
18
|
function WalletRecoveryBadge({ wallet }: { wallet: UserWallet }) {
|
|
10
|
-
let Icon = LockClosedIcon
|
|
11
|
-
let label =
|
|
19
|
+
let Icon = LockClosedIcon
|
|
20
|
+
let label = 'Unknown'
|
|
12
21
|
|
|
13
22
|
switch (wallet.recoveryMethod) {
|
|
14
23
|
case RecoveryMethod.PASSWORD:
|
|
15
|
-
Icon = KeyIcon
|
|
16
|
-
label =
|
|
17
|
-
break
|
|
24
|
+
Icon = KeyIcon
|
|
25
|
+
label = 'Password'
|
|
26
|
+
break
|
|
18
27
|
case RecoveryMethod.AUTOMATIC:
|
|
19
|
-
Icon = LockClosedIcon
|
|
20
|
-
label =
|
|
21
|
-
break
|
|
28
|
+
Icon = LockClosedIcon
|
|
29
|
+
label = 'Automatic'
|
|
30
|
+
break
|
|
22
31
|
case RecoveryMethod.PASSKEY:
|
|
23
|
-
Icon = FingerPrintIcon
|
|
24
|
-
label =
|
|
25
|
-
break
|
|
32
|
+
Icon = FingerPrintIcon
|
|
33
|
+
label = 'Passkey'
|
|
34
|
+
break
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
return (
|
|
@@ -30,20 +39,28 @@ function WalletRecoveryBadge({ wallet }: { wallet: UserWallet }) {
|
|
|
30
39
|
<span>{label}</span>
|
|
31
40
|
<Icon className="h-5 w-5 ml-2" />
|
|
32
41
|
</div>
|
|
33
|
-
)
|
|
42
|
+
)
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
export function WalletListCard() {
|
|
37
|
-
const {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
const {
|
|
47
|
+
wallets,
|
|
48
|
+
isLoadingWallets,
|
|
49
|
+
availableWallets,
|
|
50
|
+
setActiveWallet,
|
|
51
|
+
isConnecting,
|
|
52
|
+
} = useWallets()
|
|
53
|
+
const { user, isAuthenticated } = useUser()
|
|
54
|
+
const { isConnected } = useAccount()
|
|
55
|
+
const { signOut } = useSignOut()
|
|
56
|
+
|
|
57
|
+
const [createWalletSheetOpen, setCreateWalletSheetOpen] = useState(false)
|
|
58
|
+
const [walletToRecover, setWalletToRecover] = useState<UserWallet | null>(
|
|
59
|
+
null,
|
|
60
|
+
)
|
|
44
61
|
|
|
45
62
|
if (isLoadingWallets || (!user && isAuthenticated)) {
|
|
46
|
-
return <div>Loading wallets...</div
|
|
63
|
+
return <div>Loading wallets...</div>
|
|
47
64
|
}
|
|
48
65
|
|
|
49
66
|
if (availableWallets.length === 0) {
|
|
@@ -53,27 +70,29 @@ export function WalletListCard() {
|
|
|
53
70
|
<p>You do not have any wallet yet.</p>
|
|
54
71
|
<CreateWallet />
|
|
55
72
|
</div>
|
|
56
|
-
)
|
|
73
|
+
)
|
|
57
74
|
}
|
|
58
75
|
|
|
59
76
|
const handleWalletClick = (wallet: UserWallet) => {
|
|
60
|
-
if (wallet.isActive || isConnecting) return
|
|
77
|
+
if (wallet.isActive || isConnecting) return
|
|
61
78
|
|
|
62
79
|
if (wallet.recoveryMethod === RecoveryMethod.PASSWORD) {
|
|
63
|
-
setWalletToRecover(wallet)
|
|
64
|
-
return
|
|
80
|
+
setWalletToRecover(wallet)
|
|
81
|
+
return
|
|
65
82
|
}
|
|
66
83
|
|
|
67
84
|
setActiveWallet({
|
|
68
|
-
walletId:
|
|
85
|
+
walletId: 'xyz.openfort',
|
|
69
86
|
address: wallet.address,
|
|
70
|
-
})
|
|
71
|
-
}
|
|
87
|
+
})
|
|
88
|
+
}
|
|
72
89
|
|
|
73
90
|
return (
|
|
74
91
|
<div className="flex flex-col w-full">
|
|
75
92
|
<h1>Wallets</h1>
|
|
76
|
-
<p className="mb-4 text-sm text-zinc-400">
|
|
93
|
+
<p className="mb-4 text-sm text-zinc-400">
|
|
94
|
+
Select a wallet to connect to your account.
|
|
95
|
+
</p>
|
|
77
96
|
|
|
78
97
|
<div className="space-y-4 pb-4">
|
|
79
98
|
<h2>Your Wallets</h2>
|
|
@@ -91,7 +110,7 @@ export function WalletListCard() {
|
|
|
91
110
|
) : (
|
|
92
111
|
<div className="flex justify-between items-center">
|
|
93
112
|
<p className="font-medium mr-2">
|
|
94
|
-
{wallet.address.substring(0, 6)
|
|
113
|
+
{`${wallet.address.substring(0, 6)}...${wallet.address.substring(wallet.address.length - 4)}`}
|
|
95
114
|
</p>
|
|
96
115
|
<WalletRecoveryBadge wallet={wallet} />
|
|
97
116
|
</div>
|
|
@@ -108,14 +127,21 @@ export function WalletListCard() {
|
|
|
108
127
|
</div>
|
|
109
128
|
</div>
|
|
110
129
|
|
|
111
|
-
<WalletRecoverPasswordSheet
|
|
130
|
+
<WalletRecoverPasswordSheet
|
|
131
|
+
wallet={walletToRecover}
|
|
132
|
+
open={!!walletToRecover}
|
|
133
|
+
onClose={() => setWalletToRecover(null)}
|
|
134
|
+
/>
|
|
112
135
|
|
|
113
|
-
<CreateWalletSheet
|
|
136
|
+
<CreateWalletSheet
|
|
137
|
+
open={createWalletSheetOpen}
|
|
138
|
+
onClose={() => setCreateWalletSheetOpen(false)}
|
|
139
|
+
/>
|
|
114
140
|
|
|
115
141
|
{!isConnected && (
|
|
116
142
|
<button
|
|
117
143
|
onClick={() => {
|
|
118
|
-
signOut()
|
|
144
|
+
signOut()
|
|
119
145
|
}}
|
|
120
146
|
className="mt-auto btn"
|
|
121
147
|
>
|
|
@@ -123,5 +149,5 @@ export function WalletListCard() {
|
|
|
123
149
|
</button>
|
|
124
150
|
)}
|
|
125
151
|
</div>
|
|
126
|
-
)
|
|
152
|
+
)
|
|
127
153
|
}
|
package/template/openfort-templates/firebase/src/ui/openfort/wallets/WalletPasswordSheets.tsx
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
import { CheckCircleIcon } from
|
|
2
|
-
import { RecoveryMethod,
|
|
1
|
+
import { CheckCircleIcon } from '@heroicons/react/24/outline'
|
|
2
|
+
import { RecoveryMethod, type UserWallet, useWallets } from '@openfort/react'
|
|
3
3
|
|
|
4
|
-
import { Sheet } from
|
|
4
|
+
import { Sheet } from '../../../components/ui/Sheet'
|
|
5
5
|
|
|
6
6
|
type CreateWalletPasswordSheetProps = {
|
|
7
|
-
open: boolean
|
|
8
|
-
onClose: () => void
|
|
9
|
-
onCreateWallet?: () => void
|
|
10
|
-
}
|
|
7
|
+
open: boolean
|
|
8
|
+
onClose: () => void
|
|
9
|
+
onCreateWallet?: () => void
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
-
export function CreateWalletPasswordSheet({
|
|
13
|
-
|
|
12
|
+
export function CreateWalletPasswordSheet({
|
|
13
|
+
open,
|
|
14
|
+
onClose,
|
|
15
|
+
onCreateWallet,
|
|
16
|
+
}: CreateWalletPasswordSheetProps) {
|
|
17
|
+
const { createWallet, error, isCreating, reset } = useWallets()
|
|
14
18
|
|
|
15
19
|
return (
|
|
16
20
|
<Sheet
|
|
17
21
|
open={open}
|
|
18
22
|
onClose={() => {
|
|
19
|
-
onClose()
|
|
20
|
-
reset()
|
|
23
|
+
onClose()
|
|
24
|
+
reset()
|
|
21
25
|
}}
|
|
22
26
|
title="Enter Password"
|
|
23
27
|
description="Please enter the password of your wallet."
|
|
@@ -25,20 +29,20 @@ export function CreateWalletPasswordSheet({ open, onClose, onCreateWallet }: Cre
|
|
|
25
29
|
<form
|
|
26
30
|
className="flex-1 w-full flex flex-col justify-center max-w-md mx-auto"
|
|
27
31
|
onSubmit={async (event) => {
|
|
28
|
-
event.preventDefault()
|
|
29
|
-
const formData = new FormData(event.target as HTMLFormElement)
|
|
30
|
-
const password = formData.get(
|
|
32
|
+
event.preventDefault()
|
|
33
|
+
const formData = new FormData(event.target as HTMLFormElement)
|
|
34
|
+
const password = formData.get('password') as string
|
|
31
35
|
|
|
32
36
|
const { error: walletError } = await createWallet({
|
|
33
37
|
recovery: {
|
|
34
38
|
recoveryMethod: RecoveryMethod.PASSWORD,
|
|
35
39
|
password,
|
|
36
40
|
},
|
|
37
|
-
})
|
|
41
|
+
})
|
|
38
42
|
|
|
39
43
|
if (!walletError) {
|
|
40
|
-
onCreateWallet?.()
|
|
41
|
-
onClose()
|
|
44
|
+
onCreateWallet?.()
|
|
45
|
+
onClose()
|
|
42
46
|
}
|
|
43
47
|
}}
|
|
44
48
|
>
|
|
@@ -49,7 +53,10 @@ export function CreateWalletPasswordSheet({ open, onClose, onCreateWallet }: Cre
|
|
|
49
53
|
</div>
|
|
50
54
|
<div className="flex items-center gap-2">
|
|
51
55
|
<CheckCircleIcon className="h-5 w-5 text-primary my-4 shrink-0" />
|
|
52
|
-
<span>
|
|
56
|
+
<span>
|
|
57
|
+
If you lose this password, you will not be able to access your
|
|
58
|
+
wallet.
|
|
59
|
+
</span>
|
|
53
60
|
</div>
|
|
54
61
|
</div>
|
|
55
62
|
<input
|
|
@@ -58,30 +65,40 @@ export function CreateWalletPasswordSheet({ open, onClose, onCreateWallet }: Cre
|
|
|
58
65
|
placeholder="Enter your wallet's password"
|
|
59
66
|
className="w-full mt-2 p-2 border border-gray-300 rounded"
|
|
60
67
|
/>
|
|
61
|
-
{error &&
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
{error && (
|
|
69
|
+
<span className="text-red-500 text-sm mt-2">{error?.message}</span>
|
|
70
|
+
)}
|
|
71
|
+
<button
|
|
72
|
+
className="mt-4 w-full bg-zinc-700 text-white p-2 rounded cursor-pointer"
|
|
73
|
+
type="submit"
|
|
74
|
+
disabled={isCreating}
|
|
75
|
+
>
|
|
76
|
+
{isCreating ? 'Creating wallet...' : 'Create Wallet'}
|
|
64
77
|
</button>
|
|
65
78
|
</form>
|
|
66
79
|
</Sheet>
|
|
67
|
-
)
|
|
80
|
+
)
|
|
68
81
|
}
|
|
69
82
|
|
|
70
83
|
type WalletRecoverPasswordSheetProps = {
|
|
71
|
-
open: boolean
|
|
72
|
-
onClose: () => void
|
|
73
|
-
wallet: UserWallet | null
|
|
74
|
-
}
|
|
84
|
+
open: boolean
|
|
85
|
+
onClose: () => void
|
|
86
|
+
wallet: UserWallet | null
|
|
87
|
+
}
|
|
75
88
|
|
|
76
|
-
export function WalletRecoverPasswordSheet({
|
|
77
|
-
|
|
89
|
+
export function WalletRecoverPasswordSheet({
|
|
90
|
+
open,
|
|
91
|
+
onClose,
|
|
92
|
+
wallet,
|
|
93
|
+
}: WalletRecoverPasswordSheetProps) {
|
|
94
|
+
const { setActiveWallet, error, isConnecting, reset } = useWallets()
|
|
78
95
|
|
|
79
96
|
return (
|
|
80
97
|
<Sheet
|
|
81
98
|
open={open}
|
|
82
99
|
onClose={() => {
|
|
83
|
-
onClose()
|
|
84
|
-
reset()
|
|
100
|
+
onClose()
|
|
101
|
+
reset()
|
|
85
102
|
}}
|
|
86
103
|
title="Enter Password"
|
|
87
104
|
description="Please enter the password of your wallet."
|
|
@@ -89,24 +106,25 @@ export function WalletRecoverPasswordSheet({ open, onClose, wallet }: WalletReco
|
|
|
89
106
|
<form
|
|
90
107
|
className="w-full flex-1 flex flex-col justify-center"
|
|
91
108
|
onSubmit={(event) => {
|
|
92
|
-
event.preventDefault()
|
|
93
|
-
const formData = new FormData(event.target as HTMLFormElement)
|
|
94
|
-
const password = formData.get(
|
|
95
|
-
if (!wallet) throw new Error(
|
|
109
|
+
event.preventDefault()
|
|
110
|
+
const formData = new FormData(event.target as HTMLFormElement)
|
|
111
|
+
const password = formData.get('password') as string
|
|
112
|
+
if (!wallet) throw new Error('No wallet to recover')
|
|
96
113
|
|
|
97
114
|
setActiveWallet({
|
|
98
|
-
walletId:
|
|
115
|
+
walletId: 'xyz.openfort',
|
|
99
116
|
recovery: {
|
|
100
117
|
recoveryMethod: RecoveryMethod.PASSWORD,
|
|
101
118
|
password,
|
|
102
119
|
},
|
|
103
120
|
address: wallet.address,
|
|
104
|
-
})
|
|
121
|
+
})
|
|
105
122
|
}}
|
|
106
123
|
>
|
|
107
124
|
{wallet && (
|
|
108
125
|
<p>
|
|
109
|
-
Recover wallet {wallet.address.slice(0, 6)}...
|
|
126
|
+
Recover wallet {wallet.address.slice(0, 6)}...
|
|
127
|
+
{wallet.address.slice(-4)} with password
|
|
110
128
|
</p>
|
|
111
129
|
)}
|
|
112
130
|
<input
|
|
@@ -115,11 +133,17 @@ export function WalletRecoverPasswordSheet({ open, onClose, wallet }: WalletReco
|
|
|
115
133
|
placeholder="Enter your wallet's password"
|
|
116
134
|
className="w-full mt-2 p-2 border border-gray-300 rounded"
|
|
117
135
|
/>
|
|
118
|
-
{error &&
|
|
119
|
-
|
|
120
|
-
|
|
136
|
+
{error && (
|
|
137
|
+
<span className="text-red-500 text-sm mt-2">{error?.message}</span>
|
|
138
|
+
)}
|
|
139
|
+
<button
|
|
140
|
+
className="mt-4 w-full bg-zinc-700 text-white p-2 rounded cursor-pointer"
|
|
141
|
+
type="submit"
|
|
142
|
+
disabled={isConnecting}
|
|
143
|
+
>
|
|
144
|
+
{isConnecting ? 'Recovering...' : 'Recover Wallet'}
|
|
121
145
|
</button>
|
|
122
146
|
</form>
|
|
123
147
|
</Sheet>
|
|
124
|
-
)
|
|
148
|
+
)
|
|
125
149
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineConfig, loadEnv } from 'vite'
|
|
2
|
-
import react from '@vitejs/plugin-react'
|
|
3
1
|
import tailwindcss from '@tailwindcss/vite'
|
|
2
|
+
import react from '@vitejs/plugin-react'
|
|
3
|
+
import { defineConfig, loadEnv } from 'vite'
|
|
4
4
|
|
|
5
5
|
// https://vite.dev/config/
|
|
6
6
|
export default defineConfig(({ mode }) => {
|
|
7
7
|
const env = loadEnv(mode, process.cwd(), '')
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
return {
|
|
10
10
|
plugins: [react(), tailwindcss()],
|
|
11
11
|
server: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/2.
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
|
|
3
3
|
"root": true,
|
|
4
4
|
"vcs": {
|
|
5
5
|
"enabled": true,
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
"useIgnoreFile": true
|
|
8
8
|
},
|
|
9
9
|
"files": {
|
|
10
|
-
"ignoreUnknown": true
|
|
10
|
+
"ignoreUnknown": true,
|
|
11
|
+
"includes": ["**/*.tsx", "**/*.ts", "**/*.jsx", "**/*.js"]
|
|
11
12
|
},
|
|
12
13
|
"formatter": {
|
|
13
14
|
"enabled": true,
|
|
@@ -49,7 +50,6 @@
|
|
|
49
50
|
},
|
|
50
51
|
"overrides": [
|
|
51
52
|
{
|
|
52
|
-
"includes": ["**/*.tsx", "**/*.ts", "**/*.jsx", "**/*.js"],
|
|
53
53
|
"linter": {
|
|
54
54
|
"rules": {
|
|
55
55
|
"correctness": {
|
|
@@ -110,10 +110,10 @@ const AuthForm = () => {
|
|
|
110
110
|
const [isLogin, setIsLogin] = useState(true)
|
|
111
111
|
const { isLoading } = useAuthCallback({
|
|
112
112
|
onSuccess: () => {
|
|
113
|
-
|
|
113
|
+
console.log('Authentication verified!')
|
|
114
114
|
},
|
|
115
115
|
onError: (e) => {
|
|
116
|
-
|
|
116
|
+
console.error(`Authentication verification failed!${e.message}`)
|
|
117
117
|
},
|
|
118
118
|
})
|
|
119
119
|
|
|
@@ -22,9 +22,7 @@ export const Profile = ({
|
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<div className="flex flex-col flex-1 gap-4">
|
|
25
|
-
<h1 className="truncate">
|
|
26
|
-
Welcome, {user?.player?.name || user?.linkedAccounts[0]?.email}
|
|
27
|
-
</h1>
|
|
25
|
+
<h1 className="truncate">Welcome, {user?.name || user?.email}</h1>
|
|
28
26
|
<p className="text-zinc-400 text-sm">
|
|
29
27
|
{description}
|
|
30
28
|
<br />
|
|
@@ -24,8 +24,11 @@ export function Providers({ children }: { children: React.ReactNode }) {
|
|
|
24
24
|
walletConfig={{
|
|
25
25
|
shieldPublishableKey: import.meta.env.VITE_SHIELD_PUBLISHABLE_KEY!, // The public key for your Openfort Shield account get it from https://dashboard.openfort.io
|
|
26
26
|
ethereumProviderPolicyId: import.meta.env.VITE_POLICY_ID, // The policy ID for sponsoring transactions
|
|
27
|
+
// If you want to use AUTOMATIC embedded wallet recovery, an encryption session is required.
|
|
28
|
+
// See: https://www.openfort.io/docs/products/embedded-wallet/react-native/quickstart/automatic
|
|
29
|
+
// For backend setup, check: https://github.com/openfort-xyz/openfort-backend-quickstart
|
|
27
30
|
createEncryptedSessionEndpoint: import.meta.env
|
|
28
|
-
.VITE_CREATE_ENCRYPTED_SESSION_ENDPOINT,
|
|
31
|
+
.VITE_CREATE_ENCRYPTED_SESSION_ENDPOINT,
|
|
29
32
|
recoverWalletAutomaticallyAfterAuth: true, // We will manually call create/setActive wallet after auth
|
|
30
33
|
}}
|
|
31
34
|
>
|
|
@@ -89,7 +89,6 @@
|
|
|
89
89
|
--card-width: 29rem;
|
|
90
90
|
--card-group-height: 600px;
|
|
91
91
|
|
|
92
|
-
|
|
93
92
|
@media (max-width: calc(64rem - 1px)) {
|
|
94
93
|
--card-group-width: 29rem;
|
|
95
94
|
}
|
|
@@ -111,7 +110,7 @@
|
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
.logo:hover {
|
|
114
|
-
filter: drop-shadow(0 0 3em #
|
|
113
|
+
filter: drop-shadow(0 0 3em #fc3627);
|
|
115
114
|
}
|
|
116
115
|
|
|
117
116
|
@keyframes spin {
|
|
@@ -156,7 +155,11 @@
|
|
|
156
155
|
color: var(--color-zinc-100);
|
|
157
156
|
border: 1px solid var(--color-zinc-100);
|
|
158
157
|
background-color: var(--color-zinc-800);
|
|
159
|
-
transition:
|
|
158
|
+
transition:
|
|
159
|
+
border-color 300ms,
|
|
160
|
+
background-color 300ms,
|
|
161
|
+
color 300ms,
|
|
162
|
+
filter 300ms;
|
|
160
163
|
|
|
161
164
|
overflow: hidden;
|
|
162
165
|
|
|
@@ -164,7 +167,10 @@
|
|
|
164
167
|
min-height: 2rem;
|
|
165
168
|
|
|
166
169
|
.hover-description {
|
|
167
|
-
transition:
|
|
170
|
+
transition:
|
|
171
|
+
transform 300ms,
|
|
172
|
+
max-height 500ms,
|
|
173
|
+
opacity 300ms;
|
|
168
174
|
|
|
169
175
|
max-height: 2.5rem;
|
|
170
176
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/2.
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
|
|
3
3
|
"root": true,
|
|
4
4
|
"vcs": {
|
|
5
5
|
"enabled": true,
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
"useIgnoreFile": true
|
|
8
8
|
},
|
|
9
9
|
"files": {
|
|
10
|
-
"ignoreUnknown": true
|
|
10
|
+
"ignoreUnknown": true,
|
|
11
|
+
"includes": ["**/*.tsx", "**/*.ts", "**/*.jsx", "**/*.js"]
|
|
11
12
|
},
|
|
12
13
|
"formatter": {
|
|
13
14
|
"enabled": true,
|
|
@@ -49,7 +50,6 @@
|
|
|
49
50
|
},
|
|
50
51
|
"overrides": [
|
|
51
52
|
{
|
|
52
|
-
"includes": ["**/*.tsx", "**/*.ts", "**/*.jsx", "**/*.js"],
|
|
53
53
|
"linter": {
|
|
54
54
|
"rules": {
|
|
55
55
|
"correctness": {
|