( userOp: PackedUserOperation, entryPointAddress: string, txOverrides?: any)
| 470 | * @param txOverrides |
| 471 | */ |
| 472 | export async function simulateValidation ( |
| 473 | userOp: PackedUserOperation, |
| 474 | entryPointAddress: string, |
| 475 | txOverrides?: any): Promise<IEntryPointSimulations.ValidationResultStructOutput> { |
| 476 | const entryPointSimulations = EntryPointSimulations__factory.createInterface() |
| 477 | const data = entryPointSimulations.encodeFunctionData('simulateValidation', [userOp]) |
| 478 | const tx: TransactionRequest = { |
| 479 | to: entryPointAddress, |
| 480 | data, |
| 481 | ...txOverrides |
| 482 | } |
| 483 | const stateOverride = { |
| 484 | [entryPointAddress]: { |
| 485 | code: EntryPointSimulationsJson.deployedBytecode |
| 486 | } |
| 487 | } |
| 488 | try { |
| 489 | const simulationResult = await ethers.provider.send('eth_call', [tx, 'latest', stateOverride]) |
| 490 | const res = entryPointSimulations.decodeFunctionResult('simulateValidation', simulationResult) |
| 491 | // note: here collapsing the returned "tuple of one" into a single value - will break for returning actual tuples |
| 492 | return res[0] |
| 493 | } catch (error: any) { |
| 494 | const revertData = error?.data |
| 495 | if (revertData != null) { |
| 496 | // note: this line throws the revert reason instead of returning it |
| 497 | entryPointSimulations.decodeFunctionResult('simulateValidation', revertData) |
| 498 | } |
| 499 | throw error |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | // TODO: this code is very much duplicated but "encodeFunctionData" is based on 20 overloads |
| 504 | // TypeScript is not able to resolve overloads with variables: https://github.com/microsoft/TypeScript/issues/14107 |
no outgoing calls
no test coverage detected