@@ -224,9 +224,13 @@ const getDefaultAddresses = ({
224224}
225225
226226export const getEcdsaRootIdentifierForKernelV3 = (
227- validatorAddress : Address
227+ validatorAddress : Address ,
228+ eip7702 = false
228229) => {
229- return concatHex ( [ VALIDATOR_TYPE . VALIDATOR , validatorAddress ] )
230+ return concatHex ( [
231+ eip7702 ? VALIDATOR_TYPE . EIP7702 : VALIDATOR_TYPE . VALIDATOR ,
232+ eip7702 ? "0x" : validatorAddress
233+ ] )
230234}
231235
232236/**
@@ -723,46 +727,60 @@ export async function toKernelSmartAccount<
723727 return this . signMessage ( { message : hash } )
724728 } ,
725729 async signMessage ( { message } ) {
726- if ( eip7702 ) {
727- throw new Error ( "Kernel with EIP-7702 isn't 1271 compliant" )
730+ if (
731+ "isDeployed" in this &&
732+ ! ( await ( this as any ) . isDeployed ( ) ) &&
733+ eip7702
734+ ) {
735+ throw new Error (
736+ "Kernel with EIP-7702 isn't 1271 compliant before delegation."
737+ )
728738 }
729739
730740 const signature = await signMessage ( {
731741 owner,
732742 message,
733743 accountAddress : await this . getAddress ( ) ,
734744 kernelVersion : kernelVersion ,
735- chainId : await getMemoizedChainId ( )
745+ chainId : await getMemoizedChainId ( ) ,
746+ eip7702 : eip7702
736747 } )
737748
738749 if ( isKernelV2 ( kernelVersion ) ) {
739750 return signature
740751 }
741752
742753 return concatHex ( [
743- getEcdsaRootIdentifierForKernelV3 ( validatorAddress ) ,
754+ getEcdsaRootIdentifierForKernelV3 ( validatorAddress , eip7702 ) ,
744755 signature
745756 ] )
746757 } ,
747758 async signTypedData ( typedData ) {
748- if ( eip7702 ) {
749- throw new Error ( "Kernel with EIP-7702 isn't 1271 compliant" )
759+ if (
760+ "isDeployed" in this &&
761+ ! ( await ( this as any ) . isDeployed ( ) ) &&
762+ eip7702
763+ ) {
764+ throw new Error (
765+ "Kernel with EIP-7702 isn't 1271 compliant before delegation."
766+ )
750767 }
751768
752769 const signature = await signTypedData ( {
753770 owner : owner ,
754771 chainId : await getMemoizedChainId ( ) ,
755772 ...( typedData as TypedDataDefinition ) ,
756773 accountAddress : await this . getAddress ( ) ,
757- kernelVersion : kernelVersion
774+ kernelVersion : kernelVersion ,
775+ eip7702
758776 } )
759777
760778 if ( isKernelV2 ( kernelVersion ) ) {
761779 return signature
762780 }
763781
764782 return concatHex ( [
765- getEcdsaRootIdentifierForKernelV3 ( validatorAddress ) ,
783+ getEcdsaRootIdentifierForKernelV3 ( validatorAddress , eip7702 ) ,
766784 signature
767785 ] )
768786 } ,
@@ -788,7 +806,8 @@ export async function toKernelSmartAccount<
788806 message : { raw : hash } ,
789807 chainId,
790808 accountAddress : await this . getAddress ( ) ,
791- kernelVersion
809+ kernelVersion,
810+ eip7702 : false
792811 } )
793812 : await owner . signMessage ( {
794813 message : { raw : hash }
0 commit comments