@@ -27,7 +27,7 @@ import {
27
27
getUserOperationHash ,
28
28
toSmartAccount
29
29
} from "viem/account-abstraction"
30
- import { signMessage as _signMessage , getChainId } from "viem/actions"
30
+ import { getChainId } from "viem/actions"
31
31
import { getAction } from "viem/utils"
32
32
import { getAccountNonce } from "../../actions/public/getAccountNonce.js"
33
33
import { getSenderAddress } from "../../actions/public/getSenderAddress.js"
@@ -44,6 +44,7 @@ import {
44
44
VALIDATOR_TYPE
45
45
} from "./constants.js"
46
46
import { encodeCallData } from "./utils/encodeCallData.js"
47
+ import { getActualKernelVersion } from "./utils/getActualKernelVersion.js"
47
48
import { getNonceKeyWithEncoding } from "./utils/getNonceKey.js"
48
49
import { isKernelV2 } from "./utils/isKernelV2.js"
49
50
import { signMessage } from "./utils/signMessage.js"
@@ -479,15 +480,22 @@ export async function toEcdsaKernelSmartAccount<
479
480
return this . signMessage ( { message : hash } )
480
481
} ,
481
482
async signMessage ( { message } ) {
483
+ const accountAddress = await this . getAddress ( )
484
+ const actualKernelVersion = await getActualKernelVersion (
485
+ client ,
486
+ accountAddress ,
487
+ kernelVersion
488
+ )
489
+
482
490
const signature = await signMessage ( {
483
491
owner : localOwner ,
484
492
message,
485
493
accountAddress : await this . getAddress ( ) ,
486
- kernelVersion,
494
+ kernelVersion : actualKernelVersion ,
487
495
chainId : await getMemoizedChainId ( )
488
496
} )
489
497
490
- if ( isKernelV2 ( kernelVersion ) ) {
498
+ if ( isKernelV2 ( actualKernelVersion ) ) {
491
499
return signature
492
500
}
493
501
@@ -497,15 +505,22 @@ export async function toEcdsaKernelSmartAccount<
497
505
] )
498
506
} ,
499
507
async signTypedData ( typedData ) {
508
+ const accountAddress = await this . getAddress ( )
509
+ const actualKernelVersion = await getActualKernelVersion (
510
+ client ,
511
+ accountAddress ,
512
+ kernelVersion
513
+ )
514
+
500
515
const signature = await signTypedData ( {
501
516
owner : localOwner ,
502
517
chainId : await getMemoizedChainId ( ) ,
503
518
...( typedData as TypedDataDefinition ) ,
504
519
accountAddress : await this . getAddress ( ) ,
505
- kernelVersion
520
+ kernelVersion : actualKernelVersion
506
521
} )
507
522
508
- if ( isKernelV2 ( kernelVersion ) ) {
523
+ if ( isKernelV2 ( actualKernelVersion ) ) {
509
524
return signature
510
525
}
511
526
0 commit comments