@@ -933,7 +933,7 @@ export class LazorkitClient {
933933 timestamp : BN ;
934934 } ) : Promise < Buffer > {
935935 let message : Buffer ;
936- const { action, smartWallet, passkeyPublicKey, timestamp } = params ;
936+ const { action, smartWallet, passkeyPublicKey, credentialHash , timestamp } = params ;
937937
938938 switch ( action . type ) {
939939 case types . SmartWalletAction . Execute : {
@@ -972,15 +972,37 @@ export class LazorkitClient {
972972 action . args as types . ArgsByAction [ types . SmartWalletAction . CreateChunk ] ;
973973
974974 const smartWalletConfig = await this . getWalletStateData ( smartWallet ) ;
975-
976- message = buildCreateChunkMessage (
977- smartWallet ,
978- smartWalletConfig . lastNonce ,
979- timestamp ,
980- policyInstruction ,
981- cpiInstructions ,
982- [ ...( cpiSigners ?? [ ] ) , params . payer ]
983- ) ;
975+ if ( ! policyInstruction ) {
976+ const policySigner = this . getWalletDevicePubkey (
977+ smartWallet ,
978+ credentialHash
979+ )
980+ const defaultPolicyInstruction = await this . defaultPolicyProgram . buildCheckPolicyIx ( {
981+ walletId : smartWalletConfig . walletId ,
982+ passkeyPublicKey : passkeyPublicKey ,
983+ policySigner,
984+ smartWallet,
985+ credentialHash : credentialHash ,
986+ policyData : smartWalletConfig . policyData ,
987+ } ) ;
988+ message = buildCreateChunkMessage (
989+ smartWallet ,
990+ smartWalletConfig . lastNonce ,
991+ timestamp ,
992+ defaultPolicyInstruction ,
993+ cpiInstructions ,
994+ [ ...( cpiSigners ?? [ ] ) , params . payer ]
995+ ) ;
996+ } else {
997+ message = buildCreateChunkMessage (
998+ smartWallet ,
999+ smartWalletConfig . lastNonce ,
1000+ timestamp ,
1001+ policyInstruction ,
1002+ cpiInstructions ,
1003+ [ ...( cpiSigners ?? [ ] ) , params . payer ]
1004+ ) ;
1005+ }
9841006 break ;
9851007 }
9861008 default :
0 commit comments