mirror of
https://github.com/getwax/bundler.git
synced 2026-01-08 23:28:10 -05:00
bugfix: estimateUserOperationGas gas values are overridden by the default values (#119)
default values are for missing values, and should not override user-specified values. (reported by: https://t.me/sherifabdelmoatty) * update node version
This commit is contained in:
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '14'
|
||||
node-version: '18'
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '14'
|
||||
node-version: '18'
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"gasFactor": "1",
|
||||
"port": "3000",
|
||||
"network": "http://localhost:8545",
|
||||
"network": "http://127.0.0.1:8545",
|
||||
"entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
||||
"beneficiary": "0xd21934eD8eAf27a67f0A70042Af50A1D6d195E81",
|
||||
"minBalance": "1",
|
||||
|
||||
@@ -94,18 +94,18 @@ export class UserOpMethodHandler {
|
||||
|
||||
/**
|
||||
* eth_estimateUserOperationGas RPC api.
|
||||
* @param userOp1
|
||||
* @param userOp1 input userOp (may have gas fields missing, so they can be estimated)
|
||||
* @param entryPointInput
|
||||
*/
|
||||
async estimateUserOperationGas (userOp1: UserOperationStruct, entryPointInput: string): Promise<EstimateUserOpGasResult> {
|
||||
const userOp = {
|
||||
...await resolveProperties(userOp1),
|
||||
// default values for missing fields.
|
||||
paymasterAndData: '0x',
|
||||
maxFeePerGas: 0,
|
||||
maxPriorityFeePerGas: 0,
|
||||
preVerificationGas: 0,
|
||||
verificationGasLimit: 10e6
|
||||
verificationGasLimit: 10e6,
|
||||
...await resolveProperties(userOp1) as any
|
||||
}
|
||||
|
||||
// todo: checks the existence of parameters, but since we hexlify the inputs, it fails to validate
|
||||
|
||||
@@ -111,11 +111,19 @@ describe('UserOpMethodHandler', function () {
|
||||
})
|
||||
})
|
||||
it('estimateUserOperationGas should estimate even without eth', async () => {
|
||||
// fail without gas
|
||||
const op = await smartAccountAPI.createSignedUserOp({
|
||||
target,
|
||||
data: '0xdeadface'
|
||||
})
|
||||
const ret = await methodHandler.estimateUserOperationGas(await resolveHexlify(op), entryPoint.address)
|
||||
expect(await methodHandler.estimateUserOperationGas(await resolveHexlify(op), entryPoint.address).catch(e => e.message)).to.eql('AA21 didn\'t pay prefund')
|
||||
// should estimate with gasprice=0
|
||||
const op1 = await smartAccountAPI.createSignedUserOp({
|
||||
maxFeePerGas: 0,
|
||||
target,
|
||||
data: '0xdeadface'
|
||||
})
|
||||
const ret = await methodHandler.estimateUserOperationGas(await resolveHexlify(op1), entryPoint.address)
|
||||
// verification gas should be high - it creates this wallet
|
||||
expect(ret.verificationGasLimit).to.be.closeTo(300000, 100000)
|
||||
// execution should be quite low.
|
||||
|
||||
Reference in New Issue
Block a user