Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

feat: update eth_patchUserOperation to return optional gas limit values #250

Merged
merged 4 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/diagrams/user_operation_signing.puml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ MetaMask -> Snap ++: ""patchUserOperation({""\n\

Snap --> MetaMask --: ""{""\n\
"" paymasterAndData?,""\n\
"" callGasLimit?,""\n\
"" verificationGasLimit?,""\n\
"" preVerificationGas?,""\n\
""}""

MetaMask -> MetaMask: Update ""paymasterAndData"" and\n\
Expand Down
14 changes: 13 additions & 1 deletion docs/evm_methods_userOp.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ Patch _some_ allowed properties of an UserOperation.
- `paymasterAndData`
- Type: `string`
- Pattern: `^0x[0-9a-f]*$`
- `callGasLimit` (optional)
- Type: `string`
- Pattern: `^0x[0-9a-f]*$`
montelaidev marked this conversation as resolved.
Show resolved Hide resolved
- `preverificationGas` (optional)
montelaidev marked this conversation as resolved.
Show resolved Hide resolved
- Type: `string`
- Pattern: `^0x[0-9a-f]*$`
montelaidev marked this conversation as resolved.
Show resolved Hide resolved
- `verificationGasLimit` (optional)
- Type: `string`
- Pattern: `^0x[0-9a-f]*$`
montelaidev marked this conversation as resolved.
Show resolved Hide resolved

### Example

Expand Down Expand Up @@ -180,7 +189,10 @@ Patch _some_ allowed properties of an UserOperation.

```json
{
"paymasterAndData": "0x952514d7cBCB495EACeB86e02154921401dB0Cd9dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000779b3fbb00000000000000006565b267000000000000000000000000000000000000000029195b31a9b1c6ccdeff53e359ebbcd5f075a93c1aaed93302e5fde5faf8047028b296b8a3fa4e22b063af5069ae9f656736ffda0ee090c0311155722b905f781b"
"paymasterAndData": "0x952514d7cBCB495EACeB86e02154921401dB0Cd9dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000779b3fbb00000000000000006565b267000000000000000000000000000000000000000029195b31a9b1c6ccdeff53e359ebbcd5f075a93c1aaed93302e5fde5faf8047028b296b8a3fa4e22b063af5069ae9f656736ffda0ee090c0311155722b905f781b",
"callGasLimit": "0x58a83",
"verificationGasLimit": "0xe8c4",
"preVerificationGas": "0xc57c"
}
```

Expand Down
5 changes: 4 additions & 1 deletion src/eth/erc4337/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { string, type Infer } from 'superstruct';
import { optional, string, type Infer } from 'superstruct';

montelaidev marked this conversation as resolved.
Show resolved Hide resolved
import { exactOptional, object } from '../../superstruct';
import { EthAddressStruct, EthBytesStruct, EthUint256Struct } from '../types';
Expand Down Expand Up @@ -66,6 +66,9 @@ export type EthBaseUserOperation = Infer<typeof EthBaseUserOperationStruct>;

export const EthUserOperationPatchStruct = object({
paymasterAndData: EthBytesStruct,
callDataLimit: optional(EthUint256Struct),
verificationGasLimit: optional(EthUint256Struct),
montelaidev marked this conversation as resolved.
Show resolved Hide resolved
preVerificationGas: optional(EthUint256Struct),
});

export type EthUserOperationPatch = Infer<typeof EthUserOperationPatchStruct>;
Loading