Skip to content

Commit 44d06f8

Browse files
authored
Merge pull request #194 from etherspot/fix/add-authorization-param-delegatesEoa-userOp
fix/add-authorization-param-delegatesEoa-userOp
2 parents 0c9476a + 923aea8 commit 44d06f8

9 files changed

Lines changed: 1602 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [2.1.1] - 2025-01-27
4+
5+
### Added Changes
6+
7+
- **Authorization parameter**: Added optional `authorization` parameter to `estimate()`, `send()`, `estimateBatches()`, and `sendBatches()` in `delegatedEoa` mode. This allows providing a freshly signed EIP-7702 authorization so delegation can occur atomically as part of the UserOperation. Not supported in `modular` mode.
8+
39
## [2.1.0] - 2025-01-27
410

511
### Added Changes

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,81 @@ const removeDelegation = async () => {
291291
};
292292
```
293293

294+
### Using the authorization parameter (delegatedEoa mode)
295+
296+
You can perform EOA delegation and a transaction atomically by passing a freshly signed authorization to `estimate()`, `send()`, `estimateBatches()`, or `sendBatches()`.
297+
298+
#### Single Transaction Example
299+
300+
```typescript
301+
// 1) Get a signed authorization without executing the installation
302+
const { authorization } = await kit.delegateSmartAccountToEoa({
303+
chainId: 137,
304+
delegateImmediately: false,
305+
});
306+
307+
if (!authorization) {
308+
// Already delegated, proceed without the authorization parameter
309+
}
310+
311+
// 2) Create and name a transaction on the SAME chain as authorization.chainId
312+
kit
313+
.transaction({
314+
to: '0x000000000000000000000000000000000000dEaD',
315+
value: '100000000000000',
316+
chainId: authorization?.chainId ?? 137,
317+
})
318+
.name({ transactionName: 'txWithAuth' });
319+
320+
// 3) Estimate or send by passing the authorization (delegation will be executed within the UserOp)
321+
const named = kit.name({ transactionName: 'txWithAuth' });
322+
const estimate = await named.estimate({ authorization });
323+
const result = await named.send({ authorization });
324+
```
325+
326+
#### Batch Example
327+
328+
```typescript
329+
// 1) Get a signed authorization without executing the installation
330+
const { authorization } = await kit.delegateSmartAccountToEoa({
331+
chainId: 137,
332+
delegateImmediately: false,
333+
});
334+
335+
if (!authorization) {
336+
// Already delegated, proceed without the authorization parameter
337+
}
338+
339+
// 2) Create transactions on the SAME chain as authorization.chainId
340+
kit
341+
.transaction({
342+
to: '0x000000000000000000000000000000000000dEaD',
343+
value: '100000000000000',
344+
chainId: authorization?.chainId ?? 137,
345+
})
346+
.name({ transactionName: 'batch-tx1' })
347+
.addToBatch({ batchName: 'auth-batch' });
348+
349+
kit
350+
.transaction({
351+
to: '0x000000000000000000000000000000000000beef',
352+
value: '200000000000000',
353+
chainId: authorization?.chainId ?? 137,
354+
})
355+
.name({ transactionName: 'batch-tx2' })
356+
.addToBatch({ batchName: 'auth-batch' });
357+
358+
// 3) Estimate or send batches by passing the authorization (delegation will be executed within the UserOp)
359+
const estimate = await kit.estimateBatches({ authorization });
360+
const result = await kit.sendBatches({ authorization });
361+
```
362+
363+
Notes:
364+
- The `authorization` must match the transaction `chainId` and Kernel v3.3 implementation.
365+
- For multi-chain batches, the `authorization` will only be applied to chain groups matching the authorization's `chainId`.
366+
- `authorization` is only supported in `delegatedEoa` mode; using it in `modular` mode will cause validation errors.
367+
- If the EOA is already delegated, `authorization` is not required.
368+
294369
### Multi-Chain Batch Operations
295370

296371
Enhanced batch operations with chain-based grouping:
@@ -471,6 +546,8 @@ const txHash = await kit.getTransactionHash(
471546
- `delegateSmartAccountToEoa()` - Delegate EOA to smart account
472547
- `undelegateSmartAccountToEoa()` - Remove EOA delegation
473548

549+
When calling `delegateSmartAccountToEoa({ delegateImmediately: false })`, the method returns an `authorization` object that can be passed to `estimate({ authorization })`, `send({ authorization })`, `estimateBatches({ authorization })`, and `sendBatches({ authorization })` for atomic delegation-and-execution flows.
550+
474551
### Client Management Methods (delegatedEoa mode only)
475552

476553
- `getPublicClient()` - Get viem PublicClient for a chain

0 commit comments

Comments
 (0)