Skip to content

Commit

Permalink
use a diff dummy sig for subsequent userops
Browse files Browse the repository at this point in the history
  • Loading branch information
mmv08 committed Apr 17, 2024
1 parent 2611549 commit 43f1e29
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/4337-passkeys/src/hooks/useUserOpGasEstimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function useUserOpGasLimitEstimation(userOp: UnsignedPackedUserOperation) {
try {
const estimation = await estimateUserOpGasLimit(userOp)
// Increase the gas limit by 50%, otherwise the user op will fail during simulation with "verification more than gas limit" error
estimation.verificationGasLimit = '0x' + ((BigInt(estimation.verificationGasLimit) * 20n) / 10n).toString(16)
estimation.verificationGasLimit = '0x' + ((BigInt(estimation.verificationGasLimit) * 15n) / 10n).toString(16)
setUserOpGasLimitEstimation(estimation)
setStatus(RequestStatus.SUCCESS)
} catch (error) {
Expand Down
12 changes: 9 additions & 3 deletions examples/4337-passkeys/src/logic/userOp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type UnsignedPackedUserOperation = Omit<PackedUserOperation, 'signature'>
// code) & `preVerificationGas` (The signature length in bytes should be accurate) estimate.
// The challenge is neither P256 Verification Gas nor signature length are stable, so we make
// a calculated guess.
const DUMMY_SIGNATURE = ethers.solidityPacked(
const DUMMY_SIGNATURE_LAUNCHPAD = ethers.solidityPacked(
['uint48', 'uint48', 'bytes'],
[
0,
Expand All @@ -59,6 +59,9 @@ const DUMMY_SIGNATURE = ethers.solidityPacked(
],
)

const DUMMY_SIGNATURE =
'0x000000000000000000000000000000000000000000000000f8b27791e7f90e68ff769ba8fa20ee5fdd3570f30000000000000000000000000000000000000000000000000000000000000041000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e06e6ef49c05823a567596e35e5838c4cbc1f3bc3565b14192b33d834a4a59e1884c541f13d7fd3ce47716ed030c2f019494c82e6e733cca3d2b1ca8949e310a52000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034226f726967696e223a22687474703a2f2f6c6f63616c686f73743a35313733222c2263726f73734f726967696e223a66616c7365000000000000000000000000'

/**
* Generates the user operation initialization code.
* @param proxyFactory - The address of the proxy factory.
Expand Down Expand Up @@ -125,7 +128,7 @@ function prepareUserOperationWithInitialisation(
console.log('Safe deployment data: ', safeDeploymentData)
console.log(
'validateUserOp data for estimation: ',
getValidateUserOpData({ ...userOp, signature: DUMMY_SIGNATURE }, ethers.ZeroHash, 10000000000),
getValidateUserOpData({ ...userOp, signature: DUMMY_SIGNATURE_LAUNCHPAD }, ethers.ZeroHash, 10000000000),
)
}

Expand Down Expand Up @@ -215,7 +218,10 @@ function estimateUserOpGasLimit(
entryPointAddress = ENTRYPOINT_ADDRESS,
): Promise<UserOpGasLimitEstimation> {
const provider = getEip4337BundlerProvider()
const rpcUserOp = unpackUserOperationForRpc(userOp, DUMMY_SIGNATURE)

const placeholderSignature = userOp.initCode.length > 0 && userOp.initCode !== '0x' ? DUMMY_SIGNATURE_LAUNCHPAD : DUMMY_SIGNATURE

const rpcUserOp = unpackUserOperationForRpc(userOp, placeholderSignature)
const estimation = provider.send('eth_estimateUserOperationGas', [rpcUserOp, entryPointAddress])

return estimation
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 43f1e29

Please sign in to comment.