permissionless 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js +21 -9
  3. package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
  4. package/_cjs/accounts/index.js +3 -1
  5. package/_cjs/accounts/index.js.map +1 -1
  6. package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js +4 -7
  7. package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -1
  8. package/_cjs/accounts/safe/signerToSafeSmartAccount.js +4 -7
  9. package/_cjs/accounts/safe/signerToSafeSmartAccount.js.map +1 -1
  10. package/_cjs/accounts/simple/signerToSimpleSmartAccount.js +11 -16
  11. package/_cjs/accounts/simple/signerToSimpleSmartAccount.js.map +1 -1
  12. package/_cjs/accounts/toSmartAccount.js +84 -0
  13. package/_cjs/accounts/toSmartAccount.js.map +1 -0
  14. package/_cjs/actions/smartAccount/prepareUserOperationRequest.js +2 -6
  15. package/_cjs/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
  16. package/_cjs/clients/decorators/pimlico.js +5 -2
  17. package/_cjs/clients/decorators/pimlico.js.map +1 -1
  18. package/_cjs/clients/pimlico.js +1 -1
  19. package/_cjs/clients/pimlico.js.map +1 -1
  20. package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js +21 -10
  21. package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
  22. package/_esm/accounts/index.js +2 -1
  23. package/_esm/accounts/index.js.map +1 -1
  24. package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js +4 -8
  25. package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -1
  26. package/_esm/accounts/safe/signerToSafeSmartAccount.js +4 -7
  27. package/_esm/accounts/safe/signerToSafeSmartAccount.js.map +1 -1
  28. package/_esm/accounts/simple/signerToSimpleSmartAccount.js +12 -17
  29. package/_esm/accounts/simple/signerToSimpleSmartAccount.js.map +1 -1
  30. package/_esm/accounts/toSmartAccount.js +80 -0
  31. package/_esm/accounts/toSmartAccount.js.map +1 -0
  32. package/_esm/actions/pimlico/sendCompressedUserOperation.js +1 -1
  33. package/_esm/actions/smartAccount/prepareUserOperationRequest.js +2 -6
  34. package/_esm/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
  35. package/_esm/clients/decorators/pimlico.js +5 -2
  36. package/_esm/clients/decorators/pimlico.js.map +1 -1
  37. package/_esm/clients/pimlico.js +1 -1
  38. package/_esm/clients/pimlico.js.map +1 -1
  39. package/_types/accounts/biconomy/signerToBiconomySmartAccount.d.ts +2 -2
  40. package/_types/accounts/biconomy/signerToBiconomySmartAccount.d.ts.map +1 -1
  41. package/_types/accounts/index.d.ts +2 -1
  42. package/_types/accounts/index.d.ts.map +1 -1
  43. package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts +2 -2
  44. package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts.map +1 -1
  45. package/_types/accounts/safe/signerToSafeSmartAccount.d.ts +2 -2
  46. package/_types/accounts/safe/signerToSafeSmartAccount.d.ts.map +1 -1
  47. package/_types/accounts/simple/signerToSimpleSmartAccount.d.ts +2 -2
  48. package/_types/accounts/simple/signerToSimpleSmartAccount.d.ts.map +1 -1
  49. package/_types/accounts/toSmartAccount.d.ts +26 -0
  50. package/_types/accounts/toSmartAccount.d.ts.map +1 -0
  51. package/_types/accounts/types.d.ts +1 -1
  52. package/_types/accounts/types.d.ts.map +1 -1
  53. package/_types/actions/bundler/estimateUserOperationGas.d.ts +2 -2
  54. package/_types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
  55. package/_types/actions/pimlico/sendCompressedUserOperation.d.ts +1 -1
  56. package/_types/actions/pimlico/sponsorUserOperation.d.ts +6 -6
  57. package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts.map +1 -1
  58. package/_types/clients/decorators/pimlico.d.ts +3 -3
  59. package/_types/clients/decorators/pimlico.d.ts.map +1 -1
  60. package/_types/types/bundler.d.ts +3 -3
  61. package/_types/types/bundler.d.ts.map +1 -1
  62. package/_types/types/userOperation.d.ts +6 -6
  63. package/_types/types/userOperation.d.ts.map +1 -1
  64. package/accounts/biconomy/signerToBiconomySmartAccount.ts +36 -18
  65. package/accounts/index.ts +3 -0
  66. package/accounts/kernel/signerToEcdsaKernelSmartAccount.ts +6 -11
  67. package/accounts/safe/signerToSafeSmartAccount.ts +218 -209
  68. package/accounts/simple/signerToSimpleSmartAccount.ts +14 -30
  69. package/accounts/toSmartAccount.ts +167 -0
  70. package/accounts/types.ts +2 -2
  71. package/actions/bundler/estimateUserOperationGas.ts +4 -4
  72. package/actions/pimlico/sendCompressedUserOperation.ts +1 -1
  73. package/actions/smartAccount/prepareUserOperationRequest.ts +2 -6
  74. package/clients/decorators/pimlico.ts +35 -21
  75. package/clients/pimlico.ts +1 -1
  76. package/package.json +1 -1
  77. package/types/bundler.ts +3 -3
  78. package/types/userOperation.ts +6 -6
@@ -20,7 +20,6 @@ import {
20
20
  toBytes,
21
21
  zeroAddress
22
22
  } from "viem"
23
- import { toAccount } from "viem/accounts"
24
23
  import {
25
24
  getChainId,
26
25
  readContract,
@@ -32,6 +31,7 @@ import type { ENTRYPOINT_ADDRESS_V06_TYPE, Prettify } from "../../types"
32
31
  import type { EntryPoint } from "../../types/entrypoint"
33
32
  import { getEntryPointVersion } from "../../utils"
34
33
  import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed"
34
+ import { toSmartAccount } from "../toSmartAccount"
35
35
  import {
36
36
  SignTransactionNotSupportedBySmartAccount,
37
37
  type SmartAccount,
@@ -493,7 +493,7 @@ const getDefaultAddresses = (
493
493
 
494
494
  export type SignerToSafeSmartAccountParameters<
495
495
  entryPoint extends EntryPoint,
496
- TSource extends string = "custom",
496
+ TSource extends string = string,
497
497
  TAddress extends Address = Address
498
498
  > = Prettify<{
499
499
  signer: SmartAccountSigner<TSource, TAddress>
@@ -526,7 +526,7 @@ export async function signerToSafeSmartAccount<
526
526
  entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
527
527
  TTransport extends Transport = Transport,
528
528
  TChain extends Chain | undefined = Chain | undefined,
529
- TSource extends string = "custom",
529
+ TSource extends string = string,
530
530
  TAddress extends Address = Address
531
531
  >(
532
532
  client: Client<TTransport, TChain>,
@@ -598,46 +598,11 @@ export async function signerToSafeSmartAccount<
598
598
 
599
599
  let safeDeployed = await isSmartAccountDeployed(client, accountAddress)
600
600
 
601
- const account = toAccount({
602
- address: accountAddress,
603
- async signMessage({ message }) {
604
- const messageHash = hashTypedData({
605
- domain: {
606
- chainId: chainId,
607
- verifyingContract: accountAddress
608
- },
609
- types: {
610
- SafeMessage: [{ name: "message", type: "bytes" }]
611
- },
612
- primaryType: "SafeMessage",
613
- message: {
614
- message: generateSafeMessageMessage(message)
615
- }
616
- })
617
-
618
- return adjustVInSignature(
619
- "eth_sign",
620
- await signMessage(client, {
621
- account: viemSigner,
622
- message: {
623
- raw: toBytes(messageHash)
624
- }
625
- })
626
- )
627
- },
628
- async signTransaction(_, __) {
629
- throw new SignTransactionNotSupportedBySmartAccount()
630
- },
631
- async signTypedData<
632
- const TTypedData extends TypedData | Record<string, unknown>,
633
- TPrimaryType extends
634
- | keyof TTypedData
635
- | "EIP712Domain" = keyof TTypedData
636
- >(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) {
637
- return adjustVInSignature(
638
- "eth_signTypedData",
639
- await signTypedData(client, {
640
- account: viemSigner,
601
+ const safeSmartAccount: SafeSmartAccount<entryPoint, TTransport, TChain> =
602
+ toSmartAccount({
603
+ address: accountAddress,
604
+ async signMessage({ message }) {
605
+ const messageHash = hashTypedData({
641
606
  domain: {
642
607
  chainId: chainId,
643
608
  verifyingContract: accountAddress
@@ -647,195 +612,239 @@ export async function signerToSafeSmartAccount<
647
612
  },
648
613
  primaryType: "SafeMessage",
649
614
  message: {
650
- message: generateSafeMessageMessage<
651
- TTypedData,
652
- TPrimaryType
653
- >(typedData)
615
+ message: generateSafeMessageMessage(message)
654
616
  }
655
617
  })
656
- )
657
- }
658
- })
659
618
 
660
- const safeSmartAccount: SafeSmartAccount<entryPoint, TTransport, TChain> = {
661
- ...account,
662
- client: client,
663
- publicKey: accountAddress,
664
- entryPoint: entryPointAddress,
665
- source: "SafeSmartAccount",
666
- async getNonce() {
667
- return getAccountNonce(client, {
668
- sender: accountAddress,
669
- entryPoint: entryPointAddress
670
- })
671
- },
672
- async signUserOperation(userOperation) {
673
- const signatures = [
674
- {
675
- signer: viemSigner.address,
676
- data: await signTypedData(client, {
619
+ return adjustVInSignature(
620
+ "eth_sign",
621
+ await signMessage(client, {
622
+ account: viemSigner,
623
+ message: {
624
+ raw: toBytes(messageHash)
625
+ }
626
+ })
627
+ )
628
+ },
629
+ async signTransaction(_, __) {
630
+ throw new SignTransactionNotSupportedBySmartAccount()
631
+ },
632
+ async signTypedData<
633
+ const TTypedData extends TypedData | Record<string, unknown>,
634
+ TPrimaryType extends
635
+ | keyof TTypedData
636
+ | "EIP712Domain" = keyof TTypedData
637
+ >(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) {
638
+ return adjustVInSignature(
639
+ "eth_signTypedData",
640
+ await signTypedData(client, {
677
641
  account: viemSigner,
678
642
  domain: {
679
643
  chainId: chainId,
680
- verifyingContract: safe4337ModuleAddress
644
+ verifyingContract: accountAddress
645
+ },
646
+ types: {
647
+ SafeMessage: [{ name: "message", type: "bytes" }]
681
648
  },
682
- types: EIP712_SAFE_OPERATION_TYPE,
683
- primaryType: "SafeOp",
649
+ primaryType: "SafeMessage",
684
650
  message: {
685
- safe: accountAddress,
686
- callData: userOperation.callData,
687
- entryPoint: entryPointAddress,
688
- nonce: userOperation.nonce,
689
- initCode: userOperation.initCode,
690
- maxFeePerGas: userOperation.maxFeePerGas,
691
- maxPriorityFeePerGas:
692
- userOperation.maxPriorityFeePerGas,
693
- preVerificationGas:
694
- userOperation.preVerificationGas,
695
- verificationGasLimit:
696
- userOperation.verificationGasLimit,
697
- callGasLimit: userOperation.callGasLimit,
698
- paymasterAndData: userOperation.paymasterAndData,
699
- validAfter: validAfter,
700
- validUntil: validUntil
651
+ message: generateSafeMessageMessage<
652
+ TTypedData,
653
+ TPrimaryType
654
+ >(typedData)
701
655
  }
702
656
  })
703
- }
704
- ]
657
+ )
658
+ },
659
+ client: client,
660
+ publicKey: accountAddress,
661
+ entryPoint: entryPointAddress,
662
+ source: "SafeSmartAccount",
663
+ async getNonce() {
664
+ return getAccountNonce(client, {
665
+ sender: accountAddress,
666
+ entryPoint: entryPointAddress
667
+ })
668
+ },
669
+ async signUserOperation(userOperation) {
670
+ const signatures = [
671
+ {
672
+ signer: viemSigner.address,
673
+ data: await signTypedData(client, {
674
+ account: viemSigner,
675
+ domain: {
676
+ chainId: chainId,
677
+ verifyingContract: safe4337ModuleAddress
678
+ },
679
+ types: EIP712_SAFE_OPERATION_TYPE,
680
+ primaryType: "SafeOp",
681
+ message: {
682
+ safe: accountAddress,
683
+ callData: userOperation.callData,
684
+ entryPoint: entryPointAddress,
685
+ nonce: userOperation.nonce,
686
+ initCode: userOperation.initCode,
687
+ maxFeePerGas: userOperation.maxFeePerGas,
688
+ maxPriorityFeePerGas:
689
+ userOperation.maxPriorityFeePerGas,
690
+ preVerificationGas:
691
+ userOperation.preVerificationGas,
692
+ verificationGasLimit:
693
+ userOperation.verificationGasLimit,
694
+ callGasLimit: userOperation.callGasLimit,
695
+ paymasterAndData:
696
+ userOperation.paymasterAndData,
697
+ validAfter: validAfter,
698
+ validUntil: validUntil
699
+ }
700
+ })
701
+ }
702
+ ]
705
703
 
706
- signatures.sort((left, right) =>
707
- left.signer
708
- .toLowerCase()
709
- .localeCompare(right.signer.toLowerCase())
710
- )
704
+ signatures.sort((left, right) =>
705
+ left.signer
706
+ .toLowerCase()
707
+ .localeCompare(right.signer.toLowerCase())
708
+ )
711
709
 
712
- const signatureBytes = concat(signatures.map((sig) => sig.data))
710
+ const signatureBytes = concat(signatures.map((sig) => sig.data))
713
711
 
714
- return encodePacked(
715
- ["uint48", "uint48", "bytes"],
716
- [validAfter, validUntil, signatureBytes]
717
- )
718
- },
719
- async getInitCode() {
720
- if (safeDeployed) return "0x"
712
+ return encodePacked(
713
+ ["uint48", "uint48", "bytes"],
714
+ [validAfter, validUntil, signatureBytes]
715
+ )
716
+ },
717
+ async getInitCode() {
718
+ if (safeDeployed) return "0x"
721
719
 
722
- safeDeployed = await isSmartAccountDeployed(client, accountAddress)
720
+ safeDeployed = await isSmartAccountDeployed(
721
+ client,
722
+ accountAddress
723
+ )
723
724
 
724
- if (safeDeployed) return "0x"
725
+ if (safeDeployed) return "0x"
726
+
727
+ const initCodeCallData = await getAccountInitCode({
728
+ owner: viemSigner.address,
729
+ addModuleLibAddress,
730
+ safe4337ModuleAddress,
731
+ safeSingletonAddress,
732
+ multiSendAddress,
733
+ saltNonce,
734
+ setupTransactions,
735
+ safeModules
736
+ })
725
737
 
726
- const initCodeCallData = await getAccountInitCode({
727
- owner: viemSigner.address,
728
- addModuleLibAddress,
729
- safe4337ModuleAddress,
730
- safeSingletonAddress,
731
- multiSendAddress,
732
- saltNonce,
733
- setupTransactions,
734
- safeModules
735
- })
738
+ return concatHex([safeProxyFactoryAddress, initCodeCallData])
739
+ },
740
+ async getFactory() {
741
+ if (safeDeployed) return undefined
736
742
 
737
- return concatHex([safeProxyFactoryAddress, initCodeCallData])
738
- },
739
- async getFactory() {
740
- if (safeDeployed) return undefined
743
+ safeDeployed = await isSmartAccountDeployed(
744
+ client,
745
+ accountAddress
746
+ )
741
747
 
742
- safeDeployed = await isSmartAccountDeployed(client, accountAddress)
748
+ if (safeDeployed) return undefined
743
749
 
744
- if (safeDeployed) return undefined
750
+ return safeProxyFactoryAddress
751
+ },
752
+ async getFactoryData() {
753
+ if (safeDeployed) return undefined
745
754
 
746
- return safeProxyFactoryAddress
747
- },
748
- async getFactoryData() {
749
- if (safeDeployed) return undefined
750
-
751
- safeDeployed = await isSmartAccountDeployed(client, accountAddress)
752
-
753
- if (safeDeployed) return undefined
754
-
755
- return await getAccountInitCode({
756
- owner: viemSigner.address,
757
- addModuleLibAddress,
758
- safe4337ModuleAddress,
759
- safeSingletonAddress,
760
- multiSendAddress,
761
- saltNonce,
762
- setupTransactions,
763
- safeModules
764
- })
765
- },
766
- async encodeDeployCallData(_) {
767
- throw new Error("Safe account doesn't support account deployment")
768
- },
769
- async encodeCallData(args) {
770
- let to: Address
771
- let value: bigint
772
- let data: Hex
773
- let operationType = 0
774
-
775
- if (Array.isArray(args)) {
776
- const argsArray = args as {
777
- to: Address
778
- value: bigint
779
- data: Hex
780
- }[]
781
-
782
- to = multiSendCallOnlyAddress
783
- value = 0n
784
-
785
- data = encodeMultiSend(
786
- argsArray.map((tx) => ({ ...tx, operation: 0 }))
755
+ safeDeployed = await isSmartAccountDeployed(
756
+ client,
757
+ accountAddress
787
758
  )
788
- operationType = 1
789
- } else {
790
- const singleTransaction = args as {
791
- to: Address
792
- value: bigint
793
- data: Hex
794
- }
795
- to = singleTransaction.to
796
- data = singleTransaction.data
797
- value = singleTransaction.value
798
- }
799
759
 
800
- return encodeFunctionData({
801
- abi: [
802
- {
803
- inputs: [
804
- {
805
- internalType: "address",
806
- name: "to",
807
- type: "address"
808
- },
809
- {
810
- internalType: "uint256",
811
- name: "value",
812
- type: "uint256"
813
- },
814
- {
815
- internalType: "bytes",
816
- name: "data",
817
- type: "bytes"
818
- },
819
- {
820
- internalType: "uint8",
821
- name: "operation",
822
- type: "uint8"
823
- }
824
- ],
825
- name: "executeUserOpWithErrorString",
826
- outputs: [],
827
- stateMutability: "nonpayable",
828
- type: "function"
760
+ if (safeDeployed) return undefined
761
+
762
+ return await getAccountInitCode({
763
+ owner: viemSigner.address,
764
+ addModuleLibAddress,
765
+ safe4337ModuleAddress,
766
+ safeSingletonAddress,
767
+ multiSendAddress,
768
+ saltNonce,
769
+ setupTransactions,
770
+ safeModules
771
+ })
772
+ },
773
+ async encodeDeployCallData(_) {
774
+ throw new Error(
775
+ "Safe account doesn't support account deployment"
776
+ )
777
+ },
778
+ async encodeCallData(args) {
779
+ let to: Address
780
+ let value: bigint
781
+ let data: Hex
782
+ let operationType = 0
783
+
784
+ if (Array.isArray(args)) {
785
+ const argsArray = args as {
786
+ to: Address
787
+ value: bigint
788
+ data: Hex
789
+ }[]
790
+
791
+ to = multiSendCallOnlyAddress
792
+ value = 0n
793
+
794
+ data = encodeMultiSend(
795
+ argsArray.map((tx) => ({ ...tx, operation: 0 }))
796
+ )
797
+ operationType = 1
798
+ } else {
799
+ const singleTransaction = args as {
800
+ to: Address
801
+ value: bigint
802
+ data: Hex
829
803
  }
830
- ],
831
- functionName: "executeUserOpWithErrorString",
832
- args: [to, value, data, operationType]
833
- })
834
- },
835
- async getDummySignature(_userOperation) {
836
- return "0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
837
- }
838
- }
804
+ to = singleTransaction.to
805
+ data = singleTransaction.data
806
+ value = singleTransaction.value
807
+ }
808
+
809
+ return encodeFunctionData({
810
+ abi: [
811
+ {
812
+ inputs: [
813
+ {
814
+ internalType: "address",
815
+ name: "to",
816
+ type: "address"
817
+ },
818
+ {
819
+ internalType: "uint256",
820
+ name: "value",
821
+ type: "uint256"
822
+ },
823
+ {
824
+ internalType: "bytes",
825
+ name: "data",
826
+ type: "bytes"
827
+ },
828
+ {
829
+ internalType: "uint8",
830
+ name: "operation",
831
+ type: "uint8"
832
+ }
833
+ ],
834
+ name: "executeUserOpWithErrorString",
835
+ outputs: [],
836
+ stateMutability: "nonpayable",
837
+ type: "function"
838
+ }
839
+ ],
840
+ functionName: "executeUserOpWithErrorString",
841
+ args: [to, value, data, operationType]
842
+ })
843
+ },
844
+ async getDummySignature(_userOperation) {
845
+ return "0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
846
+ }
847
+ })
839
848
 
840
849
  return safeSmartAccount
841
850
  }
@@ -1,4 +1,3 @@
1
- import type { TypedData } from "viem"
2
1
  import {
3
2
  type Address,
4
3
  type Chain,
@@ -6,12 +5,10 @@ import {
6
5
  type Hex,
7
6
  type LocalAccount,
8
7
  type Transport,
9
- type TypedDataDefinition,
10
8
  concatHex,
11
9
  encodeFunctionData
12
10
  } from "viem"
13
- import { toAccount } from "viem/accounts"
14
- import { getChainId, signMessage, signTypedData } from "viem/actions"
11
+ import { getChainId, signMessage } from "viem/actions"
15
12
  import { getAccountNonce } from "../../actions/public/getAccountNonce"
16
13
  import { getSenderAddress } from "../../actions/public/getSenderAddress"
17
14
  import type {
@@ -23,6 +20,7 @@ import type { EntryPoint } from "../../types/entrypoint"
23
20
  import { getEntryPointVersion } from "../../utils"
24
21
  import { getUserOperationHash } from "../../utils/getUserOperationHash"
25
22
  import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed"
23
+ import { toSmartAccount } from "../toSmartAccount"
26
24
  import {
27
25
  SignTransactionNotSupportedBySmartAccount,
28
26
  type SmartAccount,
@@ -108,7 +106,7 @@ const getAccountAddress = async <
108
106
 
109
107
  export type SignerToSimpleSmartAccountParameters<
110
108
  entryPoint extends EntryPoint,
111
- TSource extends string = "custom",
109
+ TSource extends string = string,
112
110
  TAddress extends Address = Address
113
111
  > = Prettify<{
114
112
  signer: SmartAccountSigner<TSource, TAddress>
@@ -127,7 +125,7 @@ export async function signerToSimpleSmartAccount<
127
125
  entryPoint extends EntryPoint,
128
126
  TTransport extends Transport = Transport,
129
127
  TChain extends Chain | undefined = Chain | undefined,
130
- TSource extends string = "custom",
128
+ TSource extends string = string,
131
129
  TAddress extends Address = Address
132
130
  >(
133
131
  client: Client<TTransport, TChain, undefined>,
@@ -165,32 +163,17 @@ export async function signerToSimpleSmartAccount<
165
163
  accountAddress
166
164
  )
167
165
 
168
- const account = toAccount({
166
+ return toSmartAccount({
169
167
  address: accountAddress,
170
- async signMessage({ message }) {
171
- return signMessage(client, { account: viemSigner, message })
168
+ signMessage: async (_) => {
169
+ throw new Error("Simple account isn't 1271 compliant")
172
170
  },
173
- async signTransaction(_, __) {
171
+ signTransaction: (_, __) => {
174
172
  throw new SignTransactionNotSupportedBySmartAccount()
175
173
  },
176
- async signTypedData<
177
- const TTypedData extends TypedData | Record<string, unknown>,
178
- TPrimaryType extends
179
- | keyof TTypedData
180
- | "EIP712Domain" = keyof TTypedData
181
- >(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) {
182
- return signTypedData<TTypedData, TPrimaryType, TChain, undefined>(
183
- client,
184
- {
185
- account: viemSigner,
186
- ...typedData
187
- }
188
- )
189
- }
190
- })
191
-
192
- return {
193
- ...account,
174
+ signTypedData: async (_) => {
175
+ throw new Error("Simple account isn't 1271 compliant")
176
+ },
194
177
  client: client,
195
178
  publicKey: accountAddress,
196
179
  entryPoint: entryPointAddress,
@@ -202,7 +185,8 @@ export async function signerToSimpleSmartAccount<
202
185
  })
203
186
  },
204
187
  async signUserOperation(userOperation) {
205
- return account.signMessage({
188
+ return signMessage(client, {
189
+ account: viemSigner,
206
190
  message: {
207
191
  raw: getUserOperationHash({
208
192
  userOperation,
@@ -359,5 +343,5 @@ export async function signerToSimpleSmartAccount<
359
343
  async getDummySignature(_userOperation) {
360
344
  return "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
361
345
  }
362
- }
346
+ })
363
347
  }