(userOp: UserOperation, forSignature = true)
| 114 | } |
| 115 | |
| 116 | export function encodeUserOp (userOp: UserOperation, forSignature = true): string { |
| 117 | const packedUserOp = packUserOp(userOp) |
| 118 | if (forSignature) { |
| 119 | return defaultAbiCoder.encode( |
| 120 | ['bytes32', |
| 121 | 'address', 'uint256', 'bytes32', 'bytes32', |
| 122 | 'bytes32', 'uint256', 'bytes32', |
| 123 | 'bytes32'], |
| 124 | [PACKED_USEROP_TYPEHASH, |
| 125 | packedUserOp.sender, packedUserOp.nonce, keccak256(packedUserOp.initCode), keccak256(packedUserOp.callData), |
| 126 | packedUserOp.accountGasLimits, packedUserOp.preVerificationGas, packedUserOp.gasFees, |
| 127 | keccakPaymasterAndData(hexlify(packedUserOp.paymasterAndData))]) |
| 128 | } else { |
| 129 | // for the purpose of calculating gas cost encode also signature (and no keccak of bytes) |
| 130 | return defaultAbiCoder.encode( |
| 131 | ['bytes32', |
| 132 | 'address', 'uint256', 'bytes', 'bytes', |
| 133 | 'bytes32', 'uint256', 'bytes32', |
| 134 | 'bytes', 'bytes'], |
| 135 | [PACKED_USEROP_TYPEHASH, |
| 136 | packedUserOp.sender, packedUserOp.nonce, packedUserOp.initCode, packedUserOp.callData, |
| 137 | packedUserOp.accountGasLimits, packedUserOp.preVerificationGas, packedUserOp.gasFees, |
| 138 | packedUserOp.paymasterAndData, packedUserOp.signature]) |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | export function getUserOpHash (op: UserOperation, entryPoint: string, chainId: number): string { |
| 143 | const packed = encodeUserOp(op, true) |
no test coverage detected