permissionless 0.1.4 → 0.1.6
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 +12 -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/clients/createSmartAccountClient.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/clients/createSmartAccountClient.js.map +1 -1
- 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.map +1 -1
- package/_types/accounts/safe/signerToSafeSmartAccount.d.ts.map +1 -1
- 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/clients/createSmartAccountClient.d.ts +5 -5
- package/_types/clients/createSmartAccountClient.d.ts.map +1 -1
- package/accounts/biconomy/signerToBiconomySmartAccount.ts +34 -16
- package/accounts/index.ts +3 -0
- package/accounts/kernel/signerToEcdsaKernelSmartAccount.ts +4 -9
- package/accounts/safe/signerToSafeSmartAccount.ts +216 -207
- package/accounts/simple/signerToSimpleSmartAccount.ts +12 -28
- package/accounts/toSmartAccount.ts +167 -0
- package/accounts/types.ts +2 -2
- package/clients/createSmartAccountClient.ts +14 -13
- package/package.json +1 -1
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
keccak256,
|
|
17
17
|
parseAbiParameters
|
|
18
18
|
} from "viem"
|
|
19
|
-
import { toAccount } from "viem/accounts"
|
|
20
19
|
import { getChainId, signMessage, signTypedData } from "viem/actions"
|
|
21
20
|
import { getAccountNonce } from "../../actions/public/getAccountNonce"
|
|
22
21
|
import type { Prettify } from "../../types"
|
|
@@ -24,6 +23,7 @@ import type { ENTRYPOINT_ADDRESS_V06_TYPE } from "../../types/entrypoint"
|
|
|
24
23
|
import { getEntryPointVersion } from "../../utils"
|
|
25
24
|
import { getUserOperationHash } from "../../utils/getUserOperationHash"
|
|
26
25
|
import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed"
|
|
26
|
+
import { toSmartAccount } from "../toSmartAccount"
|
|
27
27
|
import {
|
|
28
28
|
SignTransactionNotSupportedBySmartAccount,
|
|
29
29
|
type SmartAccount,
|
|
@@ -269,11 +269,22 @@ export async function signerToBiconomySmartAccount<
|
|
|
269
269
|
accountAddress
|
|
270
270
|
)
|
|
271
271
|
|
|
272
|
-
|
|
273
|
-
const account = toAccount({
|
|
272
|
+
return toSmartAccount({
|
|
274
273
|
address: accountAddress,
|
|
275
274
|
async signMessage({ message }) {
|
|
276
|
-
|
|
275
|
+
let signature = await signMessage(client, {
|
|
276
|
+
account: viemSigner,
|
|
277
|
+
message
|
|
278
|
+
})
|
|
279
|
+
const potentiallyIncorrectV = parseInt(signature.slice(-2), 16)
|
|
280
|
+
if (![27, 28].includes(potentiallyIncorrectV)) {
|
|
281
|
+
const correctV = potentiallyIncorrectV + 27
|
|
282
|
+
signature = signature.slice(0, -2) + correctV.toString(16)
|
|
283
|
+
}
|
|
284
|
+
return encodeAbiParameters(
|
|
285
|
+
[{ type: "bytes" }, { type: "address" }],
|
|
286
|
+
[signature as Hex, ecdsaModuleAddress]
|
|
287
|
+
)
|
|
277
288
|
},
|
|
278
289
|
async signTransaction(_, __) {
|
|
279
290
|
throw new SignTransactionNotSupportedBySmartAccount()
|
|
@@ -284,18 +295,25 @@ export async function signerToBiconomySmartAccount<
|
|
|
284
295
|
| keyof TTypedData
|
|
285
296
|
| "EIP712Domain" = keyof TTypedData
|
|
286
297
|
>(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
298
|
+
let signature = await signTypedData<
|
|
299
|
+
TTypedData,
|
|
300
|
+
TPrimaryType,
|
|
301
|
+
TChain,
|
|
302
|
+
undefined
|
|
303
|
+
>(client, {
|
|
304
|
+
account: viemSigner,
|
|
305
|
+
...typedData
|
|
306
|
+
})
|
|
307
|
+
const potentiallyIncorrectV = parseInt(signature.slice(-2), 16)
|
|
308
|
+
if (![27, 28].includes(potentiallyIncorrectV)) {
|
|
309
|
+
const correctV = potentiallyIncorrectV + 27
|
|
310
|
+
signature = signature.slice(0, -2) + correctV.toString(16)
|
|
311
|
+
}
|
|
312
|
+
return encodeAbiParameters(
|
|
313
|
+
[{ type: "bytes" }, { type: "address" }],
|
|
314
|
+
[signature as Hex, ecdsaModuleAddress]
|
|
293
315
|
)
|
|
294
|
-
}
|
|
295
|
-
})
|
|
296
|
-
|
|
297
|
-
return {
|
|
298
|
-
...account,
|
|
316
|
+
},
|
|
299
317
|
client: client,
|
|
300
318
|
publicKey: accountAddress,
|
|
301
319
|
entryPoint: entryPointAddress,
|
|
@@ -415,5 +433,5 @@ export async function signerToBiconomySmartAccount<
|
|
|
415
433
|
const dynamicPart = moduleAddress.substring(2).padEnd(40, "0")
|
|
416
434
|
return `0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000${dynamicPart}000000000000000000000000000000000000000000000000000000000000004181d4b4981670cb18f99f0b4a66446df1bf5b204d24cfcb659bf38ba27a4359b5711649ec2423c5e1247245eba2964679b6a1dbb85c992ae40b9b00c6935b02ff1b00000000000000000000000000000000000000000000000000000000000000`
|
|
417
435
|
}
|
|
418
|
-
}
|
|
436
|
+
})
|
|
419
437
|
}
|
package/accounts/index.ts
CHANGED
|
@@ -44,6 +44,8 @@ import {
|
|
|
44
44
|
type SmartAccountSigner
|
|
45
45
|
} from "./types"
|
|
46
46
|
|
|
47
|
+
import { toSmartAccount } from "./toSmartAccount"
|
|
48
|
+
|
|
47
49
|
export {
|
|
48
50
|
type SafeVersion,
|
|
49
51
|
type SmartAccountSigner,
|
|
@@ -60,6 +62,7 @@ export {
|
|
|
60
62
|
signerToEcdsaKernelSmartAccount,
|
|
61
63
|
type BiconomySmartAccount,
|
|
62
64
|
signerToBiconomySmartAccount,
|
|
65
|
+
toSmartAccount,
|
|
63
66
|
type SignerToSimpleSmartAccountParameters,
|
|
64
67
|
type SignerToSafeSmartAccountParameters,
|
|
65
68
|
type PrivateKeyToSimpleSmartAccountParameters,
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
encodeFunctionData,
|
|
12
12
|
isAddressEqual
|
|
13
13
|
} from "viem"
|
|
14
|
-
import { toAccount } from "viem/accounts"
|
|
15
14
|
import {
|
|
16
15
|
getChainId,
|
|
17
16
|
readContract,
|
|
@@ -25,6 +24,7 @@ import type { ENTRYPOINT_ADDRESS_V06_TYPE } from "../../types/entrypoint"
|
|
|
25
24
|
import { getEntryPointVersion } from "../../utils"
|
|
26
25
|
import { getUserOperationHash } from "../../utils/getUserOperationHash"
|
|
27
26
|
import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed"
|
|
27
|
+
import { toSmartAccount } from "../toSmartAccount"
|
|
28
28
|
import type { SmartAccount } from "../types"
|
|
29
29
|
import {
|
|
30
30
|
SignTransactionNotSupportedBySmartAccount,
|
|
@@ -289,8 +289,7 @@ export async function signerToEcdsaKernelSmartAccount<
|
|
|
289
289
|
accountAddress
|
|
290
290
|
)
|
|
291
291
|
|
|
292
|
-
|
|
293
|
-
const account = toAccount({
|
|
292
|
+
return toSmartAccount({
|
|
294
293
|
address: accountAddress,
|
|
295
294
|
async signMessage({ message }) {
|
|
296
295
|
return signMessage(client, { account: viemSigner, message })
|
|
@@ -311,11 +310,7 @@ export async function signerToEcdsaKernelSmartAccount<
|
|
|
311
310
|
...typedData
|
|
312
311
|
}
|
|
313
312
|
)
|
|
314
|
-
}
|
|
315
|
-
})
|
|
316
|
-
|
|
317
|
-
return {
|
|
318
|
-
...account,
|
|
313
|
+
},
|
|
319
314
|
client: client,
|
|
320
315
|
publicKey: accountAddress,
|
|
321
316
|
entryPoint: entryPointAddress,
|
|
@@ -420,5 +415,5 @@ export async function signerToEcdsaKernelSmartAccount<
|
|
|
420
415
|
async getDummySignature(_userOperation) {
|
|
421
416
|
return "0x00000000fffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
|
|
422
417
|
}
|
|
423
|
-
}
|
|
418
|
+
})
|
|
424
419
|
}
|
|
@@ -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,
|
|
@@ -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
|
}
|