abstractionkit 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -0
- package/README.md +29 -14
- package/dist/index.cjs +5091 -4931
- package/dist/index.d.cts +659 -638
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +659 -638
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +5091 -4931
- package/dist/index.mjs +5092 -4932
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,71 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.4
|
|
4
|
+
|
|
5
|
+
### New Features
|
|
6
|
+
|
|
7
|
+
- **`SafeAccount.isDeployed(accountAddress, nodeRpcUrl)`**: static method that checks whether a Safe account is already deployed on-chain. Returns `true` when `accountAddress` has non-empty bytecode, `false` otherwise. Useful for branching between `new SafeAccountV0_3_0(address)` (existing account) and `SafeAccountV0_3_0.initializeNewAccount([owners])` (counterfactual) without inspecting `eth_getCode` manually.
|
|
8
|
+
|
|
9
|
+
## 0.3.3
|
|
10
|
+
|
|
11
|
+
### New Features
|
|
12
|
+
|
|
13
|
+
- **`TokenQuote` type** exported from the package root: `{ token: string; exchangeRate: bigint; tokenCost: bigint }`. Surfaces the exchange rate and maximum token cost the paymaster applied when paying gas with an ERC-20 token, so consumers can display the cost to users or log/meter it without a second RPC round-trip.
|
|
14
|
+
- **`CandidePaymaster.createTokenPaymasterUserOperation` and `Erc7677Paymaster.createPaymasterUserOperation` now return `tokenQuote`** alongside the UserOperation. Populated on the token-payment flow; absent on sponsored flows and on Candide's `signingPhase: "finalize"` path (no gas estimation → no cost computation).
|
|
15
|
+
- **`skipGasEstimation` flag on `createUserOperation` overrides** for `SafeAccount`, `Calibur7702Account`, and `Simple7702Account`. When set, the UserOperation is returned with a dummy signature and zero (or override-provided) gas limits, skipping the bundler's `eth_estimateUserOperationGas` roundtrip. Useful when gas estimation is run separately, for example by a paymaster sponsorship call that returns its own gas limits.
|
|
16
|
+
- **`SponsorInfo` type** exported from the package root. Represents the raw `{ name, icon? }` shape returned by paymasters per ERC-7677; `CandidePaymaster` normalizes it into the public `SponsorMetadata` shape.
|
|
17
|
+
|
|
18
|
+
### Breaking Changes
|
|
19
|
+
|
|
20
|
+
- **Three paymaster methods changed return shape** from a raw UserOperation / tuple to a named-field object. All now return `{ userOperation, tokenQuote? | sponsorMetadata? }`:
|
|
21
|
+
- `CandidePaymaster.createTokenPaymasterUserOperation` — returns `{ userOperation, tokenQuote? }` (was `SameUserOp<T>`).
|
|
22
|
+
- `CandidePaymaster.createSponsorPaymasterUserOperation` — returns `{ userOperation, sponsorMetadata? }` (was `[SameUserOp<T>, SponsorMetadata | undefined]`).
|
|
23
|
+
- `Erc7677Paymaster.createPaymasterUserOperation` — returns `{ userOperation, tokenQuote? }` (was `SameUserOp<T>`).
|
|
24
|
+
|
|
25
|
+
Migration:
|
|
26
|
+
```ts
|
|
27
|
+
// Before
|
|
28
|
+
const [sponsoredOp, sponsorMetadata] = await paymaster.createSponsorPaymasterUserOperation(...);
|
|
29
|
+
const tokenOp = await paymaster.createTokenPaymasterUserOperation(...);
|
|
30
|
+
const userOp = await erc7677.createPaymasterUserOperation(...);
|
|
31
|
+
|
|
32
|
+
// After
|
|
33
|
+
const { userOperation: sponsoredOp, sponsorMetadata } = await paymaster.createSponsorPaymasterUserOperation(...);
|
|
34
|
+
const { userOperation: tokenOp, tokenQuote } = await paymaster.createTokenPaymasterUserOperation(...);
|
|
35
|
+
const { userOperation, tokenQuote } = await erc7677.createPaymasterUserOperation(...);
|
|
36
|
+
```
|
|
37
|
+
- **`CandidePaymasterContext` moved back to a dedicated parameter** on `CandidePaymaster.createSponsorPaymasterUserOperation` and `createTokenPaymasterUserOperation`. The `context` field was removed from `GasPaymasterUserOperationOverrides`, and `context` is now the second-to-last argument (optional) on both methods, with `overrides` as the last argument. Migration:
|
|
38
|
+
```ts
|
|
39
|
+
// Before (0.3.2): context nested inside overrides
|
|
40
|
+
await paymaster.createSponsorPaymasterUserOperation(
|
|
41
|
+
smartAccount, userOp, bundlerRpc, sponsorshipPolicyId,
|
|
42
|
+
{ context: { signingPhase: "commit" }, maxFeePerGasMultiplier: 110n },
|
|
43
|
+
);
|
|
44
|
+
await paymaster.createTokenPaymasterUserOperation(
|
|
45
|
+
smartAccount, userOp, tokenAddress, bundlerRpc,
|
|
46
|
+
{ context: { signingPhase: "commit" }, maxFeePerGasMultiplier: 110n },
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// After (0.3.3): context is a dedicated argument
|
|
50
|
+
await paymaster.createSponsorPaymasterUserOperation(
|
|
51
|
+
smartAccount, userOp, bundlerRpc, sponsorshipPolicyId,
|
|
52
|
+
{ signingPhase: "commit" },
|
|
53
|
+
{ maxFeePerGasMultiplier: 110n },
|
|
54
|
+
);
|
|
55
|
+
// For createTokenPaymasterUserOperation, `context` is optional: the method
|
|
56
|
+
// always derives `context.token` from the `tokenAddress` argument, so pass
|
|
57
|
+
// `undefined` unless you need other context fields (e.g. `signingPhase`).
|
|
58
|
+
await paymaster.createTokenPaymasterUserOperation(
|
|
59
|
+
smartAccount, userOp, tokenAddress, bundlerRpc,
|
|
60
|
+
undefined,
|
|
61
|
+
{ maxFeePerGasMultiplier: 110n },
|
|
62
|
+
);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Bug Fixes
|
|
66
|
+
|
|
67
|
+
- **`CandidePaymaster` now parses sponsor info per ERC-7677.** Paymasters return sponsor info under `sponsor: { name, icon? }` (singular `icon`); the previous code read a non-standard `sponsorMetadata` key and therefore always returned `undefined`. The raw response is now normalized into the public `SponsorMetadata` shape (`{ name, description, url, icons[] }`).
|
|
68
|
+
|
|
3
69
|
## 0.3.2
|
|
4
70
|
|
|
5
71
|
### New Features
|
package/README.md
CHANGED
|
@@ -38,10 +38,10 @@ npm install abstractionkit
|
|
|
38
38
|
|
|
39
39
|
### Upgrading to v0.3.0
|
|
40
40
|
|
|
41
|
-
v0.3.0 is a major release.
|
|
41
|
+
v0.3.0 is a major release. The following API changes are likely to break existing paymaster code:
|
|
42
42
|
|
|
43
|
-
- `CandidePaymaster.createSponsorPaymasterUserOperation(...)` now takes `smartAccount` as the **first** argument: `(smartAccount, userOp, bundlerRpc, sponsorshipPolicyId?, overrides?)`.
|
|
44
|
-
- `
|
|
43
|
+
- `CandidePaymaster.createSponsorPaymasterUserOperation(...)` now takes `smartAccount` as the **first** argument: `(smartAccount, userOp, bundlerRpc, sponsorshipPolicyId?, context?, overrides?)`.
|
|
44
|
+
- `CandidePaymaster.createTokenPaymasterUserOperation(...)` adds a dedicated `context?` argument before `overrides?`: `(smartAccount, userOp, tokenAddress, bundlerRpc, context?, overrides?)`. Callers that previously passed `overrides` positionally at argument 5 must insert `undefined` (or an explicit context) so `overrides` shifts to argument 6.
|
|
45
45
|
|
|
46
46
|
See [CHANGELOG.md](./CHANGELOG.md) for the full list of new features, renames, type export changes, and fixes.
|
|
47
47
|
|
|
@@ -143,12 +143,13 @@ const userOp = await smartAccount.createUserOperation(
|
|
|
143
143
|
|
|
144
144
|
// Sponsor it. Sets paymaster fields and re-estimates gas.
|
|
145
145
|
// Note: as of v0.3.0, smartAccount is the first argument.
|
|
146
|
-
const
|
|
146
|
+
const { userOperation: sponsoredOp, sponsorMetadata } = await paymaster.createSponsorPaymasterUserOperation(
|
|
147
147
|
smartAccount,
|
|
148
148
|
userOp,
|
|
149
149
|
bundlerRpc,
|
|
150
150
|
sponsorshipPolicyId,
|
|
151
|
-
//
|
|
151
|
+
// context (optional — e.g. { signingPhase: "commit" } for EP v0.9 parallel signing)
|
|
152
|
+
// overrides (optional — gas limits and multipliers)
|
|
152
153
|
);
|
|
153
154
|
|
|
154
155
|
// Sign and send as usual
|
|
@@ -173,12 +174,14 @@ const userOp = await smartAccount.createUserOperation(
|
|
|
173
174
|
// Automatically prepends token approval + sets paymaster fields.
|
|
174
175
|
// For tokens like USDT that require resetting allowance to 0 first, pass
|
|
175
176
|
// { resetApproval: true } in the overrides.
|
|
176
|
-
|
|
177
|
+
// `tokenQuote` carries the exchange rate and max token cost used for the approval.
|
|
178
|
+
const { userOperation: tokenOp, tokenQuote } = await paymaster.createTokenPaymasterUserOperation(
|
|
177
179
|
smartAccount,
|
|
178
180
|
userOp,
|
|
179
181
|
gasTokenAddress,
|
|
180
182
|
bundlerRpc,
|
|
181
|
-
//
|
|
183
|
+
// context (optional)
|
|
184
|
+
// overrides (optional — gas limits, multipliers, resetApproval)
|
|
182
185
|
);
|
|
183
186
|
|
|
184
187
|
tokenOp.signature = smartAccount.signUserOperation(tokenOp, [ownerPrivateKey], chainId);
|
|
@@ -187,20 +190,20 @@ const response = await smartAccount.sendUserOperation(tokenOp, bundlerRpc);
|
|
|
187
190
|
|
|
188
191
|
### Pass paymaster context (sponsorship policy, parallel signing)
|
|
189
192
|
|
|
190
|
-
|
|
193
|
+
`CandidePaymasterContext` is passed as its own argument, separate from gas overrides.
|
|
191
194
|
|
|
192
195
|
```typescript
|
|
193
|
-
const
|
|
196
|
+
const { userOperation: sponsoredOp } = await paymaster.createSponsorPaymasterUserOperation(
|
|
194
197
|
smartAccount,
|
|
195
198
|
userOp,
|
|
196
199
|
bundlerRpc,
|
|
197
200
|
sponsorshipPolicyId,
|
|
198
201
|
{
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
// gas overrides
|
|
202
|
+
// For EntryPoint v0.9 parallel signing flows:
|
|
203
|
+
// signingPhase: "commit" | "finalize",
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
// gas overrides:
|
|
204
207
|
callGasLimitPercentageMultiplier: 110,
|
|
205
208
|
},
|
|
206
209
|
);
|
|
@@ -239,6 +242,18 @@ const newAccount = SafeAccountV0_3_0.initializeNewAccount(["0xOwnerAddress"]);
|
|
|
239
242
|
// First UserOp will deploy it automatically
|
|
240
243
|
```
|
|
241
244
|
|
|
245
|
+
When you have a stored Safe address and need to pick between the two paths at runtime, use `isDeployed` to avoid emitting redundant factory data (and the `AA10 sender already constructed` error) on subsequent UserOps:
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
import { SafeAccountV0_3_0 } from "abstractionkit";
|
|
249
|
+
|
|
250
|
+
const smartAccount = (await SafeAccountV0_3_0.isDeployed(safeAddress, nodeRpc))
|
|
251
|
+
? new SafeAccountV0_3_0(safeAddress)
|
|
252
|
+
: SafeAccountV0_3_0.initializeNewAccount(owners);
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
`isDeployed` only checks for bytecode at the address. It does not verify that the deployed code is a Safe or that its on-chain owners match a given set. If your owners may have changed, compare `createAccountAddress(owners)` against the stored address yourself before calling `initializeNewAccount`.
|
|
256
|
+
|
|
242
257
|
### Calibur 7702: delegate an EOA and send a transfer
|
|
243
258
|
|
|
244
259
|
`Calibur7702Account` is Uniswap's EIP-7702 smart account. It upgrades a regular EOA in place so the same address becomes a programmable smart account on EntryPoint v0.8.
|