@@ -7,28 +7,15 @@ import {
77 WalletSource ,
88 type Wallet ,
99 type WalletAccount ,
10+ type HandleImportPrivateKeyParams ,
1011} from "@turnkey/react-wallet-kit" ;
11- import type { v1AddressFormat , v1Curve } from "@turnkey/sdk-types" ;
12+ import type {
13+ v1AddressFormat ,
14+ v1PrivateKey ,
15+ v1Curve ,
16+ } from "@turnkey/sdk-types" ;
1217import { useRouter } from "next/navigation" ;
1318
14- type PrivateKeyAddress = {
15- format : string ;
16- address : string ;
17- } ;
18-
19- type PrivateKey = {
20- privateKeyId : string ;
21- privateKeyName ?: string ;
22- publicKey ?: string ;
23- curve ?: string ;
24- addresses ?: PrivateKeyAddress [ ] ;
25- privateKeyTags ?: string [ ] ;
26- createdAt ?: { seconds : string ; nanos : string } ;
27- updatedAt ?: unknown ;
28- exported ?: boolean ;
29- imported ?: boolean ;
30- } ;
31-
3219export default function Dashboard ( ) {
3320 const turnkey = useTurnkey ( ) ;
3421 const { authState, logout, session, wallets } = turnkey ;
@@ -46,7 +33,7 @@ export default function Dashboard() {
4633 return < p className = "p-6" > Loading…</ p > ;
4734 }
4835
49- /** ---------- Embedded wallets (Turnkey-generated) ---------- */
36+ /** ---------- Embedded wallets ---------- */
5037
5138 const embeddedWallets = useMemo (
5239 ( ) =>
@@ -143,9 +130,9 @@ export default function Dashboard() {
143130 }
144131 } ;
145132
146- /** ---------- Private keys (imported) ---------- */
133+ /** ---------- Private keys ---------- */
147134
148- const [ privateKeys , setPrivateKeys ] = useState < PrivateKey [ ] > ( [ ] ) ;
135+ const [ privateKeys , setPrivateKeys ] = useState < v1PrivateKey [ ] > ( [ ] ) ;
149136 const [ selectedPrivateKeyId , setSelectedPrivateKeyId ] = useState <
150137 string | null
151138 > ( null ) ;
@@ -180,7 +167,7 @@ export default function Dashboard() {
180167 setPkError ( null ) ;
181168 try {
182169 const keys = ( await turnkey . fetchPrivateKeys ?.( ) ) as
183- | PrivateKey [ ]
170+ | v1PrivateKey [ ]
184171 | undefined ;
185172 if ( ! cancelled && keys ) {
186173 setPrivateKeys ( keys ) ;
@@ -206,11 +193,11 @@ export default function Dashboard() {
206193 } ;
207194 } , [ authState , turnkey ] ) ;
208195
209- const isSolanaPrivateKey = ( pk : PrivateKey ) : boolean => {
196+ const isSolanaPrivateKey = ( pk : v1PrivateKey ) : boolean => {
210197 const addrs = pk . addresses ?? [ ] ;
211198 return addrs . some (
212199 ( a ) =>
213- a . format === "ADDRESS_FORMAT_SOLANA" || a . format . includes ( "SOLANA" ) ,
200+ a . format === "ADDRESS_FORMAT_SOLANA" || a . format ? .includes ( "SOLANA" ) ,
214201 ) ;
215202 } ;
216203
@@ -255,14 +242,16 @@ export default function Dashboard() {
255242 const addressFormats = rawFormats as v1AddressFormat [ ] ;
256243 const curve = pkCurve as v1Curve ;
257244
258- const newPrivateKeyId = await turnkey . handleImportPrivateKey ( {
245+ const params : HandleImportPrivateKeyParams = {
259246 curve,
260247 addressFormats,
261248 successPageDuration : 4000 ,
262- } as any ) ;
249+ } ;
250+
251+ const newPrivateKeyId = await turnkey . handleImportPrivateKey ( params ) ;
263252
264253 const keys = ( await turnkey . fetchPrivateKeys ?.( ) ) as
265- | PrivateKey [ ]
254+ | v1PrivateKey [ ]
266255 | undefined ;
267256 if ( keys ) {
268257 setPrivateKeys ( keys ) ;
0 commit comments