@aa-sdk/core 4.35.0 → 4.36.0
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/README.md +1 -1
- package/dist/esm/account/smartContractAccount.d.ts +1 -1
- package/dist/esm/account/smartContractAccount.js.map +1 -1
- package/dist/esm/actions/bundler/estimateUserOperationGas.d.ts +3 -2
- package/dist/esm/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/dist/esm/actions/bundler/getSupportedEntryPoints.js.map +1 -1
- package/dist/esm/actions/bundler/getUserOperationByHash.js.map +1 -1
- package/dist/esm/actions/bundler/getUserOperationReceipt.js.map +1 -1
- package/dist/esm/actions/bundler/sendRawUserOperation.d.ts +2 -1
- package/dist/esm/actions/bundler/sendRawUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.js +8 -1
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
- package/dist/esm/actions/smartAccount/getAddress.js.map +1 -1
- package/dist/esm/actions/smartAccount/getUserOperationError.d.ts +14 -0
- package/dist/esm/actions/smartAccount/getUserOperationError.js +90 -0
- package/dist/esm/actions/smartAccount/getUserOperationError.js.map +1 -0
- package/dist/esm/actions/smartAccount/internal/initUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/sendUserOperation.js +11 -4
- package/dist/esm/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransaction.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransactions.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/signMessage.js.map +1 -1
- package/dist/esm/actions/smartAccount/signTypedData.js.map +1 -1
- package/dist/esm/actions/smartAccount/signUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/types.js.map +1 -1
- package/dist/esm/actions/smartAccount/upgradeAccount.js.map +1 -1
- package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
- package/dist/esm/client/addBreadcrumb.js.map +1 -1
- package/dist/esm/client/bundlerClient.js.map +1 -1
- package/dist/esm/client/decorators/bundlerClient.js.map +1 -1
- package/dist/esm/client/decorators/smartAccountClient.js.map +1 -1
- package/dist/esm/client/isSmartAccountClient.js.map +1 -1
- package/dist/esm/client/schema.d.ts +25 -25
- package/dist/esm/client/schema.js.map +1 -1
- package/dist/esm/client/smartAccountClient.js.map +1 -1
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/ens/utils.js.map +1 -1
- package/dist/esm/entrypoint/0.6.d.ts +2 -2
- package/dist/esm/entrypoint/0.6.js.map +1 -1
- package/dist/esm/entrypoint/0.7.d.ts +1 -1
- package/dist/esm/entrypoint/0.7.js.map +1 -1
- package/dist/esm/entrypoint/index.d.ts +1 -1
- package/dist/esm/entrypoint/index.js.map +1 -1
- package/dist/esm/entrypoint/types.js.map +1 -1
- package/dist/esm/errors/account.js.map +1 -1
- package/dist/esm/errors/client.js.map +1 -1
- package/dist/esm/errors/entrypoint.js.map +1 -1
- package/dist/esm/errors/signer.js.map +1 -1
- package/dist/esm/errors/useroperation.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/middleware/actions.js.map +1 -1
- package/dist/esm/middleware/defaults/7702gasEstimator.d.ts +2 -2
- package/dist/esm/middleware/defaults/7702gasEstimator.js +2 -2
- package/dist/esm/middleware/defaults/7702gasEstimator.js.map +1 -1
- package/dist/esm/middleware/defaults/7702signer.d.ts +1 -1
- package/dist/esm/middleware/defaults/7702signer.js +1 -1
- package/dist/esm/middleware/defaults/7702signer.js.map +1 -1
- package/dist/esm/middleware/defaults/feeEstimator.js.map +1 -1
- package/dist/esm/middleware/defaults/gasEstimator.js.map +1 -1
- package/dist/esm/middleware/defaults/paymasterAndData.js.map +1 -1
- package/dist/esm/middleware/defaults/userOpSigner.js.map +1 -1
- package/dist/esm/middleware/erc7677middleware.js.map +1 -1
- package/dist/esm/middleware/types.js.map +1 -1
- package/dist/esm/signer/local-account.d.ts +2 -207
- package/dist/esm/signer/local-account.js.map +1 -1
- package/dist/esm/signer/schema.d.ts +1 -1
- package/dist/esm/signer/types.js.map +1 -1
- package/dist/esm/signer/wallet-client.d.ts +2 -207
- package/dist/esm/signer/wallet-client.js.map +1 -1
- package/dist/esm/transport/split.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/bigint.js.map +1 -1
- package/dist/esm/utils/defaults.js.map +1 -1
- package/dist/esm/utils/index.d.ts +2 -2
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/schema.js.map +1 -1
- package/dist/esm/utils/stateOverride.js.map +1 -1
- package/dist/esm/utils/testUtils.js.map +1 -1
- package/dist/esm/utils/traceHeader.js.map +1 -1
- package/dist/esm/utils/types.js.map +1 -1
- package/dist/esm/utils/userop.d.ts +2 -2
- package/dist/esm/utils/userop.js +1 -1
- package/dist/esm/utils/userop.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/account/smartContractAccount.d.ts +1 -1
- package/dist/types/account/smartContractAccount.d.ts.map +1 -1
- package/dist/types/actions/bundler/estimateUserOperationGas.d.ts +3 -2
- package/dist/types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
- package/dist/types/actions/bundler/getSupportedEntryPoints.d.ts.map +1 -1
- package/dist/types/actions/bundler/getUserOperationByHash.d.ts.map +1 -1
- package/dist/types/actions/bundler/getUserOperationReceipt.d.ts.map +1 -1
- package/dist/types/actions/bundler/sendRawUserOperation.d.ts +2 -1
- package/dist/types/actions/bundler/sendRawUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperationFromTx.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/checkGasSponsorshipEligibility.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/estimateUserOperationGas.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/getUserOperationError.d.ts +15 -0
- package/dist/types/actions/smartAccount/getUserOperationError.d.ts.map +1 -0
- package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendTransaction.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/signUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/types.d.ts.map +1 -1
- package/dist/types/client/decorators/smartAccountClient.d.ts.map +1 -1
- package/dist/types/client/schema.d.ts +25 -25
- package/dist/types/client/schema.d.ts.map +1 -1
- package/dist/types/ens/utils.d.ts.map +1 -1
- package/dist/types/entrypoint/0.6.d.ts +2 -2
- package/dist/types/entrypoint/0.6.d.ts.map +1 -1
- package/dist/types/entrypoint/0.7.d.ts +1 -1
- package/dist/types/entrypoint/0.7.d.ts.map +1 -1
- package/dist/types/entrypoint/index.d.ts +1 -1
- package/dist/types/entrypoint/index.d.ts.map +1 -1
- package/dist/types/entrypoint/types.d.ts.map +1 -1
- package/dist/types/errors/useroperation.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/middleware/actions.d.ts.map +1 -1
- package/dist/types/middleware/defaults/7702gasEstimator.d.ts +2 -2
- package/dist/types/middleware/defaults/7702signer.d.ts +1 -1
- package/dist/types/middleware/types.d.ts.map +1 -1
- package/dist/types/signer/local-account.d.ts +2 -207
- package/dist/types/signer/local-account.d.ts.map +1 -1
- package/dist/types/signer/schema.d.ts +1 -1
- package/dist/types/signer/schema.d.ts.map +1 -1
- package/dist/types/signer/utils.d.ts.map +1 -1
- package/dist/types/signer/wallet-client.d.ts +2 -207
- package/dist/types/signer/wallet-client.d.ts.map +1 -1
- package/dist/types/transport/split.d.ts.map +1 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/bigint.d.ts.map +1 -1
- package/dist/types/utils/bytes.d.ts.map +1 -1
- package/dist/types/utils/defaults.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +2 -2
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/testUtils.d.ts.map +1 -1
- package/dist/types/utils/traceHeader.d.ts.map +1 -1
- package/dist/types/utils/userop.d.ts +2 -2
- package/dist/types/utils/userop.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -6
- package/src/account/smartContractAccount.ts +27 -25
- package/src/actions/bundler/estimateUserOperationGas.ts +2 -2
- package/src/actions/bundler/getSupportedEntryPoints.ts +2 -2
- package/src/actions/bundler/getUserOperationByHash.ts +2 -2
- package/src/actions/bundler/getUserOperationReceipt.ts +2 -2
- package/src/actions/bundler/sendRawUserOperation.ts +2 -2
- package/src/actions/smartAccount/buildUserOperation.ts +5 -4
- package/src/actions/smartAccount/buildUserOperationFromTx.ts +4 -3
- package/src/actions/smartAccount/buildUserOperationFromTxs.ts +9 -8
- package/src/actions/smartAccount/checkGasSponsorshipEligibility.ts +5 -4
- package/src/actions/smartAccount/dropAndReplaceUserOperation.ts +7 -6
- package/src/actions/smartAccount/estimateUserOperationGas.ts +15 -8
- package/src/actions/smartAccount/getAddress.ts +2 -2
- package/src/actions/smartAccount/getUserOperationError.ts +119 -0
- package/src/actions/smartAccount/internal/initUserOperation.ts +7 -6
- package/src/actions/smartAccount/internal/runMiddlewareStack.ts +13 -12
- package/src/actions/smartAccount/internal/sendUserOperation.ts +13 -6
- package/src/actions/smartAccount/sendTransaction.ts +5 -4
- package/src/actions/smartAccount/sendTransactions.ts +3 -3
- package/src/actions/smartAccount/sendUserOperation.ts +4 -3
- package/src/actions/smartAccount/signMessage.ts +3 -3
- package/src/actions/smartAccount/signTypedData.ts +3 -3
- package/src/actions/smartAccount/signUserOperation.ts +4 -3
- package/src/actions/smartAccount/types.ts +23 -15
- package/src/actions/smartAccount/upgradeAccount.ts +3 -3
- package/src/actions/smartAccount/waitForUserOperationTransacation.ts +5 -5
- package/src/client/addBreadcrumb.ts +1 -1
- package/src/client/bundlerClient.ts +5 -5
- package/src/client/decorators/bundlerClient.ts +7 -7
- package/src/client/decorators/smartAccountClient.ts +20 -18
- package/src/client/isSmartAccountClient.ts +4 -4
- package/src/client/schema.ts +2 -2
- package/src/client/smartAccountClient.ts +14 -14
- package/src/client/types.ts +2 -2
- package/src/ens/utils.ts +1 -1
- package/src/entrypoint/0.6.ts +3 -3
- package/src/entrypoint/0.7.ts +4 -4
- package/src/entrypoint/index.ts +10 -9
- package/src/entrypoint/types.ts +30 -28
- package/src/errors/account.ts +1 -1
- package/src/errors/client.ts +3 -3
- package/src/errors/entrypoint.ts +2 -2
- package/src/errors/signer.ts +1 -1
- package/src/errors/useroperation.ts +6 -3
- package/src/index.ts +1 -0
- package/src/middleware/actions.ts +3 -3
- package/src/middleware/defaults/7702gasEstimator.ts +4 -4
- package/src/middleware/defaults/7702signer.ts +3 -3
- package/src/middleware/defaults/feeEstimator.ts +4 -4
- package/src/middleware/defaults/gasEstimator.ts +6 -6
- package/src/middleware/defaults/paymasterAndData.ts +1 -1
- package/src/middleware/defaults/userOpSigner.ts +2 -2
- package/src/middleware/erc7677middleware.ts +9 -9
- package/src/middleware/types.ts +7 -5
- package/src/signer/local-account.ts +7 -7
- package/src/signer/types.ts +3 -3
- package/src/signer/wallet-client.ts +2 -2
- package/src/transport/split.ts +1 -1
- package/src/types.ts +29 -29
- package/src/utils/bigint.ts +4 -4
- package/src/utils/defaults.ts +1 -1
- package/src/utils/index.ts +12 -9
- package/src/utils/schema.ts +2 -2
- package/src/utils/stateOverride.ts +4 -4
- package/src/utils/testUtils.ts +2 -2
- package/src/utils/traceHeader.ts +14 -11
- package/src/utils/types.ts +1 -1
- package/src/utils/userop.ts +17 -17
- package/src/version.ts +1 -1
package/src/types.ts
CHANGED
|
@@ -53,49 +53,49 @@ export type UserOperationFeeOptionsField = z.input<
|
|
|
53
53
|
>;
|
|
54
54
|
|
|
55
55
|
export type UserOperationFeeOptions<
|
|
56
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
56
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
57
57
|
> = TEntryPointVersion extends "0.6.0"
|
|
58
58
|
? z.input<typeof UserOperationFeeOptionsSchema_v6>
|
|
59
59
|
: TEntryPointVersion extends "0.7.0"
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
? z.input<typeof UserOperationFeeOptionsSchema_v7>
|
|
61
|
+
: z.input<typeof UserOperationFeeOptionsSchema>;
|
|
62
62
|
|
|
63
63
|
export type UserOperationOverridesParameter<
|
|
64
64
|
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
65
|
-
Required extends boolean = false
|
|
65
|
+
Required extends boolean = false,
|
|
66
66
|
> = Required extends true
|
|
67
67
|
? { overrides: UserOperationOverrides<TEntryPointVersion> }
|
|
68
68
|
: { overrides?: UserOperationOverrides<TEntryPointVersion> };
|
|
69
69
|
|
|
70
70
|
// [!region UserOperationPaymasterOverrides]
|
|
71
71
|
export type UserOperationPaymasterOverrides<
|
|
72
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
72
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
73
73
|
> = TEntryPointVersion extends "0.6.0"
|
|
74
74
|
? {
|
|
75
75
|
// paymasterData overrides to bypass paymaster middleware
|
|
76
76
|
paymasterAndData: Hex;
|
|
77
77
|
}
|
|
78
78
|
: TEntryPointVersion extends "0.7.0"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
79
|
+
? {
|
|
80
|
+
// paymasterData overrides to bypass paymaster middleware
|
|
81
|
+
// if set to '0x', all paymaster related fields are omitted from the user op request
|
|
82
|
+
paymasterData: Hex;
|
|
83
|
+
paymaster: Address;
|
|
84
|
+
paymasterVerificationGasLimit:
|
|
85
|
+
| NoUndefined<
|
|
86
|
+
UserOperationStruct<"0.7.0">["paymasterVerificationGasLimit"]
|
|
87
|
+
>
|
|
88
|
+
| Multiplier;
|
|
89
|
+
paymasterPostOpGasLimit:
|
|
90
|
+
| NoUndefined<UserOperationStruct<"0.7.0">["paymasterPostOpGasLimit"]>
|
|
91
|
+
| Multiplier;
|
|
92
|
+
}
|
|
93
|
+
: {};
|
|
94
94
|
// [!endregion UserOperationOverridesParameter]
|
|
95
95
|
|
|
96
96
|
// [!region UserOperationOverrides]
|
|
97
97
|
export type UserOperationOverrides<
|
|
98
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
98
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
99
99
|
> = Partial<
|
|
100
100
|
{
|
|
101
101
|
callGasLimit:
|
|
@@ -221,19 +221,19 @@ export type Eip7702ExtendedFields = {
|
|
|
221
221
|
// [!region UserOperationRequest]
|
|
222
222
|
// Reference: https://eips.ethereum.org/EIPS/eip-4337#definitions
|
|
223
223
|
export type UserOperationRequest<
|
|
224
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
224
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
225
225
|
> = (TEntryPointVersion extends "0.6.0"
|
|
226
226
|
? UserOperationRequest_v6
|
|
227
227
|
: TEntryPointVersion extends "0.7.0"
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
? UserOperationRequest_v7
|
|
229
|
+
: never) &
|
|
230
230
|
Eip7702ExtendedFields;
|
|
231
231
|
|
|
232
232
|
// [!endregion UserOperationRequest]
|
|
233
233
|
|
|
234
234
|
// [!region UserOperationEstimateGasResponse]
|
|
235
235
|
export interface UserOperationEstimateGasResponse<
|
|
236
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
236
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
237
237
|
> {
|
|
238
238
|
/* Gas overhead of this UserOperation */
|
|
239
239
|
preVerificationGas: BigNumberish;
|
|
@@ -254,7 +254,7 @@ export interface UserOperationEstimateGasResponse<
|
|
|
254
254
|
|
|
255
255
|
// [!region UserOperationResponse]
|
|
256
256
|
export interface UserOperationResponse<
|
|
257
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
257
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
258
258
|
> {
|
|
259
259
|
/* the User Operation */
|
|
260
260
|
userOperation: UserOperationRequest<TEntryPointVersion>;
|
|
@@ -364,11 +364,11 @@ export interface UserOperationStruct_v7 {
|
|
|
364
364
|
|
|
365
365
|
// [!region UserOperationStruct]
|
|
366
366
|
export type UserOperationStruct<
|
|
367
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
367
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
368
368
|
> = (TEntryPointVersion extends "0.6.0"
|
|
369
369
|
? UserOperationStruct_v6
|
|
370
370
|
: TEntryPointVersion extends "0.7.0"
|
|
371
|
-
|
|
372
|
-
|
|
371
|
+
? UserOperationStruct_v7
|
|
372
|
+
: never) &
|
|
373
373
|
Eip7702ExtendedFields;
|
|
374
374
|
// [!endregion UserOperationStruct]
|
package/src/utils/bigint.ts
CHANGED
|
@@ -41,14 +41,14 @@ export const bigIntMin = (...args: bigint[]): bigint => {
|
|
|
41
41
|
export const bigIntClamp = (
|
|
42
42
|
value: BigNumberish,
|
|
43
43
|
lower: BigNumberish | null | undefined,
|
|
44
|
-
upper: BigNumberish | null | undefined
|
|
44
|
+
upper: BigNumberish | null | undefined,
|
|
45
45
|
): bigint => {
|
|
46
46
|
lower = lower != null ? BigInt(lower) : null;
|
|
47
47
|
upper = upper != null ? BigInt(upper) : null;
|
|
48
48
|
|
|
49
49
|
if (upper != null && lower != null && upper < lower) {
|
|
50
50
|
throw new Error(
|
|
51
|
-
`invalid range: upper bound ${upper} is less than lower bound ${lower}
|
|
51
|
+
`invalid range: upper bound ${upper} is less than lower bound ${lower}`,
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -79,11 +79,11 @@ export enum RoundingMode {
|
|
|
79
79
|
export const bigIntMultiply = (
|
|
80
80
|
base: BigNumberish,
|
|
81
81
|
multiplier: Multiplier["multiplier"],
|
|
82
|
-
roundingMode: RoundingMode = RoundingMode.ROUND_UP
|
|
82
|
+
roundingMode: RoundingMode = RoundingMode.ROUND_UP,
|
|
83
83
|
) => {
|
|
84
84
|
if (!isMultiplier({ multiplier })) {
|
|
85
85
|
throw new Error(
|
|
86
|
-
"bigIntMultiply requires a multiplier validated number as the second argument"
|
|
86
|
+
"bigIntMultiply requires a multiplier validated number as the second argument",
|
|
87
87
|
);
|
|
88
88
|
}
|
|
89
89
|
|
package/src/utils/defaults.ts
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -46,7 +46,7 @@ export async function resolveProperties<T>(object: Deferrable<T>): Promise<T> {
|
|
|
46
46
|
results.reduce((accum, curr) => {
|
|
47
47
|
accum[curr.key as keyof T] = curr.value;
|
|
48
48
|
return accum;
|
|
49
|
-
}, {} as T)
|
|
49
|
+
}, {} as T),
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -75,7 +75,7 @@ export function deepHexlify(obj: any): any {
|
|
|
75
75
|
...set,
|
|
76
76
|
[key]: deepHexlify(obj[key]),
|
|
77
77
|
}),
|
|
78
|
-
{}
|
|
78
|
+
{},
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -151,7 +151,7 @@ export const allEqual = (...params: any[]): boolean => {
|
|
|
151
151
|
*/
|
|
152
152
|
export const conditionalReturn = <T>(
|
|
153
153
|
condition: Promise<boolean>,
|
|
154
|
-
value: () => Promise<T
|
|
154
|
+
value: () => Promise<T>,
|
|
155
155
|
): Promise<T | undefined> => condition.then((t) => (t ? value() : undefined));
|
|
156
156
|
|
|
157
157
|
/**
|
|
@@ -177,16 +177,19 @@ export const conditionalReturn = <T>(
|
|
|
177
177
|
export const toRecord = <
|
|
178
178
|
T extends { [K in RecordableKeys<T>]: string | number | symbol },
|
|
179
179
|
K extends RecordableKeys<T>,
|
|
180
|
-
V
|
|
180
|
+
V,
|
|
181
181
|
>(
|
|
182
182
|
array: T[],
|
|
183
183
|
selector: K,
|
|
184
|
-
fn: (item: T) => V
|
|
184
|
+
fn: (item: T) => V,
|
|
185
185
|
): Record<T[K], V> =>
|
|
186
|
-
array.reduce(
|
|
187
|
-
acc
|
|
188
|
-
|
|
189
|
-
|
|
186
|
+
array.reduce(
|
|
187
|
+
(acc, item) => {
|
|
188
|
+
acc[item[selector]] = fn(item);
|
|
189
|
+
return acc;
|
|
190
|
+
},
|
|
191
|
+
{} as Record<T[K], V>,
|
|
192
|
+
);
|
|
190
193
|
|
|
191
194
|
export * from "./bigint.js";
|
|
192
195
|
export * from "./bytes.js";
|
package/src/utils/schema.ts
CHANGED
|
@@ -7,7 +7,7 @@ export const ChainSchema = z.custom<Chain>(
|
|
|
7
7
|
chain != null &&
|
|
8
8
|
typeof chain === "object" &&
|
|
9
9
|
"id" in chain &&
|
|
10
|
-
typeof chain.id === "number"
|
|
10
|
+
typeof chain.id === "number",
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
export const HexSchema = z.custom<`0x${string}` | "0x">((val) => {
|
|
@@ -37,7 +37,7 @@ export const MultiplierSchema = z
|
|
|
37
37
|
(n) => {
|
|
38
38
|
return (n.toString().split(".")[1]?.length ?? 0) <= 4;
|
|
39
39
|
},
|
|
40
|
-
{ message: "Max precision is 4 decimal places" }
|
|
40
|
+
{ message: "Max precision is 4 decimal places" },
|
|
41
41
|
),
|
|
42
42
|
})
|
|
43
43
|
.strict();
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
type SerializeStateMappingParameters = StateMapping | undefined;
|
|
19
19
|
|
|
20
20
|
function serializeStateMapping(
|
|
21
|
-
stateMapping: SerializeStateMappingParameters
|
|
21
|
+
stateMapping: SerializeStateMappingParameters,
|
|
22
22
|
): RpcStateMapping | undefined {
|
|
23
23
|
if (!stateMapping || stateMapping.length === 0) return undefined;
|
|
24
24
|
return stateMapping.reduce((acc, { slot, value }) => {
|
|
@@ -33,7 +33,7 @@ function validateBytes32HexLength(value: Address): void {
|
|
|
33
33
|
if (value.length !== 66) {
|
|
34
34
|
// This is the error message from Viem's non-exported InvalidBytesLengthError.
|
|
35
35
|
throw new Error(
|
|
36
|
-
`Hex is expected to be 66 hex long, but is ${value.length} hex long
|
|
36
|
+
`Hex is expected to be 66 hex long, but is ${value.length} hex long.`,
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -44,7 +44,7 @@ type SerializeAccountStateOverrideParameters = Omit<
|
|
|
44
44
|
>;
|
|
45
45
|
|
|
46
46
|
function serializeAccountStateOverride(
|
|
47
|
-
parameters: SerializeAccountStateOverrideParameters
|
|
47
|
+
parameters: SerializeAccountStateOverrideParameters,
|
|
48
48
|
): RpcAccountStateOverride {
|
|
49
49
|
const { balance, nonce, state, stateDiff, code } = parameters;
|
|
50
50
|
const rpcAccountStateOverride: RpcAccountStateOverride = {};
|
|
@@ -65,7 +65,7 @@ type SerializeStateOverrideParameters = StateOverride | undefined;
|
|
|
65
65
|
|
|
66
66
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
67
67
|
export function serializeStateOverride(
|
|
68
|
-
parameters?: SerializeStateOverrideParameters
|
|
68
|
+
parameters?: SerializeStateOverrideParameters,
|
|
69
69
|
): RpcStateOverride | undefined {
|
|
70
70
|
if (!parameters) return undefined;
|
|
71
71
|
const rpcStateOverride: RpcStateOverride = {};
|
package/src/utils/testUtils.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { getEntryPoint } from "../entrypoint/index.js";
|
|
|
11
11
|
import type { DefaultEntryPointVersion } from "../entrypoint/types.js";
|
|
12
12
|
|
|
13
13
|
export const createDummySmartContractAccount = async <C extends BundlerClient>(
|
|
14
|
-
client: C
|
|
14
|
+
client: C,
|
|
15
15
|
): Promise<SmartContractAccount<"dummy", DefaultEntryPointVersion>> => {
|
|
16
16
|
return toSmartContractAccount({
|
|
17
17
|
source: "dummy",
|
|
@@ -37,6 +37,6 @@ export const createTestClient = (chain: Chain) => {
|
|
|
37
37
|
transport: custom({
|
|
38
38
|
request: async () => {},
|
|
39
39
|
}),
|
|
40
|
-
})
|
|
40
|
+
}),
|
|
41
41
|
);
|
|
42
42
|
};
|
package/src/utils/traceHeader.ts
CHANGED
|
@@ -2,7 +2,7 @@ function generateRandomHexString(numBytes: number) {
|
|
|
2
2
|
const hexPairs = new Array(numBytes).fill(0).map(() =>
|
|
3
3
|
Math.floor(Math.random() * 16)
|
|
4
4
|
.toString(16)
|
|
5
|
-
.padStart(2, "0")
|
|
5
|
+
.padStart(2, "0"),
|
|
6
6
|
);
|
|
7
7
|
return hexPairs.join("");
|
|
8
8
|
}
|
|
@@ -46,7 +46,7 @@ export class TraceHeader {
|
|
|
46
46
|
traceId: string,
|
|
47
47
|
parentId: string,
|
|
48
48
|
traceFlags: string,
|
|
49
|
-
traceState: TraceHeader["traceState"]
|
|
49
|
+
traceState: TraceHeader["traceState"],
|
|
50
50
|
) {
|
|
51
51
|
this.traceId = traceId;
|
|
52
52
|
this.parentId = parentId;
|
|
@@ -68,7 +68,7 @@ export class TraceHeader {
|
|
|
68
68
|
clientTraceId,
|
|
69
69
|
generateRandomHexString(8),
|
|
70
70
|
"00", //Means no flag have been set, and no sampled state https://www.w3.org/TR/trace-context/#trace-flags
|
|
71
|
-
{}
|
|
71
|
+
{},
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
@@ -82,7 +82,7 @@ export class TraceHeader {
|
|
|
82
82
|
* @returns {TraceHeader | undefined} The trace header object, or nothing if not found
|
|
83
83
|
*/
|
|
84
84
|
static fromTraceHeader(
|
|
85
|
-
headers: Record<string, string
|
|
85
|
+
headers: Record<string, string>,
|
|
86
86
|
): TraceHeader | undefined {
|
|
87
87
|
if (!headers[TRACE_HEADER_NAME]) {
|
|
88
88
|
return undefined;
|
|
@@ -91,16 +91,19 @@ export class TraceHeader {
|
|
|
91
91
|
headers[TRACE_HEADER_NAME]?.split("-");
|
|
92
92
|
|
|
93
93
|
const traceState =
|
|
94
|
-
headers[TRACE_HEADER_STATE]?.split(",").reduce(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
headers[TRACE_HEADER_STATE]?.split(",").reduce(
|
|
95
|
+
(acc, curr) => {
|
|
96
|
+
const [key, value] = curr.split("=");
|
|
97
|
+
acc[key] = value;
|
|
98
|
+
return acc;
|
|
99
|
+
},
|
|
100
|
+
{} as Record<string, string>,
|
|
101
|
+
) || {};
|
|
99
102
|
if (version !== "00") {
|
|
100
103
|
console.debug(
|
|
101
104
|
new Error(
|
|
102
|
-
`Invalid version for traceheader: ${headers[TRACE_HEADER_NAME]}
|
|
103
|
-
)
|
|
105
|
+
`Invalid version for traceheader: ${headers[TRACE_HEADER_NAME]}`,
|
|
106
|
+
),
|
|
104
107
|
);
|
|
105
108
|
return undefined;
|
|
106
109
|
}
|
package/src/utils/types.ts
CHANGED
|
@@ -62,7 +62,7 @@ export type EqualsOneOfTheComponents<T, Union> = Union extends infer Component /
|
|
|
62
62
|
export type IsMemberOrSubtypeOfAComponent<
|
|
63
63
|
T,
|
|
64
64
|
Union,
|
|
65
|
-
ConjunctionOfExplicitComponentChecks extends boolean
|
|
65
|
+
ConjunctionOfExplicitComponentChecks extends boolean,
|
|
66
66
|
> = [T] extends [Union]
|
|
67
67
|
? true extends ConjunctionOfExplicitComponentChecks
|
|
68
68
|
? true
|
package/src/utils/userop.ts
CHANGED
|
@@ -20,9 +20,9 @@ import { allEqual, isBigNumberish } from "./index.js";
|
|
|
20
20
|
* @returns {boolean} a type guard that asserts the UserOperationRequest is valid
|
|
21
21
|
*/
|
|
22
22
|
export function isValidRequest<
|
|
23
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
23
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
24
24
|
>(
|
|
25
|
-
request: UserOperationStruct<TEntryPointVersion
|
|
25
|
+
request: UserOperationStruct<TEntryPointVersion>,
|
|
26
26
|
): request is UserOperationRequest<TEntryPointVersion> {
|
|
27
27
|
// These are the only ones marked as optional in the interface above
|
|
28
28
|
return (
|
|
@@ -43,7 +43,7 @@ export function isValidRequest<
|
|
|
43
43
|
* @returns {boolean} a type guard that asserts the UserOperationRequest is a UserOperationRequest
|
|
44
44
|
*/
|
|
45
45
|
export function isValidPaymasterAndData<
|
|
46
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
46
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
47
47
|
>(request: UserOperationStruct<TEntryPointVersion>): boolean {
|
|
48
48
|
if ("paymasterAndData" in request) {
|
|
49
49
|
return (request as UserOperationStruct_v6).paymasterAndData != null;
|
|
@@ -54,7 +54,7 @@ export function isValidPaymasterAndData<
|
|
|
54
54
|
(request as UserOperationStruct_v7).paymaster == null,
|
|
55
55
|
(request as UserOperationStruct_v7).paymasterData == null,
|
|
56
56
|
(request as UserOperationStruct_v7).paymasterPostOpGasLimit == null,
|
|
57
|
-
(request as UserOperationStruct_v7).paymasterVerificationGasLimit == null
|
|
57
|
+
(request as UserOperationStruct_v7).paymasterVerificationGasLimit == null,
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -65,7 +65,7 @@ export function isValidPaymasterAndData<
|
|
|
65
65
|
* @returns {boolean} a type guard that asserts the UserOperationStruct is a UserOperationRequest
|
|
66
66
|
*/
|
|
67
67
|
export function isValidFactoryAndData<
|
|
68
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
68
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
69
69
|
>(request: UserOperationStruct<TEntryPointVersion>): boolean {
|
|
70
70
|
if ("initCode" in request) {
|
|
71
71
|
const { initCode } = request as UserOperationStruct_v6;
|
|
@@ -75,7 +75,7 @@ export function isValidFactoryAndData<
|
|
|
75
75
|
// either all exist, or none.
|
|
76
76
|
return allEqual(
|
|
77
77
|
(request as UserOperationStruct_v7).factory == null,
|
|
78
|
-
(request as UserOperationStruct_v7).factoryData == null
|
|
78
|
+
(request as UserOperationStruct_v7).factoryData == null,
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -89,7 +89,7 @@ export function isValidFactoryAndData<
|
|
|
89
89
|
*/
|
|
90
90
|
export function applyUserOpOverride<TValue extends BigNumberish | undefined>(
|
|
91
91
|
value: TValue,
|
|
92
|
-
override?: BigNumberish | Multiplier
|
|
92
|
+
override?: BigNumberish | Multiplier,
|
|
93
93
|
): TValue | BigNumberish {
|
|
94
94
|
if (override == null) {
|
|
95
95
|
return value;
|
|
@@ -115,7 +115,7 @@ export function applyUserOpOverride<TValue extends BigNumberish | undefined>(
|
|
|
115
115
|
*/
|
|
116
116
|
export function applyUserOpFeeOption<TValue extends BigNumberish | undefined>(
|
|
117
117
|
value: TValue,
|
|
118
|
-
feeOption?: UserOperationFeeOptionsField
|
|
118
|
+
feeOption?: UserOperationFeeOptionsField,
|
|
119
119
|
): TValue | BigNumberish {
|
|
120
120
|
if (feeOption == null) {
|
|
121
121
|
return value;
|
|
@@ -127,9 +127,9 @@ export function applyUserOpFeeOption<TValue extends BigNumberish | undefined>(
|
|
|
127
127
|
? bigIntMultiply(value, feeOption.multiplier)
|
|
128
128
|
: value,
|
|
129
129
|
feeOption.min,
|
|
130
|
-
feeOption.max
|
|
130
|
+
feeOption.max,
|
|
131
131
|
)
|
|
132
|
-
: feeOption.min ?? 0n;
|
|
132
|
+
: (feeOption.min ?? 0n);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/**
|
|
@@ -143,11 +143,11 @@ export function applyUserOpFeeOption<TValue extends BigNumberish | undefined>(
|
|
|
143
143
|
* @returns {BigNumberish} the new value of the field after applying the override or fee option
|
|
144
144
|
*/
|
|
145
145
|
export function applyUserOpOverrideOrFeeOption<
|
|
146
|
-
TValue extends BigNumberish | undefined
|
|
146
|
+
TValue extends BigNumberish | undefined,
|
|
147
147
|
>(
|
|
148
148
|
value: TValue,
|
|
149
149
|
override?: BigNumberish | Multiplier,
|
|
150
|
-
feeOption?: UserOperationFeeOptionsField
|
|
150
|
+
feeOption?: UserOperationFeeOptionsField,
|
|
151
151
|
): TValue | BigNumberish {
|
|
152
152
|
return value != null && override != null
|
|
153
153
|
? applyUserOpOverride(value, override)!
|
|
@@ -164,9 +164,9 @@ export function applyUserOpOverrideOrFeeOption<
|
|
|
164
164
|
* @returns {boolean} whether the paymaster middleware should be bypassed
|
|
165
165
|
*/
|
|
166
166
|
export const bypassPaymasterAndData = <
|
|
167
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
167
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
168
168
|
>(
|
|
169
|
-
overrides: UserOperationOverrides<TEntryPointVersion> | undefined
|
|
169
|
+
overrides: UserOperationOverrides<TEntryPointVersion> | undefined,
|
|
170
170
|
): boolean =>
|
|
171
171
|
!!overrides &&
|
|
172
172
|
("paymasterAndData" in overrides || "paymasterData" in overrides);
|
|
@@ -181,9 +181,9 @@ export const bypassPaymasterAndData = <
|
|
|
181
181
|
* @returns {boolean} whether the paymaster middleware should be bypassed
|
|
182
182
|
*/
|
|
183
183
|
export const bypassPaymasterAndDataEmptyHex = <
|
|
184
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
184
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
185
185
|
>(
|
|
186
|
-
overrides: UserOperationOverrides<TEntryPointVersion> | undefined
|
|
186
|
+
overrides: UserOperationOverrides<TEntryPointVersion> | undefined,
|
|
187
187
|
): boolean =>
|
|
188
188
|
overrides !== undefined &&
|
|
189
189
|
(("paymasterAndData" in overrides && overrides.paymasterAndData === "0x") ||
|
|
@@ -197,7 +197,7 @@ export const bypassPaymasterAndDataEmptyHex = <
|
|
|
197
197
|
* @returns {{ paymaster: Hex; paymasterData: Hex}} the parsed paymaster and paymasterData fields of entrypoint v0.7 user operation request paymaster and paymasterData field
|
|
198
198
|
*/
|
|
199
199
|
export const parsePaymasterAndData = (
|
|
200
|
-
paymasterAndData: Hex
|
|
200
|
+
paymasterAndData: Hex,
|
|
201
201
|
): Pick<UserOperationRequest<"0.7.0">, "paymaster" | "paymasterData"> => ({
|
|
202
202
|
paymaster: paymasterAndData.substring(0, 42) as Address,
|
|
203
203
|
paymasterData: `0x${paymasterAndData.substring(42)}` as Hex,
|
package/src/version.ts
CHANGED