@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/entrypoint/types.ts
CHANGED
|
@@ -23,7 +23,7 @@ export type DefaultEntryPointVersion = OneOf<"0.6.0", EntryPointVersion>;
|
|
|
23
23
|
export type SupportedEntryPoint<
|
|
24
24
|
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
25
25
|
TChain extends Chain = Chain,
|
|
26
|
-
TAbi extends Abi | readonly unknown[] = Abi
|
|
26
|
+
TAbi extends Abi | readonly unknown[] = Abi,
|
|
27
27
|
> = {
|
|
28
28
|
version: TEntryPointVersion;
|
|
29
29
|
address: Record<TChain["id"] | "default", Address>;
|
|
@@ -40,7 +40,7 @@ export type SupportedEntryPoint<
|
|
|
40
40
|
getUserOperationHash: (
|
|
41
41
|
request: UserOperationRequest<TEntryPointVersion>,
|
|
42
42
|
entryPointAddress: Address,
|
|
43
|
-
chainId: number
|
|
43
|
+
chainId: number,
|
|
44
44
|
) => Hash;
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -53,7 +53,7 @@ export type SupportedEntryPoint<
|
|
|
53
53
|
* @returns the hash of the UserOperation
|
|
54
54
|
*/
|
|
55
55
|
packUserOperation: (
|
|
56
|
-
userOperation: UserOperationRequest<TEntryPointVersion
|
|
56
|
+
userOperation: UserOperationRequest<TEntryPointVersion>,
|
|
57
57
|
) => Hex;
|
|
58
58
|
};
|
|
59
59
|
|
|
@@ -69,17 +69,17 @@ export interface EntryPointRegistry<TChain extends Chain = Chain>
|
|
|
69
69
|
export type EntryPointDef<
|
|
70
70
|
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
71
71
|
TChain extends Chain = Chain,
|
|
72
|
-
TAbi extends Abi | readonly unknown[] = Abi
|
|
72
|
+
TAbi extends Abi | readonly unknown[] = Abi,
|
|
73
73
|
> = {
|
|
74
74
|
version: TEntryPointVersion;
|
|
75
75
|
address: Address;
|
|
76
76
|
chain: TChain;
|
|
77
77
|
abi: GetContractParameters<Transport, TChain, Account, TAbi>["abi"];
|
|
78
78
|
getUserOperationHash: (
|
|
79
|
-
request: UserOperationRequest<TEntryPointVersion
|
|
79
|
+
request: UserOperationRequest<TEntryPointVersion>,
|
|
80
80
|
) => Hex;
|
|
81
81
|
packUserOperation: (
|
|
82
|
-
userOperation: UserOperationRequest<TEntryPointVersion
|
|
82
|
+
userOperation: UserOperationRequest<TEntryPointVersion>,
|
|
83
83
|
) => Hex;
|
|
84
84
|
};
|
|
85
85
|
// [!endregion EntryPointDef]
|
|
@@ -93,28 +93,30 @@ export interface EntryPointDefRegistry<TChain extends Chain = Chain>
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
export type GetEntryPointOptions<
|
|
96
|
-
TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion
|
|
97
|
-
> =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
96
|
+
TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion,
|
|
97
|
+
> =
|
|
98
|
+
EQ<TEntryPointVersion, DefaultEntryPointVersion> extends true
|
|
99
|
+
?
|
|
100
|
+
| {
|
|
101
|
+
addressOverride?: Address;
|
|
102
|
+
version?: OneOf<TEntryPointVersion, EntryPointVersion>;
|
|
103
|
+
}
|
|
104
|
+
| undefined
|
|
105
|
+
: {
|
|
106
|
+
addressOverride?: Address;
|
|
107
|
+
version: OneOf<TEntryPointVersion, EntryPointVersion>;
|
|
108
|
+
};
|
|
108
109
|
|
|
109
110
|
export type EntryPointParameter<
|
|
110
111
|
TEntryPointVersion extends EntryPointVersion,
|
|
111
|
-
TChain extends Chain = Chain
|
|
112
|
-
> =
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
TChain extends Chain = Chain,
|
|
113
|
+
> =
|
|
114
|
+
EQ<TEntryPointVersion, DefaultEntryPointVersion> extends true
|
|
115
|
+
? {
|
|
116
|
+
entryPoint?: EntryPointDef<TEntryPointVersion, TChain>;
|
|
117
|
+
}
|
|
118
|
+
: {
|
|
119
|
+
entryPoint: IsOneOf<TEntryPointVersion, EntryPointVersion> extends true
|
|
120
|
+
? EntryPointDef<TEntryPointVersion, TChain>
|
|
121
|
+
: never;
|
|
122
|
+
};
|
package/src/errors/account.ts
CHANGED
|
@@ -36,7 +36,7 @@ export class DefaultFactoryNotDefinedError extends BaseError {
|
|
|
36
36
|
[
|
|
37
37
|
`No default factory for ${accountType} found on chain ${chain.name} for entrypoint version ${version}`,
|
|
38
38
|
"Supply an override via the `factoryAddress` parameter when creating an account",
|
|
39
|
-
].join("\n")
|
|
39
|
+
].join("\n"),
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/errors/client.ts
CHANGED
|
@@ -19,7 +19,7 @@ export class IncompatibleClientError extends BaseError {
|
|
|
19
19
|
[
|
|
20
20
|
`Client of type (${client.type}) is not a ${expectedClient}.`,
|
|
21
21
|
`Create one with \`createSmartAccountClient\` first before using \`${method}\``,
|
|
22
|
-
].join("\n")
|
|
22
|
+
].join("\n"),
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -67,7 +67,7 @@ export class InvalidEntityIdError extends BaseError {
|
|
|
67
67
|
*/
|
|
68
68
|
constructor(entityId: number) {
|
|
69
69
|
super(
|
|
70
|
-
`Entity ID used is ${entityId}, but must be less than or equal to uint32.max
|
|
70
|
+
`Entity ID used is ${entityId}, but must be less than or equal to uint32.max`,
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -85,7 +85,7 @@ export class InvalidNonceKeyError extends BaseError {
|
|
|
85
85
|
*/
|
|
86
86
|
constructor(nonceKey: bigint) {
|
|
87
87
|
super(
|
|
88
|
-
`Nonce key is ${nonceKey} but has to be less than or equal to 2**152
|
|
88
|
+
`Nonce key is ${nonceKey} but has to be less than or equal to 2**152`,
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
91
|
}
|
package/src/errors/entrypoint.ts
CHANGED
|
@@ -18,7 +18,7 @@ export class EntryPointNotFoundError extends BaseError {
|
|
|
18
18
|
[
|
|
19
19
|
`No default entry point v${entryPointVersion} exists for ${chain.name}.`,
|
|
20
20
|
`Supply an override.`,
|
|
21
|
-
].join("\n")
|
|
21
|
+
].join("\n"),
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -37,7 +37,7 @@ export class InvalidEntryPointError extends BaseError {
|
|
|
37
37
|
*/
|
|
38
38
|
constructor(chain: Chain, entryPointVersion: any) {
|
|
39
39
|
super(
|
|
40
|
-
`Invalid entry point: unexpected version ${entryPointVersion} for ${chain.name}
|
|
40
|
+
`Invalid entry point: unexpected version ${entryPointVersion} for ${chain.name}.`,
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/errors/signer.ts
CHANGED
|
@@ -30,8 +30,8 @@ export class InvalidUserOperationError extends BaseError {
|
|
|
30
30
|
value: value.toString(),
|
|
31
31
|
}
|
|
32
32
|
: value,
|
|
33
|
-
2
|
|
34
|
-
)}
|
|
33
|
+
2,
|
|
34
|
+
)}`,
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -47,7 +47,10 @@ export class WaitForUserOperationError extends BaseError {
|
|
|
47
47
|
* @param {UserOperationRequest} request the user operation request that failed
|
|
48
48
|
* @param {Error} error the underlying error that caused the failure
|
|
49
49
|
*/
|
|
50
|
-
constructor(
|
|
50
|
+
constructor(
|
|
51
|
+
public request: UserOperationRequest,
|
|
52
|
+
error: Error,
|
|
53
|
+
) {
|
|
51
54
|
super(`Failed to find User Operation: ${error.message}`);
|
|
52
55
|
}
|
|
53
56
|
}
|
package/src/index.ts
CHANGED
|
@@ -30,7 +30,7 @@ export type MiddlewareClient<
|
|
|
30
30
|
TChain extends Chain | undefined = Chain | undefined,
|
|
31
31
|
TAccount extends SmartContractAccount | undefined =
|
|
32
32
|
| SmartContractAccount
|
|
33
|
-
| undefined
|
|
33
|
+
| undefined,
|
|
34
34
|
> = Client<
|
|
35
35
|
TTransport,
|
|
36
36
|
TChain,
|
|
@@ -53,9 +53,9 @@ export const middlewareActions =
|
|
|
53
53
|
TChain extends Chain | undefined = Chain | undefined,
|
|
54
54
|
TAccount extends SmartContractAccount | undefined =
|
|
55
55
|
| SmartContractAccount
|
|
56
|
-
| undefined
|
|
56
|
+
| undefined,
|
|
57
57
|
>(
|
|
58
|
-
client: MiddlewareClient<TTransport, TChain, TAccount
|
|
58
|
+
client: MiddlewareClient<TTransport, TChain, TAccount>,
|
|
59
59
|
): { middleware: ClientMiddleware } => ({
|
|
60
60
|
middleware: {
|
|
61
61
|
customMiddleware: overrides.customMiddleware ?? noopMiddleware,
|
|
@@ -35,11 +35,11 @@ import { defaultGasEstimator } from "./gasEstimator.js";
|
|
|
35
35
|
* }
|
|
36
36
|
* ```
|
|
37
37
|
*
|
|
38
|
-
* @param {ClientMiddlewareFn}
|
|
39
|
-
* @returns {
|
|
38
|
+
* @param {ClientMiddlewareFn} gasEstimator Optional custom gas estimator function
|
|
39
|
+
* @returns {ClientMiddlewareFn} A function that takes user operation struct and parameters, estimates gas usage, and returns the user operation with gas limits.
|
|
40
40
|
*/
|
|
41
41
|
export const default7702GasEstimator: (
|
|
42
|
-
gasEstimator?: ClientMiddlewareFn
|
|
42
|
+
gasEstimator?: ClientMiddlewareFn,
|
|
43
43
|
) => ClientMiddlewareFn =
|
|
44
44
|
(gasEstimator?: ClientMiddlewareFn) => async (struct, params) => {
|
|
45
45
|
const gasEstimator_ = gasEstimator ?? defaultGasEstimator(params.client);
|
|
@@ -52,7 +52,7 @@ export const default7702GasEstimator: (
|
|
|
52
52
|
const entryPoint = account.getEntryPoint();
|
|
53
53
|
if (entryPoint.version !== "0.7.0") {
|
|
54
54
|
throw new Error(
|
|
55
|
-
"This middleware is only compatible with EntryPoint v0.7.0"
|
|
55
|
+
"This middleware is only compatible with EntryPoint v0.7.0",
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -38,10 +38,10 @@ import { defaultUserOpSigner } from "./userOpSigner.js";
|
|
|
38
38
|
* ```
|
|
39
39
|
*
|
|
40
40
|
* @param {ClientMiddlewareFn} [userOpSigner] Optional user operation signer function
|
|
41
|
-
* @returns {
|
|
41
|
+
* @returns {ClientMiddlewareFn} A middleware function that signs EIP-7702 authorization tuples if necessary, and also uses the provided or default user operation signer to generate the user op signature.
|
|
42
42
|
*/
|
|
43
43
|
export const default7702UserOpSigner: (
|
|
44
|
-
userOpSigner?: ClientMiddlewareFn
|
|
44
|
+
userOpSigner?: ClientMiddlewareFn,
|
|
45
45
|
) => ClientMiddlewareFn =
|
|
46
46
|
(userOpSigner?: ClientMiddlewareFn) => async (struct, params) => {
|
|
47
47
|
const userOpSigner_ = userOpSigner ?? defaultUserOpSigner;
|
|
@@ -52,7 +52,7 @@ export const default7702UserOpSigner: (
|
|
|
52
52
|
// Strip out the dummy eip7702 fields.
|
|
53
53
|
eip7702Auth: undefined,
|
|
54
54
|
},
|
|
55
|
-
params
|
|
55
|
+
params,
|
|
56
56
|
);
|
|
57
57
|
|
|
58
58
|
const account = params.account ?? params.client.account;
|
|
@@ -24,7 +24,7 @@ import type { ClientMiddlewareFn } from "../types";
|
|
|
24
24
|
* @returns {ClientMiddlewareFn} A middleware function that takes in the struct and options, estimates the fees, and updates the struct with the estimated fees
|
|
25
25
|
*/
|
|
26
26
|
export function defaultFeeEstimator<C extends MiddlewareClient>(
|
|
27
|
-
client: C
|
|
27
|
+
client: C,
|
|
28
28
|
): ClientMiddlewareFn {
|
|
29
29
|
return async (struct, { overrides, feeOptions }) => {
|
|
30
30
|
// maxFeePerGas must be at least the sum of maxPriorityFeePerGas and baseFee
|
|
@@ -39,7 +39,7 @@ export function defaultFeeEstimator<C extends MiddlewareClient>(
|
|
|
39
39
|
const feeData = await client.estimateFeesPerGas();
|
|
40
40
|
if (!feeData.maxFeePerGas || feeData.maxPriorityFeePerGas == null) {
|
|
41
41
|
throw new Error(
|
|
42
|
-
"feeData is missing maxFeePerGas or maxPriorityFeePerGas"
|
|
42
|
+
"feeData is missing maxFeePerGas or maxPriorityFeePerGas",
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -49,7 +49,7 @@ export function defaultFeeEstimator<C extends MiddlewareClient>(
|
|
|
49
49
|
maxPriorityFeePerGas = applyUserOpOverrideOrFeeOption(
|
|
50
50
|
maxPriorityFeePerGas,
|
|
51
51
|
overrides?.maxPriorityFeePerGas,
|
|
52
|
-
feeOptions?.maxPriorityFeePerGas
|
|
52
|
+
feeOptions?.maxPriorityFeePerGas,
|
|
53
53
|
);
|
|
54
54
|
|
|
55
55
|
let maxFeePerGas: BigNumberish =
|
|
@@ -60,7 +60,7 @@ export function defaultFeeEstimator<C extends MiddlewareClient>(
|
|
|
60
60
|
maxFeePerGas = applyUserOpOverrideOrFeeOption(
|
|
61
61
|
maxFeePerGas,
|
|
62
62
|
overrides?.maxFeePerGas,
|
|
63
|
-
feeOptions?.maxFeePerGas
|
|
63
|
+
feeOptions?.maxFeePerGas,
|
|
64
64
|
);
|
|
65
65
|
|
|
66
66
|
struct.maxFeePerGas = maxFeePerGas;
|
|
@@ -17,7 +17,7 @@ import type { ClientMiddlewareFn } from "../types.js";
|
|
|
17
17
|
* @returns {ClientMiddlewareFn} middleware execution function used to estimate gas for user operations
|
|
18
18
|
*/
|
|
19
19
|
export const defaultGasEstimator: <C extends MiddlewareClient>(
|
|
20
|
-
client: C
|
|
20
|
+
client: C,
|
|
21
21
|
) => ClientMiddlewareFn =
|
|
22
22
|
(client: MiddlewareClient): ClientMiddlewareFn =>
|
|
23
23
|
async (struct, { account, overrides, feeOptions }) => {
|
|
@@ -26,23 +26,23 @@ export const defaultGasEstimator: <C extends MiddlewareClient>(
|
|
|
26
26
|
const estimates = await client.estimateUserOperationGas(
|
|
27
27
|
request,
|
|
28
28
|
account.getEntryPoint().address,
|
|
29
|
-
overrides?.stateOverride
|
|
29
|
+
overrides?.stateOverride,
|
|
30
30
|
);
|
|
31
31
|
|
|
32
32
|
const callGasLimit = applyUserOpOverrideOrFeeOption(
|
|
33
33
|
estimates.callGasLimit,
|
|
34
34
|
overrides?.callGasLimit,
|
|
35
|
-
feeOptions?.callGasLimit
|
|
35
|
+
feeOptions?.callGasLimit,
|
|
36
36
|
);
|
|
37
37
|
const verificationGasLimit = applyUserOpOverrideOrFeeOption(
|
|
38
38
|
estimates.verificationGasLimit,
|
|
39
39
|
overrides?.verificationGasLimit,
|
|
40
|
-
feeOptions?.verificationGasLimit
|
|
40
|
+
feeOptions?.verificationGasLimit,
|
|
41
41
|
);
|
|
42
42
|
const preVerificationGas = applyUserOpOverrideOrFeeOption(
|
|
43
43
|
estimates.preVerificationGas,
|
|
44
44
|
overrides?.preVerificationGas,
|
|
45
|
-
feeOptions?.preVerificationGas
|
|
45
|
+
feeOptions?.preVerificationGas,
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
struct.callGasLimit = callGasLimit;
|
|
@@ -56,7 +56,7 @@ export const defaultGasEstimator: <C extends MiddlewareClient>(
|
|
|
56
56
|
(overrides as UserOperationOverrides<"0.7.0">)
|
|
57
57
|
?.paymasterVerificationGasLimit,
|
|
58
58
|
(feeOptions as UserOperationFeeOptions<"0.7.0">)
|
|
59
|
-
?.paymasterVerificationGasLimit
|
|
59
|
+
?.paymasterVerificationGasLimit,
|
|
60
60
|
);
|
|
61
61
|
const uo_v7 = struct as UserOperationStruct<"0.7.0">;
|
|
62
62
|
|
|
@@ -11,7 +11,7 @@ import type { ClientMiddlewareFn } from "../types";
|
|
|
11
11
|
*/
|
|
12
12
|
export const defaultPaymasterAndData: ClientMiddlewareFn = async (
|
|
13
13
|
struct,
|
|
14
|
-
{ account }
|
|
14
|
+
{ account },
|
|
15
15
|
) => {
|
|
16
16
|
const entryPoint = account.getEntryPoint();
|
|
17
17
|
if (entryPoint.version === "0.6.0") {
|
|
@@ -20,7 +20,7 @@ import type { ClientMiddlewareFn } from "../types";
|
|
|
20
20
|
*/
|
|
21
21
|
export const defaultUserOpSigner: ClientMiddlewareFn = async (
|
|
22
22
|
struct,
|
|
23
|
-
{ client, account = client.account }
|
|
23
|
+
{ client, account = client.account },
|
|
24
24
|
) => {
|
|
25
25
|
if (!account) {
|
|
26
26
|
throw new AccountNotFoundError();
|
|
@@ -39,7 +39,7 @@ export const defaultUserOpSigner: ClientMiddlewareFn = async (
|
|
|
39
39
|
return {
|
|
40
40
|
...resolvedStruct,
|
|
41
41
|
signature: await account.signUserOperationHash(
|
|
42
|
-
account.getEntryPoint().getUserOperationHash(request)
|
|
42
|
+
account.getEntryPoint().getUserOperationHash(request),
|
|
43
43
|
),
|
|
44
44
|
};
|
|
45
45
|
};
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import type { ClientMiddlewareFn } from "./types";
|
|
24
24
|
|
|
25
25
|
export type Erc7677RpcSchema<
|
|
26
|
-
TContext extends Record<string, any> = Record<string, any
|
|
26
|
+
TContext extends Record<string, any> = Record<string, any>,
|
|
27
27
|
> = [
|
|
28
28
|
{
|
|
29
29
|
Method: "pm_getPaymasterStubData";
|
|
@@ -46,19 +46,19 @@ export type Erc7677RpcSchema<
|
|
|
46
46
|
paymasterData?: Hex; // Paymaster data (entrypoint v0.7)
|
|
47
47
|
paymasterAndData?: Hex; // Paymaster and data (entrypoint v0.6)
|
|
48
48
|
};
|
|
49
|
-
}
|
|
49
|
+
},
|
|
50
50
|
];
|
|
51
51
|
|
|
52
52
|
export type Erc7677Client<
|
|
53
53
|
T extends Transport = Transport,
|
|
54
|
-
TContext extends Record<string, any> = Record<string, any
|
|
54
|
+
TContext extends Record<string, any> = Record<string, any>,
|
|
55
55
|
> = Client<T, Chain, undefined, Erc7677RpcSchema<TContext>>;
|
|
56
56
|
|
|
57
57
|
export type Erc7677MiddlewareParams<
|
|
58
58
|
TContext extends Record<string, any> | undefined =
|
|
59
59
|
| Record<string, any>
|
|
60
60
|
| undefined,
|
|
61
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
61
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
62
62
|
> = {
|
|
63
63
|
context?:
|
|
64
64
|
| ((
|
|
@@ -66,7 +66,7 @@ export type Erc7677MiddlewareParams<
|
|
|
66
66
|
args: {
|
|
67
67
|
overrides?: UserOperationOverrides<TEntryPointVersion>;
|
|
68
68
|
feeOptions?: UserOperationFeeOptions;
|
|
69
|
-
}
|
|
69
|
+
},
|
|
70
70
|
) => Promise<TContext>)
|
|
71
71
|
| TContext;
|
|
72
72
|
};
|
|
@@ -95,15 +95,15 @@ export type Erc7677MiddlewareParams<
|
|
|
95
95
|
export function erc7677Middleware<
|
|
96
96
|
TContext extends Record<string, any> | undefined =
|
|
97
97
|
| Record<string, any>
|
|
98
|
-
| undefined
|
|
98
|
+
| undefined,
|
|
99
99
|
>(
|
|
100
|
-
params?: Erc7677MiddlewareParams<TContext
|
|
100
|
+
params?: Erc7677MiddlewareParams<TContext>,
|
|
101
101
|
): Required<
|
|
102
102
|
Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">
|
|
103
103
|
> {
|
|
104
104
|
const dummyPaymasterAndData: ClientMiddlewareFn = async (
|
|
105
105
|
uo,
|
|
106
|
-
{ client, account, feeOptions, overrides }
|
|
106
|
+
{ client, account, feeOptions, overrides },
|
|
107
107
|
) => {
|
|
108
108
|
const userOp = deepHexlify(await resolveProperties(uo));
|
|
109
109
|
|
|
@@ -161,7 +161,7 @@ export function erc7677Middleware<
|
|
|
161
161
|
|
|
162
162
|
const paymasterAndData: ClientMiddlewareFn = async (
|
|
163
163
|
uo,
|
|
164
|
-
{ client, account, feeOptions, overrides }
|
|
164
|
+
{ client, account, feeOptions, overrides },
|
|
165
165
|
) => {
|
|
166
166
|
const userOp = deepHexlify(await resolveProperties(uo));
|
|
167
167
|
const context =
|
package/src/middleware/types.ts
CHANGED
|
@@ -17,7 +17,8 @@ export type ClientMiddlewareArgs<
|
|
|
17
17
|
TContext extends UserOperationContext | undefined =
|
|
18
18
|
| UserOperationContext
|
|
19
19
|
| undefined,
|
|
20
|
-
TEntryPointVersion extends
|
|
20
|
+
TEntryPointVersion extends
|
|
21
|
+
GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,
|
|
21
22
|
> = {
|
|
22
23
|
overrides?: UserOperationOverrides<TEntryPointVersion>;
|
|
23
24
|
context?: TContext;
|
|
@@ -30,14 +31,15 @@ export type ClientMiddlewareArgs<
|
|
|
30
31
|
export type ClientMiddlewareFn<
|
|
31
32
|
TContext extends UserOperationContext | undefined =
|
|
32
33
|
| UserOperationContext
|
|
33
|
-
| undefined
|
|
34
|
+
| undefined,
|
|
34
35
|
> = <
|
|
35
36
|
TAccount extends SmartContractAccount,
|
|
36
37
|
C extends MiddlewareClient,
|
|
37
|
-
TEntryPointVersion extends
|
|
38
|
+
TEntryPointVersion extends
|
|
39
|
+
GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,
|
|
38
40
|
>(
|
|
39
41
|
struct: Deferrable<UserOperationStruct<TEntryPointVersion>>,
|
|
40
|
-
args: ClientMiddlewareArgs<TAccount, C, TContext, TEntryPointVersion
|
|
42
|
+
args: ClientMiddlewareArgs<TAccount, C, TContext, TEntryPointVersion>,
|
|
41
43
|
) => Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>>;
|
|
42
44
|
// [!endregion ClientMiddlewareFn]
|
|
43
45
|
|
|
@@ -45,7 +47,7 @@ export type ClientMiddlewareFn<
|
|
|
45
47
|
export type ClientMiddleware<
|
|
46
48
|
TContext extends UserOperationContext | undefined =
|
|
47
49
|
| UserOperationContext
|
|
48
|
-
| undefined
|
|
50
|
+
| undefined,
|
|
49
51
|
> = {
|
|
50
52
|
dummyPaymasterAndData: ClientMiddlewareFn<TContext>;
|
|
51
53
|
feeEstimator: ClientMiddlewareFn<TContext>;
|
|
@@ -20,7 +20,7 @@ import type { AuthorizationRequest, SmartAccountSigner } from "./types.js";
|
|
|
20
20
|
* Represents a local account signer and provides methods to sign messages and transactions, as well as static methods to create the signer from mnemonic or private key.
|
|
21
21
|
*/
|
|
22
22
|
export class LocalAccountSigner<
|
|
23
|
-
T extends HDAccount | PrivateKeyAccount | LocalAccount
|
|
23
|
+
T extends HDAccount | PrivateKeyAccount | LocalAccount,
|
|
24
24
|
> implements SmartAccountSigner<T>
|
|
25
25
|
{
|
|
26
26
|
inner: T;
|
|
@@ -62,7 +62,7 @@ export class LocalAccountSigner<
|
|
|
62
62
|
* @returns {Promise<any>} A promise that resolves to the signed message
|
|
63
63
|
*/
|
|
64
64
|
readonly signMessage: (message: SignableMessage) => Promise<`0x${string}`> = (
|
|
65
|
-
message
|
|
65
|
+
message,
|
|
66
66
|
) => {
|
|
67
67
|
return this.inner.signMessage({ message });
|
|
68
68
|
};
|
|
@@ -89,9 +89,9 @@ export class LocalAccountSigner<
|
|
|
89
89
|
*/
|
|
90
90
|
readonly signTypedData = async <
|
|
91
91
|
const TTypedData extends TypedData | Record<string, unknown>,
|
|
92
|
-
TPrimaryType extends keyof TTypedData | "EIP712Domain" = keyof TTypedData
|
|
92
|
+
TPrimaryType extends keyof TTypedData | "EIP712Domain" = keyof TTypedData,
|
|
93
93
|
>(
|
|
94
|
-
params: TypedDataDefinition<TTypedData, TPrimaryType
|
|
94
|
+
params: TypedDataDefinition<TTypedData, TPrimaryType>,
|
|
95
95
|
): Promise<Hex> => {
|
|
96
96
|
return this.inner.signTypedData(params);
|
|
97
97
|
};
|
|
@@ -118,7 +118,7 @@ export class LocalAccountSigner<
|
|
|
118
118
|
|
|
119
119
|
signAuthorization(
|
|
120
120
|
this: LocalAccountSigner<PrivateKeyAccount>,
|
|
121
|
-
unsignedAuthorization: AuthorizationRequest<number
|
|
121
|
+
unsignedAuthorization: AuthorizationRequest<number>,
|
|
122
122
|
): Promise<SignedAuthorization<number>> {
|
|
123
123
|
return this.inner.signAuthorization(unsignedAuthorization);
|
|
124
124
|
}
|
|
@@ -158,7 +158,7 @@ export class LocalAccountSigner<
|
|
|
158
158
|
*/
|
|
159
159
|
static mnemonicToAccountSigner(
|
|
160
160
|
key: string,
|
|
161
|
-
opts?: HDOptions
|
|
161
|
+
opts?: HDOptions,
|
|
162
162
|
): LocalAccountSigner<HDAccount> {
|
|
163
163
|
const signer = mnemonicToAccount(key, opts);
|
|
164
164
|
return new LocalAccountSigner(signer);
|
|
@@ -179,7 +179,7 @@ export class LocalAccountSigner<
|
|
|
179
179
|
* @returns {LocalAccountSigner<PrivateKeyAccount>} An instance of `LocalAccountSigner` initialized with the provided private key
|
|
180
180
|
*/
|
|
181
181
|
static privateKeyToAccountSigner(
|
|
182
|
-
key: Hex
|
|
182
|
+
key: Hex,
|
|
183
183
|
): LocalAccountSigner<PrivateKeyAccount> {
|
|
184
184
|
const signer = privateKeyToAccount(key);
|
|
185
185
|
return new LocalAccountSigner(signer);
|
package/src/signer/types.ts
CHANGED
|
@@ -55,13 +55,13 @@ export interface SmartAccountSigner<Inner = any> {
|
|
|
55
55
|
|
|
56
56
|
signTypedData: <
|
|
57
57
|
const TTypedData extends TypedData | Record<string, unknown>,
|
|
58
|
-
TPrimaryType extends keyof TTypedData | "EIP712Domain" = keyof TTypedData
|
|
58
|
+
TPrimaryType extends keyof TTypedData | "EIP712Domain" = keyof TTypedData,
|
|
59
59
|
>(
|
|
60
|
-
params: TypedDataDefinition<TTypedData, TPrimaryType
|
|
60
|
+
params: TypedDataDefinition<TTypedData, TPrimaryType>,
|
|
61
61
|
) => Promise<Hex>;
|
|
62
62
|
|
|
63
63
|
signAuthorization?: (
|
|
64
|
-
unsignedAuthorization: AuthorizationRequest<number
|
|
64
|
+
unsignedAuthorization: AuthorizationRequest<number>,
|
|
65
65
|
) => Promise<SignedAuthorization<number>>;
|
|
66
66
|
}
|
|
67
67
|
// [!endregion SmartAccountSigner]
|
|
@@ -129,9 +129,9 @@ export class WalletClientSigner implements SmartAccountSigner<WalletClient> {
|
|
|
129
129
|
*/
|
|
130
130
|
signTypedData = async <
|
|
131
131
|
const TTypedData extends TypedData | Record<string, unknown>,
|
|
132
|
-
TPrimaryType extends keyof TTypedData | "EIP712Domain" | string = string
|
|
132
|
+
TPrimaryType extends keyof TTypedData | "EIP712Domain" | string = string,
|
|
133
133
|
>(
|
|
134
|
-
typedData: TypedDataDefinition<TTypedData, TPrimaryType
|
|
134
|
+
typedData: TypedDataDefinition<TTypedData, TPrimaryType>,
|
|
135
135
|
): Promise<Hex> => {
|
|
136
136
|
const account = this.inner.account ?? (await this.getAddress());
|
|
137
137
|
|
package/src/transport/split.ts
CHANGED
|
@@ -45,7 +45,7 @@ export const split = (params: SplitTransportParams): CustomTransport => {
|
|
|
45
45
|
curr.methods.forEach((method) => {
|
|
46
46
|
if (accum.has(method) && accum.get(method) !== curr.transport) {
|
|
47
47
|
throw new Error(
|
|
48
|
-
"A method cannot be handled by more than one transport"
|
|
48
|
+
"A method cannot be handled by more than one transport",
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
|