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

Commit

Permalink
feat: update eth_patchUserOperation to return optional gas limit va…
Browse files Browse the repository at this point in the history
…lues (#250)

* feat: update patch useroperation to return optional gas limit values

* fix: pattern for gas

* fix: use exactOptional
  • Loading branch information
montelaidev authored Feb 20, 2024
1 parent 57d60fd commit a868ea2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
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([1-9a-f][0-9a-f]*|0)$`
- `preVerificationGas` (optional)
- Type: `string`
- Pattern: `^0x([1-9a-f][0-9a-f]*|0)$`
- `verificationGasLimit` (optional)
- Type: `string`
- Pattern: `^0x([1-9a-f][0-9a-f]*|0)$`

### 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
3 changes: 3 additions & 0 deletions src/eth/erc4337/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export type EthBaseUserOperation = Infer<typeof EthBaseUserOperationStruct>;

export const EthUserOperationPatchStruct = object({
paymasterAndData: EthBytesStruct,
callGasLimit: exactOptional(EthUint256Struct),
verificationGasLimit: exactOptional(EthUint256Struct),
preVerificationGas: exactOptional(EthUint256Struct),
});

export type EthUserOperationPatch = Infer<typeof EthUserOperationPatchStruct>;

0 comments on commit a868ea2

Please sign in to comment.