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.
- package/CHANGELOG.md +15 -0
- package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js +21 -9
- package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
- package/_cjs/accounts/index.js +3 -1
- package/_cjs/accounts/index.js.map +1 -1
- package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js +4 -7
- package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -1
- package/_cjs/accounts/safe/signerToSafeSmartAccount.js +4 -7
- package/_cjs/accounts/safe/signerToSafeSmartAccount.js.map +1 -1
- package/_cjs/accounts/simple/signerToSimpleSmartAccount.js +11 -16
- package/_cjs/accounts/simple/signerToSimpleSmartAccount.js.map +1 -1
- package/_cjs/accounts/toSmartAccount.js +84 -0
- package/_cjs/accounts/toSmartAccount.js.map +1 -0
- package/_cjs/actions/smartAccount/prepareUserOperationRequest.js +2 -6
- package/_cjs/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
- package/_cjs/clients/decorators/pimlico.js +5 -2
- package/_cjs/clients/decorators/pimlico.js.map +1 -1
- package/_cjs/clients/pimlico.js +1 -1
- package/_cjs/clients/pimlico.js.map +1 -1
- package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js +21 -10
- package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
- package/_esm/accounts/index.js +2 -1
- package/_esm/accounts/index.js.map +1 -1
- package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js +4 -8
- package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -1
- package/_esm/accounts/safe/signerToSafeSmartAccount.js +4 -7
- package/_esm/accounts/safe/signerToSafeSmartAccount.js.map +1 -1
- package/_esm/accounts/simple/signerToSimpleSmartAccount.js +12 -17
- package/_esm/accounts/simple/signerToSimpleSmartAccount.js.map +1 -1
- package/_esm/accounts/toSmartAccount.js +80 -0
- package/_esm/accounts/toSmartAccount.js.map +1 -0
- package/_esm/actions/pimlico/sendCompressedUserOperation.js +1 -1
- package/_esm/actions/smartAccount/prepareUserOperationRequest.js +2 -6
- package/_esm/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
- package/_esm/clients/decorators/pimlico.js +5 -2
- package/_esm/clients/decorators/pimlico.js.map +1 -1
- package/_esm/clients/pimlico.js +1 -1
- package/_esm/clients/pimlico.js.map +1 -1
- package/_types/accounts/biconomy/signerToBiconomySmartAccount.d.ts +2 -2
- package/_types/accounts/biconomy/signerToBiconomySmartAccount.d.ts.map +1 -1
- package/_types/accounts/index.d.ts +2 -1
- package/_types/accounts/index.d.ts.map +1 -1
- package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts +2 -2
- package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts.map +1 -1
- package/_types/accounts/safe/signerToSafeSmartAccount.d.ts +2 -2
- package/_types/accounts/safe/signerToSafeSmartAccount.d.ts.map +1 -1
- package/_types/accounts/simple/signerToSimpleSmartAccount.d.ts +2 -2
- package/_types/accounts/simple/signerToSimpleSmartAccount.d.ts.map +1 -1
- package/_types/accounts/toSmartAccount.d.ts +26 -0
- package/_types/accounts/toSmartAccount.d.ts.map +1 -0
- package/_types/accounts/types.d.ts +1 -1
- package/_types/accounts/types.d.ts.map +1 -1
- package/_types/actions/bundler/estimateUserOperationGas.d.ts +2 -2
- package/_types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
- package/_types/actions/pimlico/sendCompressedUserOperation.d.ts +1 -1
- package/_types/actions/pimlico/sponsorUserOperation.d.ts +6 -6
- package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts.map +1 -1
- package/_types/clients/decorators/pimlico.d.ts +3 -3
- package/_types/clients/decorators/pimlico.d.ts.map +1 -1
- package/_types/types/bundler.d.ts +3 -3
- package/_types/types/bundler.d.ts.map +1 -1
- package/_types/types/userOperation.d.ts +6 -6
- package/_types/types/userOperation.d.ts.map +1 -1
- package/accounts/biconomy/signerToBiconomySmartAccount.ts +36 -18
- package/accounts/index.ts +3 -0
- package/accounts/kernel/signerToEcdsaKernelSmartAccount.ts +6 -11
- package/accounts/safe/signerToSafeSmartAccount.ts +218 -209
- package/accounts/simple/signerToSimpleSmartAccount.ts +14 -30
- package/accounts/toSmartAccount.ts +167 -0
- package/accounts/types.ts +2 -2
- package/actions/bundler/estimateUserOperationGas.ts +4 -4
- package/actions/pimlico/sendCompressedUserOperation.ts +1 -1
- package/actions/smartAccount/prepareUserOperationRequest.ts +2 -6
- package/clients/decorators/pimlico.ts +35 -21
- package/clients/pimlico.ts +1 -1
- package/package.json +1 -1
- package/types/bundler.ts +3 -3
- 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 =
|
|
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 =
|
|
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
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
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
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
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:
|
|
644
|
+
verifyingContract: accountAddress
|
|
645
|
+
},
|
|
646
|
+
types: {
|
|
647
|
+
SafeMessage: [{ name: "message", type: "bytes" }]
|
|
681
648
|
},
|
|
682
|
-
|
|
683
|
-
primaryType: "SafeOp",
|
|
649
|
+
primaryType: "SafeMessage",
|
|
684
650
|
message: {
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
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
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
704
|
+
signatures.sort((left, right) =>
|
|
705
|
+
left.signer
|
|
706
|
+
.toLowerCase()
|
|
707
|
+
.localeCompare(right.signer.toLowerCase())
|
|
708
|
+
)
|
|
711
709
|
|
|
712
|
-
|
|
710
|
+
const signatureBytes = concat(signatures.map((sig) => sig.data))
|
|
713
711
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
712
|
+
return encodePacked(
|
|
713
|
+
["uint48", "uint48", "bytes"],
|
|
714
|
+
[validAfter, validUntil, signatureBytes]
|
|
715
|
+
)
|
|
716
|
+
},
|
|
717
|
+
async getInitCode() {
|
|
718
|
+
if (safeDeployed) return "0x"
|
|
721
719
|
|
|
722
|
-
|
|
720
|
+
safeDeployed = await isSmartAccountDeployed(
|
|
721
|
+
client,
|
|
722
|
+
accountAddress
|
|
723
|
+
)
|
|
723
724
|
|
|
724
|
-
|
|
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
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
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
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
743
|
+
safeDeployed = await isSmartAccountDeployed(
|
|
744
|
+
client,
|
|
745
|
+
accountAddress
|
|
746
|
+
)
|
|
741
747
|
|
|
742
|
-
|
|
748
|
+
if (safeDeployed) return undefined
|
|
743
749
|
|
|
744
|
-
|
|
750
|
+
return safeProxyFactoryAddress
|
|
751
|
+
},
|
|
752
|
+
async getFactoryData() {
|
|
753
|
+
if (safeDeployed) return undefined
|
|
745
754
|
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
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
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
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
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
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 {
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
166
|
+
return toSmartAccount({
|
|
169
167
|
address: accountAddress,
|
|
170
|
-
async
|
|
171
|
-
|
|
168
|
+
signMessage: async (_) => {
|
|
169
|
+
throw new Error("Simple account isn't 1271 compliant")
|
|
172
170
|
},
|
|
173
|
-
|
|
171
|
+
signTransaction: (_, __) => {
|
|
174
172
|
throw new SignTransactionNotSupportedBySmartAccount()
|
|
175
173
|
},
|
|
176
|
-
async
|
|
177
|
-
|
|
178
|
-
|
|
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
|
|
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
|
}
|