@@ -454,27 +454,27 @@ export const registerWrappedKeysExecuteJsTests = () => {
454454
455455 throw error ;
456456 }
457+ } ) ;
457458 } ) ;
458- } ) ;
459459
460- describe ( 'Solana network' , ( ) => {
461- test ( 'generatePrivateKey creates a new Solana wrapped key' , async ( ) => {
460+ describe ( 'Solana network' , ( ) => {
461+ test ( 'generatePrivateKey creates a new Solana wrapped key' , async ( ) => {
462462 const pkpSessionSigs = await createPkpSessionSigs ( ) ;
463463
464- const { pkpAddress, generatedPublicKey, id } =
465- await wrappedKeysApi . generatePrivateKey ( {
466- pkpSessionSigs,
467- network : SOLANA_NETWORK ,
468- litClient : ctx . litClient ,
469- memo : randomMemo ( 'sol-generate' ) ,
470- } ) ;
464+ const { pkpAddress, generatedPublicKey, id } =
465+ await wrappedKeysApi . generatePrivateKey ( {
466+ pkpSessionSigs,
467+ network : SOLANA_NETWORK ,
468+ litClient : ctx . litClient ,
469+ memo : randomMemo ( 'sol-generate' ) ,
470+ } ) ;
471471
472- expect ( pkpAddress ) . toBe ( ctx . aliceViemAccountPkp . ethAddress ) ;
473- expect ( ( ) => assertIsAddress ( generatedPublicKey ) ) . not . toThrow ( ) ;
474- expect ( id ) . toEqual ( expect . any ( String ) ) ;
475- } ) ;
472+ expect ( pkpAddress ) . toBe ( ctx . aliceViemAccountPkp . ethAddress ) ;
473+ expect ( ( ) => assertIsAddress ( generatedPublicKey ) ) . not . toThrow ( ) ;
474+ expect ( id ) . toEqual ( expect . any ( String ) ) ;
475+ } ) ;
476476
477- test ( 'exportPrivateKey decrypts a stored Solana wrapped key' , async ( ) => {
477+ test ( 'exportPrivateKey decrypts a stored Solana wrapped key' , async ( ) => {
478478 const { id, publicKey } = await generateSolanaWrappedKeyForTest (
479479 randomMemo ( 'sol-export' )
480480 ) ;
@@ -504,99 +504,101 @@ export const registerWrappedKeysExecuteJsTests = () => {
504504 exportedPublicKey
505505 ) ;
506506
507- expect ( derivedPublicKey ) . toBe ( publicKey ) ;
508- } ) ;
507+ expect ( derivedPublicKey ) . toBe ( publicKey ) ;
508+ } ) ;
509+
510+ test ( 'listEncryptedKeyMetadata returns metadata for Solana keys' , async ( ) => {
511+ const memo = randomMemo ( 'sol-list' ) ;
512+ const { id } = await generateSolanaWrappedKeyForTest ( memo ) ;
513+ const pkpSessionSigs = await createPkpSessionSigs ( ) ;
509514
510- test ( 'listEncryptedKeyMetadata returns metadata for Solana keys' , async ( ) => {
511- const memo = randomMemo ( 'sol-list' ) ;
512- const { id } = await generateSolanaWrappedKeyForTest ( memo ) ;
513- const pkpSessionSigs = await createPkpSessionSigs ( ) ;
515+ const metadata = await wrappedKeysApi . listEncryptedKeyMetadata ( {
516+ pkpSessionSigs ,
517+ litClient : ctx . litClient ,
518+ } ) ;
514519
515- const metadata = await wrappedKeysApi . listEncryptedKeyMetadata ( {
516- pkpSessionSigs ,
517- litClient : ctx . litClient ,
520+ const entry = metadata . find ( ( item ) => item . id === id ) ;
521+ expect ( entry ) . toBeDefined ( ) ;
522+ expect ( entry ?. memo ) . toBe ( memo ) ;
518523 } ) ;
519524
520- const entry = metadata . find ( ( item ) => item . id === id ) ;
521- expect ( entry ) . toBeDefined ( ) ;
522- expect ( entry ?. memo ) . toBe ( memo ) ;
523- } ) ;
525+ test ( 'getEncryptedKey fetches ciphertext for a Solana key' , async ( ) => {
526+ const { id } = await generateSolanaWrappedKeyForTest (
527+ randomMemo ( 'sol-get' )
528+ ) ;
529+ const pkpSessionSigs = await createPkpSessionSigs ( ) ;
524530
525- test ( 'getEncryptedKey fetches ciphertext for a Solana key' , async ( ) => {
526- const { id } = await generateSolanaWrappedKeyForTest ( randomMemo ( 'sol-get' ) ) ;
527- const pkpSessionSigs = await createPkpSessionSigs ( ) ;
531+ const storedKey = await wrappedKeysApi . getEncryptedKey ( {
532+ pkpSessionSigs,
533+ litClient : ctx . litClient ,
534+ id,
535+ } ) ;
528536
529- const storedKey = await wrappedKeysApi . getEncryptedKey ( {
530- pkpSessionSigs ,
531- litClient : ctx . litClient ,
532- id ,
537+ expect ( storedKey . id ) . toBe ( id ) ;
538+ expect ( storedKey . ciphertext ) . toBeTruthy ( ) ;
539+ expect ( storedKey . dataToEncryptHash ) . toBeTruthy ( ) ;
540+ expect ( storedKey . keyType ) . toBe ( 'ed25519' ) ;
533541 } ) ;
534542
535- expect ( storedKey . id ) . toBe ( id ) ;
536- expect ( storedKey . ciphertext ) . toBeTruthy ( ) ;
537- expect ( storedKey . dataToEncryptHash ) . toBeTruthy ( ) ;
538- expect ( storedKey . keyType ) . toBe ( 'ed25519' ) ;
539- } ) ;
543+ test ( 'storeEncryptedKey persists provided Solana ciphertext' , async ( ) => {
544+ const pkpSessionSigs = await createPkpSessionSigs ( ) ;
545+ const payload = createSolanaStorePayload ( ) ;
540546
541- test ( 'storeEncryptedKey persists provided Solana ciphertext' , async ( ) => {
542- const pkpSessionSigs = await createPkpSessionSigs ( ) ;
543- const payload = createSolanaStorePayload ( ) ;
547+ const result = await wrappedKeysApi . storeEncryptedKey ( {
548+ pkpSessionSigs,
549+ litClient : ctx . litClient ,
550+ ...payload ,
551+ } ) ;
544552
545- const result = await wrappedKeysApi . storeEncryptedKey ( {
546- pkpSessionSigs,
547- litClient : ctx . litClient ,
548- ...payload ,
553+ expect ( result . pkpAddress ) . toBe ( ctx . aliceViemAccountPkp . ethAddress ) ;
554+ expect ( result . id ) . toEqual ( expect . any ( String ) ) ;
549555 } ) ;
550556
551- expect ( result . pkpAddress ) . toBe ( ctx . aliceViemAccountPkp . ethAddress ) ;
552- expect ( result . id ) . toEqual ( expect . any ( String ) ) ;
553- } ) ;
557+ test ( 'storeEncryptedKeyBatch persists multiple Solana ciphertexts' , async ( ) => {
558+ const pkpSessionSigs = await createPkpSessionSigs ( ) ;
559+ const keyBatch = [
560+ createSolanaStorePayload ( ) ,
561+ createSolanaStorePayload ( ) ,
562+ ] ;
554563
555- test ( 'storeEncryptedKeyBatch persists multiple Solana ciphertexts' , async ( ) => {
556- const pkpSessionSigs = await createPkpSessionSigs ( ) ;
557- const keyBatch = [
558- createSolanaStorePayload ( ) ,
559- createSolanaStorePayload ( ) ,
560- ] ;
561-
562- const result = await wrappedKeysApi . storeEncryptedKeyBatch ( {
563- pkpSessionSigs ,
564- litClient : ctx . litClient ,
565- keyBatch ,
564+ const result = await wrappedKeysApi . storeEncryptedKeyBatch ( {
565+ pkpSessionSigs ,
566+ litClient : ctx . litClient ,
567+ keyBatch ,
568+ } ) ;
569+
570+ expect ( result . pkpAddress ) . toBe ( ctx . aliceViemAccountPkp . ethAddress ) ;
571+ expect ( result . ids . length ) . toBe ( keyBatch . length ) ;
572+ for ( const id of result . ids ) {
573+ expect ( id ) . toEqual ( expect . any ( String ) ) ;
574+ }
566575 } ) ;
567576
568- expect ( result . pkpAddress ) . toBe ( ctx . aliceViemAccountPkp . ethAddress ) ;
569- expect ( result . ids . length ) . toBe ( keyBatch . length ) ;
570- for ( const id of result . ids ) {
571- expect ( id ) . toEqual ( expect . any ( String ) ) ;
572- }
573- } ) ;
577+ test ( 'importPrivateKey persists a Solana wrapped key' , async ( ) => {
578+ const pkpSessionSigs = await createPkpSessionSigs ( ) ;
579+ const keyPair = nacl . sign . keyPair ( ) ;
580+ const secretKeyBytes = keyPair . secretKey ;
581+ const publicKey = bs58 . encode ( keyPair . publicKey ) ;
582+ const privateKeyHex = Buffer . from ( secretKeyBytes ) . toString ( 'hex' ) ;
574583
575- test ( 'importPrivateKey persists a Solana wrapped key' , async ( ) => {
576- const pkpSessionSigs = await createPkpSessionSigs ( ) ;
577- const keyPair = nacl . sign . keyPair ( ) ;
578- const secretKeyBytes = keyPair . secretKey ;
579- const publicKey = bs58 . encode ( keyPair . publicKey ) ;
580- const privateKeyHex = Buffer . from ( secretKeyBytes ) . toString ( 'hex' ) ;
581-
582- const memo = randomMemo ( 'sol-import' ) ;
583- const result = await wrappedKeysApi . importPrivateKey ( {
584- pkpSessionSigs,
585- litClient : ctx . litClient ,
586- privateKey : privateKeyHex ,
587- publicKey,
588- keyType : 'ed25519' ,
589- memo,
590- } ) ;
584+ const memo = randomMemo ( 'sol-import' ) ;
585+ const result = await wrappedKeysApi . importPrivateKey ( {
586+ pkpSessionSigs,
587+ litClient : ctx . litClient ,
588+ privateKey : privateKeyHex ,
589+ publicKey,
590+ keyType : 'ed25519' ,
591+ memo,
592+ } ) ;
591593
592- expect ( result . pkpAddress ) . toBe ( ctx . aliceViemAccountPkp . ethAddress ) ;
593- expect ( result . id ) . toEqual ( expect . any ( String ) ) ;
594- } ) ;
594+ expect ( result . pkpAddress ) . toBe ( ctx . aliceViemAccountPkp . ethAddress ) ;
595+ expect ( result . id ) . toEqual ( expect . any ( String ) ) ;
596+ } ) ;
595597
596- test ( 'signMessageWithEncryptedKey signs messages with Solana keys' , async ( ) => {
597- const { id, publicKey } = await generateSolanaWrappedKeyForTest (
598- randomMemo ( 'sol-sign-message' )
599- ) ;
598+ test ( 'signMessageWithEncryptedKey signs messages with Solana keys' , async ( ) => {
599+ const { id, publicKey } = await generateSolanaWrappedKeyForTest (
600+ randomMemo ( 'sol-sign-message' )
601+ ) ;
600602 const pkpSessionSigs = await createPkpSessionSigs ( ) ;
601603 const message = 'hello from solana wrapped-keys' ;
602604
0 commit comments